From: Faiz Ali on 21 Apr 2010 06:13 clear all; RGB = imread('im5.jpg'); f1 = figure(); imshow(RGB); [r c z] = size(RGB); RGB = RGB(floor(r*0.2):r,:,:); [r c z] = size(RGB); I = zeros(r,c); for i=1:r for j=1:c if((RGB(i,j,1)>100 && RGB(i,j,1)<250)&&(RGB(i,j,2)>50 && RGB(i,j,2)<180)&&(RGB(i,j,3)>0 && RGB(i,j,3)<100)) I(i,j)=1; end end end this is a code which read image pixel wise, and changes yellow pixels to white and rest to black. I want to change color of all pixels to black except white. White should remain as white and rest all pixels should change to black. Can somebody plz help me?
From: ImageAnalyst on 21 Apr 2010 06:48 If RGB = [255,255,255] then just set I to 255 for white, or to 0 for black (if the color is anything other than [255,255,255].
From: Salim Azak on 21 Apr 2010 07:06 [r c z] = size(RGB); for i=1:r for j=1:c if (RGB(i,j,1)==255 && RGB(i,j,2)==255 && RGB(i,j,3)==255) break % if it's value is white, do not change end RGB(i,j,1)=0; RGB(i,j,2)=0; RGB(i,j,3)=0; % change value out of white end end I hope this code solve your problem.
From: Walter Roberson on 21 Apr 2010 11:16 Faiz Ali wrote: > this is a code which read image pixel wise, and changes yellow pixels to > white and rest to black. I want to change color of all pixels to black > except white. White should remain as white and rest all pixels should > change to black. I gave you a reply 14 hours before, in your thread 'CHANGING COLORS'. If my method was not suitable for your images, you could have replied there, along with clarification of the points that I indicated you had not told us about. The one line of code I presented there to do the job would be fine after you had used im2double() to convert your uint8 image to double precision -- a possibility that I specifically mentioned in my response.
|
Pages: 1 Prev: save image without display Next: Regarding Fast Matlab code |