APP下载

Turbidity analysis using visible and near-infrared light images

2021-04-14ZHUYuanyangZHAOWenzhuLIUShengGAOHongwen

ZHU Yuanyang,ZHAO Wenzhu,LIU Sheng,GAO Hongwen

(1. School of Computer Science and Technology,Huaibei Normal University,Huaibei 235000,China;2. College of Environmental Science and Engineering,Tongji University,Shanghai 200092,China)

Abstract:The conventional photoelectric detection system requires complex circuitry and spectroscopic systems as well as specialized personnel for its operation.To replace such a system,a method of measuring turbidity using a camera is proposed by combining the imaging characteristics of a digital camera and the high-speed information processing capability of a computer.Two turbidity measurement devices based on visible and near-infrared (NIR) light cameras and a light source driving circuit with constant light intensity were designed.The RGB data in the turbidity images were acquired using a self-developed image processing software and converted to the CIE Lab color space.Based on the relationship between the luminance,chromatic aberration,and turbidity,the turbidity detection models for luminance and chromatic aberration of visible and NIR light devices exhibiting values from 0-1 000 NTU,less than 100 NTU,and more than 100 NTU were established.By comparing and analyzing the proposed models,the two measurement models with the best all-around performance were selected and fused to generate new measurement models.The experimental results prove that the correlation between the three models and the commercial turbidity meter measurements exhibite a significance value higher than 0.999.The error of the fusion model is within 1.05%,with a mean square error of 1.14.The visible light device has less error at low turbidity measurements and is less influenced by the color of the image.The NIR light device is more stable and accurate at full range and high turbidity measurements and is therefore more suitable for such measurements.

Key words:image processing;water quality;turbidity measurement;near-infrared image;color space conversion

0 Introduction

The turbidity of natural water is caused by sediment,clay,fine organic and inorganic matter,and suspended matter such as plankton and other microorganisms in the water.The amount of suspended matter in the water,called turbidity[1],directly affects water clarity and biochemical reactions in the water[2],and turbid water is a threat to human beings and other living creatures[3-5].Therefore,turbidity becomes an important parameter to measure water quality[3].

Turbidity analysis focuses on optical properties that result in the scattering and absorption of light,thus causing a reduction in the transparency of a liquid[6].Spectral analysis is a technique that uses the characteristics of the emission,absorption,and scattering spectra of various chemical substances to determine their properties,structure,and content[7].Compared with traditional turbidity measurement methods such as turbid metric method and chemical analysis method the measurement methods based on photoelectric principle have the advantages of high speed and accuracy.Common forms of optical measurements include scattered light[8],transmitted light[9-10],and integrated scattered transmission[11-12].

With the rapid development of computer and image processing techniques,measurement methods using images have received much attention[13].For example,the photoelectric images of printed circuit boards (PCBs) captured by a charge-coupled device (CCD) and microscope are used for image-edge information detection to obtain better edge information for both subjective and objective results[14].Measurement methods based on digital imaging technology have been used to identify cable forces by capturing single and multi-point images from a camera[15].Real-time analysis of fish behavior using computer vision has been proposed to monitor the presence or absence of water pollution[16].Image detection also can be used in the field of photoelectric detection where each pixel of a digital camera is equivalent to a photoelectric detection element.Visible light detection and near-infrared (NIR) light detection work on the same principle,however,these two methods have different light source requirements and exhibit some differences in application areas,whereas both show the same value for turbidity measurements.

As an emerging method for turbidity measurement,the imaging method exhibits the most stringent requirements for cameras.In this study,we obtained the luminance and chromatic aberration values corresponding to the standard turbidity by designing a measurement system for the visible and NIR light cameras,establishing turbidity detection models,and then using them to compare the measurement performance of the visible and NIR light cameras.Finally,the practical applications of the two devices are stated and the user can select them according to the requirements.

1 Theoretical analysis

1.1 Principle of turbidity measurement

The difference between NIR and visible light measurement devices is their sensitivity to the wavelength of light,however,they are based on the same measurement principle.The measurement of turbidity using a digital camera is also based on the law of absorption and scattering of light.The camera is used instead of a photoelectric sensor to receive the light beam.Its variation in the transmitted light intensity during transmission measurement is also based on the Beer-Lambert law[17].After being absorbed and scattered through the turbid solution,the transmitted light intensityICconforms to

