%I have the following code:
RGB = imread('image.png');[r c z] = size(RGB);for i=1:rfor j=1:cif (RGB(i,j,1)==50 && RGB(i,j,2)==205 && RGB(i,j,3)==50) RGB(i,j,1)=255; RGB(i,j,2)=255; RGB(i,j,3)=255;elseif (RGB(i,j,1)==255 && RGB(i,j,2)==228 && RGB(i,j,3)==181)RGB(i,j,1)=255; RGB(i,j,2)=255; RGB(i,j,3)=255;elseif (RGB(i,j,1)==0 && RGB(i,j,2)==0 && RGB(i,j,3)==0) %MATLAB won't run this part
RGB(i,j,1)==255 && RGB(i,j,2)==255 && RGB(i,j,3)==255;elseif (RGB(i,j,1)==250 && RGB(i,j,2)==250 && RGB(i,j,3)==250) %MATLAB also won't run this part
RGB(i,j,1)==255 && RGB(i,j,2)==255 && RGB(i,j,3)==255; else RGB(i,j,1)=0; RGB(i,j,2)=0; RGB(i,j,3)=0; end endend%So that's my code
My problem now is why MATLAB does not change the RGB values as indicated in the code comments? Also, is there a way to use operators to simplify the code instead of using so much elseifs? I shall be using this for one of my clustering algorithms. Thank you so much in advance for any help.
Best Answer