Optimal Color Space Selection for Vermicompost Nitrogen Classification: A Comparative Study Using the KNN Model
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.
Authors
- Suthisa Leasen
- Panida Lorwongtragool (ORCID: https://orcid.org/0000-0001-7911-5318)
Institutions
- Rajamangala University of Technology Isan (TH)
- Rajamangala University of Technology Suvarnabhumi (TH)
Publication Details
- Journal
- Applied Sciences
- Published
- 2025-10-29
- DOI
- https://doi.org/10.3390/app152111578
- Primary Topic
- Composting and Vermicomposting Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00