Borrar filtros
Borrar filtros

clustering rgb image only green channel

1 visualización (últimos 30 días)
Tomas
Tomas el 20 de Abr. de 2014
Comentada: Tomas el 20 de Abr. de 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

Respuestas (1)

Image Analyst
Image Analyst el 20 de Abr. de 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 comentarios
Image Analyst
Image Analyst el 20 de Abr. de 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 el 20 de Abr. de 2014
I was lost, you can not tell me how I found out somehow automatically ?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by