rgbImage = imread('GEMS_Vegetation.png');
imshow(rgbImage);
[x,y] = ginput(1);
row = round(y);
column = round(x);
r = rgbImage(:,:,1); r_dou = im2double(r)*255; Red = r_dou(row, column);
g = rgbImage(:,:,2); g_dou = im2double(g)*255; Green = g_dou(row, column);
b = rgbImage(:,:,3); b_dou = im2double(b)*255; Blue = b_dou(row, column);
Error_R = 0.15;
[R_r R_c] = find(r_dou <= Red+(Error_R*Red) & r_dou >= Red-(Error_R*Red)); R = [R_r R_c];
[G_r G_c] = find(g_dou <= Green+(Error_R*Green) & g_dou >= Green-(Error_R*Green)); G = [G_r G_c];
[B_r B_c] = find(b_dou <= Blue+(Error_R*Blue) & b_dou >= Blue-(Error_R*Blue)); B = [B_r B_c];
[RG,ia,ib] = intersect(R,G,'rows'); [RGB,ic,id] = intersect(RG,B,'rows');
figure()
imshow(rgbImage); hold on;
plot(RGB(:,2), RGB(:,1), 'ro', 'markersize', 3);
T_color = find(r_dou ~= 0);
Obj_pixels = (length(RGB)/length(T_color))*100;