A Smartphone-Based Automatic Measurement Method for Colorimetric pH Detection Using a Color Adaptation Algorithm

This paper proposes a smartphone-based colorimetric pH detection method using a color adaptation algorithm for point-of-care applications. Although a smartphone camera can be utilized to measure the color information of colorimetric sensors, ambient light changes and unknown built-in automatic image correction operations make it difficult to obtain stable color information. This paper utilizes a 3D printed mini light box and performs a calibration procedure with a paper-printed comparison chart and a reference image which overcomes the drawbacks of smartphone cameras and the difficulty in preparing for the calibration procedure. The color adaptation is performed in the CIE 1976 u’v’ color space by using the reference paper in order to stabilize the color variations. Non-rigid u’v’ curve interpolation is used to produce the high-resolution pH estimate. The final pH value is estimated by using the best-matching method to handle the nonlinear curve properties of multiple color patches. The experimental results obtained using a pH indicator paper show that the proposed algorithm provides reasonably good estimation of pH detection. With paper-printed accurate color comparison charts and smart color adaptation techniques, superior estimation is achieved in the smartphone-based colorimetric pH detection system for point-of-care application.


Introduction
Colorimetric microfluidic paper-based analytical devices (µPADs) are emerging as new point-of-care devices, which have advantages of low-cost manufacturing, easy disposability, as well as the fact no external power is needed for fluidic transportation [1]. Traditional colorimetric-based tests such as pregnancy tests depend on true or false result determined by the naked eye and cannot provide quantified values since they have poor accuracy that is sensitive to the environment, and need an expensive camera. After smartphones were developed and became widespread, there have been many studies to utilize smartphones as digital instruments for water quality monitoring [2][3][4], health-related diagnostics [5,6], and various special-purpose colorimetric sensor measurements [7][8][9][10]. In particular, smartphone-based pH measurements have been used for various applications [4,11,12]. Smartphone cameras are cheap, portable, and easy to use, however they have some drawbacks. They are vulnerable to ambient light changes. In addition, their unknown built-in automatic image correction operations such as automatic brightness control and white balance prevent a smartphone camera from acquiring stable color information of colorimetric sensors [11]. Therefore, they require additional image calibration techniques for acquiring color information in a stable way. Chang used the hue component only in colorimetric measurements for handling the brightness variation [12]. Shen et al. proposed a point-of-care colorimetric detection method in which a pH strip image is acquired with a known reference image and a two-dimensional calibration plane is applied in the CIE 1931 xy color space to stabilize the built-in camera functions [11]. Schaefer proposed two colorimetric water quality detection systems using smartphones with additional hardware modules [4]. The first system attaching a sensor module to the smartphone uses the built-in flash as the light source and the smartphone camera measures the water quality as the pH value. The second system uses a separate color sensor and light source to measure the water quality, and the smartphone is used for user interface only via wireless connection.
Colors are determined by light sources and image sensors. Many colorimetric sensor measurement studies have focused on finding the true color of a material by isolating the side effects that may be caused by ambient light and intrinsic image sensor properties. In order to cope with the ambient light effect, which is not a simple matter, we implement a mini light box incorporating two LED light modules to isolate the ambient light effect. 3D Printers have recently been used extensively to implement analytical sensing devices [2,4,7], so we built a simple mini light box model with a 3D printer. A light box accessory attached to a fixed smartphone model makes it easy for a developer to build the system accurately. However, the type of smartphone model that can be used is limited on the user side. We choose a simple mini light box structure that allows a user to manually place a smartphone on the mini light box, even though it requires an additional automatic color retrieving algorithm.
In order to cope with various intrinsic image sensor properties, calibration techniques [13] are usually applied with real accurate pH buffers or high-quality verified pH measuring devices [4]. However, just like the typical use of pH paper that does not require real accurate pH buffers, we use the paper-printed color comparison chart provided by the pH indicator paper manufacturer and the reference image composed of various colors to perform the color calibration in the proposed system. The calibration step is based on color adaptation in the CIE 1976 u'v' color space [14] and non-rigid u'v' curve interpolation is used to obtain high-precision pH estimate. In the measurement step, a best-matching method handling the nonlinear curve properties of multiple color patches is utilized instead of deriving a specific analytic estimation function based on linear fitting or curve fitting.
In our system, the smartphone camera is not a fixed non-mobile instrument device with common camera attributes. The relative positions of the color patches in the captured image are changeable for various reasons, such as various camera aspect ratios, focal lengths, and the location of the smartphone camera. Therefore, an automatic color retrieving algorithm based on contour extraction is also proposed to automatically obtain all the color values of the captured image.
Three Android smartphones and Whatman pH indicator paper are used in the experiments to evaluate the performance of the developed colorimetric pH detection system. After checking whether the color information is retrieved automatically from the captured image, we examine the detailed results of the calibration step and the measurement step.

