Effacer les filtres
Effacer les filtres

clustering rgb image only green channel

1 vue (au cours des 30 derniers jours)
Tomas
Tomas le 20 Avr 2014
Commenté : Tomas le 20 Avr 2014
Hello, i have image
i want to clustering only green channel from rgb image.
my code is :
I = imread('obraz1.png'); %%input image
r = I(:,:,1);
g = I(:,:,2);
b = I(:,:,3);
I = g(:);%%green channel
I = ( I - min(I(:)) ) ./ ( max(I(:)) - min(I(:)) );
I = ~I;
[m n]=size(I)
P = [];
for i=1:m
for j=1:n
if I(i,j)>0
P = [P ; i j];
end
end
end
size(P)
MON=P;
[IDX,C]=kmeans(MON,3,'emptyaction','singleton')
How do I display my output image?
Thanks for you help

Réponses (1)

Image Analyst
Image Analyst le 20 Avr 2014
Tomas, since this normalizes (the badly-named) I into the range 0-1, and then you set I equal to the "inverse" what do you think that will do to the values of I. Check this out:
>> ~0.8
ans =
0
So basically I is all zero.
  3 commentaires
Image Analyst
Image Analyst le 20 Avr 2014
No, not really. For one thing, the whole loop can be replaced by
[rows, columns] = find(g < 255);
but even that won't do it because other colored spots might have green values less than 255. You have to find out the specific RGB value of the green spots you want to find so that you don't get other colors. Try calling impixelinfo() so you can mouse around on the image and see what colors the spots have. Or use imtool().
Tomas
Tomas le 20 Avr 2014
I was lost, you can not tell me how I found out somehow automatically ?

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