IC=I0exp(kTl),

(1)

whereI0is the intensity of incident light,kis the proportionality constant,Tis the solution turbidity,andlis the optical path length.

The principle of transmission measurement is shown in Fig.1.The light source emits a parallel incident beam through Lens1,which produces a transmission beam after the incident beam passes through the turbid solution.The detector receives it after it passes through the Filter and Lens2.In the image-based measurement method,the combination of Filter,Lens2,and Detector in Fig.1 is replaced by a digital camera.

Fig.1 Measurement principle of transmitted light method

1.2 Algorithm for image-based measurement

The conversion from theRGBcolor space to the CIELabcolor space uses an approximate conversion algorithm that is different from the Adobe Photoshop software transformation.TheRGBcolor space cannot be directly converted to the CIELabcolor space.TheRGBcolor space is first converted to the CIEXYZcolor space.

(2)

(3)

Then,the three stimulus values (X,YandZ) of the CIEXYZcolor space are converted to the CIELabcolor space

(4)

(5)

whereLindicates the luminance of the light transmitted from the solution,aindicates the color range from green to red,andbindicates the color range from blue to yellow.The range ofLvalues is from 0 to 100,and the range of values for bothaandbis from -127 to +128.

We use the chromatic aberration formula in Eqs.(6)-(8) to obtain the chromatic aberration values of the turbid solution from the CIELabcolor space as

(6)

(7)

(8)

where (L1,a1,b1) is the reference color,that is,theLabvalues of zero turbidity water;(L2,a2,b2) is the contrast color,that is,theLabvalues of the turbid solution to be measured;ΔL,ΔCab,and ΔHabare the differences between the two colors in luminance,chroma,and hue.SL,SC,andSHare the weight functions of ΔL,ΔCab,and ΔHabin the total color difference.In this study,the values of scale factorskL,kCandkHare all 1.

CIELabis a device-independent and physiological feature-based color model that allows the visual representation of luminance[18].Therefore,the luminance of an image of a turbid solution can be used to reflect the turbidity of the sample.The NIR light device can reflect the changes in luminance through the chromatic aberration,and the chromatic aberration of the visible light device can express both the luminance and color changes and reflect the overall changes.

2 Design of turbidity analysis system

2.1 General framework

The structure of the measurement system with a digital camera is shown in Fig.2.The system is placed in a dark box and consists of a light source and its driver circuit,a sample cell,a digital camera,and a computer connected via a universal serial bus (USB).The computer supplies power to the digital camera and the system via the USB with a voltage of +5 V.The drive circuit of the light source ensures its stability.A cuvette containing the solution was placed in the sample cell.The digital camera acquires and processes the optical information and transmits the data stream via the USB to the image turbidity analysis system (ITAS) software on the computer.The software processes and acquires the averageRGBvalues of 400 pixels in the central region of the solution images.It calculates theLaband chromatic aberration values using the algorithms stated in Section 1.2.The system is transmissive,with the light source,cuvette,and digital camera centered on the same line.The advantage of the device is that the digital camera offers a complete optical path system with integrated signal processing elements that replace the photoelectric detection circuit,signal amplification,processing circuit,and analog-to-digital conversion circuit.The visible and NIR light devices are slightly different in terms of the light source and digital camera;however,they use the same ITAS software.

Fig.2 Structure diagram of image turbidity analysis system

2.2 Light source and drive circuit

The light source for both the visible and NIR light devices uses a constant light intensity drive circuit,as shown in Fig.3.

Fig.3 Constant light intensity drive circuit for light source

The circuit consists of an operational amplifier circuit,a reference voltage,and a transistor.The LM385 chip provides the reference voltage for the constant light intensity circuit,and adjusting the potentiometer W1 can change the voltage at the positive input of U1A.The photo-diode D2 collects the voltage signal from the light intensity signal of the backlight board,compares it with the reference voltage in U1A,and then controls the current of the light-emitting diode (LED) D1 in the backlight board to achieve a constant light intensity.The visible light source using a backlight board consists of two parallel white LEDs of 0.3 W,light guide,light intensifier,and reflector,emitting uniform and constant white light with an operating current of about 10 mA.The NIR light source uses an LED with a wavelength of 850 nm,a power of 0.5 W,and an operating current of approximately 15 mA.The circuit uses a closed-loop operation.By sampling and comparing the light intensity,it can achieve a constant light intensity within a few seconds after the power is switched on,thus ensuring the stability of the light source and the shortening of the warm-up time of the device.