Materials
In this paper, we utilize a 3D printed mini light box, a pH indicator paper, a reference paper, three Android smart phones, and pH buffer solutions. The 3D printed mini light box is modeled by OpenSCAD [15], a script-based 3D object modeling software, and it is printed with black resin by a Formlabs Form 1+ 3D printer [16]. Two white LED backlight modules used as the light source in the mini light box were purchased from Adafruit [17]. Whatman pH indicator paper with resolution of 1.0 (pH 0~14, No. 2613991 from Fisher Scientific, Waltham, MA, USA) was used. Each strip of the pH indicator paper has four colorimetric sensor patches. A reference paper used for color adaptation algorithm is printed with a photo printer. Three Android smartphones (version 4.x) manufactured by Samsung (Suwon, Korea) and LG Electronics (Seoul, Korea) were used. An Android App was developed for camera image capturing and pH measurement. All images are captured after all camera settings are set to 'auto'. The calibration algorithm implemented with C++ and Octave [18] language is performed offline on a personal computer after the calibration-purpose captured images are obtained by the smartphone. The core of measurement algorithm that is purely programmed with C++ language is implemented in the Android App via Android Native Development Kit (NDK) [19]. The OpenCV software library is utilized for implementing the image processing parts [20]. In order to evaluate the pH detection performance, real samples of standard pH buffer solutions and a few other samples of phosphate buffer solutions (BS) and phosphate-buffered saline (PBS) are used. pH buffer solutions of pH 1.68, 4.01, 7.00, 10.01, 12.46 (No. 916099, 910168, 910112, Orion, Waltham, MA, USA), pH 6.0 BS (Ricca, Arlington, TX, USA), pH 6.5 BS (EMS, Hatfield, PA, USA), and pH 7.4 PBS (Gibco, Waltham, MA, USA) were used for verification.

Calibration Step Using a Paper-Printed Comparison Chart
From an ideal point of view, the calibration step is to establish an analytic relationship between the color information of the pH strip and the ideal pH values by examining accurate known pH buffers. Once the calibration step is completed, the pH value can be estimated from the color information of the pH strip to be measured. In this paper, however we utilize the paper-printed comparison chart image that is usually supplied together with pH strips instead of using accurate known pH buffers in the calibration step. This approach is attractive because a user doesn't need accurate calibration-purpose pH buffers. Typical use of pH strips doesn't require for a user to buy accurate calibration-purpose pH buffers. A user simply compares the pH strip with the comparison chart and finds the best-match to estimate the pH value. We follow the basic concept of the typical pH strip usage in the calibration and measurement steps. However, since the measured color can vary due to a variety of factors caused by smartphone camera characteristics such as the unknown built-in automatic color control mechanism, the measured color should be normalized by a color adaptation algorithm. The color adaptation is performed by utilizing the reference images captured together with a pH strip. The color adaptation makes the color of reference images be the same and eventually produces the calibrated color information even if the camera characteristics are changed.
All color information on the reference regions composed of various colors and the target region where the paper-printed pH strip is placed are collected automatically. Here, the obtained colors are depicted in Figure 1 to explain the following calibration procedure. In Figure 1, the colors of the upper and lower reference regions for calibration are noted as C R ij P and the colors of the target region for calibration are noted as C T k P , where P is the pH index, i and j are the reference color indexes, and k is the target color index. In this paper, P = 0~14, i = 1~12, j = 1~18, and k = 1~4. Therefore, total number of indexes for the reference image is 216 (=12 × 18). and Octave [18] language is performed offline on a personal computer after the calibration-purpose captured images are obtained by the smartphone. The core of measurement algorithm that is purely programmed with C++ language is implemented in the Android App via Android Native Development Kit (NDK) [19]. The OpenCV software library is utilized for implementing the image processing parts [20]. In order to evaluate the pH detection performance, real samples of standard pH

