Abstract
Accurate monitoring of nitrate and nitrite concentrations in water is essential for sustainable agriculture, safeguarding public health, and protecting aquatic ecosystems from nutrient pollution. Traditional methods for detecting nitrate and nitrite in water samples are precise but costly, complex, and time-consuming, limiting their practicality for frequent on-site testing. This research proposes deep learning-based computer vision techniques to classify nitrate and nitrite concentrations using images of colorimetric test strips. An RGB IMX219 camera was used to acquire images of colorimetric test strips under standardized, controlled illumination conditions to ensure consistent image quality. A total of 1938 nitrate images and 1190 nitrite images were collected before augmentation. After preprocessing and training-only data augmentation, both classical machine learning baselines based on hand-crafted color and texture features and deep learning models-including a multilayer perceptron (MLP) and convolutional neural networks (AlexNet, VGG16, ResNet18, and GoogLeNet)-were trained and evaluated using an independent test set and stratified fivefold cross-validation. For nitrate classification, ResNet18 and GoogLeNet achieved near-perfect 100% test accuracy, with mean cross-validation accuracy of 99.97% ± 0.04%, substantially outperforming classical baseline models based on hand-crafted color and texture features, which achieved at most 83.5% test accuracy. For nitrite classification, GoogLeNet achieved the strongest overall performance, with a test accuracy of 97.48% and a fivefold cross-validation accuracy of 95.22% ± 1.17%, substantially outperforming the best classical baseline model, which achieved a maximum test accuracy of 83.19%. These results demonstrate that deep CNN-based feature learning provides a significant performance advantage over simpler methods under controlled imaging conditions, supporting the suitability of the proposed system for rapid, image-based water quality assessment and motivating future evaluation under broader real-world deployment scenarios.