*Article* **Chromaticity Measurement Based on the Image Method and Its Application in Water Quality Detection**

#### **Pingping Cao <sup>1</sup> , Yuanyang Zhu <sup>1</sup> , Wenzhu Zhao <sup>1</sup> , Sheng Liu 1,\* and Hongwen Gao <sup>2</sup>**


Received: 4 October 2019; Accepted: 5 November 2019; Published: 8 November 2019

**Abstract:** In order to measure the chromaticity of water and the content of dissolved matter more accurately, effectively, and cheaply, a chromaticity measurement system based on the image method was proposed and applied. The measurement system used the designed acquisition device and image processing software to obtain the Red-Green-Blue (RGB) values of the image and converted the color image from RGB color space to Hue-Saturation-Intensity (HSI) space to separate the chromaticity and brightness. According to the definition of chromaticity, the hue (H), saturation (S) values, and chromaticity of standard chromaticity solution images were fitted by a non-linear surface, and a three-dimensional chromaticity measurement model was established based on the H and S values of water images. For the measurement of a standard chromaticity solution, the proposed method has higher accuracy than spectrophotometry. For actual water sample measurements, there is no significant difference between the results of this method and the spectrophotometer method, which verified the validity of the method. In addition, the system was tried to measure the concentration of ammonia nitrogen, phosphate, and chloride in water with satisfactory results.

**Keywords:** water quality; analysis method; chromaticity measurement; surface fitting; concentration of dissolved matter

#### **1. Introduction**

Pollution can lead to changes in water color, especially in textile, leather, paper, pharmaceutical, printing, and dyeing industries [1,2]. Therefore, the pollution degree of water can be monitored by measuring the chromaticity of water [3]. Chromaticity is an index for the quantitative determination of the color of natural water or treated water, usually in the unit of degree (◦ ). Natural water often shows light-yellow, light-brown, yellow-green, and other different colors. The cause of color is due to humus, organic or inorganic substances dissolved in water [4].

China's current national standard method for water chromaticity measurement, "Water quality-determination of colority" (GB/T 11903-1989), is the platinum-cobalt colorimetric method and dilution multiple method [5]. Among them, platinum-cobalt colorimetric refers to the international standard "Clear liquids—Estimation of color by the platinum-cobalt scale—Part 1: Visual method" (ISO 6271-1-2004) [6]. At present, the international methods of measuring chromaticity include a spectrophotometer [7], a three-wavelength transmittance method [8], and a support vector machine regression prediction method [9]. In practical application, the platinum-cobalt colorimetric method has no obvious difference between 5 and 25, is not easy to judge, and its error is large. In the dilution multiple method, the response of different color tones to optic nerve stimulation is different because

of the great difference of water sample tones, which creates personal subjectivity in discriminating. Finally, it is difficult for the dilution end point (colorless) to have a unified standard, and the final result will have a great error. Spectrophotometry is a method for the qualitative or quantitative analysis of the absorbance of light of a specific wavelength or a certain wavelength range. Because the substances in the solution have selectivity to absorb light, the absorbance and absorption spectra of different substances are different at different wavelengths, which make the solution present different colors [10]. Therefore, spectrophotometry can identify substances or measure their content according to the absorption spectra of different substances. A spectrophotometer is used to determine the chromaticity value of water samples by establishing the correlation between the absorbance value of a standard chromaticity solution at a characteristic wavelength or the peak area of the absorption spectrum and the chromaticity value. This method improves the accuracy of the water chromaticity measurement, but the price of a professional spectrophotometer is higher, and the characteristic wavelength of a chromaticity solution is no uniform standard, which inevitably leads to disagreements in measurement. The method of water chromaticity measurement based on three-wavelength transmittance is also a spectrophotometric method, which measures the true chromaticity of water quality by measuring the transmittance at three wavelengths. However, the selection of measuring points (three wavelengths) can be different because of different measurers, and the selection of measuring points will also be different, so the measurement results will also be different. The application of support vector machine regression to predict water chromaticity can obtain a high accuracy prediction model, but a large number of learning samples are needed. A large number of training samples will increase the workload of the measurement, leading to low measurement efficiency.

