**4. Assay preparation**

In previous sections, various hardware and software designs were introduced for smartphone-based spectrometer and colorimetry. These designs need to be tested under the conditions that users may encounter in real life. In this section, strip and assay preparations are introduced, which are commonly used for water quality and field tests.

Colorimetric detection of pH values was studied in [41], which used pH strips to test their proposed system. First, solutions were prepared by mixing deionized water with sodium hydroxide (NaOH) and nitric acid (HNO3) to ensure the pH values in the range of 0–14.0. During the preparations, pH values were checked with a pH meter (HI 2223, Hanna Instruments, RI, USA) calibrated with standard buffers, pH 4.0 (HI 7004) and 7.0 (HI 7007) prior to using pH indicator strips (Merck, Germany). In addition, dual-illumination tests were performed with buffer solutions (4.0–9.0, Sigma-Aldrich, USA). Before imaging pH strips, they were immersed into the pH solutions for 5 s and wiped gently with tissue paper, so that light refraction caused by the liquid drops could be minimized.

*Color Detection*

**Figure 7.**

**3.2 Image acquisition and processing**

A digital image can be acquired either as monochrome (black and white) or color image using electronic equipment utilizing charge-coupled device (CCD) or

*Opening page of the ChemTrainerSIR app is given in (a). The top row (b–g) shows training steps, while the* 

These sensors use a two-dimensional array of millions of tiny light pixels to capture an image. These pixels collect photons and store them as an electrical signal after the shutter button of the camera is pressed which leads to the beginning of the exposure. The pixels are closed after the exposure finishes, and intensity value in the pixel is quantified as digital values by measuring the strength of the electrical signal, which is directly related with the number of photons stored in the pixel. However, this approach would only create a monochrome or gray scale image as the pixels are unable to distinguish photons in terms of color. A color filter needs to be placed over the pixel to capture a color image. This filter allows only one of the primary colors, that is red (R), green (G), or blue (B), to pass into the pixel, so that it stores only filtered photons for the respective color. In other words, the intensity of each pixel gives single color information which leads to a RAW image. Here, each pixel has only one of R, G, or B information while all R, G, and B values need to be known for each pixel. Therefore, demosaicing is applied to determine other two missing color values by interpolating from nearby pixels where those colors are known. After demosaicing, other methods such as white-balance, gamma correction, color space correction, and compression

are applied to convert the image from RAW to a common format like JPEG.

JPEG images have a small size and they can be displayable instantly. However, there are some concerns because of the methods that are applied to convert an image from RAW to JPEG. In the conversion process, the image is compressed resulting in providing a non-linear RGB color space with only 8-bit color depth [43, 53]. However, RAW images contain original image data with 10–14 bits of color information. The conversion process corrupts the linearity of the image. A linear image conserves the relation between the intensity value and the number of photons which maintains the linearity with scene radiance. This linearity is required for quantitative scientific data acquisition in many applications [6, 30, 36, 37, 54]. As a linear image, the RAW format is therefore generally chosen. The main issue is

complementary metal oxide semiconductor (CMOS) sensors.

*bottom row (h–m) presents the implementation of the app on the sample.*

**74**

Peroxide quantification with colorimetric tests was investigated in [28] and hydrogen peroxide (H2O2) solutions were prepared for the peroxide test strips (Quantofix Peroxide 100). First, a stock solution with 500 ppm concentration of H2O2 (Sigma-Aldrich) was prepared in distilled water. The stock solution was later diluted to prepare the initial concentrations such as 1, 3, 10, 30, and 100 ppm. The peroxide test strips were dipped into these solutions for 1 s, and images were taken by smartphone after they were dried on tissue paper for 5 s.