2.3 Digital cameras

The visible and NIR light devices use the same AR0130 complementary metal-oxide-semiconductor (CMOS) sensor camera,as shown in Fig.4.The maximum resolution reaches 1 280×960 pixels,with an operating voltage of 3.3 V-5 V and an imaging distance of 1 cm minimum.The 850 nm narrowband filter is added to the camera of the NIR light device,which can effectively eliminate the influence of other wavelengths and improve the sensitivity,with a focal length of 3.6 mm.To ensure the consistency of parameters during the measurement and to verify the experimental results,the digital camera requires manual zoom,manual exposure adjustment,and adjustable camera parameters such as brightness,contrast,hue,saturation,clarity,gamma,and white balance.

Fig.4 Front and back of digital camer

2.4 ITAS software

The ITAS software design is based on the Microsoft Visual Studio platform and developed using C# with Camera_NET control.Fig.5(a) is the main interface of the software,which shows the measurement process of the visible light device.Fig.5(b) is the picture of only the right side of the software for the NIR light device,while the left side of the software for the NIR light device is the same as the left side of Fig.5(a).When the measurement device is connected to the computer via the USB,the digital camera used in the current experiment is selected.Both cameras exhibit the same resolution of 1 280×960 pixels.The fixed camera parameters are necessary for the measurement experiment and are controlled in the “Camera Settings” sub-screen,with the main parameters mentioned in Section 2.3.During the measurement,the turbidity values are obtained from the average color component of the 400 pixels in the center of the current images.These values are displayed in the corresponding area.

Fig.5 Screenshot of ITAS software

3 Experimental results and discussion

The solutions of standard turbidity used in the experiments were prepared according to the international standard ISO 7027.Distilled water was filtered at least twice through a micro-porous membrane with a pore size of 0.2 μm to obtain zero turbidity water.The standard turbidity solutions in the range of 0-1 000 NTU were diluted proportionally with 4 000 NTU of formalin and zero turbidity water.

3.1 Comparative experiments with full range (0-1 000 NTU) models

The luminance (L) of 15 standard turbidity solution images in the full range (0-1 000 NTU) was obtained using the ITAS software combined with visible and NIR light devices.The chromatic aberration (ΔE) was calculated for each corresponding turbidity solution and zero turbidity water.TheLand ΔEdata were linearly fitted to the turbidity data using the ordinary least squares method,and the experimental data and fit results are shown in Fig.6.

Fig.6 Full range experiments and fit results

The correlation coefficients of both the visible light luminance (full-VIS-L) and chromatic aberration (full-VIS-E) models are smaller than those for the NIR light luminance (full-NIR-L) and chromatic aberration (full-NIR-E) models.Notably,owing to the specificity of chromatic aberration,zero turbidity water with a chromatic aberration of 0 NBS must,in principle,pass through the point (0,0).However,in the ordinary least squares fitting method,the chromatic aberration model does not necessarily pass through the original point.Therefore,for better results,the full-VIS-E and full-NIR-E models in Fig.6 are the results of the fitting with a control intercept of 0 NBS.TheR2of the uncontrollable fitting curve for the visible light chromatic aberration is 0.999 41,which is smaller than that of the full-VIS-E model because of the control fitting.The definition ofR2was changed after the intercept was fixed;however,the uncontrolled fitting was still the optimal model.TheR2of the full-VIS-E model is smaller than that of full-VIS-L model because the visible light chromatic aberration includes color variations and demonstrates that color affects turbidity measurements.The NIR light image exhibits only luminance and no color,thus,the NIR light chromatic aberration is equivalent to the luminance variation.Except for the difference in their formulas,the uncontrolled NIR light chromatic aberration fitting curves are identical to the controlled full-NIR-E model’s calculated results,including theR2and absolute values of the slope.The turbidity detection model was developed based on the formulas in Fig.6,and a series of standard turbidity solutions were measured with the visible and the NIR light devices.The results and analyses are shown in Fig.7 and Table 1,respectively.