Excessive ammonia nitrogen in the water environment will cause much harm to water bodies, such as reducing the dissolved oxygen concentration in water and accelerating water eutrophication [11]. Phosphate can disrupt the ecological balance of the water environment by promoting the proliferation of algae (called eutrophication) and the consequent consumption of dissolved oxygen (when algae decay) [12]. Chloride dissolved in water is toxic and can cause dizziness, nausea, dyspnea, and even death [13]. Therefore, the measurement of ammonia nitrogen, phosphate, and chloride content in water is very important. At present, the methods for the determination of the properties and contents of organic matter in water are ultraviolet visible spectroscopy [14], mobile mass spectrometry [15], linear regression and artificial neural network [16], the sensor method [17], the trace element tracing method [18,19] and the potentiometric titration method [20]. Among them, ultraviolet visible spectroscopy, mobile mass spectrometry, and the sensor method need professional analytical instruments that come with high measurement cost; the linear regression and artificial neural network method needs a large number of training data to ensure the accuracy of the measurement, and the measurement efficiency is low; the trace element tracing method and potentiometric titration method have low operability and need professional technicians to operate in water quality detection.

Cameras have been widely used in various fields. In physics, a digital camera is used to study the trajectory of the water jet, the outline of the suspension chain, and the defocus figure reflected on the mirror of different shapes [21]. Digital cameras are also used to describe the color and physical properties of soil samples [22]. In chemistry, Red-Green-Blue (RGB) values can be converted into other color spaces, and then, the conversion functions of soil organic carbon and iron can be derived by using these color spaces to measure their concentrations quickly and accurately [23]. Moreover, a digital camera was used to determine iron and residual chlorine in water using N,N-diethylphenylenediamine [24]. In Maputo Bay, Mozambique, digital cameras are also used to measure the suspended sediment concentration, which prompted discussion on the possibility of using digital photography to measure the suspended sediment concentration in other coastal waters [25]. The development of using digital cameras within the field of water quality detection can provide a new measurement method for water quality detection. In order to measure water chromaticity more accurately, quickly, and cheaply, a water chromaticity measurement system based on the image method is proposed. The proposed chromaticity measurement system based on a digital camera can be used to measure the content of ammonia

nitrogen, phosphate, and chloride in water. And it can simplify the design of measuring instruments and improve the accuracy of measurement, which is of great significance in water quality detection.

The designed chromaticity measurement system uses an image acquisition device to collect the image of a standard chromaticity solution. The solution image captured by the camera is the color image of the standard chromaticity solution. The color can be separated into brightness and chromaticity [26]. Chromaticity is the property of color that does not include brightness. It reflects the hue and saturation of color. The image processing software designed in this paper actually converts the color solution image from RGB color space to Hue-Saturation-Intensity (his) space. Then, the brightness can be separated. Finally, a three-dimensional relationship model between hue (H), saturation (S), and chromaticity and a standard curve between H, S-standard-deviation (△HS), and solute concentration are established for the measurement of water chromaticity and solute content. △

#### **2. Materials and Methods**

#### *2.1. Design of a Measurement System Structure*

The water chromaticity measurement system was designed to include a water image acquisition device and image processing software, as shown in Figure 1.

**Figure 1.** Structure of a water chromaticity measurement system.

The acquisition device is used to collect a liquid image, which is processed by the image processing software to get RGB and HSI values and to achieve chromaticity separation.

#### 2.1.1. Image Acquisition Device

The water image acquisition device consists of a high-color-rendering LED, a backlight panel, a constant light source circuit, a digital camera, and a sealed box. The light color of the LED is warm white, the color temperature is in the range of 2600–4500 K, the corresponding luminous intensity is 9.5 cd(lm), and the forward voltage is 2.9–3.5 V.