Bisphenol-A (BPA) detection with smartphone spectrometer was demonstrated in [29]. The BPA concentration was determined with absorbance measurements using an immersion probe. The phenolic compound was put into reaction with 4-Aminoantipyrine (4-AAP) (Sigma-Aldrich, >98%) and potassium ferricyanide (Carlo Erba) for colorimetric quantification. Around 200 ppm of BPA stock solution was prepared in ethanol and then test solutions ranging from 0.1 to 10.0 ppm were prepared by serial dilution from the stock solution. The pH of all solutions was set to 8.0 using 0.25 M sodium bicarbonate (NaHCO3) (Sigma-Aldrich, ≤99.7%) and distilled water. To finalize the solutions, 1.5 mL of 20.8 mM 4-AAP and 1.5 mL of 83.4 mM potassium ferricyanide solutions were mixed into 12 mL of BPA solutions. The solutions were ready for the absorbance measurement after 10 min of incubation.

Single-image-referenced colorimetric water quality detection in [45] was performed using four different analyte solutions. The first solution is nitrite (NO2 − ); it reacts with sulfanilamide to form diazonium ion which was coupled with *N*-(1-naphthyl) ethylene diamine dihydrochloride (NED) to produce an azo dye. A stock solution (821 ppm) was prepared by dissolving 1.232 g sodium nitrite in 1 L of distilled water. The buffer stock (164 ppm) and standard (1.64 ppm) solutions were prepared to obtain solutions in concentrations of 0, 0.05, 0.10, 0.20, 0.40, and 0.50 ppm by dilution. The pH of solutions was adjusted with 1 N HCl or NH4OH to give a pH between 5.0 and 9.0. For the color reagent, 10 g of sulfanilamide was dissolved in a mixture of 100 mL of 85% phosphoric acid and 800 mL of distilled water. Then, 1 g of NED was added and diluted to 1 L. After addition of this reagent (2.0 mL) to NO2 − -containing solutions (50 mL), a stable red-violet color was observed. The second solution is the phosphate (**PO4 −3** ) determined by the reaction of ammonium molybdate and antimony potassium tartrate in an acidic medium with solutions containing phosphorus to form an antimony-phosphomolybdate complex which is reduced by ascorbic acid. A stock solution of 50ppm **PO4 −3** *<sup>−</sup>* **<sup>P</sup>** was prepared by dissolving 219.5 mg of anhydrous potassium dihydrogenphosphate in 1 L of distilled water. The solutions of PO4 −3 standards in concentrations of 0, 0.25, 0.50, 0.75, 0.40, 1.00, and 3.00 ppm were prepared by serial dilution. A composite reagent containing (15 mL, 0.032 M), (5 mL, 0.008 M), and (30 mL, 0.100 M) in 50 mL of 5 N sulfuric acid was provided after each reagent addition. The pH of solution was controlled by 1 drop of phenolphthalein addition into the 50 mL of sample solution. If a red color develops, a strong acid is dropped till the color disappears. Then, 8 mL of the composite reagent was added to the sample solutions and they are allowed to stand for at least 10 min to measure the stable blue color. Hexavalent chromium (Cr(VI)) detection is performed by the formation of a colored complex resulting from the reaction of Cr(VI) with diphenylcarbazide in an acidic medium. A stock solution of 500 ppm Cr(VI) was prepared by dissolving 141.4 mg of dried potassium dichromate in distilled water and diluted to 100 mL. To prepare a standard solution of 5.00 ppm Cr(VI), 1.00 mL of the stock solution was diluted to 100 mL. The solutions of Cr(VI) standards in concentrations of 0, 0.05, 0.10, 0.20, 0.40, 0.50, and 1.00 ppm were prepared by serial dilution. The pH of the standards was adjusted to 2.0 ± 0.5 with 0.25 mL of nitric acid and 0.2 N sulfuric acid. Around 2.0 mL of complexation reagent, freshly prepared by dissolving 250 mg

**77**

*From Sophisticated Analysis to Colorimetric Determination: Smartphone Spectrometers…*

