MATLAB: Is this the right way to classify tomatoes based on Hue of HSI

fruitimage analysisimage processingImage Processing Toolbox

Hello. I have coded my project based on advice from my lecturers, as well as online tutorials, and for this project I want to classify tomatoes based on their hue from HSI colorspace. But after getting the HSI variables needed to execute this, I'm not sure where to go, and how to proceed. I have run some single tomato images and found that there is a pattern for ripe and unripe tomatoes, in which ripe's hue is around 0-20 based on my hue histogram, and green tomatoes around 30-60. I could be wrong, and I need to know if what I'm doing is wrong or not, because I'm at my wit's end here. I have attached my codes as below. I really appreciate any constructive comments or answers, and thank you in advance.

Best Answer

See attached code. It works with the images you supplied.