Adding a backlight panel between the light source and the solution can bring uniformity to the light and improve the image quality, avoid the uneven brightness of the collected image, and affect the color value of the image. The constant light source circuit makes the light intensity of the light source constant, which is a closed-loop control circuit, as shown in Figure 2. Within the circuit, D2 detects the light intensity of D1 and generates a voltage signal, which is buffered by U1B, then controls the working current of D1 to stabilize the light intensity. Although the design is relatively simple, the effect of constant light intensity is very good [27].

**Figure 2.** Constant light intensity circuit diagram.

The digital camera used is a JD-300 digital camera produced by Shenzhou Jiuding Technology Co., Ltd. in Beijing, China, and its structure is shown in Figure 3.

**Figure 3.** Camera printed circuit board details.

The camera can adjust brightness, contrast, hue, saturation, and white balance, and use manual adjustments for exposure and zoom. When using this camera to acquire chromaticity images, it is necessary to ensure that the various parameters are constant and adjust the exposure and focus to the appropriate size.

#### 2.1.2. Software Design

The image processing software designed in the measurement system is developed on the platform of Visual Studio 2012 based on the open source camera development toolkit and C# language. The software digitalizes the collected water image, that is, to get the pixel value of the image.

The edge of the liquid image captured by the camera will be geometrically distorted, and the RGB value of the image will be affected when the image is digitized. In order to avoid the effect of edge distortion on the accuracy of data, the RGB values of 400 pixels in the central region of the image are selected, and then the average RGB values of these pixels are obtained. The image was then transformed from RGB color space to HSI color space to separate the chromaticity and brightness by the image processing software. The conversion algorithm is as follows.

Given the RGB value of the acquired water image, the H component can be obtained by Formula (1): ,B G 

$$\mathbf{H} = \begin{cases} \ \theta \text{,} (\mathbf{B} \le \mathbf{G})\\ \ \mathbf{360} - \theta \text{,} (\mathbf{B} > \mathbf{G}) \end{cases} \tag{1}$$

in which,

$$\theta = \arccos\left\{ \frac{\frac{1}{2} \left[ (\mathbf{R} - \mathbf{G}) + (\mathbf{R} - \mathbf{B}) \right]}{\left[ (\mathbf{R} - \mathbf{G})^2 + (\mathbf{R} - \mathbf{G})(\mathbf{G} - \mathbf{B}) \right]^{\frac{1}{3}}} \right\}.\tag{2}$$

The saturation component S is derived from Formula (3):

$$\mathbf{S} = 1 - \frac{\mathbf{3}}{(\mathbf{R} + \mathbf{G} + \mathbf{B})} [\min(\mathbf{R}, \mathbf{G}, \mathbf{B})],\tag{3}$$

and the final intensity component Intensity (I) is derived from Formula (4):

$$\mathbf{I} = \frac{1}{3}(\mathbf{R} + \mathbf{G} + \mathbf{B}).\tag{4}$$

The color space conversion is shown in Figure 4.

**Figure 4.** Diagram of the color space model from Red-Green-Blue (RGB) to Hue-Saturation-Intensity (HSI).

The software designed can control the exposure, contrast, hue, saturation, and other properties of the camera. It is necessary to adjust and fix the camera attributes when measuring a water image. The designed software interface and camera property control are shown in Figure 5.

Figure 5b shows the main interface of the image processing software, which contains buttons such as camera settings and image capture. The camera setting button controls the properties of the camera. Figure 5a shows the camera parameters of this experiment. The function of the image capture button is to get the RGB and HSI values of the current image. Combining the image processing software and the image acquisition device, it can be used to measure the chromaticity of water.

**Figure 5.** Software interface and camera property settings. (**a**) is the camera parameters of this experiment. (**b**) is the main interface of the image processing software.

#### *2.2. Preparation and Information Acquisition of Chromaticity Standard Solution*

