A detecting device for a medium inside a tube portion comprises at least one light source being arranged at a first position relative to the tube portion adapted to be transilluminated with light and being configured to irradiate light onto the tube portion, a detector unit being arranged at a second position relative to the tube portion and being configured to receive light from the at least one light source passed through the tube portion and to analyze a medium inside the tube portion in a spatially resolving manner, and a homogenizing device being arranged at a position between the at least one light source and the tube portion and being configured, for detecting and quantifying differences in brightness due to local differences of the medium inside the tube portion, to create a homogenous and/or isotropic distribution of the light from the at least one light source before the light enters into the tube portion.