let us consider following image
i have found one topic about how to keep one of the RGB color(for instance red) and remove all others, here is code in matlab which does the same task
I=imread('fruit.jpg');
m=size(I,1);
n=size(I,2);
for mm=1:m
for nn=1:n
if I(mm,nn,1)<80 || I(mm,nn,2)>80 || I(mm,nn,3)>100
gsc=0.3*I(mm,nn,1)+0.59*I(mm,nn,2)+0.11*I(mm,nn,3);
I(mm,nn,:)=[gsc gsc gsc];
end
end
end
imshow(I);
after running, i have got following result
result seems ok , but is that only way i can change colors? can i do it without loops?what i need is more intuitive way of implementing colors changing