In this design, 1.245 g of potassium chloroplatinate (MESCO Chemical Co., Ltd, Tianjin, China) and 1.000 g of cobalt chloride (Jingshiji mall, Changsha, China) were dissolved in 200 mL hydrochloric acid (Mingcheng Chemical Co., Ltd, Qidong, China) with a concentration of 6 mol/L, and then diluted to 1000 mL with deionized water. The standard platinum-cobalt chromaticity solution with a chromaticity of 500 was prepared. Thirty standard solutions of different chromaticity in the range of 0–500 were obtained by diluting the 500-degree chromaticity solution according to a gradient. The standard chromaticity solution was poured into the colorimetric dish (size is 34 × 15 × 43 mm<sup>3</sup> , and the optical path is 30 mm) and then put into the sample trough of the designed chromaticity measurement system to measure. The RGB and HSI values of the chromaticity image are obtained by the designed chromaticity measurement system. Some image data are shown in Figure 6.


**Figure 6.** Partial image data and the corresponding color components.

With the increase of solution chromaticity, the RGB and HSI values of corresponding images also change, reflecting the corresponding relationship between RGB and HSI values and chromaticity. The obtained HS value is fitted with the standard chromaticity, and the no-linear relationship between

HgI 2KI K HgI 2 2 <sup>4</sup>

2 4 3 22 2 2K HgI 3KOH NH NH Hg OI 7KI 2H O yellow-brown complex

the chromaticity and the HS value is established. The chromaticity value of the solution to be measured is calculated according to the fitting expression.

#### *2.3. Preparation and Data Acquisition of Standard Solutions of Ammonia Nitrogen, Phosphate, and Chloride*

The 1000 mg/L ammonia-nitrogen standard solution: ammonium chloride 3.819 g (NH4Cl, superior purity, China Jiehui Chemical Reagent, Wuhan, China) dried at 100 ◦C was dissolved in a small amount of deionized water. It was then transferred into a 1000 mL capacity bottle and diluted to 1000 mL by adding deionized water. The mixture was uniform. The standard ammonia-nitrogen solutions with concentrations of 0 mg/L, 0.2 mg/L, 0.4 mg/L, 0.7 mg/L, 1.0 mg/L, and 1.5 mg/L were prepared by further dilution. Ammonia nitrogen was detected by Nessler's reagent color reaction, such as Formulas (5) and (6):

$$\rm{HgI}\_2 + 2\rm{KI} \to \rm{K}\_2\rm{HgI}\_{4\prime} \tag{5}$$

$$2\text{K}\_2\text{HgI}\_4 + 3\text{KOH} + \text{NH}\_3 \rightarrow \text{NH}\_2\text{Hg}\_2\text{OI} + 7\text{KI} + 2\text{H}\_2\text{O} \text{(yellow-brown complex)},\tag{6}$$

the designed chromaticity measurement system is used to obtain image information of the complex solution, as shown in Figure 7a.

**Figure 7.** Image information of solutions with different concentrations. (**a**) is the image information of the yellow-brown complex solution. (**b**) is the image information of the blue phosphomolybdenum blue solution. (**c**) is the image information of the brick red complex solution.

H PO 12(NH ) MoO 21HNO (NH ) H [P(Mo O ) ] 21NH NO 10H O 3 4 42 4 3 43 4 2 76 4 3 2

43 4 2 76 2 42 4 2 75 4 2 (NH ) H [P(Mo O ) ] 2SnCl 4HCL (NH ) H [(Mo O ) ] 2SnCl 2H O

The 500 mg/L phosphorus standard solution: potassium dihydrogen phosphate was dried at 110 ◦C for four hours (KH2PO4, superior purity, Shanghai Reagent Plant, Shanghai, China). Then, 5.444 g was accurately weighed. It was dissolved in a small amount of deionized water, transferred to a 500 mL capacity bottle, and diluted to 500 mL calibration with deionized water. The standard phosphorus solutions with concentration of 0 mg/L, 0.05 mg/L, 0.1 mg/L, 0.3 mg/L, 0.5 mg/L, and 1.0 mg/L were prepared by further dilution. Under acidic conditions, the active phosphate reacts with ammonium molybdate to form yellowish phosphomolybdenum yellow, which is reduced to blue phosphomolybdenum blue by stannous chloride, such as Formulas (7) and (8):

