Find Color/Pixel in RGB BMP

  • Follow


Hi,

i want to find all pixels which have a special color (e.g. [230 130 135], RGB [0-255] ) in a bitmap file and manipulate them somehow.

Is there a fast way to this? I'm using a for loop, but i'm think there should be a better way, perhaps with the find command?
0
Reply George34 1/13/2011 3:18:05 AM

Perhaps something like this:

B = ceil(rand(15,15,3)*3);  % An Image
I = B(:,:,1)==1 & B(:,:,2)==2 & B(:,:,3)==3;  % Find [1 2 3] pixels, change to [50 80 90]
B(repmat(I,[1,1,3]))  = [50*ones(1,nnz(I)),80*ones(1,nnz(I)),90*ones(1,nnz(I))]
0
Reply Matt 1/13/2011 3:39:04 AM


"Matt Fig" wrote in message <igls4o$7ii$1@fred.mathworks.com>...
> Perhaps something like this:
> 
> B = ceil(rand(15,15,3)*3);  % An Image
> I = B(:,:,1)==1 & B(:,:,2)==2 & B(:,:,3)==3;  % Find [1 2 3] pixels, change to [50 80 90]
> B(repmat(I,[1,1,3]))  = [50*ones(1,nnz(I)),80*ones(1,nnz(I)),90*ones(1,nnz(I))]

Thanks, that's very usefull, but not exaxtly what i'm looking for..

For example i want to calculate the difference to another bmp (same size), but only with pixels that have a special color (or color range). 
Or I want to copy all non white pixels into another bitmap.

I think therefore I will need the x,y coordinates of these pixels?
0
Reply George34 1/13/2011 4:00:26 AM

2 Replies
845 Views

(page loaded in 0.002 seconds)

Similiar Articles:













7/24/2012 3:08:52 PM


Reply: