Illumination problem with lab based segmentation..

When i am thresolding my images with lab model thresold it won't segment disease from normal area and when i am putting some thresold sometimes it work for disease classification but not for ripe and unripe mangoes..
see the code...
if true
I=imread('1.jpg')
BW=hsv2seg(I);% segmentation for background
cform = makecform('srgb2lab');
lab = applycform(I,cform);
maskedImage = bsxfun(@times, lab, cast(BW, class((lab))));
figure,subplot(1,4,1),imshow(I),title(img(k).name);
subplot(1,4,2),imshow(BW),title('BW image');
subplot(1,4,3),imshow(maskedImage),title('masked image');
l=maskedImage(:,:,1);
a=maskedImage(:,:,2);
b=maskedImage(:,:,3);
mask = ((a > 128 & b > 128 & l >= 128 & abs(a-b) < 10) | ((a <= 128 & b >= 128)));
subplot(1,4,4),imshow(mask),title('mask image');
end
above db images are not working for given thresold.i need output like

Answers (1)

What is not working? You shouldn't use mask again in the third column since it means something totally different than you first used it for, which was the overall mask of mango and background. But the badly-named mask in the third column looks like it shows in white the areas that are yellow and green and the areas that are not yellow and green as black. So what's the problem with that?
For reference, I answered the prior question about how to get the mask in this question though perhaps I shouldn't have.

8 Comments

from 3d view of lab color model I have set threshold to separate disease region and healthy (yellow/green) region from above output but above threshold not working for above linked images (dropbox) so please help to fix dis issue
From lab color model. The L channel is sensitive to illumination...so which threshold will work for my code?
You have not explained what's wrong. To me it looks like it's doing an okay job on those two images identifying areas of the fruit that are good/ripe and those that are not. Which areas is it misclassifying?
I have given database. .its not working for all images. ...because of non uniform illumination healthy area is considered in diseased...I have shown 2 image for that above code is working but not for all images. .so I need solution of that misclassification. ..I have tried threshold ing with hsv but its not working to separate out light Brown disease
wt should I do to remove non uniform illumination
Well it won't be perfect since you can only estimate the illumination pattern on the background and your object is 3D rising above the background so the illumination pattern won't be the same on the fruit as it would be on the flat background. But you can get an estimate of the background by using the background mask and calling polyfitn(). Attached is an example.
Why did you attach working examples and then complain about non-working examples? Why didn't you show the images that it did not work for if those are the images you're having trouble with? That's what I would have done if it were my problem.
Sabanam
Sabanam on 18 Apr 2014
Edited: Sabanam on 18 Apr 2014
i have just shown my issue that how m facing trouble in thresolding.I was asking about solution of illumination by showing working example..
Above BGCorrect_demo.m have error and m not getting wt to do
If you read the comments/instructions at the beginning of the demo you'll see
% Then models it to a 4th order polynomial in both directions
% using John D'Errico's File Exchange submission:
% http://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn
It looks like you did not download polyfitn from the link I gave you. Did you? If not, please do so. I've attached a new demo that checks for that.
Ohh,,ya...Thank you sir..for giving me such help and your precious time..I ll check it and inform whether its working or not...

Sign in to comment.

Categories

Asked:

on 17 Apr 2014

Commented:

on 21 Apr 2014

Community Treasure Hunt

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

Start Hunting!