Fig.7 Measurement results of full range comparison experiment

Table 1 Analysis of measurement results of full range comparison experiment

The absolute errors in Fig.7 are marked with plus and minus signs to reflect the positive and negative deviations in the errors,respectively.However,the relative error calculations and the analytical data in Table 1 are in the form of absolute errors.Fig.7 and Table 1 show that all the detection models exhibit the maximum relative error (MAX_RE) at 10 NTU,with the full-NIR-E model exhibiting the smallest mean relative error (MRE).The absolute error of the full-VIS-L model is more significant at low turbidity,and the maximum absolute error (MAX_AE) at 10 NTU is 6.93.Among the three statistical indicators of MAX_AE,mean absolute error (MAE) and mean square error (MSE),the full-VIS-E model exhibits the largest,indicating that the visible light device exhibits a considerable color variation in the range of 0-1 000 NTU,which affects the measurement results.The MAX_AE and MAX_RE of the full-NIR-E model in this measurement are larger than those of the full-NIR-L model.Interestingly,the other indicators of the full-NIR-E model are smaller than those of the full-NIR-L model.The NIR light detection model exhibits smaller measurement errors than the visible light detection model,thus indicating that the NIR light device is more accurate than the visible light device in the range of 0-1 000 NTU.

3.2 Comparative experiments with low turbidity (0-100 NTU) models

The visible and NIR light data obtained for six standard turbidity solutions within the 0-100 NTU range were linearly fitted.The coefficients of determination and fitted equations forLand ΔEfor the two devices are shown in Fig.8.

Fig.8 Low turbidity experiments and fitting results

The detection models were developed based on the formulas for visible light luminance (low-VIS-L),visible light chromatic aberration (low-VIS-E),NIR light luminance (low-NIR-L),and NIR light chromatic aberration (low-NIR-E),as shown in Fig.8.The results of measuring a series of standard turbidity solutions using each detection model and the corresponding measurement devices are shown in Fig.9 and Table 2.

Fig.9 Results of low turbidity comparison experiments

Table 2 Analysis of measurement results of low turbidity comparison experiment

According to the data in Fig.9 and Table 2,low-VIS-E is the smallest of the many statistical indicators,with a MAE of 0.7 NTU and a MSE of 0.57.The measurements are relatively accurate and stable.The visible light device indicators are also all the better than those of the NIR light device,and the MAX_AE,MAE and MSE of the visible device are less than 1 than that of the NIR light device in the 0-80 NTU range.At lower concentrations,the chromatic aberration of the solution does not change significantly.The chromatic aberration more adequately reflects the change in light after it passes through the sample,thus rendering the low-VIS-E model better than the low-VIS-L model.Removing the unusual data of the NIR light device at 50 NTU,the absolute error of the other data is closer to that of the visible light device.However,the NIR light device exhibits a larger MSE of 15.92% and 9.78%,respectively.Therefore,it is less stable than the visible light device.

3.3 Comparative experiments with high turbidity (100-1 000 NTU) models

TheLand ΔEof 10 standard turbidity solutions in the range of 100-1000 NTU were collected using visible and NIR light devices for fitting to obtain the detection model shown in Fig.10.

Turbidity detection models for visible light luminance (high-VIS-L) and chromatic aberration (high-VIS-E) as well as NIR light luminance (high-NIR-L) and chromatic aberration (high-NIR-E) were developed using the formulas,as shown in Fig.10.The turbidity values of the standard turbidity solutions were calculated using each detection model combined with the visible and NIR light measurement devices.The results are shown in Fig.11 and Table 3.

Fig.10 High turbidity experiments and fit resultss

Fig.11 Results of high turbidity comparison experiments

Table 3 Analysis of measurement results of high turbidity comparison experiment

