A detecting device for a medium inside a tube portion, comprising: an imaging optical system; the tube portion; 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, wherein the homogenizing device comprises predetermined concentrations of light-absorbing substances, which provide a variably light-absorbing function of the homogenizing device, along a direction perpendicularly to the transilluminating direction in predetermined areas of the homogenizing device, characterized in that the homogenizing device is arranged at a smallest distance from the tube portion determined by at least the imaging optical system, its opening angle and its focal range; a light conducting device comprising a first and a second light conducting device and being configured in at least the area between the homogenizing device and the tube portion as a circumferential wall surrounding at least the area in a sheathing manner, wherein the at least one light source and/or the homogenizing device is/are arranged between the first and the second light conducting device; and the predetermined concentrations of light-absorbing substances are integrated in the homogenizing device in such a manner that in an upper and in a lower outer area of the homogenizing device, the concentration of the added substances is respectively higher and in a central area or middle area, in contrast, lower, wherein the upper and the lower outer area of the homogenizing device as well as its central area or middle area are arranged along the direction perpendicular to the transilluminating direction, and a light absorption profile resulting therefrom is adapted to geometrical conditions of the tube portion and the optical properties of the medium. an imaging optical system; the tube portion; 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, wherein the homogenizing device comprises predetermined concentrations of light-absorbing substances, which provide a variably light-absorbing function of the homogenizing device, along a direction perpendicularly to the transilluminating direction in predetermined areas of the homogenizing device, characterized in that the homogenizing device is arranged at a smallest distance from the tube portion determined by at least the imaging optical system, its opening angle and its focal range; a light conducting device comprising a first and a second light conducting device and being configured in at least the area between the homogenizing device and the tube portion as a circumferential wall surrounding at least the area in a sheathing manner, wherein the at least one light source and/or the homogenizing device is/are arranged between the first and the second light conducting device; and the predetermined concentrations of light-absorbing substances are integrated in the homogenizing device in such a manner that in an upper and in a lower outer area of the homogenizing device, the concentration of the added substances is respectively higher and in a central area or middle area, in contrast, lower, wherein the upper and the lower outer area of the homogenizing device as well as its central area or middle area are arranged along the direction perpendicular to the transilluminating direction, and a light absorption profile resulting therefrom is adapted to geometrical conditions of the tube portion and the optical properties of the medium.