Optimal Color Space Selection for Vermicompost Nitrogen Classification: A Comparative Study Using the KNN Model
Source abstract
Abstract
This study presents a cost-effective and accurate method for assessing nitrogen concentration in vermicompost fertilizer using a low-cost TCS3200 color sensor and a K-Nearest Neighbors (KNN) machine learning model. The objective was to evaluate the performance of four different color spaces—RGB, Lab, LCh, and CMYK—identify the most effective feature representation for a multi-class classification task based on accuracy and theoretical robustness to ambient light variations. A total of 2400 data points were collected from a standard chemical test kit and processed. A rigorous 60-fold cross-validation approach was used to determine the optimal model hyperparameters and to ensure the robustness of the findings. The results demonstrate that the model trained on the LCh color space achieved the highest classification accuracy of 0.9708 with an optimal K-value of 6, significantly outperforming Lab (0.9688), RGB (0.9625), and CMYK (0.9583). A detailed analysis of the confusion matrix revealed that the model successfully classified the ‘High’ and ‘Medium’ nitrogen levels with near-perfect accuracy, while minor misclassifications occurred between the ‘Low’ and ‘Trace’ categories (5 Low ⟶ Trace, 6 Trace ⟶ Low). The proposed system offers a practical, robust, and accessible tool for precision agriculture, enabling farmers to make informed decisions regarding fertilization, and directly supporting sustainable agriculture and responsible resource management. The findings indicate that the LCh color space is highly effective for this application, providing a viable solution for the rapid and reliable assessment of vermicompost quality. Most importantly, this inexpensive, on-site system removes the need for costly, time-consuming laboratory analyses, giving farmers and compost users the instantaneous, accurate nitrogen data they need to maximize crop yield, optimize nutrient application, and significantly reduce input costs from overfertilization.
Source: crossref · Quality: baseline
Research context
OpenAlex topics: Composting and Vermicomposting Techniques · Smart Agriculture and AI · Soil Geostatistics and Mapping
SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.
Affiliations
Faculty of Science and Technology, Rajamangala University of Technology Suvarnabhumi, Nonthaburi 11000, Thailand
Funding
National Research Council of Thailand
References (30)
Show source-provided references
1. Rapid in-field soil analysis of plant-available nutrients and pH for precision agriculture—A review10.1007/s11119-024-10181-6 ↗
2. Simple LED spectrophotometer for analysis of color information
3. Abu Hassan, S.N.S., Masrie, M., and Burham, N. (2024, January 19–20). Optical Sensor Analysis of NPK Nutrients Using Visible and Near-Infrared Light. Proceedings of the 2024 IEEE 22nd Student Conference on Research and Development (SCOReD), Shah Alam, Malaysia.10.1109/SCOReD64708.2024.10872641 ↗
4. Caya, M.V., Arcagua, A.J., Cleofas, D.R., Hornada, R.N., and Ballado, A.H. (2019, January 14–18). Soil Survey Implementation Using Rasberry PI Through Colorimetric Determination of Nitrogen, Phosphorus, Potassium, and pH Level. Proceedings of the 40th Asian Conference on Remote Sensing (ACRS 2019), Daejeon, Republic of Korea.
5. AI-Powered Adaptive Fertilizer Recommendation System Using Soil And Weather Data10.64252/00tx6j54 ↗
6. Stevens, J.D., Murray, D., Diepeveen, D., and Toohey, D. (2024). A low-cost spectroscopic nutrient management system for Microscale Smart Hydroponic system. PLoS ONE, 19.10.1371/journal.pone.0302638 ↗
7. Han, F., Huang, X., Aheto, J.H., Zhang, D., and Feng, F. (2020). Detection of Beef Adulterated with Pork Using a Low-Cost Electronic Nose Based on Colorimetric Sensors. Foods, 9.10.3390/foods9020193 ↗
8. RGB color sensor for colorimetric determinations: Evaluation and quantitative analysis of colored liquid samples10.1016/j.talanta.2022.123244 ↗
9. Masrie, M., Rosman, M.S.A., Sam, R., and Janin, Z. (2017, January 28–30). Detection of nitrogen, phosphorus, and potassium (NPK) nutrients of soil using optical transducer. Proceedings of the 2017 IEEE 4th International Conference on Smart Instrumentation, Measurement and Application (ICSIMA), Putrajaya, Malaysia.10.1109/ICSIMA.2017.8312001 ↗
10. Silva, F.M., Jorge, P.A., and Martins, R.C. (2019). Optical sensing of nitrogen, phosphorus and potassium: A spectrophotometrical approach toward smart nutrient deployment. Chemosensors, 7.10.3390/chemosensors7040051 ↗
11. Simultaneous detection of nitrate and nitrite based on UV absorption spectroscopy and machine learning
12. Senapaty, M.K., Ray, A., and Padhy, N. (2023). IoT-enabled soil nutrient analysis and crop recommendation model for precision agriculture. Computers, 12.10.3390/computers12030061 ↗
13. Low-cost precision agriculture for sustainable farming using paper-based analytical devices10.1039/D4RA02310B ↗
14. Li, J., Wu, Z., Liang, J., Gao, Y., and Wang, C. (2024). Spectrophotometric-Based sensor for the detection of multiple fertilizer solutions. Agriculture, 14.10.3390/agriculture14081291 ↗
15. Wang, P., Zhang, Y., and Jiang, W. (2021, January 18–20). Application of K-Nearest Neighbor (KNN) algorithm for human action recognition. Proceedings of the 2021 IEEE 4th Advanced Information Management, Communicates, Electronic and Automation Control Conference, Chongqing, China.10.1109/IMCEC51613.2021.9482165 ↗
16. Alstrøm, T.S., Larsen, J., Kostesha, N.V., Jakobsen, M.H., and Boisen, A. (2011, January 18–21). Data representation and feature selection for colorimetric sensor arrays used as explosives detectors. Proceedings of the IEEE International Conference on Acoustics, Speech and Signal Processing, Beijing, China.10.1109/MLSP.2011.6064615 ↗
17. kNN Classification: A review10.1007/s10472-023-09882-x ↗
18. Uddin, S., Haque, I., Lu, H., Moni, M.A., and Gide, E. (2022). Comparative performance analysis of K-nearest neighbour (KNN) algorithm and its different variants for disease prediction. Sci. Rep., 12.10.1038/s41598-022-10358-x ↗
19. Critical importance of RGB color space specificity for colorimetric bio/chemical sensing: A comprehensive study10.1016/j.talanta.2023.124957 ↗
20. Color Space Transformation-Based Smartphone Algorithm for Colorimetric Urinalysis10.1021/acsomega.8b01270 ↗
21. Tania, M.H., Shabut, A.M., Lwin, K.T., and Hossain, M.A. (2018, January 16–17). Clustering and classification of a qualitative colorimetric test. Proceedings of the 2018 International Conference on Computing, Electronics & Communications Engineering, Southend, UK.10.1109/iCCECOME.2018.8658480 ↗
22. CMYK-CIELAB Color Space Transformation Using Machine Learning Techniques10.2352/issn.2694-118X.2021.LIM-73 ↗
23. Samec, J., Štruc, E., Berzina, I., Naglič, P., and Cugmas, B. (2024). Comparative Analysis of Low-Cost Portable Spectrophotometers for Colorimetric Accuracy on the RAL Design System Plus Color Calibration Target. Sensors, 24.10.3390/s24248208 ↗
24. Trinh, V.Q., Babilon, S., Myland, P., and Khanh, T.Q. (2022). Processing RGB color sensors for measuring the circadian stimulus of artificial and daylight light sources. Appl. Sci., 12.10.3390/app12031132 ↗
25. Alberti, G., Zanoni, C., Magnaghi, L.R., and Biesuz, R. (2020). Disposable and Low-Cost Colorimetric Sensors for Environmental Analysis. Int. J. Environ. Res. Public Health, 17.10.3390/ijerph17228331 ↗
26. Diaz, F.J., Ahmad, A., Parra, L., Sendra, S., and Lloret, J. (2024). Low-Cost Optical Sensors for Soil Composition Monitoring. Sensors, 24.10.3390/s24041140 ↗
27. Colorimetric detection of nitrogen, phosphorus, and potassium contents and integration into field irrigation decision technology10.1088/1755-1315/651/4/042044 ↗
28. Performance of advanced machine learning models in the prediction of amylose content in rice using internet of things-based colorimetric sensor10.18520/cs/v124/i6/722-730 ↗
29. Modification of colorimetric method based digital soil test kit for determination of macronutrients in oil palm plantation
30. Agarwal, S., Bhangale, N., Dhanure, K., Gavhane, S., Chakkarwar, V.A., and Nagori, M.B. (2018, January 10–12). Application of colorimetry to determine soil fertility through naive bayes classification algorithm. Proceedings of the 9th International Conference on Computing, Communication and Networking Technologies, Bengaluru, India.10.1109/ICCCNT.2018.8494113 ↗