As shown in Fig.11 and Table 3,the turbidity detection model for the NIR light device exhibits less measurement error than that for the visible light device in the high turbidity range,that is 100-1 000 NTU.As predicted,the high-NIR-L and high-NIR-E models exhibit the same detection data,analysis results,and are thus equivalent to one model.The high-VIS-L model exhibits better statistical indicators than the high-VIS-E model.The images of the high turbidity samples are susceptible to color,and the high-VIS-E model does not provide better results.Although the high-VIS-L model is less affected by image color,its performance is still inferior to that of the high-NIR-L model.

According to the above analysis of each model at full range,low turbidity,and high turbidity,the measurement results of the NIR light device are more stable than those of the visible light device.The measurement error is always within 5 NTU,with a MAE of approximately 2 NTU.Visible light devices present better results at low turbidity,and the low-VIS-E model is recommended for better measurement of low turbidity samples.The full-NIR-E model performs best in full range measurements and is not inferior to the high-NIR-E model in high turbidity measurements,thus,it is recommended for comprehensive measures.

3.4 Comparative measurement of real water samples

After discussion,the full-NIR-E model is more suitable for turbidity measurement;however,it exhibits a relatively large error at low turbidity.Because the difference between the visible and NIR light devices results from of the camera itself and the light source,the NIR light camera has only one more 850 nm narrowband filter than the visible light camera.If an automatic filter loading system is designed,a fusion of the visible and NIR light devices can be achieved with a dual visible/NIR light source.With the new device,it is possible to use the low-VIS-E model for measuring samples at low turbidity and the full-NIR-E model for high turbidity measurements,which results in a new detection mode,that is the visible/near-infrared (VIS/NIR) model.

To validate the measurement performance of the low-VIS-E,full-NIR-E,and VIS/NIR models,we compared their turbidity measurements with those of two commercial turbidity meters.One is the Shanghai XINRUI WGZ-1B (TM-1) with a measuring range of 0-200 NTU,and the other is the Shanghai YUKE YKM-FZD (TM-2) with a measuring range of 0-1 000 NTU.A total of 12 water samples were tested,the first four were formulated with the turbidity of 50 NTU,10 NTU,150 NTU,and 200 NTU,and the last eight were obtained from local rivers and domestic water in Huaibei.The measurement results of the real water samples are shown in Table 4.

Table 4 Actual water sample measurement results (NTU)

First,the error analysis of the measurement results of the standard turbidity samples with serial Nos.1-4 was performed according to the five measurement modes,and the results are shown in Table 5.

Table 5 Error analysis of five measurement modes

Among the five measurement modes,the VIS-NIR mode is the best among all the statistical indicators,with a MSE of 1.14,which indicates high stability.The MRE was 1.05%,with the highest measurement accuracy observed in the experiment.The TM-2 mode underperformed the most among all the statistical indicators.The MAX_RE of the TM-1 mode is smaller than those of the full-NIR-E and low-VIS-E modes;however,the MAX_AE,MAE,MSE and MRE of the full-NIR-E mode are smaller than those of the TM-1 mode.The correlation analysis was performed on the real samples with serial Nos.5-12,and the results are shown in Table 6.

Table 6 Correlation analysis of five measurement modes

The correlation coefficients of all five measurement modes are above 0.999,and the correlation coefficient between the TM-1 and the VIS-NIR modes is 0.999 949,which is notably close to 1.We believe that the results of the five measurement modes are correlated,and the results are very close to each other in value.This experiment verifies that our proposed detection modes exhibit the same or even better detection performances compared with commercial turbidity meters.

4 Conclusions

In this study,turbidity measurement devices with visible and NIR light cameras were designed to obtain the luminance and chromatic aberration of the images of turbid solutions and perform turbidity measurements using 12 detection models.Finally,the measurement performances of these two devices were compared.Comparing the same devices,the measurement error of the visible light luminance detection model is generally smaller than that of the visible light chromatic aberration detection model.At low turbidity,the visible light chromatic aberration model presents the most accurate measurements and is less influenced by the color of the solution.The NIR light devices present similar measurement results for the luminance and chromatic aberration detection models and are not affected by color of the solution.Compared to the two devices,the visible light device exhibits a higher measurement accuracy at low turbidity.The NIR light device exhibits more stable measurement results and higher accuracy at full range and high turbidity,which is more suitable for turbidity measurement.Combining the characteristics of the two devices to form a visible/NIR measurement model can further improve the measurement accuracy.