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.

  • 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.

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.

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

The experimental set-up for estimating turbidity exclusively through a smartphone consisted of an A4 background paper with a 3 cm diameter black dot as a reference pattern, sample containers, a tripod and a Samsung Galaxy Ultra S21 smartphone, as shown in Figure 1. The background reference pattern is necessary to discern variations in blur. The edges of the reference pattern are especially important as it is there that it is easiest to spot these variations. The tripod, though not strictly necessary, was used in the experimental phase of this work to minimise sources of variability.
Figure 1

Experimental set-up used in image collection of turbid water samples.

Figure 1

Experimental set-up used in image collection of turbid water samples.

Close modal
Samples were first collected with the circular glass cuvettes to demonstrate a proof of concept, and subsequently with the plastic bottles to simulate field conditions. A circular glass cuvette (diameter = 26 cm) and 500 mL Coca-Cola-tinted plastic bottle were placed in front of the A4 paper as shown in Figure 2. The cuvette and bottle were used to sample 20 and 90 mL of water, respectively, after the samples were thoroughly mixed. The smartphone camera was then placed 7 cm from the background.
Figure 2

The images of synthetic water at different turbidity levels and different container types.

Figure 2

The images of synthetic water at different turbidity levels and different container types.

Close modal

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.

Table 1

Camera settings

ParametersValues
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 
ParametersValues
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

The synthetic turbid water sample images were used to train the CNN to recognise turbid water images and classify them into 8 bins: 0, 1, 2.5, 4, 5, 7.5, 10, and 40 NTU (Wilches et al. 2022). The output results were validated against conventional turbidimeter readings. As the image recognition algorithm was designed to recognise and analyse features of the dot, the collected image samples were pre-treated to select only the area containing the dot. Images taken were cropped to bound the dot (244 × 244 pixels) and were used to train the algorithm. Once the training images were ready to be used by the algorithm, a small number of new testing images were introduced into the data set in an 80:20 ratio. The algorithm included five convolutional layers with depths from 16 to 256 pixels. The filter size was 3 × 3 with the Rectified Linear Unit (ReLU) activation function. The average pooling was activated after each layer. An Adam optimizer was implemented with a learning rate of 0.001. The batch size and epoch were fixed at 32 and 38, respectively. Classification results were outputted to Softmax, and the classification underwent the training utilising categorical entropy. A schematic diagram of the CNN used for estimating turbidity is shown in Figure 3.
Figure 3

Schematic diagram of the CNN algorithm used to estimate turbidity.

Figure 3

Schematic diagram of the CNN algorithm used to estimate turbidity.

Close modal

Image capture protocol

The fixed background in the laboratory setting was condensed onto a single A4 background paper with a central 3 cm diameter dot (Figure 4), serving as a guideline for the user to aim the smartphone camera at. Images of water samples with different turbidity values were taken using different containers often found in the home, such as a 500 mL Coca-Cola-tinted plastic bottle and a 500 mL clear plastic drinking water bottle.
Figure 4

The background sheet created for the image collection protocol with instructions for users in their local language.

Figure 4

The background sheet created for the image collection protocol with instructions for users in their local language.

Close modal
The sampling protocol consisted of the following steps (Figure 5):
  • (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

Figure 5

Four steps of the protocol.

Figure 5

Four steps of the protocol.

Close modal

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.

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.

Table 2

Breakdown of current bin classification for each turbidity bin for the formazine and kaolin samples

TurbidityClassification accuracy (%)
NTUFormazineKaolin
100.0 100.0 
99.6 89.8 
2.5 97.5 88.7 
97.5 88.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 
TurbidityClassification accuracy (%)
NTUFormazineKaolin
100.0 100.0 
99.6 89.8 
2.5 97.5 88.7 
97.5 88.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.

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.

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.

All relevant data are included in the paper or its Supplementary Information.

The authors declare there is no conflict.

Acharya
K.
,
Blackburn
A.
,
Mohammed
J.
,
Haile
A. T.
,
Hiruy
A. M.
&
Werner
D.
2020
Metagenomic water quality monitoring with a portable laboratory
.
Water Research
184
,
116112
.
doi:10.1016/j.watres.2020.116112
.
Chai
M. M. E.
,
Ng
S. M.
&
Chua
H. S.
2017
An alternative cost-effective image processing based sensor for continuous turbidity monitoring
.
AIP Conference Proceedings
1808
.
https://doi.org/10.1063/1.4975247
.
Hamidi
F. N.
,
Zainuddin
M. F.
,
Abbas
Z.
&
Ahmad
A. F.
2017
Low cost and simple procedure to determine water turbidity with image processing
. In:
ACM International Conference Proceeding Series, Part F 131372
, pp.
30
34
.
https://doi.org/10.1145/3132300.3132302
.
Hussain
I.
,
Ahamad
K.
&
Nath
P.
2016
Water turbidity sensing using a smartphone
.
RSC Advances
6
(
27
),
22374
22382
.
https://doi.org/10.1039/c6ra02483a
.
Koydemir Ceylan
H.
,
Rajpal
S.
,
Gumustekin
E.
,
Karinca
D.
,
Liang
K.
,
Göröcs
Z.
&
Ozcan
A.
2019
Smartphone-based turbidity reader
.
Scientific Reports
9
(
1
),
1
11
.
https://doi.org/10.1038/s41598-019-56474-z
.
Kumpel
E.
,
Peletz
R.
,
Bonham
M.
,
Fay
A.
,
Cock-Esteb
A.
&
Khush
R.
2015
When are mobile phones useful for water quality data collection? An analysis of data flows and ICT applications among regulated monitoring institutions in Sub-Saharan Africa
.
International Journal of Environmental Research and Public Health
12
(
9
),
10846
10860
.
https://doi.org/10.3390/ijerph120910846.
Organization, W. H.
2017
Water Quality and Health-Review of Turbidity: Information for Regulators and Water Suppliers, Technical Brief. WHO/FWC/WSH/ 17, 01
.
Wilches
L. M. L.
,
Jantarakasem
C.
,
Sioné
L.
,
Templeton
R. M.
&
Mikolajczyk
K.
2022
Estimating water turbidity from a smartphone camera
. In
33rd British Machine Vision Conference 2022
,
November 21–24
,
London, UK
.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Licence (CC BY 4.0), which permits copying, adaptation and redistribution, provided the original work is properly cited (http://creativecommons.org/licenses/by/4.0/).