Calibration Step Using a Paper-Printed Comparison Chart
From an ideal point of view, the calibration step is to establish an analytic relationship between the color information of the pH strip and the ideal pH values by examining accurate known pH buffers. Once the calibration step is completed, the pH value can be estimated from the color information of the pH strip to be measured. In this paper, however we utilize the paper-printed comparison chart image that is usually supplied together with pH strips instead of using accurate known pH buffers in the calibration step. This approach is attractive because a user doesn't need accurate calibration-purpose pH buffers. Typical use of pH strips doesn't require for a user to buy accurate calibration-purpose pH buffers. A user simply compares the pH strip with the comparison chart and finds the best-match to estimate the pH value. We follow the basic concept of the typical pH strip usage in the calibration and measurement steps. However, since the measured color can vary due to a variety of factors caused by smartphone camera characteristics such as the unknown built-in automatic color control mechanism, the measured color should be normalized by a color adaptation algorithm. The color adaptation is performed by utilizing the reference images captured together with a pH strip. The color adaptation makes the color of reference images be the same and eventually produces the calibrated color information even if the camera characteristics are changed.
All color information on the reference regions composed of various colors and the target region where the paper-printed pH strip is placed are collected automatically. Here, the obtained colors are depicted in Figure 1 to explain the following calibration procedure. In Figure 1, the colors of the upper and lower reference regions for calibration are noted as and the colors of the target region for calibration are noted as , where P is the pH index, i and j are the reference color indexes, and k is the target color index. In this paper, P = 0~14, i = 1~12, j = 1~18, and k = 1~4. Therefore, total number of indexes for the reference image is 216 (=12 × 18). We perform a color adaptation method in the CIE 1976 u'v' color space. One of the pH index values is chosen as the pivot index noted as . We derive a color converting model to match the We perform a color adaptation method in the CIE 1976 u'v' color space. One of the pH index values is chosen as the pivot index noted as Φ. We derive a color converting model to match the reference color of the captured image with the reference color of the pivot index image. Although various color adaptation algorithms such as the linear von Kries based adaptation model can be applied [21], we use the third-order polynomial model of 20 parameters expressed as in Equations (1) and (2) for color adaptation.
respectively. a 00 ∼ a 09 and a 10 ∼ a 19 are the 20 parameters. For each pH index P, the color converting model is derived and denoted as F P . In order to obtain a robust estimate, we use the minimum absolute deviation solution obtained by iterative reweighted least square [22]. Since the color information (u s , v s ) and (u d , v d ) of all reference color indexes can be expressed in a single matrix form as y = Xa by considering Equations (1) or (2), the optimal solution a is formulated as Equation (3) The solution a is obtained by iterative reweighted least square as expressed in Equation (4).
where W (t) is the diagonal matrix of weights of Equations (5) and (6).
In this paper, δ is set to 0.01 and the number of iterations is 20. The pivot index Φ is set to 7.
After the color converting model F P is derived, the initial target color C T k P is converted to the calibrated target color C T k P by using the same color converting model F P . In order to achieve better resolution of pH estimate from C T k P , we apply thin plate spline interpolation [23,24] and obtain the high-resolution calibrated target colors. The interpolation is achieved by finding f k (x) that minimizes the energy function of Equation (7): In Equation (7), the tuning parameter λ is used to control how non-rigidness is allowed for the deformation. In this paper, λ is set to 3/7 so that the energy ratio of E error ( f k ):E smooth ( f k ) becomes 7:3.
is used and the estimated curve becomes a straight line. The high-resolution calibrated target colors colors C T k p are obtained by f k (x). In this paper, the pH resolution of 0.1 is used from pH ≈ 0.0 to pH ≈ 14.0 for C T k p . It should be noted that the final calibration data to be stored for the following measurement procedure are the reference colors of the pivot index for calibration, C

