ABSTRACT
The lack of robust water quality data in drinking water services in many low-income settings can be attributed to inadequate funding for regular monitoring using analytical equipment. Turbidity is an indicator that is relatively quick and easy to measure; however, it still requires a turbidimeter and a trained operator. This study developed an entire smartphone camera-based application to measure turbidity in drinking water, removing both the need for external equipment and skilled labour. The application was created using a convolutional neural network, able to classify water samples into eight turbidity bins ranging from 0 to 40 NTU. The turbidity of the samples was created using formazine and kaolin clay suspensions. The in-built camera of a smartphone was used to capture images of water samples with known turbidity values. This algorithm was then embedded in a smartphone application, thereby providing an easy-to-use tool for users to estimate turbidity. Specifically, the protocol for using this application was developed with the intention that it will be used in low-resource settings by laypersons. Formazine samples achieved a turbidity classification accuracy of 98.7%, while kaolin clay samples achieved 90.9% accuracy using this method, which provides an encouraging proof of concept, as justification for further testing and improvements.
HIGHLIGHTS
An algorithm and accompanying protocol for estimating drinking water turbidity using only a smartphone camera were developed. The protocol is designed for use in low-resource settings by laypersons.
A correct turbidity bin classification accuracy of 98.7% was obtained for formazine samples between 0 and 40 NTU in the laboratory.
INTRODUCTION
Water quality monitoring is a crucial step in attaining United Nations' Sustainable Development Goal 6 (SDG6) (Kumpel et al. 2015; Acharya et al. 2020). The scarcity of robust water quality data in drinking water services remains a major challenge in many low-income settings. This can be attributed to inadequate funding for regular monitoring using analytical equipment and a lack of specialised labour. There is an urgent need to develop simple low-cost water quality measurement tools to aid developing countries in identifying potential contamination in drinking water. Turbidity is one of the indicators of poor water quality and can be considered as a proxy for microbial contamination (WHO 2017). Conventionally, turbidity measurement requires the collection of water samples and then laboratory analysis, a process that requires technical expertise and specialist analytical equipment.
Research in recent years has focused on smartphone-based applications for water turbidity measurement. These methods require additional external equipment and use image-processing techniques. For example, one method used a black box chamber to eliminate light interference, taking a photograph and then calculating its mean greyscale index as a proxy for turbidity (Hamidi et al. 2017). A similar approach was developed by Hussain et al. (2016) using a nylon chamber equipped with a smartphone camera, which used an infra-red sensor and a built-in camera to detect the light scattering in water samples. Another approach proposed by Chai et al. (2017) used an image-processing algorithm for measuring turbidity by detecting the visibility of circular patterns on a submerged board. Also, Koydemir Ceylan et al. (2019) proposed using a light source and optical fibre attached to a smartphone for estimating turbidity. However, a drawback of all of these approaches is their reliance on external equipment, rather than just using the smartphone camera on its own.
To our knowledge, this is the first study which reports the ability to measure turbidity using a built-in smartphone camera without the use of additional equipment, and with an accompanying step-by-step protocol for laypeople to be able to perform the turbidity measurement themselves. The protocol was optimised to allow the user to capture the clearest possible images of the water samples while being simple enough for users from the general population to follow, irrespective of their education level or knowledge of water quality principles. The protocol was customised for implementation in low-resource settings, by highlighting simplicity and accessibility, with the aim of widespread adoption. A user can simply use their phone to launch an application and measure turbidity without the need for purchasing standard chemicals or attaching a device to the phone. If successful, this platform would be beneficial in enhancing water quality datasets in low-resource settings. It would also serve to raise the public's awareness on the importance of water quality and empower them with evidence to support their case for requesting better water quality from their water suppliers. The protocol presented in this study not only fills a gap in water quality monitoring but also holds the potential for improving public health and contributing to the achievement of UN SDG6 in underserved communities.
MATERIALS AND METHODS
To develop a protocol and algorithm for testing water turbidity, the experiment was divided into four parts. The first part involved synthesising a wide range of turbid samples in the laboratory. Subsequently, a laboratory-based image collection protocol for measuring drinking water turbidity was established. Following that, the protocol was employed to capture images of the synthetic water samples and construct turbidity image datasets. These datasets were then used to train and test a convolutional neural network (CNN). Finally, the protocol was simplified for use by laypeople.
Dataset construction
An Android smartphone with 12-megapixel camera was used. This is a commonly available camera in many low-income settings and standard camera resolution for many current smartphone models. A stock suspension was synthesised to mimic turbid water using formazine, widely accepted as a standard for turbidity measurement. Kaolin clay was used to represent inorganic particles. We used these different stock solutions to demonstrate the versatility and reliability of the developed application across different turbidity levels.
For the formazine preparation, a stock suspension of hydrazine was first prepared at a concentration of 1,000 mg/L, where 1 g of hydrazine sulphate was dissolved in 100 mL of reverse-osmosis (RO) water in a volumetric flask. A stock solution of hexamethylenetetramine was prepared at a concentration of 10,000 mg/L. 10 g of hexamethylenetetramine was dissolved in 100 mL of RO water in a volumetric flask. A mixture between hydrazine and hexamethylenetetramine, 5 mL each and 90 mL of RO water, was used to prepare a standard formazine suspension of 400 NTU turbidity. The solution was incubated for 24 h at 25 °C for suspended solid formation.
A stock suspension of kaolin clay suspension was prepared by mixing the 1.078 g of kaolin clay with RO water. The turbid water samples were prepared from kaolin clay stock suspension 1,000 NTU diluting with RO water.
The obtained formazine and kaolin clay suspensions were diluted appropriately to obtain solutions with turbidity values corresponding to 0, 1, 2.5, 4, 5, 7.5, 10, 40 NTU. A turbidimeter (Palintest, UK) was used to measure the turbid stock suspension to establish ‘ground truth’ turbidity. The turbidimeter was calibrated using a standard suspension, styrene-divinylbenzene copolymer (SDVB) provided by the instrument manufacturer, which is much more stable than diluted formazine suspensions. The diluted formazine suspension was stored in an amber bottle. The formazine stock suspension was a primary standard. A commercial 4,000 NTU formazine suspension (Sigma-Aldrich, USA) was purchased and used as a secondary standard. The secondary standard was compared with the primary standard for routine quality control. The formazine and kaolin clay stock suspensions were finally sampled, and their turbidity was first measured with the calibrated turbidimeter, and then again using the laboratory-based testing protocol developed in this study, discussed later.
Laboratory-based testing protocol for measuring drinking water turbidity
To minimise in-camera image processing that may affect the observed blur, all of the internal and external camera settings were kept fixed (as shown in Table 1). After varying the magnification, it was observed that when the magnification was higher than 1 ×, extra blur and noise appeared in the pictures and compromised the quality of the photograph. Hence, the magnification was fixed at 1×. Similarly, the flash function was kept off to avoid reflective light appearing in the images and to avoid the camera changing the focus – the focus being set to the centre of the dot behind the container. Since the experimental set-up was under fluorescent light, the ISO (International Standard Organisation) was fixed at 50. The ISO number determines the amount of light reaching the camera sensors. A low ISO was maintained in a bright indoor setting to preserve good image quality and prevent overexposure. A white balance setting was selected to match the warm fluorescent light temperature, aligning with the light condition in the laboratory. Similar lighting may be found in some low-income households, though admittedly not all.
Parameters . | Values . |
---|---|
1. Magnification | 1 × |
2. Flash | Off |
3. ISO | 50 |
4. Shutter speed (per second) | 1/15–1/30 |
5. Exposure compensation (EV) | 0.0 |
6. White balance (K) | 3,500 |
7. Autofocus | Off – set manually in the centre of the reference pattern |
Parameters . | Values . |
---|---|
1. Magnification | 1 × |
2. Flash | Off |
3. ISO | 50 |
4. Shutter speed (per second) | 1/15–1/30 |
5. Exposure compensation (EV) | 0.0 |
6. White balance (K) | 3,500 |
7. Autofocus | Off – set manually in the centre of the reference pattern |
Following the laboratory protocol establishment, images of the formazine standard and kaolin clay were collected as a database for CNN training. An additional formazine in a tinted plastic container was collected for enhancing algorithm generalisation. The formazine dataset was first used as a training and testing datasets. Following that, the kaolin dataset was used as a training and a testing dataset to determine the algorithm's capability for estimating the turbidity of different particle types.
Turbidity estimation
Image capture protocol
- (1)
Collect water in a clear and smooth plastic water bottle
- (2)
Shake the bottle to enable complete mixing of the water sample
- (3)
Place the bottle in front of the dot on the A4 background provided and place the smartphone camera 7 cm away from the background
- (4)
Deactivate the smartphone camera's auto-mode and capture an image
The simplified protocol was used to capture turbid images under natural light conditions. This protocol was used to capture images of formazine samples in a tinted plastic bottle and in a clear plastic bottle. The laboratory-based testing protocol and the simplified protocol were used to create 19,514 images of synthetic turbid water, which were then used to train an image recognition algorithm.
RESULTS AND DISCUSSION
The algorithm classified the turbidity in the correct bin with validation accuracy of 98.7 and 90.9% for the formazine and kaolin clay training datasets, respectively. It is hypothesised that the difference in the validation accuracies obtained was due to the different particle sizes and light-reflecting properties of kaolin clay compared with formazine. The breakdown of accuracy for each of the eight class formazine and kaolin turbidity bins is shown in Table 2. The algorithm demonstrated robust efficacy, yielding a high level of accuracy across all classes.
Turbidity . | Classification accuracy (%) . | |
---|---|---|
NTU . | Formazine . | Kaolin . |
0 | 100.0 | 100.0 |
1 | 99.6 | 89.8 |
2.5 | 97.5 | 88.7 |
4 | 97.5 | 88.5 |
5 | 100.0 | 79.3 |
7.5 | 96.4 | 93.4 |
10 | 99.2 | 87.6 |
40 | 100.0 | 100.0 |
Overall | 98.7 | 90.9 |
Turbidity . | Classification accuracy (%) . | |
---|---|---|
NTU . | Formazine . | Kaolin . |
0 | 100.0 | 100.0 |
1 | 99.6 | 89.8 |
2.5 | 97.5 | 88.7 |
4 | 97.5 | 88.5 |
5 | 100.0 | 79.3 |
7.5 | 96.4 | 93.4 |
10 | 99.2 | 87.6 |
40 | 100.0 | 100.0 |
Overall | 98.7 | 90.9 |
The classification accuracy of formazine in the tinted plastic container was 96.2%. The classification accuracy of formazine in plastic was lower than that of formazine in the glass 98.7%. The discrepancy is attributed to differences in the refraction index, transparency, surface curvature and surface quality of the plastic and glass containers.
The classification performance was 98.5 and 97.7% for the tinted bottle and the clear bottle, respectively, suggesting not a significant effect of the tint.
The training accuracy of all tests was higher than 99.0% which means that the algorithm learns well from the training datasets. The training loss of all tests was below 0.02 indicating that the algorithm adapts well to the training datasets. Similarly, the validation accuracy of all tests was higher than 90.0%, which means that the algorithm performed well with previously unseen data. The validation loss of all tests was lower than 0.38 confirming that the algorithm performs well with the unseen data.
Given the relatively high accuracy of turbidity bin classification that has been demonstrated in this study, with two particle types, clear and tinted containers, and glass and plastic containers, this provides encouragement to proceed to test the method using non-synthetic drinking water samples and with images captured by users from the general public. This next step in our research will be reported in subsequent papers.
CONCLUSIONS
This paper presents a proof of concept of a novel protocol for capturing and analysing images of turbid water samples using only a built-in smartphone camera without the use of additional external equipment. The main advantage of this new tool is that it is convenient and user-friendly for estimating turbidity in low-resource settings, empowering laypersons to effectively monitor their water quality. By leveraging CNN technologies, the results have shown that the algorithm is able to categorise water samples with an accuracy of 90.9 and 98.7% for samples containing kaolin clay and formazine, respectively. The algorithm achieved good accuracy (>90%) in clear and tinted containers, as well as glass versus plastic containers. These results provide encouraging evidence that drinking water turbidity can be evaluated with current smartphone technology and CNN, paving the way for easier, routine water quality monitoring in low-resource settings.
ACKNOWLEDGEMENTS
The authors acknowledge the input provided by Professor Krystian Mikolajczyk and Lina Maria Lozano Wilches of the Department of Electrical and Electronic Engineering, Imperial College London. This research was supported by the Scholarship in Commemoration of Her Royal Highness Princess Chulabhorn's 60th Birthday Anniversary under HRH Princess Chulabhorn College of Medical Science, Chulabhorn Royal Academy.
DATA AVAILABILITY STATEMENT
All relevant data are included in the paper or its Supplementary Information.
CONFLICT OF INTEREST
The authors declare there is no conflict.