Smartphone-Based Digital Image Analysis for Qualitative Classification of Food Dyes Using Machine Learning: Effects of Color Space and Lighting Conditions
Abstract
Smartphone-based digital image analysis (DIA) has emerged as an affordable and accessible method for chemical analysis, particularly in colorimetry. While most existing studies have focused on quantitative applications, this study explores a machine learning–assisted DIA approach for the qualitative classification of synthetic food dyes. Digital images of nine food dyes solutions (Carmoisine, Sunset Yellow, Allura Red, Ponceau 4R, Tartrazine, Fast Green FCF, Brilliant Blue FCF, Quinoline Yellow WS, and Indigo Carmine), were captured under both controlled (closed) and open lighting conditions using a smartphone camera. The images were subsequently processed to extract color values in different color spaces, namely RGB, normalized RGB (rgb), HSL, and CIELAB. These values served as input features for a k-nearest neighbors (KNN) classifier trained to identify the dye present in each solution. The KNN model performed well on model solutions, with at least 86% accuracy across all color spaces and lighting conditions. To assess practical applicability, the classifier was also tested on seven commercial food and health products. The results show that HSL color space yielded the highest classification accuracy in the commercial sample testing, across both lighting setups, with the open condition consistently producing better performance. These findings demonstrate the potential use of smartphone-based DIA combined with machine learning for low-cost, portable, and reliable solutions for qualitative colorimetric analysis.
Keywords
References
[1] Y. Ohno, "CIE fundamentals for color measurements," in IS&T NIP16 International Conference on Digital Printing Technologies, pp. 540–545, 2000.
[2] V. Kılıç, N. Horzum, and M. E. Solmaz, "From sophisticated analysis to colorimetric determination: Smartphone spectrometers and colorimetry," in Color Detection, IntechOpen, 2018, doi: 10.5772/intechopen.82227
[3] G. M. Fernandes et al., "Novel approaches for colorimetric measurements in analytical chemistry–a review," Anal. Chim. Acta, vol. 1135, pp. 187–203, 2020.
[4] F. C. Böck et al., "PhotoMetrix and colorimetric image analysis using smartphones," J. Chemom., vol. 34, no. 12, p. e3251, 2020.
[5] M. Saadati, “Smartphone-Based Digital Image Analysis for Determination of Some Food Dyes in Commercial Products,” Food Anal. Methods, vol. 14, no. 11, pp. 2367-2374, 2021.
[6] Y. Fan, J. Li, Y. Guo, L. Xie, and G. Zhang, "Digital image colorimetry on smartphone for chemical analysis: A review," Measurement, vol. 171, p. 108829, 2021.
[7] S. Erdemir and S. Malkondu, "On-site and low-cost detection of cyanide by simple colorimetric and fluorogenic sensors: smartphone and test strip applications," Talanta, vol. 207, p. 120278, 2020.
[8] V. Doğan, M. Evliya, L. N. Kahyaoglu, and V. Kılıç, "On-site colorimetric food spoilage monitoring with smartphone embedded machine learning," Talanta, vol. 266, p. 125021, 2024.
[9] W. Fu, X. Fu, Z. Li, Z. Liu, and X. Li, "Advances in smartphone assisted sensors for on-site detection of food safety based on fluorescence on-off-on mode: A review," Chem. Eng. J., vol. 481, p. 151225, 2024.
[10] H. Nguyen et al., "Smartphone nanocolorimetry for on-demand lead detection and quantitation in drinking water," Anal. Chem., vol. 90, no. 19, pp. 11517–11522, 2018.
[11] P. Jarujamrus et al., "Use of a smartphone as a colorimetric analyzer in paper-based devices for sensitive and selective determination of mercury in water samples," Anal. Sci., vol. 34, no. 1, pp. 75–81, 2018.
[12] H.-C. Wang et al., "Development and clinical trial of a smartphone-based colorimetric detection system for self-monitoring of blood glucose," Biomed. Opt. Express, vol. 11, no. 4, pp. 2166–2177, 2020.
[13] T. T. Wang, C. K. Lio, H. Huang, R. Y. Wang, H. Zhou, P. Luo, and L. S. Qing, "A feasible image-based colorimetric assay using a smartphone RGB camera for point-of-care monitoring of diabetes," Talanta, vol. 206, p. 120211, 2020.
[14] S. K. Biswas, A. Bairagi, S. Nag, A. Bandopadhyay, I. Banerjee, A. Mondal, and S. Chakraborty, "Nucleic acid based point-of-care diagnostic technology for infectious disease detection using machine learning empowered smartphone-interfaced quantitative colorimetry," Int. J. Biol. Macromol., vol. 253, p. 127137, Dec. 2023.
[15] S. Chunta, P. Jarujamrus, A. Prakobkij, S. Khongwichit, N. Ditcharoen, S. Pencharee, and M. Amatatongchai, "Point-of-care blood tests using a smartphone-based colorimetric analyzer for health check-up," Microchim. Acta, vol. 191, no. 7, p. 402, 2024.
[16] M. Tobiszewski and C. Vakh, "Analytical applications of smartphones for agricultural soil analysis," Anal. Bioanal. Chem., vol. 415, no. 18, pp. 3703–3715, 2023.
[17] L. Ciaccheri, B. Adinolfi, A. A. Mencaglia, and A. G. Mignani, "Smartphone-Enabled Colorimetry," Sensors (Basel), vol. 23, no. 12, p. 5559, Jun. 14, 2023, doi: 10.3390/s23125559.
[18] M. Joh, S. Kumaran, Y. Shin, H. Cha, E. Oh, K. H. Lee, and H.-J. Choi, "An ensemble model of machine learning regression techniques and color spaces integrated with a color sensor: application to color-changing biochemical assays," RSC Adv., vol. 15, pp. 1754–1765, 2025, doi: 10.1039/D4RA07510B.
[19] A. A. Abdella and E. A. Elshenawy, “A spatial hue smartphone‑based colorimetric detection and discrimination of carmine and carminic acid in food products based on differential adsorptivity,” Talanta, vol. 282, Art. no. 127053, 2025, doi: 10.1016/j.talanta.2024.127053
[20] A. Y. Mutlu, V. Kılıç, G. K. Özdemir, A. Bayram, N. Horzum, and M. E. Solmaz, "Smartphone-based colorimetric detection via machine learning," Analyst, vol. 142, no. 13, pp. 2434–2441, 2017.
[21] M. E. Solmaz, A. Y. Mutlu, G. Alankus, V. Kılıç, A. Bayram, and N. Horzum, "Quantifying colorimetric tests using a smartphone app based on machine learning classifiers," Sens. Actuators B Chem., vol. 255, pp. 1967–1973, 2018.
[22] S. Bhatt, S. Kumar, M. K. Gupta, S. K. Datta, and S. K. Dubey, "Colorimetry-based and smartphone-assisted machine-learning model for quantification of urinary albumin," Meas. Sci. Technol., vol. 35, no. 1, p. 015030, 2023.
[23] R. Thakur, S. Bhatt, and S. K. Dubey, "Effect of smartphone camera settings in colorimetric measurements under controlled illumination," in Proc. 14th Int. Congr. Image Signal Process., BioMedical Eng. Informatics (CISP-BMEI), Oct. 2021, doi: 10.1109/CISP-BMEI53629.2021.9624389.
[24] B. Khanal, P. Pokhrel, B. Khanal, and B. Giri, "Machine-learning-assisted analysis of colorimetric assays on paper analytical devices," ACS Omega, vol. 6, no. 49, pp. 33837–33845, Dec. 2021.
[25] S. Duan, T. Cai, J. Zhu, X. Yang, E. G. Lim, K. Huang, K. Hoettges et al., "Deep learning-assisted ultra-accurate smartphone testing of paper-based colorimetric ELISA assays," Anal. Chim. Acta, vol. 1248, p. 340868, 2023.
[26] G. E. Halim and M. Tjahjono, "Evaluation of color models for quantitative determination of food dyes using smartphone-based digital image analysis," JKPK (Jurnal Kimia dan Pendidikan Kimia), vol. 8, no. 1, pp. 86–100, 2023.
[27] M. A. Ansari and D. K. Singh, "Significance of Color Spaces and Their Selection for Image Processing: A Survey," Recent Adv. Comput. Sci. Commun., vol. 15, no. 7, pp. 946–956, Sep. 2022.
[28] E. Chavolla, D. Zaldivar, E. Cuevas, and M. A. Perez, "Color spaces advantages and disadvantages in image color clustering segmentation," in Advances in Soft Computing and Machine Learning in Image Processing, 2018, pp. 3–22.
[29] Y. Tjandra, G. Halim, J. Briano, and M. Tjahjono, "Food Dyes RGB data for Digital Image Colorimetry," Kaggle, Dataset, 2025. [Online]. Available: https://doi.org/10.34740/KAGGLE/DSV/10386234.
[30] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and É. Duchesnay, "Scikit-learn: Machine learning in Python," J. Mach. Learn. Res., vol. 12, pp. 2825–2830, 2011.
[31] J. Park, Y. S. Cho, D. W. Seo, and J. Y. Choi, "An update on the sample preparation and analytical methods for synthetic food colorants in food products," Food Chem., vol. 459, p. 140333, 2024, doi: 10.1016/j.foodchem.2024.140333.
[32] R. Hamdini, N. Diffellah, and A. Namane, "Color based object categorization using histograms of oriented hue and saturation," Trait. Signal, vol. 38, no. 5, pp. 1293–1307, Oct. 2021, doi: 10.18280/ts.380504..
Refbacks
- There are currently no refbacks.