Measurement Step Based on Color Adaptation and Best-Matching
All colors in the reference regions and the target region are obtained in a similar way as in the calibration step. However, we denote the reference colors and the target colors obtained in the measurement step as M R ij and M T k , respectively.
In the measurement step, color adaptation is performed between M R ij and C R ij Φ in a similar way as performed in the calibration step based on the color adaptation model of Equations (1) and (2).
respectively. The color converting model derived in the measurement step is denoted as F M , and the initial target color M T k is converted to the calibrated target color M T k by using the same color converting model F M .
The final pH estimate is obtained by finding the best match of M T k among C T k p as expressed in Equation (8): Instead of deriving a linear equation or performing curve fitting, this approach doesn't require any prior knowledge of best-fitting curves and it can be used for pH strips with multiple color patches. In this paper, we used the pH strip composed of four color patches.

Automatic Color Retrieving Algorithm
Since the smartphone cameras with different characteristics are manually placed on the mini light box, the color patch positions in the captured image are not fixed. Therefore, in order to retrieve the color information for calibration and measurement steps, it is necessary to find all color patch positions in the captured image automatically. The proposed procedure of the automatic color retrieving algorithm based on contour extraction consists of the following six steps: first, a noise reduction and image simplification step is performed on the input captured image. Second, the edges of the simplified image are detected. Third, the initial contours are extracted with the initial constraints that accept only rectangular shapes and ignore small size contours and non-convex contours. Fourth, the final contour labeling step follows. In this step, the contours of the reference region and the target region are separated. The reference region constraints accept only the rectangles whose aspect ratio is greater than 3.5 because the reference paper of 30 × 8 mm (aspect ratio = 3.75) is used in this experiment. It also rejects the contours near center line because the contours near the center line tend to belong to the target region. In a similar way, the target region constraints accept only the squares near center line and reject the contours of different size. After the sorting and labeling steps, the final contours for the reference region and the target region are determined. Fifth, the positions for retrieving the color information of the upper reference region are determined. Principal component analysis is performed to obtain principal axes of the upper reference rectangle contour. And then four crossing points between the principal axes and the upper reference rectangle are found. 6 × 18 upper reference region positions are determined using the crossing points. Similar approach is also applied for lower reference region. After the positions of the reference colors are obtained, the positions for the target colors are calculated by using the averaged center and slope of the two reference regions. Finally, the reference colors and the target colors are retrieved from the determined positions.

