COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Find Color/Pixel in RGB BMP

• Email
• 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

See related articles to this posting

```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

```"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

2 Replies
1119 Views

Similar Articles

11/30/2013 3:19:01 PM
page loaded in 42397 ms. (0)