Smartphone-based spectrometer and colorimetry have been gaining relevance due to the widespread advances of devices with increasing computational power, their relatively low cost and portable designs with user-friendly interfaces, and their compatibility with data acquisition and processing for “lab-on-a-chip” systems. They find applications in interdisciplinary fields, including but not limited to medical science, water monitoring, agriculture, and chemical and biological sensing. However, spectrometer and colorimetry designs are challenging tasks in real-life scenarios as several distinctive issues influence the quantitative evaluation process, such as ambient light conditions and device independence. Several approaches have been proposed to overcome the aforementioned challenges and to enhance the performance of smartphone-based colorimetric analysis. This chapter aims at providing researchers with a state-of-the-art overview of smartphone-based spectrometer and colorimetry, which includes hardware designs with 3D printers and sensors and software designs with image processing algorithms and smartphone applications. In addition, assay preparation to mimic the real-life testing environments and performance metrics for quantitative evaluation of proposed designs are presented with the list of new and future trends in this field.
- color sensing
- smartphone spectrometer
- image processing
- Android application
Smartphone-based analysis has recently emerged as a useful tool, and it has been found to be promising in several fields including point-of-care analyses , chemical and biological sensing , microscopy and healthcare diagnostics , water quality sensing for environment [4, 5, 6], leaf color analysis for agriculture , pH [8, 9] and glucose  sensing, fluorescent imaging , imaging cytometry , electrochemical sensing , and immunoassays .
With recent advances on camera and sensor technologies, current smartphones are equipped with a low-power high-performance processor with up to 2.5 GHz operating frequencies; built-in high-resolution digital camera, generally above 5 Mpixels and up to 40 Mpixels; and built-in single or dual LEDs, which allow capturing an image even in low-light conditions . Moreover, they are provided with advanced onboard sensors such as moisture sensors, proximity sensors, electromagnetic compasses, accelerometers, and gyroscopes . These sensors generally provide fast response, being portable and of low cost, and the ability to be used in the field without extensive training . Therefore, smartphones have become a tool as powerful as low-cost computers, which lead them to be valuable instruments in the analysis.
Over the last decade, smartphones have been increasingly used in a variety of scientific fields as spectrometers [18, 19, 20, 21, 22] and colorimeters [23, 24, 25]. Smartphone spectrometers use the wavelength components, which give spectral information, of the collimated light from the optical source which is dispersed after interaction with samples . The color spectrum image is transformed into various color spaces for the extraction of quantitative data. The wavelength of the spectrum generally changes between 400 and 700 nm because of the optical filters set in front of the camera in the manufacturing process. Spectral information has been used in many applications including water monitoring , gas detection , and food quality control . Smartphone colorimeters are commonly used instruments that quantify the concentration of the samples based on color changes due to concentration (like peroxide amount ) or time (methylene blue degradation ). In the colorimetric analysis, features of the referenced images need to be extracted for training the system, mostly created with machine learning or neural networks, which perform the quantitative analysis for the test images. Smartphone colorimeters have applications in both solid samples like paper-based test and liquid samples like colored solutions . Both smartphone spectrometers and colorimeters are powerful tools for rapid qualitative and quantitative analyses due to the fact that they can be used in conditions where sophisticated tools or time-consuming steps cannot be used. They are rapid and low-cost tools that require less sample consumption and provide portability to perform the analysis in remote locations or locations with poor infrastructure .
While smartphones offer an attractive alternative to sophisticated tools for imaging and analysis in the field, there are some concerns about their suitability for quantitative analysis . First, unlike scientific cameras, smartphone cameras have mostly limited control of camera parameters like exposure time, shutter speed, ISO, and color balance, and no access to raw image data which has a linear relationship with scene radiation. In addition, image processing algorithms, such as demosaicing, noise reduction, edge sharpening, white balance, and image compression, are applied automatically and vary significantly across smartphones. These methods corrupt the linearity of the pixel intensity values which causes loss of information that can be used in quantitative analysis. So, it is difficult to set and maintain imaging parameters to get accurate and repeatable information for analysis . Second, ambient light conditions are hard to control during imaging in uncontrolled environments. Last, small color changes cannot be detected in an analysis as the red, green, and blue (RGB) intensity values may not be sufficient. These aforementioned concerns make smartphones questionable for quantitative analysis. Early studies in smartphone-based colorimetric analysis for medical and scientific applications pointed out these concerns and concluded that smartphones are incapable of pathology  or limited due to their image quality .
However, subsequent researchers have proposed a smartphone camera-based microscope which captures qualitatively relevant features of malaria and tuberculosis . These counter conclusions and also advancements in camera and sensors together with the increasing capability in computer processing prove that smartphones are more portable, cost-efficient, and user-friendly platforms which make them alternatives to sophisticated and high-cost devices in quantitative analysis.
For instance, it was shown that a smartphone by itself is capable of quantifying colorimetric test strips without any external attachments [1, 34]. In , water monitoring was implemented with a simple holding attachment. With the help of 3D printing, housing and optical components were integrated into a colorimetric plate reader for enzyme-linked immunosorbent assay (ELISA) . A 3D printed custom cradle including various optical components and an external broadband source, was demonstrated in  for biomarker absorption analysis. To detect miRNA sequences in a liquid-based assay, a smartphone-based fluorimeter system was designed using an external laser as the source . Due to precise light confinement and flexible nature, optical fibers were integrated to smartphone spectrometer and applied for food quality monitoring . To have more portable and cheap spectrometers, new designs were proposed without external electrical and optical components. A fiber optical bench was assembled on top of the smartphone without external LEDs to design a surface plasmon resonance-based refractive index sensor . A spectrometer system was reported in  to detect glucose and troponin-I using built-in flash as a light source and a compact disk for the reflection grating.
In the colorimetric analysis, color information could be obtained with paper-based sensors to quantify the color variation in different color spaces such as RGB, HSV, and L*a*b* [24, 39, 40, 41]. In , alcohol concentration in saliva was detected using paper-based test converting images from RGB to HSV color space. This was the conventional approach which needs only a smartphone camera to capture and process an image. Besides the conventional approach, non-conventional approaches were applied on liquid samples in vials for detection of chlorine in water , and ripeness estimation of fruits . Here, quantification was calculated using analytical formulas extracted from color space parameters. However, it is prone to deviation due to the disadvantages of JPEG images such as low bit depth and heavy post-processing (white balance, contrast, and brightness adjustment) [43, 44]. On the other hand, it was shown in [28, 41] that JPEG images could be used in the colorimetric analysis when advanced algorithms like machine learning were used to process the images. Unfortunately, advanced algorithms need more computational power as they need much larger datasets for training and testing the images. To address this issue, it was reported to use local database referenced with a single image for the quantification of the concentration level of solutions . The proposed design was applied on nitrite, phosphate, chromium, and phenol solutions to quantify the concentration value using a single reference image which was captured and processed initially.
In literature, there are many lab-on-a-chip designs proposed for various applications [17, 46]. Bisphenol-A (BPA) detection in distilled and commercial water samples was demonstrated in  where a plastic fiber-based smartphone spectrometer with a custom-designed immersion probe and a cradle were used. The smartphone spectrometer was converted to a reflection probe spectrometer working within the visible spectrum. Explosive types were detected in  with the paper-based test using hierarchical clustering analysis and principal component analysis (PCA) regarding the color discrimination of the explosives. A closed chamber was used to eliminate ambient light conditions during imaging. Linear correlation and PCA methods were employed, respectively, for univariate and multivariate analyses . It was reported that univariate analysis did not give statistically significant results due to ambient light conditions as imaging was not performed in a controlled environment. However, multivariate analysis gave promising results running PCA methods on eight different color spaces and clustering methods including red, green, blue, hue, saturation, value, lightness, and intensity parameters. A smartphone-based colorimetric reader for ELISA was proposed in  where imaging was performed in a controlled environment illuminated from the bottom. Ozcan and his research group [12, 14, 48, 49, 50, 51] had many designs for specific applications such as food allergen testing , urine  and blood  analysis, immunoassays , microscopy , and cytometry .
The rest of this chapter is organized as follows. The next section introduces the hardware designs for smartphone-based spectrometer and colorimetry. Section 3 presents the mobile apps and image processing algorithms to be used in smartphones. Section 4 describes assay preparation to be used in testing the performance of both spectrometer and colorimeter. Section 5 details the metric to evaluate the performance of the proposed designs. Closing remarks are given in Section 6.
2. Hardware designs
In this section, a brief review of hardware designs of smartphone spectrometer and colorimetry is presented. Because of space constraints, only two examples of spectrometer and colorimetry are demonstrated in Section 2.1 and 2.2, respectively.
Recently, there has been a growing variety of spectrometer designs for specific applications. In , a compact imaging spectrometer was reported equipped with motorized selfie stick for remote sensing. Another spectrometer was designed to calculate spectra and quantify analytes by the assembly of medium-density-fiberboard, a DVD slice for diffraction grid, and mini incandescent lamps . A flexible fiber bundle probe was integrated with a custom-designed cradle to convey spectra data to smartphone camera for food quality monitoring .
The next design  is illustrated in Figure 1a, which is a low-cost, portable, plastic fiber-based spectrometric smartphone to analyze dye adsorption for field-deployable environmental and wastewater management. In the design, the rear camera of LG G4 (1/2.6″ sensor size with 5312 × 2988 resolution, 1.12 μm pixel size) was used to collect the spectral data of the assays.
The smartphone was fitted into a custom-designed cradle assembled with hot-plug apparatus toting a diffraction grating, and the whole part was connected with smartphone case and cuvette holder manufactured from Acrylonitrile Butadiene Styrene polymer using a 3D printer (Zortrax M200) with a 150-g polymer. Two pieces of plastic fiber cables were used in the design. The first 1.5-mm-diameter fiber carried the light from the smartphone flash to the cuvette while the second fiber cable with a diameter of 0.25 mm transmitted the light from cuvette to the camera which passed through the assay. The diameter of the second cable was critical as the light for spectral data was carried with this cable. Therefore, the effect of diameter on spectral data was analyzed using 0.25-, 0.5-, and 1.0-mm cables as given in Figure 1b, and 0.25-mm diameter was found to be adequate based on this experiment. A custom cradle was specially designed to align plastic optical fibers with smartphone optical components. As the cradle was solid, the solution could be placed into the cuvette slot. In order to simplify the spectrometer system design, no collector lens or mirrored components were placed in the light path. Besides cost, the most important factor in choosing plastic optical fibers instead of glass-based fiber optics was the ability to use plastic optical fibers without special tools for stripping and cutting.
To test the performance of the system, methylene blue (MB) solutions were prepared with different amounts and their respective spectral views are given in Figure 2. At the top row, the concentration of the solution varies from 0 ppm (most left), which corresponds to distilled water (DW), to 10 ppm (most right). The spectrum views are given at the bottom row where the reduction in red intensity with the concentration is quite visible.
This design was further improved to make it compatible with immersion probe, which made it more practical and user-friendly as illustrated in Figure 3 . Schematic diagram of the 3D printed cradle is described in Figure 3a. The immersion probe was attached to the fiber-coupled smartphone flashlight and the reflection caused by radiation is carried to the camera via the grating. Plastic (PMMA)-based bifurcated fiber bundle was used to manufacture the probe with the diameter of 0.5 mm (also known as Y-cable) as shown in Figure 3b. The overall design is illustrated in Figure 3c. It was reported that no additional optical components were used in the reflection-based smartphone spectrometer system. The spectrum views of blank solution (left) and 5-ppm BPA solution (right) are given in Figure 3d to demonstrate color variation can be detected with the spectrometer system.
As an alternative to spectrometric analysis, colorimetry is also widely used in many applications including food allergen testing , albumin testing in urine analysis , blood analysis , pH quantification , and water monitoring .
A digital tube reader designed in the 3D printer was equipped with two interchangeable LEDs to illuminate the test and control tubes so that the absorption spectrum of the colorimetric assay could be analyzed . An albumin tester platform was proposed in  using an optomechanical attachment aligned with a smartphone camera. The 3D printed cradle was integrated to a compact laser diode, two AA batteries, a plastic lens, and an emission interference filter. An albumin-based fluorescent signal was obtained from the test tube by a digital fluorescent tube reader to calculate the albumin concentration values after comparison with a control tube. In , blood analysis was implemented with an integration of red blood cell counting, white blood cell counting, and hemoglobin measurement devices to smartphone cradle.
Smartphone-based colorimetric detection of pH, which varies between 0 and 14.0, was investigated with paper-based test . The performance of the system was tested under two conditions: controlled and ambient illumination environments. To create controlled illumination settings, 3D printed cradle was equipped with apparatus which eliminates the interference of the present light as shown in Figure 4a. Four strips of same pH level were located side by side for imaging with an apparatus, then color calibration and white balancing were performed for those strips with the X-Rite ColorChecker Passport. The imaging was continued with replacing the strips in six different orientations as in Figure 4b.
Later, random orientations as shown in Figure 4c were used to mimic scenarios that could happen when untrained users take a picture. The reason for using a group of four strips is to see the effect of luminance variation due to their positioning with respect to the camera flash.
For the ambient illumination environments, no apparatus was used, and instead of using the smartphone flash as a light source, sunlight and fluorescent and halogen sources were used. To test the system under challenging conditions, the light sources were used in solo and in dual and triple combinations. The images captured in both controlled and ambient illumination environments with a different replacement of the strips were used to train the machine learning algorithm which was designed to quantify the pH values accurately. Since the training set was enriched with the images captured in various and complicated scenarios, it was reported that pH values were detected with 100% accuracy.
One possible drawback of the colorimetry method in  is its computational cost due to its large training dataset. To address this issue, single-image referenced colorimeter was proposed in . The system was simplified in the sense of both hardware and software design. Instead of using machine learning algorithm which needs a large dataset, it used local dataset created by a user with a single reference image. In addition, images from the local dataset were compared with test images using color-matching algorithms computationally cheaper than machine learning algorithms. The hardware design was also simplified into a cardboard box as shown in Figure 5. It was painted white, and white light-emitting diodes were mounted to the box ceiling to minimize the ambient illumination effects. A holder platform with the same height as the camera was placed for the assays to maintain the same distance for imaging. The system was tested on four different (nitrite, phosphate, chromium, and phenol) assays, and it was reported that the performance accuracy was between 76 and 100% depending on the assay types.
3. Software designs
The previous section described the hardware designs for smartphone-based spectrometry and colorimetry. This section presents mobile applications and algorithms proposed for these designs.
3.1 Mobile apps
Software applications are necessary tools due to complementary characteristics for the hardware designs of spectrometer and colorimetry. Mobile apps were therefore developed to make the overall system user-friendly [14, 15, 25, 28, 36, 45, 46, 52].
Albumin Tester  application was developed for Android phones to let the user determine the albumin concentration in the urine sample. To test alcohol in saliva, SPAQ [15, 25] application was developed which estimated the alcohol level based on the histogram distribution. Colorimetric Plate Reader app  was proposed for qualitative and quantitative ELISA test. PhotoMetrix  application was introduced, which runs the univariate and multivariate analyses to quantify the analytes in the samples. Colorimetric Test Reader app was presented in , which determines pH, protein, and glucose values in the assay.
Solmaz et al.  developed ChemTrainer app which quantifies the peroxide content running machine learning algorithm on the remote server as shown in Figure 6a. After capturing a photograph of colorimetric test strips, the app sends mean RGB values for a region of interest to the remoter server as machine learning algorithm needs only mean values for the classification. A message queue service was employed to enable multiple users to reach the server simultaneously.
Screenshots of the ChemTrainer are given in Figure 6b. In the opening page, there are two options for the user: either capturing a new image with “Experiment” button or using existing image from the phone with the “Load From Gallery” button. After an image is captured or loaded from the gallery, the user may proceed or retake a new image. Next, a region of interest needs to be cropped with adjustable crop box. The app calculates the average red, green, and blue values of the cropped image and sends to the server, which runs a classification algorithm that decides the class of image. In the meantime, the app displays a progress animation until the result comes back from the server.
The ChemTrainer app was further improved to be able to work with single-image reference (SIR) and named as ChemTrainerSIR . In addition, it gained additional features like saving location and time data for the previous experiments, which help the user to analyze the past results when needed. The ChemTrainerSIR app is described in Figure 7 with screenshots. There are “train” and “experiment” options on the home page as shown in Figure 7a. Training steps are introduced in Figure 7 from b to g (top row), while testing steps are described at the bottom row from h to m. If the user selects the train option, some initial information needs to be entered such as the name of the chemical compound as the name of the model (e.g., phosphate), the units of measurement (e.g., ppm), and the number of samples with known concentration levels. The user either captures an image of samples or loads from the gallery. Then, the user enters the reference values for each sample which will be used later in the testing phase. All these information are stored in a designated folder in internal storage. In the testing phase, the user first selects the model, which was used in training. Then, a new image is taken to quantify the concentration value based on comparison with the reference model.
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 complementary metal oxide semiconductor (CMOS) sensors.
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 how to reach a RAW image in smartphones. Although most semi-professional and professional cameras have access to reach the images in a RAW format, it is unconventional for smartphones. With recent developments, the latest smartphones offer access to images in the RAW format . The RAW images could be found in three extensions such as “.NEF” (Nikon), “CR2” (Canon), and “.DNG.” The most used format is “.DNG” as it has a common open format. Currently, no app is available to process the “.DNG” images in a smartphone yet. Therefore, free DCRAW software  can be used to convert “.DNG” image to tagged image file format (TIFF) for easier extraction of the R, G, and B values of the image.
RGB is the most commonly used color model in image processing. However, it can be converted to other models such as hue, saturation, and value (HSV); hue, saturation, and lightness (HSL); hue, saturation, and intensity (HSI); and lightness, green-red, and blue-yellow (L*a*b*). Hue is defined with the color portion of the color model and described with a number from 0 to 360°. Saturation is defined with the amount of gray in the color, from 0 to 100%. Value, lightness, or intensity is the brightness or intensity of the color, from 0 to 100% where black is represented with 0 while 100 is the brightest.
After the image acquisition, numerous image processing methods can be employed to improve the image visualization so that better features can be extracted from the image. The feature extraction plays a critical role in some methods like PCA, convolutional neural network, and machine learning, which interpret multiple types of information contained in an image using these features .
The performance of these methods was investigated with RAW and JPEG image formats with different color spaces such as RGB, HSV, and L*a*b*. RAW and JPEG image formats were studied in [6, 29] after converting images from RGB to HSV. Absorbance experiments were employed based on V components of HSV and it was reported that RAW format outperforms the JPEG formats in absorbance measurements. On the other hand,  showed that JPEG images gave a similar performance with RAM image if least-squares support-vector machine (LS-SVM) was employed in creating the learning model. Based on this conclusion, RGB, HSV, and L*a*b* color spaces were investigated using JPEG formats for quantifying peroxide content based on machine learning classifiers . JPEG images were also used in  where the images were converted from RGB to L*a*b* color space. Instead of machine learning algorithms, color matching algorithms such as deltaE and color correlation methods were employed due to their simplicity. It was reported that deltaE showed superior performance with L*a*b color space for colorimetric water quality detection.
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 , 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.
Peroxide quantification with colorimetric tests was investigated in  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 . 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  was performed using four different analyte solutions. The first solution is nitrite ; 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 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 -containing solutions (50 mL), a stable red-violet color was observed. The second solution is the phosphate 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 50 ppm was prepared by dissolving 219.5 mg of anhydrous potassium dihydrogenphosphate in 1 L of distilled water. The solutions of 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 of 1,5-diphenylcarbazide in 50 mL 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.
5. Performance metrics
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 each sensing scheme.
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 ,
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 with respect to the reference wavelength point to calculate R2 (the coefficient of determination). R2 is the first metric to evaluate to assess the performance of the model. R2 values greater than 0.9 are acceptable values, although a larger coefficient 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 sensitivity of the spectrometer.
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 divided by the total number of data points. Precision is calculated by the ratio of true positive events to the sum of true and false positive events as given below:
The sensitivity (recall) is the ratio of true positive to the sum of true positive and false negative:
Lastly, f1 score is the harmonic average of precision and the recall and is equal to 1 for perfect precision and recall:
Regression and classification metrics should be chosen based on the colorimetric detection scheme. Spectrometric detection requires the use of regression metrics while the detection of discrete color change should be assessed with classification metrics.
6. Chapter summary
In this chapter, a review of smartphone-based colorimetric determination of chromogenic assays has been provided on color spaces, existing color matching and detection techniques, hardware and software designs, and performance metrics that have been developed over the past few decades.
After a broad survey of the smartphone spectrometers, a technical background of the methods for image acquisition system, image analysis, and measurement procedure, which are commonly used as baseline methods in the literature, was introduced with their basic mathematical, statistical concepts and definitions, which are required for understanding the mathematics and techniques behind the proposed colorimetric detection methods.
In addition, portable hardware designs compatible with smartphones and their Android applications were introduced with fundamental differences including physical setup, interfaces, and challenges.
Moreover, performance metrics were analyzed in order to see which aspects are considered more in the evaluation and impacts of these perspectives on the evaluation results.
The authors thank Dr. Gazihan Alankuş for mobile apps and the “Ekosfer Laboratory and Research Services” for their assistance with the colorimetric assays. This research was supported by the scientific research projects coordination unit of Izmir Katip Celebi University (project no. 2018-ÖDL-MÜMF-0021).
Conflict of interest
The authors declare no conflict of interest.