Automatic Color Retrieving in the 3D Printed Mini Light Box
One of the important things in the process of measuring colorimetric sensor is isolating ambient light effects. Ambient light conditions are so complex that simple software algorithms cannot isolate them effectively. In this experiment, we have built a 3D printed mini light box consisting of three parts; body, bottom_base, and bottom_stripbed as shown in Figure 2. The body isolates ambient light and provides a light source. Two LED lighting modules are used as the light source. Each LED is connected to a 5 V supply through a 220 Ω current limiting resistor. Smartphone is placed on top of the body and its camera is located over the center hole on the body. On the two top planes of the bottom_base, the reference images composed of various colors are placed for the purpose of calibration. The pH strip to measure is placed on top plane of the bottom_stripbed. The bottom_stripbed is inserted into the bottom_base and the bottom_base is inserted into the body.  In this experiment, three android smartphones named A, B, and C were used. Since the image is captured in the 3D printed mini light box, there are no side-effects caused by ambient light conditions. The mini light box eliminates the variation in lighting conditions [10]. Figure 3 shows the captured images of pH 7.0 strip. However, the locations of color patches on the reference regions and the target region are not in the fixed positions. Since the different camera characteristics and small movements of the smartphone cause the different color locations, it is required to apply the automatic color retrieving algorithm.  In this experiment, three android smartphones named A, B, and C were used. Since the image is captured in the 3D printed mini light box, there are no side-effects caused by ambient light conditions. The mini light box eliminates the variation in lighting conditions [10]. Figure 3 shows the captured images of pH 7.0 strip. However, the locations of color patches on the reference regions and the target region are not in the fixed positions. Since the different camera characteristics and small movements of the smartphone cause the different color locations, it is required to apply the automatic color retrieving algorithm. Figure 4 shows the step-by-step result of the automatic color retrieving algorithm. The six steps of the automatic color retrieving algorithm are illustrated from Figure 4a-f in consecutive order. In the noise reduction and image simplification step, a simplified image is obtained from the input capture image by applying the media filter [25]. The filtering strength is adjusted empirically. In the edge detection step, Canny edge detector [26] and morphological filtering are used to detect the final edge information. In the initial contour extraction step, only rectangular contours are collected. However, unwanted rectangular contours are still remained and the contours on the reference region are not separated from those on the target region. In the final contour labeling step, additional constraints are applied to separate the contours on the reference region from those on the target region. The following step is to determine the positions for retrieving reference colors and target colors automatically. Principal component analysis results performed on the reference region contours play an important role to compensate for the small movements of the smartphones. In the following final step, the reference colors and target colors are retrieved from the automatically determined positions. In this experiment, three android smartphones named A, B, and C were used. Since the image is captured in the 3D printed mini light box, there are no side-effects caused by ambient light conditions. The mini light box eliminates the variation in lighting conditions [10]. Figure 3 shows the captured images of pH 7.0 strip. However, the locations of color patches on the reference regions and the target region are not in the fixed positions. Since the different camera characteristics and small movements of the smartphone cause the different color locations, it is required to apply the automatic color retrieving algorithm.   Figure 4 shows the step-by-step result of the automatic color retrieving algorithm. The six steps of the automatic color retrieving algorithm are illustrated from Figure 4a-f in consecutive order. In the noise reduction and image simplification step, a simplified image is obtained from the input capture image by applying the media filter [25]. The filtering strength is adjusted empirically. In the edge detection step, Canny edge detector [26] and morphological filtering are used to detect the final edge information. In the initial contour extraction step, only rectangular contours are collected. However, unwanted rectangular contours are still remained and the contours on the reference region are not separated from those on the target region. In the final contour labeling step, additional constraints are applied to separate the contours on the reference region from those on the target region. The following step is to determine the positions for retrieving reference colors and target colors automatically. Principal component analysis results performed on the reference region contours play an important role to compensate for the small movements of the smartphones. In the following final step, the reference colors and target colors are retrieved from the automatically determined positions.  Figure 5 shows the calibration preparation step based on the paper-printed comparison chart and the reference image. First, we split the comparison chart into 15 pieces according to the pH value. Then, we placed the piece into the light box and captured the image with the smartphone camera. According to the pH value, 15 images are acquired and used for calibration. In Figure 5, it  Figure 5 shows the calibration preparation step based on the paper-printed comparison chart and the reference image. First, we split the comparison chart into 15 pieces according to the pH value. Then, we placed the piece into the light box and captured the image with the smartphone camera. According to the pH value, 15 images are acquired and used for calibration. In Figure 5, it should be noted that two reference images and a piece of comparison chart image are placed on the bottom_base and the bottom_stripbed, respectively. The reference colors retrieved in the capture image may change for various reasons such as the built-in unknown automatic image correction operations of the smartphones. The calibration step uses the color adaptation algorithm to compensate for the unwanted changes. After completing the calibration step, the calibrated target colors ℂ are obtained. Figure 6 shows the calibrated target color ℂ obtained from all paper-printed pH stripes of the paper-printed comparison chart. Since we used the pH indicator paper of 1.0 pH resolution, the calibrated target color ℂ also has a resolution of 1.0. However, in Figure 6, it is noticeable that there are no abrupt color changes as the pH value changes and the resolution can be improved by a sophisticated interpolation algorithm. In order to obtain higher resolution color information, we applied the non-rigid u'v' curve interpolation based on thin plate spline interpolation. Figure 7 shows the obtained high-resolution calibrated target colors . In this paper, the pH resolution of 0.1 is used from pH ≈ 0.0 to pH ≈ 14.0 for . Although the color calibration is performed on the u' and v' components only, Figures 6 and 7 are illustrated with RGB colors for better understanding. Compared with Figure 6, Figure 7 shows more continuous high-resolution color information. The reference colors retrieved in the capture image may change for various reasons such as the built-in unknown automatic image correction operations of the smartphones. The calibration step uses the color adaptation algorithm to compensate for the unwanted changes. After completing the calibration step, the calibrated target colors C T k P are obtained. Figure 6 shows the calibrated target color C T k P obtained from all paper-printed pH stripes of the paper-printed comparison chart. The reference colors retrieved in the capture image may change for various reasons such as the built-in unknown automatic image correction operations of the smartphones. The calibration step uses the color adaptation algorithm to compensate for the unwanted changes. After completing the calibration step, the calibrated target colors ℂ are obtained. Figure 6 shows the calibrated target color ℂ obtained from all paper-printed pH stripes of the paper-printed comparison chart. Since we used the pH indicator paper of 1.0 pH resolution, the calibrated target color ℂ also has a resolution of 1.0. However, in Figure 6, it is noticeable that there are no abrupt color changes as the pH value changes and the resolution can be improved by a sophisticated interpolation algorithm. In order to obtain higher resolution color information, we applied the non-rigid u'v' curve interpolation based on thin plate spline interpolation. Figure 7 shows the obtained high-resolution calibrated target colors . In this paper, the pH resolution of 0.1 is used from pH ≈ 0.0 to pH ≈ 14.0 for . Although the color calibration is performed on the u' and v' components only, Figures 6 and 7 are illustrated with RGB colors for better understanding. Compared with Figure 6, Figure 7 shows more continuous high-resolution color information. Since we used the pH indicator paper of 1.0 pH resolution, the calibrated target color C T k P also has a resolution of 1.0. However, in Figure 6, it is noticeable that there are no abrupt color changes as the pH value changes and the resolution can be improved by a sophisticated interpolation algorithm. In order to obtain higher resolution color information, we applied the non-rigid u'v' curve interpolation based on thin plate spline interpolation. Figure 7 shows the obtained high-resolution calibrated target colors curve interpolation based on thin plate spline interpolation. Figure 7 shows the obtained high-resolution calibrated target colors . In this paper, the pH resolution of 0.1 is used from pH ≈ 0.0 to pH ≈ 14.0 for . Although the color calibration is performed on the u' and v' components only, Figures 6 and 7 are illustrated with RGB colors for better understanding. Compared with Figure 6, Figure 7 shows more continuous high-resolution color information.

