Abstract

Using the standard colors provided in the instructions, PackTest products can approximate and quickly estimate the chemical characteristics of liquid samples. The combination of PackTest products and deep learning was examined for its accuracy and precision in quantifying chemical oxygen demand, ammonium ion, and phosphate ion using a pseudocolor imaging method. Each PackTest product underwent reactions with standard solutions. The generated color was scanner-read. From the color image, ten grayscale images representing the intensity values of red, green, blue, cyan, magenta, yellow, key black, and , and the values of and were generated. Using the grayscale images representing the red, green, and blue intensity values, 73 other grayscale images were generated. The grayscale intensity values were used to prepare datasets for the ten and 83 (=10 + 73) images. For both datasets, chemical oxygen demand quantification was successful, resulting in values of normalized mean absolute error of less than 0.4% and coefficients of determination that were greater than 0.9996. However, the quantification of ammonium and phosphate ions commonly provided false positive results for the standard solution that contained no ammonium ion/phosphate ion. For ammonium ion, multiple regression markedly improved the accuracy using the pseudocolor method. Phosphate ion quantification was also improved by avoiding the use of an estimated value for the reference solution that contained no phosphate ion. Real details of the measurements and the perspectives were discussed.

1. Introduction

PackTest products, like test strips, qualitatively indicate chemical characteristics of liquid samples. PackTest products are cost-effective, convenient, quick, easy to use, safe, and have minimal waste and thus are highly feasible to use. There are some ten PackTest products (http://kyoritsu-lab.co.jp/english/). Each product contains dry reagents in a handy, flexible, and elastic semitransparent plastic pack. By pressing the pack to purge the air inside and submerging the pack edge in a liquid sample, the plastic pack takes in the sample liquid from a small hole at the edge of the pack. The reagents react with the chemical to be detected. The reaction generates visible coloration of the entire reaction system in the plastic pack [1]. Thus, the user can visually observe if there is a particular chemical in the liquid sample. The products were originally designed for quick and approximate detection of chemicals, and thus, they are considered to be qualitative or semiquantitative analytical tools. For qualitative or semiquantitative detection, users refer to a series of standard colors that show the approximate concentration of the chemical in question, which generates a color after the chemical reaction. Because of the feasibility, PackTest products may be widely used in various places including secondary schools [2] and field sites with environmental issues [3].

By referring to standard colors, PackTest users find the closest value that is represented by a standard color. For this reason, PackTest was originally a tool with discrete measures for the chemical characteristics. However, recent studies indicated the possibility that the PackTest products can be tools for accurately and quantitatively determining the chemical characteristics of liquid samples [4]. These tools can be used with continuous measures provided by computation such as regression. The continuous measures can solve the difficulty in determining the closest value when a sample color nears the midpoint between two standard colors [5]. Another reason that continuous measures are preferred is that accurate quantitative determination of chemical characteristics is more advantageous than qualitative detection. An example is the critical effects of blood biochemical characteristics at low levels [6]. Improving the accuracy of PackTest products is expected to enable detection of subtle but significant signals [7]. Previous studies aimed to enhance the accuracy of the feasible tools such as test strips by determining the regression models that describe the chemical characteristics [8]. In addition to the regression techniques, deep learning tools are now commonly available.

Deep learning is especially advantageous for analyzing images. Deep learning was used to explore relationships between health and information that was derived from medical images [9]. Besides its application to image analyses, deep learning was expected to extract the patterns of color changes in the PackTest reaction mixture as responses to changes in the level of the chemical characteristics in question. Deep learning evolved from artificial neural network that was well established and used for quantitative determination of chemical characteristics [10]. Deep learning is relatively more tolerant to some limitations, such as overtraining, which more significantly affect artificial neural networks. Recently, freeware for deep learning was launched. To the best of my knowledge, few studies have involved deep learning for quantification of chemical characteristics.

Based on the above background, this study was conducted to apply deep learning to quantify chemical characteristics of liquid samples. These characteristics were chemical oxygen demand, ammonium ion concentration, and phosphate ion concentration. Standard solutions with multiple levels of the chemical characteristics were prepared. Coloration was generated by introducing the standard solutions to the PackTest products. The colored pack was optically scanned. The color image was used as the starting material for 83 grayscale images to enhance the information [4]. The grayscale intensity values for selected pixels that indicate the chemical characteristics were read and used for deep learning. Validating the training results revealed that some chemical characteristics were very accurately quantified. However, for some chemical characteristics, the training was found to have problems. These problems were, however, avoided when complementally techniques were used.

2. Materials and Methods

2.1. PackTest Products

PackTest products for determining chemical oxygen demand, ammonium (NH4+) ion, and phosphate (PO43−) ion (Kyoritsu Chemical-Check Lab, Corp., Tokyo, Japan) were purchased. PackTest is a series of products for determining the chemical characteristics of liquids (http://kyoritsu-lab.co.jp/english/). The product is a handy and flexible plastic pack that has a hole at the edge. The plastic pack contains a set of reagents that react with the chemical (characteristic) to be measured colorimetrically. After purging the air inside the pack using the hole, the pack edge is submerged in the sample liquid and the sample enters the pack through the hole. Then, the chemical characteristic is approximately determined by referring to standard colors in the instructions that come with the pack. Chemical oxygen demand is detected by applying the principle of alkaline oxidation with potassium permanganate [11]. NH4+ and PO43− are detected using an indophenol reaction [12] and a molybdenum blue reaction [13], respectively.

2.2. Standard Solutions and Reaction

Glucose solutions, the standard solutions for chemical oxygen demand, were prepared by dissolving glucose in distilled water. The concentrations were 1.46, 2.93, 5.86, 11.7, 23.4, 46.6, and 93.8 mg·glucose·L−1. These glucose concentrations are 1.56, 3.13, 6.25, 12.5, 25, 50, and 100 mg·chemical·oxygen·demand·L−1. Ammonium standard solutions were prepared by dissolving ammonium chloride in distilled water. The concentrations were 35, 69, 139, 278, and 556 µM. Phosphate ion standard solutions were prepared by dissolving sodium dihydrogen phosphate dihydrate in distilled water at 0, 13, 26, 53, and 105 µM.

The edge of a pack for chemical oxygen demand was submerged in the standard glucose solution. The standard solution was introduced into the pack from a small hole at the edge of the pack until it contained solution to a depth of 3.5 cm. Then, the standard solution in the pack was gently stirred by turning the pack, according to the manufacturer’s instructions. The reaction took 5 minutes at room temperature (approximately 23°C). Five pack replications were used for each glucose concentration.

Similarly, the phosphate ion (PO43−) standard solution was introduced into the pack for phosphate ion detection. The phosphate ion kit contained a small plastic container to accurately take in 1.5 mL of liquid sample into the pack. The reaction took 1 minute at room temperature. The ammonium chloride standard solution was introduced into the pack for the ammonium ion (NH4+) detection at 1.5 mL·pack−1 in a similar manner. The reaction took 5 minutes at room temperature. Three pack replications were used for each NH4+ or PO43− concentration.

2.3. Image Acquisition and Processing

The coloration was read using an Epson GT-S 650 optical scanner (Seiko Epson Corp., Suwa, Japan) at 300 dots per inch in the professional mode. The other settings of the scanner were set at the default. The scanner was placed vertically, and the colored pack was attached at approximately the center of the scanner’s bed glass using scotch tape to prevent the solution from leaking out. The scanner lid, with a white plastic pad on the inside, was loosely closed. An image of the colored pack was acquired in the dark. The image was saved as a JPG file and then converted to a tag image file format file in the red-green-blue (RGB) mode with the sRGB color space.

Details of the image processing methods are described elsewhere [4, 14]. With Adobe Photoshop CS2 software (Adobe Systems Inc., California, USA), the tag image file format image generated ten grayscale tag image file format images that indicated the grayscale intensity values for the color components of RGB, cyan-magenta-yellow-key black (CMYK), and the International Commission and Illumination’s color models (Figure 1). CMYK images were generated using the International Color Consortium profile of US Web Coated (SWOP) v2 for digital output such as color printing. Hereafter, these ten grayscale images will be called the original ten grayscale images (Figure 1). An RGB yellow hybrid grayscale image was prepared by merging the R and G grayscale images at the same weights [15]. Similarly, RGB cyan and RGB magenta hybrid grayscale images were prepared by merging the G and B grayscale images and the R and B grayscale images, respectively.

To prepare a pseudocolor RGB image, the entire area of a B grayscale image in an RGB color image was substituted by the RGB yellow grayscale image. Hereafter, this image is called the RGyB image (Figure 1). A pseudocolor RG-yB image was prepared by substituting the B grayscale image of the RGB color image with the black-white inverted RGB yellow grayscale image. Similarly, an RmGB pseudocolor image was prepared by placing the RGB magenta grayscale image onto the entire area of a G grayscale image of an RGB image. R-mGB, cRGB, and -cRGB pseudocolor images were also prepared and saved.

Pseudocolor images carrying two or three of the RGB cyan, RGB magenta, and RGB yellow hybrid grayscale images were also prepared (Figure 1). For example, the G and B grayscale images of an RGB image were substituted with the RGB magenta and yellow hybrid grayscale images, respectively. Hereafter, this image is called the RmGyB pseudocolor image. Similarly, cRGyB and cRmGB pseudocolor images were prepared. By substituting the R, G, and B grayscale images of the RGB color image with the RGB cyan, magenta, and yellow hybrid grayscale images, respectively, a cRmGyB pseudocolor image was also prepared.

The ten pseudocolor images were saved as tag image file format files. Each of the pseudocolor images was converted to CMYK and color images. Next, grayscale images that showed the intensity values of C, M, Y, K, and and the values of and were prepared from each pseudocolor image (Figure 1). Hereafter, the C, M, Y, K, , , and images are referred to as the RGyB C grayscale image and so on. Thus, 70 grayscale images were added to the original ten grayscale images and the three hybrid grayscale images of RGB yellow, RGB magenta, and RGB cyan. A total of 83 grayscale images were obtained for each chemical characteristic.

The grayscale intensity values for pixels representing the colors for the standard solutions were read by running MultiSpec version 3.4 for Windows (Purdue Research Foundation, Indiana, USA). The intensity values were digital numbers between 0 (complete black) and 255 (complete white). Within a single pack image, ten replication pixels and five other pixels were selected as training and validation pixels, respectively. The pixels were selected in an image area with the least diffuse reflection. The grayscale intensity values for the selected pixels were read for the 83 grayscale images. Grayscale datasets based on the original ten (RGB, CMYK, and ) and all 83 images were prepared and compared in terms of accuracy of quantification of the chemical characteristics.

To train deep learning of relationships between coloration and chemical oxygen demand levels, the grayscale intensity values for the ten replication pixels × five packs × eight chemical oxygen demand levels, 400 pixels were used. Similarly, to estimate NH4+ and PO43− concentrations, the grayscale intensity values for the ten replication pixels × three packs × six (NH4+) or five (PO43−) levels thus 180 (NH4+) or 150 (PO43−) training pixels were used. Besides the training pixels, validation pixels were selected. The numbers of pixels used for the validation were 200 (chemical oxygen demand), 90 (NH4+), and 75 (PO43−).

2.4. Deep Learning and Related Techniques

Using a SONY neural network console 1.20 (SONY Corp., Tokyo, Japan), deep learning was performed. From the basic series of architecture, 10_deep_mlp.sdcproj was selected. The architecture consisted of five layers (Figure 2). In Figure 2, Affine is a networking structure and Tanh is a process in which hyperbolic tangent-converts a value generated by the upstream processes to provide a converted value between −1 and 1. Sigmoid converts a value generated by the upstream processes to provide a sigmoid-converted value between 0 and 1. The last process of this architecture was BinaryCrossEntropy for binarization of the input data. However, in this study, it was substituted by SquaredError to minimize errors in the estimation of values. Eighty-three and the other values on the right side along the architecture diagram (Figure 2) are the number of values inputted and processed in the layer. When values derived from the ten grayscale images were inputted, the first input number was ten instead of 83. The raw grayscale intensity values were divided by 255 before the values were processed by the architecture, as recommended by the manufacture’s manual. For training and validation, ten and five grayscale intensity values were used for each plastic pack, respectively. The default settings were used in the training and validation except that the number of epochs was 3000. By confirming the discrepancy between changes in training and validation errors, overtraining was monitored.

To complement the quantification using the grayscale intensity datasets and deep learning, the author used the statistical software IBM SPSS Statistics V.24.0 (IBM Corp., New York, USA). The multiple regression model that most significantly describes changes in the chemical characteristic was identified using the stepwise method at the default criteria ( for inclusion and 0.10 for removal). This may generate multiple regression models. However, those that consist of any coefficient with a variance inflation factor of ten or greater were eliminated because the coefficient was unreliable [16].

Through the above processes, the normalized mean absolute error [17] and coefficient of determination (R2) were obtained as indicators of accuracy and precision, respectively. The normalized mean absolute error was determined as follows:

The values of these statistics were compared among the best regression models for the datasets for the ten and 83 images to investigate the effects of pseudocolor imaging on the precision and accuracy of determining the chemical characteristics.

Another error statistic was used to confirm the reproducibility of the scanner-read color intensity values. The statistic called the coefficient of variation was determined as follows:

The reproducibility was evaluated by reading the color intensity values for 30 selected Microsoft Office standard colors (Figure 1) that were printed on white paper. Using the Epson GT‐S 650 scanner, the colors were read eight times, and thus, eight RGB color images were obtained. Coefficients of variation for the intensity values of redness, greenness, and blueness were determined for the 30 standard colors.

To observe the performance of the 83 grayscale images that were used in this study, a color gamut [14] and the standard colors in Figure 1 were used. The color gamut and standard colors were provided by Microsoft Office 2016. The tag image file format image of the gamut and standard colors was used to obtain the colors’ profiles by reading the grayscale intensity values for the 83 grayscale images. There were 144 standard colors. In the gamut, 187 pixels were randomly selected. The grayscale intensity values were read for the 331 pixels in the 83 grayscale images. The intensity values for the 331 pixels × 83 images were used for principal component analysis using the IBM SPSS software.

3. Results and Discussion

Figure 3 shows color development in the plastic packs. When visually observed, the colors were comparable to those in the instructions provided by the manufacturer, but the images obtained by the scanner were less colorful than those in the instructions. The semitransparency of the plastic material may be at least partially responsible for the relative darkness. Based on the grayscale intensity values derived from the scanner-acquired colors, the chemical oxygen demand was accurately quantified (Figure 4). Training and validation curves overlapped well, and thus, there was no overtraining. The normalized mean absolute errors were 0.384% and 0.347% for the original ten and 83 images’ datasets, respectively. The normalized mean absolute error was approximately comparable to the corresponding coefficient of variation [4]. From this viewpoint, the normalized mean absolute error was very small compared with those regarded as acceptable values of 10% in areas of analytical chemistry [18] or 5 to 10% in food chemistry [19].

The chemical oxygen demand has been determined using various methods. Some researchers developed sophisticated methods such as a flow chemiluminescence method [11]. Less complicated methods are colorimetry [20] and titration [21], which are more complicated and time-consuming than the current method. Thus, the PackTest product for chemical oxygen demand could be an advantageous alternative for quantitative determination of the chemical oxygen demand. However, based on the coloration, it should have been difficult to use this tool to its fullest because changes in color are complicated. Figure 5 demonstrates this complexity. When the intensity values for the pixels in the original ten grayscale images were investigated, no monotonic increase/decrease in chemical oxygen demand was recognized. These complex patterns of color change as responses to changes in chemical oxygen demand of samples disabled the simple empirical description of chemical oxygen demand using a single color component of RGB, CMTK, and color models.

Another difficulty was suggested. The intensity values for each color component at a single chemical oxygen demand level showed errors (Figure 5). For example, the grayscale intensity values for the pixels in the B grayscale image ranged from less than 90 to 120. The scanner was investigated for its role in this difficulty. The minimum grayscale intensity values for the selected 30 Microsoft standard colors were 47 (redness), 32 (greenness), and 28 (blueness). The maximum values were 253 (redness), 243 (greenness), and 244 (blueness). The coefficient of variation ( scanning trials) ranged between 0.2% and 9.1% (redness), 0.3% and 9.0% (greenness), and 0.4% and 15.1% (blueness). The mean coefficient of variation ( colors) was 3.0% (redness), 3.9% (greenness), and 3.3% (blueness).

Therefore, the scanner was demonstrated to have good reproducibility. A more likely source of the errors was an inconsistency in attaching the pack onto the scanner’s glass bed. The pack was attached each time as consistently as possible. However, in the interface between the glass bed and the pack’s surface, slight differences should have occurred. The differences among the replication color readings were thought to be responsible for the errors indicated by the raw grayscale intensity values in Figure 5. However, the deep learning architecture completely eliminated the errors in the training processes. According to Figures 3 and 4, a chemical oxygen demand value of 4 mg·L−1 or lower is detectable by combining the PackTest product and deep learning. A chemical oxygen demand of 4 mg·L−1 or lower is favorable for a fresh water trout subspecies of Oncorhynchus masou [22], which is an important fish species ecologically and as a foodstuff. The current combination of PackTest and deep learning enabled the accurate detection of low levels of chemical oxygen demand for water samples that were polluted at levels that were marginally critical for O. masou.

Quantification of NH4+ that relied on deep learning was less successful than that of chemical oxygen demand (Figure 6) although no signals of overtraining were observed. For both the ten and 83 images' datasets, the normalized mean absolute error and R2 were around 3% and 0.99, respectively. Regression coefficients were 0.953 (10 images) and 0.954 (83 images). These values deviated from 1.0, which was considered to be a perfect match, shown as red oblique lines in Figure 6. The most critical part was that the pack containing no NH4+ was shown to contain 35 µM NH4+. This indicates the possibility of a false positive result if users rely on deep learning and the other techniques that were applied in this study. Here, multiple regression markedly improved the precision, resulting in a smaller normalized mean absolute error of 2.34%. Overall, the regression was very accurate, with a coefficient of 1.001 and a constant of 0.000. The multiple regression model was as follows:where and the other names of the grayscale images indicated the grayscale intensity values for the selected training pixels in the grayscale images. The variance inflation factor was 2.50 () or less, indicating good reliability for the three coefficients. The grayscale intensity for the images had a more significant linear correlation with the NH4+ concentration (R2 = 0.916) compared with the others for which the R2 values were smaller than 0.460 (Figure 7). Although the R2 value of 0.916 for the grayscale intensity may seem to be large, it was much smaller than the 0.992 result for the multiple regression model (Figure 6). This indicates that the multiple regression model was achieved using the combination of less linear variables as previously described [4].

In quantification of PO43−, no signals of overtraining were recognized. However, the quantification had a similar problem to that of NH4+. The pack containing no PO43− was indicated as containing a small but detectable amount of PO43− (Figure 8). The normalized mean absolute error and R2 were comparable to those for the NH4+ determination (Figure 6). A regression coefficient of 0.922 for deep learning with the original ten images’ dataset was worse than that of 0.953 for NH4+ determination by deep learning with the original ten images’ dataset (Figure 6). Unfortunately, multiple regression did not provide reliable results to improve the poor performance. However, these poor results could be circumvented by limiting the range of PO43− concentration to be determined. The deep learning-estimated values for 0 µM PO43− were eliminated (Figure 8). Although the range of PO43− concentration that the method can determine became 13.1 to 105 µM PO43−, the error statistics were significantly improved.

The 83 images’ dataset improved the accuracy of the NH4+ and PO43− determination (Figures 6 and 8). Principal component analysis of color profiles based on the 331 pixels in the Microsoft standard colors and gamut is provided in Table 1. The table shows a data structure based on the grayscale intensity values for the 331 pixels in the 83 grayscale images. Table 1 presents the results regarding significant principal components with eigenvalues of 1 or greater [23]. Principal component loading values for the 83 grayscale images are presented. In a previous study, adding the grayscale images was shown to provide more opportunities to obtain new patterns of changes in the grayscale intensity [4]. When a user of test strips relies on multiple regression, the different patterns revealed by the principal components were effective in determining the chemical characteristics by combining the best grayscale images that carry the best combination of patterns in the grayscale intensity [4]. In finding differences among color profiles of image pixels representing agricultural plots [24] or tropical forest canopies [25], the 14 grayscale images from the RGyB and RG-yB pseudocolor images together with the RGB yellow hybrid image (Figure 1) generated minor but significant principal components. In this study, among the 15 grayscale images, nine had the highest loadings on the first principal component (Table 1). Thus, the additional 58 grayscale images further diversified the data structure. The Microsoft standard colors and gamut are thought to include more colors than the images of the agricultural plots and the forest canopies. The greater number of colors is also thought to have revealed the more diversified data structure.

Additionally, most of the grayscale images from the RmGB and R-mGB pseudocolor images had the heaviest loadings on the second or third principal component while none of them had the greatest loadings on the first principal component. This was fortunate because the grayscale images even more significantly added the unique information to the original ten and 15 grayscale images examined in previous studies [24, 25]. The second and third principal components were comparable in importance compared with the first principal component, and many grayscale images derived from the RmGB and R-mGB pseudocolor images formed significant regression models in another study [4]. Additionally, the grayscale images derived from the cRGB and -cRGB pseudocolor images had the greatest loadings on the first or third principal component (Table 1). These unique loading patterns indicate greater dimensionality of changes in pixel color in the Microsoft standard colors and the gamut revealed using the pseudocolor imaging method. RGB cyan, magenta, and yellow hybrid images were likely to broaden the dimensionality because these hybrid images had uniquely different loading patterns on the most significant three principal components (Table 1).

Because of the high feasibility, PackTest products can be used to quantify the chemical characteristics of various liquid samples using optical scanners and other digital imaging devices such as digital cameras and colorimeters [26] combined with deep learning and pseudocolor imaging. The combination is applicable to solid samples and similar coloration-based tools including test strips. Examples of possible applications are eliminating difficulties in the positive or negative judgment of urinary creatinine [27], improving somewhat inaccurate description of plant biomass growth [28], and confirming the quality of foods [29] and various other materials. The application may be extended to analyses of samples in various places including laboratories, hospitals [30], schools [31], and homes [7], where the color reading-based tools can be easily introduced.

4. Conclusions

Accurate and highly feasible quantification of chemical characteristics of the liquid sample is possible using PackTest products. The SONY neural network console, as a free-of-charge deep learning tool, was the first choice for processing the grayscale intensity values derived from color readings of the pack that showed a color as a result of the chemical reaction. Multiple regression revealed the possibility to be a substitute for deep learning when deep learning resulted in unsatisfactory accuracy. Another solution was to limit the range of levels/concentrations of the chemical characteristics to be measured. These techniques to maximize the quantification accuracy are supported by enhanced information through pseudocolor imaging processes.

Data Availability

The grayscale intensity data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The author declares that he has no conflicts of interest regarding this study.