Determining defects on fruits surface

5 views (last 30 days)
Sahara Ali
Sahara Ali on 22 Nov 2015
Edited: Image Analyst on 17 Mar 2017
I am doing my term project in Image Processing where we have to develop a sorting and grading system for apples. While processing the image(having just one apple with a plain background), we need to do the following: -Determine Size of Apple -Determine Primary Color of Apple -Detect defects/scars/blemishes on the surface We are successful in doing the first two but I couldn't think of any algorithm of any filter that can identify the secondary color of apples or highlight the defects on its surface. Any sort of guidance or suggestion will be highly appreciated.
Thanks. :)

Answers (1)

Image Analyst
Image Analyst on 22 Nov 2015
I would first mask out the fruit and set the background to one color. Then you can use rgb2ind(rgbImage, 3) to segment the rgb image into 3 classes.
indexedImage = rgb2ind(rgbImage, 3);
If you want, you can then threshold the indexed image to get a mask
mask = indexedImage == 1;
and then use that to get the mean RGB in each class
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get means
meanR = mean(redChannel(mask));
meanG = mean(greenChannel (mask));
meanB = mean(blueChannel (mask));
  2 Comments
swathi
swathi on 17 Mar 2017
From the meanR, meanG and meanB values how we can get the scars/defected regions of fruit?
Image Analyst
Image Analyst on 17 Mar 2017
Edited: Image Analyst on 17 Mar 2017
I would have controlled lighting if you can (fixed location, broad source, color temperature controlled, intensity controlled, etc.). Then I'd put a X-Rite Color Checker Chart in the scene to calibrate to CIE LAB color space. Then compute the delta E (the color difference) between every pixel and the color of the disease. Pixels with low delta E have disease color. Pixels with high delta E do not have that color. So threshold the delta E image at some level that finds disease color and does not find non-disease color. See demo in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/31118-color-segmentation-by-delta-e-color-difference
Using kmeans or rgb2ind() is only good if you know for a fact that there are a significant number of disease pixels in the image that is different than the normal colors. If it's close to 100% disease or 0% disease, those methods won't work.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!