$$\mathrm{H\_3PO\_4} + 12(\mathrm{NH\_4})\_2\mathrm{MoO\_4} + 21\mathrm{HNO\_3} = (\mathrm{NH\_4})\_3\mathrm{H\_4}[\mathrm{P(MoO\_2O)\_6}] + 21\mathrm{NH\_4NO\_3} + 10\mathrm{H\_2O}, \quad (7)$$

$$\mathrm{H}(\mathrm{NH\_4})\_3\mathrm{H\_4}[\mathrm{P(Mo\_2O)\_6}] + 2\mathrm{SnCl\_2} + 4\mathrm{HCl} = (\mathrm{NH\_4})\_2\mathrm{H\_4}[(\mathrm{Mo\_2O})\_5] + 2\mathrm{SnCl\_4} + 2\mathrm{H\_2O} \tag{8}$$

The image information of the generated blue solution is obtained by the chromaticity measurement system proposed in this design, as shown in Figure 7b.

A chloride standard solution (1000 mg/L) was purchased from Zhongke Beijing Instrument Consumables Standard Materials Store of China. The chloride standard solution was diluted to 0 mg/L, 2 mg/L, 5 mg/L, 10 mg/L, 15 mg/L, and 20 mg/L. In neutral or weak alkaline solution, when potassium chromate is used as the indicator and silver nitrate is used to titrate chloride, because the solubility of silver chloride is less than that of chromate, after the chloride ion is completely precipitated, the chromium ion is precipitated in the form of silver chromate, and a brick red substance is produced. The color of the red precipitate is proportional to the chloride content. The precipitation titration reactions are Formulas (9) and (10):

$$\text{Ag}^+ + \text{Cl} \rightarrow \text{AgCl} \downarrow (\text{white})\_\prime \tag{9}$$

$$\text{2Ag}^+ + \text{CrO}\_4^{2-} \rightarrow \text{Ag}\_2\text{CrO}\_4 \downarrow \text{(brick red)}.\tag{10}$$

The brick red precipitate solution is placed in the designed chromaticity measurement system to obtain the image information of the solution, as shown in Figure 7c.

Figure 7a shows the image information and HS standard deviation of different concentrations of ammonia nitrogen, and Figure 7b,c show the image information and HS standard deviation of different concentrations of phosphate and chloride, respectively. Among them, △HS is the standard deviation between the HS value of each dissolved matter image and the HS value of the blank sample image, which is calculated by formula (11):

$$
\Delta \text{HS} = \sqrt{(\text{H} - \text{H}\_0)^2 + (\text{S} - \text{S}\_0)^2}. \tag{11}
$$

#### **3. Results**

The HS value of standard chromaticity solution was used to fit the non-linear relationship with the chromaticity, and a three-dimensional chromaticity measurement model based on HS was established. The model was applied to the measurement of the standard chromaticity solution to verify the accuracy of the measurement method. When comparing the proposed method with spectrophotometry, the accuracy of this method is higher than that of spectrophotometry for the standard chromaticity solution; for the actual water sample measurement, there is no significant difference between the measurement result of this method and that of spectrophotometry.

#### *3.1. Fitting Results*

The color includes chromaticity and brightness, and the chromaticity of the color is obtained by separating the brightness of the color. After separating the brightness, the color image only contains H and S values, which correspond to the chromaticity, so the relationship model between HS and

chromaticity can be established. The data fitting software Origin 8.0 (OriginLab, Northampton, MA, USA) is used to establish surface fitting with H and S as X and Y axes and chromaticity as Z axes, respectively. The fitting results are shown in Figure 8.

Ag Cl AgCl (white)

