필터 지우기
필터 지우기

clustering rgb image only green channel

조회 수: 1 (최근 30일)
Tomas
Tomas 2014년 4월 20일
댓글: Tomas 2014년 4월 20일
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

답변 (1개)

Image Analyst
Image Analyst 2014년 4월 20일
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
Image Analyst
Image Analyst 2014년 4월 20일
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 2014년 4월 20일
I was lost, you can not tell me how I found out somehow automatically ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by