Measurement Step Results
In measurement step, a real pH indicator paper to measure is placed on the bottom_stripbed as shown in Figure 9.

Measurement Step Results
In measurement step, a real pH indicator paper to measure is placed on the bottom_stripbed as shown in Figure 9.

Measurement Step Results
In measurement step, a real pH indicator paper to measure is placed on the bottom_stripbed as shown in Figure 9.  Figure 10 shows the overall procedure performed in the measurement step. It is assumed that the calibration data, and , are evaluated and stored in the calibration step. First, the color converting model is estimated from the color adaptation algorithm between and .  Then, the calibrated target color corrected from the initial target color is obtained using the same color converting model . Finally, the pH value is estimated by finding the best match of among . All operations in the measurement step are performed automatically on each of the three Android smartphones.  Table 1 shows the pH estimation results for real samples of standard pH buffer solutions in terms of average absolute error and standard deviation. Orion pH buffer solutions of pH 1.68, 4.01, 7.00, 10.01, 12.46 were used for the experiment. The pH indicator paper was captured four times. Although we use the pH indicator paper with resolution of 1.0 and perform the calibration step with the paper-printed comparison chart supplied by the manufacturer, the average errors are below 0.25 which is better than the original resolution of the indicator paper.   Table 1 shows the pH estimation results for real samples of standard pH buffer solutions in terms of average absolute error and standard deviation. Orion pH buffer solutions of pH 1.68, 4.01, 7.00, 10.01, 12.46 were used for the experiment. The pH indicator paper was captured four times. Although we use the pH indicator paper with resolution of 1.0 and perform the calibration step with the paper-printed comparison chart supplied by the manufacturer, the average errors are below 0.25 which is better than the original resolution of the indicator paper. We applied a similar experiment for a few other samples. Ricca pH 6.0 BS, EMS pH 6.5 BS, and Gibco pH 7.4 PBS were used for this experiment and the results were summarized in Table 2. For BS samples, the results are quite similar to Table 1. The pH 7.4 PBS sample showed a relatively large error. Since the colorimetric prediction depends only on the obtained color information and the estimated pH values of the PBS sample are consistent, it may be caused by an intrinsic property of the particular PBS sample affecting to the color response of the pH indicator paper. The standard deviation columns shown in Tables 1 and 2 show the consistency of the pH detection.  Tables 1 and 2 show reasonably good estimation results but there are some estimation errors. The errors can be attributed to a variety of reasons. The product of the spectral radiant power of the light source and the spectral reflectance of the surface is known to affect the color of the surface [27]. Therefore, the color accuracy of the paper-printed comparison chart provided by the manufacturer is not guaranteed and it can't be verified if the light conditions are not the same. The mini light box with two LEDs is a very simple structure, so the light illumination cannot be guaranteed to be uniform throughout the entire internal area. In addition, the paper characteristics of a comparison chart are quite different from the fabric-like color patches of a real pH indicator strip. Since the smartphone camera and the pH indicator paper are placed manually with some restrictions, accurate fixed locations are not guaranteed for the color information retrieval. The specular regions of an image are often saturated and can cause problems with all subsequent image processing algorithms [28]. Similarly, saturated color information caused by automatic brightness control and white balancing of the smartphone camera can cause the degradation of color adaptation performance.
Despite of all the factors causing the estimation errors, the proposed algorithm provides reasonably good estimation results. The estimation performance is expected to improve if manufacturers provide accurate color comparison charts and smart color adaptation techniques are applied.

Conclusions
We have developed a smartphone-based colorimetric pH detection system for point-of-care applications. Since the color is determined by the light source and the image sensor, the proposed system deals with the changes of the ambient light and the image sensor characteristics by means of a 3D printed mini light box and color calibration. The ambient light effects are blocked with the 3D printed mini light box. The color adaptation based on the third-order polynomial model is performed in the CIE 1976 u'v' color space by using the reference paper in order to stabilize the color variations caused by built-in unknown automatic image correction operations. The high-resolution pH estimation is performed by using the non-rigid u'v' curve interpolation and the best-matching method to handle the smooth nonlinear curve properties of multiple color patches. Automatic color retrieving algorithm has been also developed to automatically detect the color information in the calibration and measurement steps. Although we use the pH indicator paper with resolution of 1.0 and perform the calibration step with the paper-printed comparison chart supplied by the manufacturer, the experimental results show that the proposed algorithm provides reasonably good estimation results. The smartphone-based colorimetric measurement based on paper-printed accurate color comparison charts and smart color adaptation techniques is expected to be applicable to various point-of-care applications such as colorimetric µPAD-based diagnostics and chemical composition monitoring. Future work will focus on optimizing the proposed method for a specific point-of-care application.