4 2 4 2Ag CrO Ag C ) rO ( re brick d

2 2 ΔHS = (H H ) + (S S ) 0 0

△

+ 2-

**Figure 8.** Fitting results of hue (H) and saturation (S) values and chromaticity.

The chromaticity data in the graph are all distributed on the surface, which is the fitting surface of HS and chromaticity. The expression is as shown in Formula (12), and the fitting degree is as high as 0.99845:

$$Z = 634.4507 - 6.73548x - 2.61133y + 0.01882x^2 + 0.04596y^2. \tag{12}$$

In Formula (12), *x* represents the input value H, *y* is the input value S, and *Z* is the chromaticity of the corresponding solution. By substituting the HS value of the solution to be measured into the expression, the chromaticity of the solution to be measured can be calculated.

#### *3.2. Measurement Results*

In order to verify the accuracy of the designed chromaticity measurement system, the model was used to measure the standard chromaticity solution with known chromaticity. The results of measurement and comparison are shown in Table 1.


**Table 1.** Measurements of the standard chromaticity solutions.

From Table 1, the results of the proposed method are close to the standard chromaticity solution, and the error is small. Therefore, the designed chromaticity measurement system can effectively measure the chromaticity of water.

#### *3.3. Contrast Experiment of Standard Chromaticity Solution*

In order to verify the accuracy of the proposed method, the chromaticity measurement model is compared with the latest spectrophotometric method.

In this comparative experiment, a 721 G visible spectrophotometer produced by Shanghai Instrument and Electrical Analysis Instrument Co., Ltd., was used as the comparative object.

When using a spectrophotometer to measure the chromaticity of the solution, it is necessary to determine the characteristic wavelength of the solution to be measured at first. Because of the absorption wave of natural water reaches its peak at 380 nm, and the wavelength of the spectrophotometer is set to 380 nm. A 3 cm colorimetric dish was selected to hold the solution to be measured, and a higher accuracy could be obtained. The wavelength of the spectrophotometer was adjusted to 380 nm. The standard chromaticity solution was put into the spectrophotometer to measure the absorbance. Finally, the standard curve of absorbance (A) and chromaticity was established, as shown in Figure 9.

2 2 634.4507 6.73548 2.61133 0.01882 0.04596

**Figure 9.** Fitting curves of absorption and chromaticity.

The fitting expression is Formula (13), and the fitting degree is as high as 0.99741:

$$y = 555.2641x - 10.33369. \tag{13}$$

According to the fitting curve of absorbance and chromaticity, the measurement results of spectrophotometry for the standard chromaticity solution can be obtained. The results are compared with the proposed chromaticity measurement system. Some of the comparison results are as shown in Table 2.

**Table 2.** Comparison of measurement results by two methods.


Table 2 shows that the mean deviation and standard deviation of the standard chromaticity solution measured by spectrophotometry are larger than those proposed in this paper, and the proposed method has higher accuracy. The comparison results of the two methods are shown in Figure 10.

**Figure 10.** Comparisons of two measurement methods.

In Figure 10, samples one to five represent 20◦ , 55◦ , 150◦ , 265◦ , and 430◦ standard chromaticity solutions. The measurement curve of the proposed method almost coincides with the standard chromaticity curve, and the measurement error fluctuates around 0. The deviation between the spectrophotometric measurement curve and the standard chromaticity curve is relatively large, and the fluctuation range of the measurement error curve is larger than that of the method proposed in this design. Therefore, the accuracy of the proposed method is higher than that of the spectrophotometric method.

#### *3.4. Contrast Experiment of Actual Water Sample*

The local tap water (Sample 1), lake water (Sample 2 to 4), and river water (Sample 5) were taken as the actual samples of the validation experiment, and the proposed method and spectrophotometric measurement were used, respectively. First, the HS value and absorbance of actual water samples were measured by the designed chromaticity measuring device and 721 G visible spectrophotometer. Some image data acquisition results are shown in Figure 11.


**Figure 11.** Partial actual water sample data.

The HS and A (absorbance) values of the actual water samples were substituted into the chromaticity measurement model and the fitting expression of the spectrophotometry, and the results of the two methods for the actual water samples were obtained as shown in Table 3.


**Table 3.** Comparison of measurement results by two methods.

A comparison of the two measurement methods for an actual water sample is shown in Figure 12, and the results are tested by an independent sample t-test. The test results are shown in Table 4.

In Figure 12, the measurement results of the proposed method have the same trend as those of spectrophotometry, and the error is small. In Table 4, the independent sample t-test of the two methods shows that the *p* value is 0.93 (>0.05), which shows that there is no significant difference between the two methods. The validity of the design in the actual water sample measurement is verified.

**Table 4.** Comparison of measurement results by two methods.


−

**Figure 12.** Comparison of measuring results for actual water samples.

#### **4. Discussion and Further Application**

#### − *4.1. Camera Combined with Image Processing Technology instead of Photoelectric Instrument to Detect Colorable Substances in Water*

The main purpose of water quality detection is to detect and analyze the composition, nature, and content of pollutants in water to ensure the safety of water quality [28]. In order to detect water quality more effectively and conveniently, digital camera and image processing technology can be used instead of traditional photoelectric instruments to measure the content of colored organic matter in water. Most of the digital cameras use Complementary Metal-Oxide-Semiconductor (CMOS) sensors. As a semiconductor element, the CMOS photosensitive element is used to record the light changes, which is mainly composed of silicon and germanium. Their advantages are the high integration, low power consumption, and low cost. Each pixel of the camera is equivalent to a photoelectric detection element. The signal processing unit integrated by the camera can replace the digital to analog conversion circuit and the signal processing circuit of the photoelectric detection instrument. Using a camera and the HS color component of a picture to measure water quality can avoid the design of the photoelectric detection circuit, signal processing circuit, digital to analog conversion circuit, and display circuit. In theory, the detection of trace components based on color reaction can be realized by using digital camera and image processing technology.

#### *4.2. Application in the Detection of Ammonia Nitrogen, Phosphate, and Chloride in Water*

Generally, the polluted water contains solutes such as ammonia nitrogen, chloride, phosphate, and sulfide [29]. The proposed chromaticity measurement system was applied to the measurement of dissolved substances such as ammonia nitrogen, phosphate, and chloride in water for water quality detection, and the standard curve of HS standard deviation and dissolved substance content in water was established.

The RGB and HSI values of the pictures of ammonia nitrogen, phosphate, and chloride solutions with different concentrations were obtained by using the designed chromaticity measurement system. The standard deviation of HS for each concentration of solute and blank solution was obtained, as shown in Figure 7. The standard deviation of HS was fitted with the concentration of solute in water, and the standard curve was established. The standard curve expression and the fitted results are shown in Figure 13.

**Figure 13.** Fitting curve and result of soluble content in water. (**a**) is the fitting curves of ammonia nitrogen. (**b**) is the fitting curves of phosphate. (**c**) is the fitting curves of chloride.

Figure 13a–c shows the fitting curves of ammonia nitrogen, phosphate, and chloride concentration, respectively. The fitting curve is used to measure the standard organic compound solution and test the accuracy of the fitting curve. The different concentrations of ammonia nitrogen, phosphate, and chloride standard solutions were taken, respectively, and used in the chromaticity measurement system to obtain image information of the standard solution, as shown in Figure 14.

Figure 14a–c shows the image information of different concentrations of ammonia nitrogen, phosphate, and chloride solution. The established concentration measurement curve was used to measure the standard organic compound solution, and the measurement results are shown in Figure 15.

*Water* **2019**, *11*, 2339

**Figure 14.** Image information of standard organic compound solution. (**a**) is the image information of different concentrations of ammonia nitrogen solution. (**b**) is the image information of different concentrations of phosphate solution. (**c**) is the image information of different concentrations of chloride solution.

**Figure 15.** Measurement results of standard solution for ammonia nitrogen, phosphate, and chloride. (**a**) is the measurement results of standard solution for ammonia nitrogen. (**b**) is the measurement results of standard solution for phosphate. (**c**) is the measurement results of standard solution for chloride.

The errors between the measurement results and the standard concentration of solute are shown in Table 5.


**Table 5.** Comparison of fitted concentration and standard concentration.

Table 5 shows that the average difference between ammonia nitrogen concentration measured by the fitting curve and standard concentration is 0.008, phosphate concentration is 0.031, and chloride concentration is 0.372. The error between the fitted concentration of solute and the corresponding standard concentration is small, which indicates that the designed color measurement system can be applied to the measurement of solute content in water and has higher accuracy.

#### *4.3. Comparison of Water Quality Detection Methods based on Camera Image*

In recent years, a water quality detection method based on the image method has been proposed, mainly based on the ratio and reflection of three primary colors.

M. white et al. [30] found that linear relations between both the ratio of red/green digital output (O/P) values (at a particular camera exposure) and the difference in green–red digital camera O/P were found with the mineral suspended solids (MSS) concentration. A good comparison was also found between the ratios of red/green upwelling light measured with the camera and a conventional irradiance sensor. However, semi-empirical or analytical relationships between camera O/P and the inherent optical properties of the water could not be established. Then, Goddijn [31] proposed a method to measure the content of yellow substance and chlorophyll in water by using a digital camera. The RGB value of an underwater picture was obtained by using a digital camera and the linear relationship between colored dissolved organic matter and the R/B camera output. The log–log relationship between chlorophyll and the G/B camera output was established. These two methods are based on the RGB ratio of the water image.

Based on the water reflection model, a linear relationship between water column radiation and water concentration is established [32] for water quality detection. Based on a similar principle, Thomas Leeuw et al. [33] put forward an App called Hydro Color. The program first obtains three images with cameras, which are used to calculate the red, green, and blue wide band remote sensing reflection. Finally, it estimates the water reflection coefficient (the reflection coefficient can be reversed to estimate the concentration of absorbed and scattered substances in water) and turbidity value according to the remote sensing reflection. These two methods are based on the RGB reflection of water images.

From RGB to HSI color space, a water quality detection method based on the HSI component of a water image was proposed, and a sealed image acquisition device with a constant light source was designed to acquire water image, which avoids the interference of external environment on image information and ensures the accuracy of the measurement. Compared with the traditional optical instrument measurement method, the proposed method has higher accuracy and is effectively applied to the measurement of actual water samples. Compared with the above methods, the proposed method is based on the chromaticity method, which eliminates the influence of brightness, and can be used for the measurement of almost all colored substances in water. Due to a constant light source and closed measurement environment, the proposed method has high stability and practicability and is not affected by the external environment, which can be used as a perfect water quality detection instrument. In the future, we need to study various color components of water, obtain more measurement values, establish an effective and perfect water quality measurement model and apply the method to medicine, food, and other fields.

#### **5. Conclusions**

Using a digital camera to acquire a solution image to measure the chromaticity and solute content in water has the advantages of high accuracy, low cost, and strong practicability. It provides a new method for water quality detection. The RGB and HSI values of solution images can be obtained by the designed image acquisition system and processing software. The chromaticity measurement model based on H and S values was established to measure the chromaticity of water and compare it with spectrophotometry. For the measurement of a standard chromaticity solution, the proposed method has higher accuracy than spectrophotometry. For the actual water sample measurement, there is no significant difference between the results of this method and the spectrophotometer method. A curve based on the H and S standard deviation was established. The fitting results accorded with the exponential law, and the fitting degree was more than 0.999. It can be used to measure the solute content in water. This method can be widely used in almost all the determination of trace components based on color reaction, which can replace spectrophotometry without the wavelength setting and is easy to operate. The method is not only suitable for direct color analysis of natural water, but also suitable for wastewater detection. However, wastewater samples must be pretreating, such as digestion, distillation, precipitation, etc., and is preferred to separate and remove interferences.

**Author Contributions:** Conceptualization, P.C. and S.L.; data curation, S.L.; formal analysis, Y.Z.; funding acquisition, H.G.; investigation, W.Z.; methodology, Y.Z.; project administration, S.L.; resources, P.C. and Y.Z.; software, P.C.; supervision, H.G.; validation, W.Z. and H.G.; visualization, P.C.; writing—original draft, P.C.; Writing—review and editing, S.L.

**Funding:** This research was funded by the National Natural Science Foundation of China (No. 61671434) and the Natural Science Fund for Colleges and Universities of Anhui Province (No. KJ2017ZD32).

**Acknowledgments:** The authors would like to thank Hongwen Gao for their assistance on this project.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