of 1,5-diphenylcarbazide in 50mL of acetone and stored in a dark glass bottle, was added to 100 mL of Cr(VI) solutions. After 5–10 min, a red-violet color was visible. At last, phenolic compounds react with 4-aminoantipyrine (AAP) in the presence of potassium ferricyanide at alkaline pH to form a colored antipyrine dye. A preliminary distillation is required to eliminate or minimize possible interfering materials. Copper(II) sulfate pentahydrate (5 mL, 7.6 M) solution was added to a 500-mL sample after the pH of the solution was adjusted to 1–2 with 85% phosphoric acid (v/v) (1 + 9), transferred to the distillation apparatus. The distillation was stopped when the volume of distillate became about 400 mL, and 100 mL of distilled water was added to the flask. Then, distillation was continued until 500 mL of distillate was collected. About 5 mL of ammonium chloride solution was added to a 100-mL portion of distilled sample and pH of the solution was adjusted to pH 10 ± 0.2 with ammonia solution. 4-Aminoantipyrine solution (2 mL, 0.098 M, daily prepared) and potassium hexacyanoferrate(III) solution (2 mL, 0.24 M, weekly prepared)

Quantitative performance evaluations of smartphone-based spectrometer and colorimeter are an important factor in the development of new algorithms and designs. Standard metrics for regression and classification problems can be used to assess smartphone-based system performance. The importance of metrics varies for

In a spectrometer, the absorbance spectrum needs to be calculated using multicolored images. RGB images are mostly converted to HSV images and value (V of HSV) is used to calculate the absorbance (A) using the Beer-Lambert law [56],

where *I0* is the transmitted light intensity of reference solution (mostly distilled

water), and *I* is the transmitted light intensity of the other solutions. After the absorbance graph is plotted with respect to wavelength, the reference wavelength point which gives the maximum absorbance of the reference solution is selected. Then, the calibration curve, which is basically the linear regression line, is plotted

is accepted as a more successful result. Next, evaluation term is the limit of detection (LOD) defined as the lowest quantity or concentration of an analyte that can be reliably detected with a given analytical method. It is calculated as three standard deviations above the reference solution. The slope of the calibration curve is the

In classification-based colorimetry, the following metrics are available: classification accuracy, sensitivity (recall), specificity, precision, and f1-score. These metrics are the same in traditional machine learning classification tasks and can be extracted from the confusion matrix. Classification accuracy is detection accuracy in the case of analytical detection. For binary classification problems with only two classes, the receiver operation characteristic (ROC) curve and area under curve (AUC) are additional metrics. In a confusion matrix, rows represent the instances in an actual (true) class while columns represent the instances in a predicted class. To calculate the detection accuracy, diagonal elements of the confusion matrix are summed and

*I*0

is the first metric to evaluate to assess the performance of the

values greater than 0.9 are acceptable values, although a larger coefficient

*<sup>I</sup>* (1)

(the coefficient of

*DOI: http://dx.doi.org/10.5772/intechopen.82227*

were subsequently added with stirring.

*A* = log10 \_\_

with respect to the reference wavelength point to calculate *R*<sup>2</sup>

**5. Performance metrics**

each sensing scheme.

determination). *R*<sup>2</sup>

sensitivity of the spectrometer.

model. *R*<sup>2</sup>

*From Sophisticated Analysis to Colorimetric Determination: Smartphone Spectrometers… DOI: http://dx.doi.org/10.5772/intechopen.82227*

of 1,5-diphenylcarbazide in 50mL of acetone and stored in a dark glass bottle, was added to 100 mL of Cr(VI) solutions. After 5–10 min, a red-violet color was visible. At last, phenolic compounds react with 4-aminoantipyrine (AAP) in the presence of potassium ferricyanide at alkaline pH to form a colored antipyrine dye. A preliminary distillation is required to eliminate or minimize possible interfering materials. Copper(II) sulfate pentahydrate (5 mL, 7.6 M) solution was added to a 500-mL sample after the pH of the solution was adjusted to 1–2 with 85% phosphoric acid (v/v) (1 + 9), transferred to the distillation apparatus. The distillation was stopped when the volume of distillate became about 400 mL, and 100 mL of distilled water was added to the flask. Then, distillation was continued until 500 mL of distillate was collected. About 5 mL of ammonium chloride solution was added to a 100-mL portion of distilled sample and pH of the solution was adjusted to pH 10 ± 0.2 with ammonia solution. 4-Aminoantipyrine solution (2 mL, 0.098 M, daily prepared) and potassium hexacyanoferrate(III) solution (2 mL, 0.24 M, weekly prepared) were subsequently added with stirring.
