Effacer les filtres
Effacer les filtres

non-green extraction problem from image

1 vue (au cours des 30 derniers jours)
mehmet oztu
mehmet oztu le 3 Sep 2015
Commenté : Image Analyst le 5 Sep 2015
Hello, I'm trying to extract non-green from images, however It fails and does not give me a proper result. Do you know the reason? Why does it result with non-proper image? Thanks a lot.
Please see below orjinal image and result, also my matlab code.
orjinal and segmented image:
my code:
al1 = imread('image');
tex=single(al1);
%
r=single(al1(:,:,1));
g=single(al1(:,:,2));
b=single(al1(:,:,3));
ExGreen=2*g-r-b;
ExRed=1.4*r-g-b;
dev=imsubtract(ExGreen,ExRed);
% otsu thresholding
thres_level = multithresh(dev); % automatic thresholding
%b_w = im2bw(dev,thres_level);
seg_I = imquantize(dev,thres_level);
%
RGB = label2rgb(seg_I,'gray');
RGB2 = single(bwareaopen(RGB,1000));
% remove the only background
BW = RGB2(:,:,1);
BW = uint8(imfill(BW,'holes'));
leaves_only = al1;
for a = 1:3
leaves_only(:,:,a) = leaves_only(:,:,a).*BW;
end
figure;
axis off
title('RGB Segmented Image')
k=imfuse(al1, leaves_only,'montage');
imshow(k)

Réponses (2)

Image Analyst
Image Analyst le 3 Sep 2015
Try the Color Thresholder app on the Apps tab.
Or else see my color segmentation tutorials in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Image Analyst
Image Analyst le 3 Sep 2015
Try the attached m-file where I extract the non-green parts.
  3 commentaires
mehmet oztu
mehmet oztu le 4 Sep 2015
thanks Image Analyst, I found out a solution.
Image Analyst
Image Analyst le 5 Sep 2015
You're welcome. I just came back here because I noticed you have not marked it as Accepted. Are we done now, or do you still need help?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by