Open Access Article
Neta Caspin,
Olga Mindlina
,
Uriah H. Sharon
,
Vladimir V. Gridin,
Maor Manevich and
Israel Schechter
*
Schulich Faculty of Chemistry, Technion – Israel Institute of Technology, Haifa 32000, Israel. E-mail: israel@technion.ac.il
First published on 23rd February 2026
We present a simple, reagent-free method to quantify cyanuric acid (CYA) in tap water by analyzing the drying patterns of CYA solution droplets. The analytical signature is a set of white dendritic columns that grow radially from the droplet perimeter toward the center, a pattern not observed for other common dissolved organic compounds in tap water. Patterns were recorded with a basic optical camera under dark-field illumination, and their morphology varied systematically with CYA concentration. The deposits consist mainly of CYA together with ions naturally present in tap water. Using a deep learning model with data augmentation and statistical analysis, we proposed an algorithm for accurate quantitation over 0–120 ppm. The method performs best under neutral to slightly acidic conditions and is compatible with free-chlorine at the levels used for water sanitation. To our knowledge, this is the first demonstration of quantitation of an analyte in a complex mixture based on image analysis of droplet drying pattern. The approach is low cost and requires only imaging and data analysis, although it does require waiting for droplet drying (ca. 2 h under ambient conditions). The practical constraints include repeatable sampling volume (ca. 50 µL) and keeping illumination conditions as in the calibration set.
![]() | ||
| Fig. 1 The equilibrium between trichloroisocyanuric acid (TCCA) and cyanuric acid (CYA) in water maintains an effective free chlorine concentration. HOCl is the active disinfecting species. | ||
TCCA is commonly introduced in water in the form of solid tablets that serve as a source of free chlorine. During use, these tablets slowly release chlorine through the decomposition of TCCA into hypochlorous acid (HOCl), the active disinfecting agent, and cyanuric acid (CYA), which acts as a stabilizer. To maintain free chlorine in the desired range, the CYA concentration should be about 30–50 ppm (mg L−1). Because CYA is a very stable compound and is not consumed in the disinfection process, its concentration in water continuously increases with repeated addition of TCCA tablets. WHO guidelines for safe recreational water environments state that the concentration of cyanuric acid should not exceed 100 ppm. For effective sanitation and due to toxicity reasons, water is often replaced when the CYA concentration exceeds 100 or 150 ppm. Consequently, regular monitoring of CYA concentration is essential.
High-performance liquid chromatography (HPLC) provides accurate determination of CYA in water. However, this technique requires expensive instrumentation and skilled operation, making it impractical for routine use in point-of-care testing.4–6 The standard analytical method for CYA determination is based on its complexation reaction with melamine, producing an insoluble white colloidal precipitate.7 The turbidity of the resulting suspension, measured against a calibration curve, provides an estimate of CYA concentration. Commercial kits based on turbidimetric or nephelometric measurements are available. Inexpensive kits (around $100) often yield unreliable results, while more precise instruments (e.g., Palintest, about $1500) require trained technicians and daily calibration using standard solutions.
The analytical error of turbidimetric and nephelometric methods typically ranges from 10 to 70%, depending on the concentration range and the equipment used. Inaccuracies arise from sedimentation of particles, light scattering by contaminants such as dust, and incomplete reagent dissolution.8,9
The drying patterns of aqueous solutions have been studied previously.10–18 For example, Wong et al.19 demonstrated that drying droplets containing polystyrene particles of different sizes (40 nm, 1 µm, and 2 µm) form concentric rings, with smaller particles accumulating in the outer rings and larger ones in the inner rings. This phenomenon was attributed to capillary flow induced by the coffee-ring effect (CRE), which dominates particle–particle interactions during rapid drying. Tap water20 and milk21 classification were achieved from images of the coffee-ring effect. Dried droplets were suggested for the quality control of medicines.22 The applications of coffee-ring effects in analytical chemistry have been recently reviewed.23 Dried deposits have been analysed using optical spectrometric methods (e.g., Raman) and by secondary ion mass spectrometry. However, to the best of our knowledge, no quantitative analytical method for a component in a mixture has been developed based on image analysis such drying patterns.
In this work, we introduce a new analytical approach for quantifying CYA concentrations in tap water by analyzing the drying patterns of CYA solution droplets. This method is simple and more cost-effective than existing techniques and can be applied on-site.
Some substances exhibited patterns that were somewhat similar, but clearly distinguishable. For example, urea produced deposits lacking the geometric crystals and elongated columns characteristic of CYA. Uric acid formed white solids with 90° angular features distributed across the entire spot, without the radial extension from the perimeter toward the center observed for CYA. Caffeine (though unlikely to be present in tap water) produced the most comparable pattern, displaying white columns; however, these were thinner and not radially oriented. Although the existence of other compounds with similar drying patterns cannot be completely ruled out, it is unlikely that such substances are present in tap water.
Another distinctive feature of this phenomenon is that the dendritic columnar pattern appears only when CYA is dissolved in tap water, and not in distilled or deionized water. In double-distilled water (DDW), drying of CYA droplets resulted in geometrically shaped crystalline sediments rather than radial columns, suggesting a conventional single-crystal growth process (Fig. 3, for 30 ppm CYA). The formation of columnar dendritic structures occurs only in solutions containing dissolved salts, highlighting the essential role of several ionic species naturally present in tap water.
We examined the effect of various salts typically present in tap water to determine which components are essential for the formation of the characteristic drying pattern of CYA. The results revealed that three salts play a critical role: Na2CO3, CaCl2, and MgSO4. The critical ions are Ca2+, Mg 2+ and CO32−.
In order to demonstrate the critical involvement of these ions, we performed energy-dispersive X-ray spectroscopy (EDS) analysis of the dendrites. The results are shown in Fig. 4.
This figure presents mapping images of dendritic structure in drying pattern of CYA and the three essential salts in DDW (∼100 ppm of MgSO4, CaCl2, Na2CO3, pH ≈ 6.9–7.1). EDS reveals that the dendritic solid contains CYA, since nitrogen (N) comes only from CYA in this solution. The solid also contains magnesium and calcium. The Mg is more dispersed, while the calcium is more located at the spheres observed in the SEM images. The location of these elements may indicate that the CYA grows on a thin layer of Ca and Mg salts that first precipitate from the solution. In that case, the tree may be composed of sodium (Na), since co-crystals of Na ions and CYA have been documented.
Na, Ca and Mg come as cations, so negative ions are needed for balancing. As can be seen, sulfur (S), that comes only from sulfate anions (SO42−) is very localized in its mapping EDS image. Sulfur is localized in the spheres on the dendritic structure, so it can be assumed that the spheres are composed of calcium sulfate (CaSO4) or one of its hydrates. Since chloride (Cl−) is not a part of the dendritic structure, it can be concluded that the negative ions balancing the charges at the structure are carbonates (CO32−). MgCO3 and CaCO3 have a common phase diagram containing various types of co-crystals.
Oxygen and carbon EDS mapping are of low value because they compose both the CYA and the carbonate ions. The surface of silicon wafers itself is covered by a thin layer of silica (SiO2) that naturally formed in air.
Furthermore, the distinctive dendritic pattern was observed only within a pH range of 5.3–8.4, which definitely covers normal tap water. As shown in Fig. 5, out of this pH range, the dendritic sedimentation disappears.
Acidity can affect ingredients that have already been shown to be essential to the dendritic drying pattern: the CYA is a weak acid and the carbonate and sulphate ions, which are both bases. Probably a specific form of one of these compounds is essential for the dendritic growth, thus different acidity can prevent the dendritic growth. Also, the pH influences CYA speciation and interactions with Ca2+ and Mg2+, which are involved in the dendritic pattern formation.
The characteristic concentration of free chlorine in municipal tap water typically ranges from 0.2 to 2.0 ppm. Our experiments showed that free chlorine within 0–4 ppm range has no detectable effect on the drying pattern of CYA. This indicates that the observed pattern is associated with both CYA and TCCA species.
In order to improve the calibration plots, the performance of several deep learning models was examined. The most successful approach, described below, was based on a neural network architecture. Two different approaches were tested for neural network modelling:
The first approach is “simple model”, which assumes that only the CYA concentration influences the dried droplet patterns, while the effects of external conditions are neglected. Under this approach, all droplet images in the dataset are grouped solely by concentration, and their belonging to the same solution or to different solutions with the same concentration is not taken into account. Consequently, for this type of modeling, images of droplets from the same solution may appear in both the training and test sets.
The second approach is “safe model”, in which potential impact of external conditions is taken into account, and the assignment of droplet images to the same solution is important when splitting the data into training and test sets. For this type of modeling, images of droplets from the same solution are included in only one set: either the training set or the test set, but not both.
Dataset: the initial dataset consisted of 1503 images of dried droplets of CYA solutions in tap water, each representing a specific CYA concentration. The images had a resolution of 1280 × 1024 pixels. From each image, the non-zero region containing the dried drop was automatically cropped and resized to 256 × 256 pixels. These cropped regions formed the dataset used for training and testing the computer vision model. In total, 49 concentration levels were included, relatively evenly distributed across the range of 0–120 ppm. A detailed description of the dried drops dataset, including the distribution of image counts across different concentrations, is shown in Table 1.
| Training set | Validation set | Test set | ||||
|---|---|---|---|---|---|---|
| No. of samples | Description | No. of samples | Description | No. of samples | Description | |
| Scheme 1 | 1295 | Different number of images for different CYA concentrations, ranging from 16 to 100 | 98 | Reserved from the training set, 2 images for each CYA concentration | 208 | 16 images for zero concentration, 4 images for each non-zero concentration |
| Scheme 2 | 993 | Different number of images for different CYA concentrations, ranging from 10 to 86 | No | Cross-validation with different training/test splitting | 510 | 30 images for zero concentration, 10 images for each non-zero concentration |
The relatively large number of images for the zero concentration in Table 1 is due solely to the higher number of zero-concentration images in the initial dataset compared with other concentrations.
For the simple model, both data-splitting schemes were used in the study. For the safe model, only Scheme 2 with a reduced training set was applied because the typical number of dried droplet images per solution in the initial dataset was 10 across different concentrations.
Dataset balancing and augmentation: the training dataset was initially unbalanced, as each class, defined by a specific CYA concentration, contained a different number of images, as described in Table 1. The objective of balancing was to ensure equal representation of all classes during training, allowing each concentration level to contribute equally to model learning. In our research, two different approaches to dataset balancing were applied: (a) data duplication and (b) data augmentation, in which additional images were generated by applying rotational transformations at various angles. Each approach increased the number of images for each concentration in the training set to 100.
Predicting CYA concentration using a neural network: estimating the concentration of CYA from an input image represents a computer vision problem that can be addressed through neural network modelling. Our approach employs transfer learning based on a pre-trained on ImageNet-21k Vision Transformer (ViT) base model.24 Each image of a dried droplet is processed through the pre-trained ViT to extract its final hidden state, which serves as the input to a custom Multi-Layer Perceptron (MLP). The MLP consists of several linear and activation layers, culminating in a fully connected (FC) output layer that produces anumerical value corresponding to the predicted CYA concentration.
Training and testing were performed using sets of ViT-derived hidden states extracted from dried droplet images, paired with their respective CYA concentration labels. It is noteworthy that transfer learning with ViT architecture has been shown to outperform convolutional neural networks trained from scratch, even for specialized image domains such as medical imaging.25,26 The overall architecture of the algorithm is shown in Fig. 6.
During training, the objective was to minimize the difference between the model's predicted output and the true CYA concentration labels corresponding to the input images from the training set. The Mean Squared Error (MSE) was used as the loss function. Optimization was performed using the Adam algorithm with a variable learning rate, initially set to 0.001 and gradually reduced to 0.0001 over the course of training. The training batches contained 20 samples. For all models discussed in the article, the training process lasted up to 25 epochs, an early-stopping mechanism was applied for Scheme 1, cross-validation was applied for Scheme 2, using three different training–test splits.
Evaluation metrics for the predictive model: the performance of the trained model was evaluated using two standard metrics: the Mean Absolute Error (MAE) and the coefficient of determination (R2), defined as follows:
In the ideal case, where the predictions exactly match the true values, the R2 score equals 1. A baseline model that simply predicts the mean of the y-values yields an R2 score of 0. Therefore, the closer the MAE is to 0 and the closer the R2 value is to 1, the better the model's performance.
For each concentration, the predicted value represents the mean of several test samples associated with that concentration. Although the trained model can generate predictions from a single image, using multiple images of dried droplets associated with the same CYA concentration and averaging the individual predictions yields more accurate and stable results. Table 2 illustrates this trend:
| MAE | R2 | |
|---|---|---|
| Prediction from a single drop-image | 7.62 | 0.904 |
| Averaging over 3 drops for each non-zero concentration | 6.36 | 0.930 |
| Averaging over 4 drops for each non-zero concentration | 5.46 | 0.949 |
Our cross-validation experiments, using different training–test splits, confirmed that increasing the number of drops used for averaging during the model inference step improves prediction accuracy. This implies that for more accurate analysis of CYA, several images of dried droplets from the same solution should be prepared as inputs to the trained prediction system, rather than relying on a single image.
Our findings show that the prediction accuracy of the model trained on augmented data remarkedly improves when augmentation techniques are also applied to the test images. In practical applications, this implies that an additional image preprocessing step should be incorporated into the prediction pipeline of models trained on augmented data. This step would apply the same model-specific augmentation transformations to incoming images, thereby enabling the use of augmented inputs for more robust and reliable predictions through averaging.
Table 3 illustrates a performance comparison between the model trained and evaluated on the initial dataset and the model trained and evaluated with data augmentation applied. In this table, the original test set refers to 4 drops for each non-zero concentration, while the augmented test set refers to 4 drops for each non-zero concentration augmented by rotations at different angles to yield 20 samples.
| Training set | Test set | MAE | R2 |
|---|---|---|---|
| Original | Original | 5.46 | 0.949 |
| Augmented | Original | 5.53 | 0.950 |
| Original | Augmented | 6.09 | 0.925 |
| Augmented | Augmented | 4.16 | 0.968 |
It is evident that the model trained on the original dataset is sensitive to drop-image orientation: a degradation in performance is observed on the augmented test dataset, despite the increased number of drops per concentration used for prediction and averaging. In contrast, the model trained on the augmented dataset and evaluated on the augmented test set demonstrates the best performance.
Our investigation confirmed that increasing the number of initial drops for the same CYA concentration, used for subsequent augmentation, prediction and averaging at the prediction stage, tends to improve prediction accuracy. Table 4 illustrates this trend:
| Test set | MAE | R2 |
|---|---|---|
| 1 drop for each concentration | 5.81 | 0.934 |
| 3 drops for each non-zero concentration | 4.39 | 0.966 |
| 4 drops for each non-zero concentration | 4.16 | 0.968 |
The results are shown in Fig. 8a. The predicted values up to approximately 74 ppm closely match the ground truth, following a trend line with a slope of 1. For predicted values above 74 ppm, however, the results deviate and align along a line with a slope smaller than 1. The LOD based on 95% confidence intervals is 8 ppm. To improve prediction accuracy in this range, a slope correction was applied. Specifically, for predicted values greater than 74 ppm, the slope of the prediction trend line was calculated as the average of the slopes between consecutive test points. For the predicted curve shown in Fig. 8a, the slope of the prediction trend line at high concentrations is 0.62. The results after slope correction are presented, in Fig. 8b. In this case, the LOD based on 95% confidence intervals is 6 ppm.
Application of such slope correction must always be carried out with precaution, to avoid unjustified post hoc calibration. In this case the correction is justified because (a) it is supported by independent measurements: we observed the same slope change in calibration plots based on direct measurements of the number of white pixels in the images and of the length of the dendritic columns. (b) There is a physical explanation to the slope change: the physical mechanism of dendritic columnal sedimentation includes diffusion-controlled material supply plus directional preference due to kinetic material transfer (enhanced evaporation at the droplet perimeter and concentration and temperature gradients). Presenting and proving the mechanism responsible for the lower calibration plot slope at high concentrations is beyond the tasks of this paper, however, one can imagine that at high concentrations, the growth of the precipitate in the z direction (against gravity) becomes more significant. At low concentrations, the columns are short, which means that sedimentation is close to the perimeter, where the liquid layer above the surface is shallow. Thus, most sedimentation is parallel to the surface. At high concentrations, the columns continue to grow and reach the central parts of the droplet, where a thick layer of liquid is above them. This allows dendritic growing in the z direction, which cannot be measured by the camera placed from the top. If this, or a similar mechanism, is the reason for the slope change, the suggested correction is justified and not considered post hoc.
The small model shows some performance degradation compared with the model trained on the initial augmented training set (Table 4), which is expected because the training set was reduced by approximately 20%. On the other hand, the same trend is observed: increasing the number of initial drops associated with the same CYA concentration, used for subsequent augmentation, prediction, and averaging at the inference stage, tends to improve prediction accuracy. This trend is presented in Table 5, which demonstrates the performance of the small model on different test sets, using varying numbers of samples per concentration for averaging at the prediction stage.
| Test set | MAE | R2 |
|---|---|---|
| 1 drop for each concentration | 6.11 | 0.930 |
| 3 drops for each non-zero concentration | 5.14 | 0.954 |
| 4 drops for each non-zero concentration | 4.94 | 0.957 |
| 10 drops for each non-zero concentration | 4.73 | 0.962 |
The small model with smoothing produces a prediction curve is close to that shown in Fig. 8a, with a slope of the prediction trend line at high concentrations of 0.64 when tested on a dataset derived from the initial test set, containing 10 samples for each non-zero concentration.
The safe model shows noticeable performance degradation compared with the small model, which was trained on a dataset of the same size (Table 5). This implies that additional conditions, beyond the CYA concentration, might have an impact on dried droplet patterns. On the other hand, a common trend is still observed: increasing the number of initial drops associated with the same CYA concentration (for the safe model, from the same solution), used for subsequent augmentation, prediction, and averaging at the inference stage, tends to improve prediction accuracy. This is shown in Table 6, which demonstrates the performance of the safe model on different test sets, using varying numbers of samples per concentration for averaging at the prediction stage.
| Test dataset | MAE | R2 |
|---|---|---|
| 1 drop for each concentration | 7.43 | 0.892 |
| 3 drops for each non-zero concentration | 6.52 | 0.930 |
| 4 drops for each non-zero concentration | 5.75 | 0.943 |
| 10 drops for each non-zero concentration | 5.59 | 0.945 |
Smoothing in the safe model follows the same trend observed for smoothing in the simple model approach. Fig. 11 presents a comparison between the ideal and predicted values as a function of CYA concentration, together with the corresponding performance metrics for the trained safe model with smoothing. The LOD based on 95% confidence intervals is 17 ppm.
For the predicted curve shown in Fig. 11, the slope of the prediction trend line at high concentrations is 0.51.
Cross-validation with different training–test splits confirmed the consistent behavior of the trend lines produced by the smoothing models. The slopes and the prediction trend lines at high concentrations and the corresponding performance metrics for models trained using different training–test splits are shown in Table 7. Test sets 1 and 3 do not overlap, while other pairs of test sets have 30–40% overlap. Based on our experiments, applying slope correction with a common value such as 0.8 tends to improve prediction accuracy.
| Training test | Before slope correction | Slope at high concentrations | After slope correction | ||
|---|---|---|---|---|---|
| MAE | R2 | MAE | R2 | ||
| Split 1 | 5.59 | 0.945 | 0.51 | 5.05 | 0.957 |
| Split 2 | 5.17 | 0.949 | 0.51 | 4.48 | 0.963 |
| Split 3 | 4.98 | 0.955 | 0.63 | 4.77 | 0.959 |
| New predicted value = (predicted value − 74)/slope + 74, slope = 0.80 |
A comparison between the ideal and predicted values as a function of concentration labels, along with the corresponding performance metrics, for the safe model with slope correction applied, is presented in Fig. 12. The LOD based on 95% confidence intervals is 7 ppm.
The performance metrics in Fig. 12 demonstrate improved prediction accuracy compared with those in Fig. 10.
• Collect a large, well-balanced dataset of dried droplet images covering the entire concentration range.
• Use transfer learning with a pre-trained Vision Transformer as the model architecture.
• At the inference stage, rely on averaging predictions from multiple droplet images rather than on a single droplet image.
• Apply geometric data augmentation, such as image rotations at various angles, during training.
• Include an augmentation block as part of the preprocessing pipeline of the deployed prediction system to augment input images during inference.
• Study the prediction curve trend and apply slope correction at high concentrations.
We studied two main models based on neural networks: the simple model, which assumes that only the CYA concentration influences the dried droplet patterns, and the safe model, which is more conservative and allows potential unknown influences to be taken into account. The simple model seems to work better using our data set, however, the safe model might be better under a different data set.
Both models seem to work well, however, one should always be suspicious when using such models: Does they work for the right reason, or for a wrong reason? Therefore, we started our investigation using simple and intuitive tests, such as counting white pixels (estimating the precipitate quantity) and measuring the diagonal lengths of the nth longest dendritic structures identified in each image. The results provided similar trends, and the application of the deep learning models just improved the calibration plots. Therefore, we believe that the model works for good reasons.
The analytical performance of the proposed method is less accurate than HPLC and other expensive laboratory methods, but is more accurate than the turbidimetric methods, which their reported error is 10–70%.8,9 This is especially true at higher concentrations where turbidimetric methods fail due to precipitation. In terms of cost, the turbidimetric methods utilizing an optical instrument, are more expensive. The turbidimetric methods based on human vision are less expensive, but the results are subjective.
The suggested method has the potential to be is low cost and suitable for on-site use, requiring only a smartphone camera, a mechanical setup to ensure fix photographing conditions, and software for analysis. Nevertheless, several practical constraints must be respected for reliable results. First, the droplet volume used during measurement should match the volume used for calibration. Second, illumination during acquisition should closely match the calibration setup. These constraints suggest that a dedicated device with fixed droplet dispensing and controlled lighting would be advantageous for routine water monitoring. Alternatively, users can prepare their own calibration sets under their specific imaging conditions. This might anyhow be necessary, since the method has not been validated for tap water from different cities/countries. Using a smartphone camera might also require personal calibration, because the effect of camera variability has not been studies yet. Currently, no such a practical device has been designed and tested. Further research is needed for testing sensitivity to water source, testing analysis in swimming pool environments, extending of the calibrated range, and integration of automated image capture and on-device processing to deliver robust, user-friendly field measurements.
| This journal is © The Royal Society of Chemistry 2026 |