2

Context
I'm trying to extract everything that is brown out of a ".bmp" of a slide. Since it's a staining of human tissue the exact color of brown is going to be different between slides.

So thus far I've found a plethora of topics of finding a single color.
So far I haven't found anything on being able to search through a picture with a color range. I know that I could do a Color compare = Color.FromArgb(X,X,X,X) several thousand times with different values, but is there any other way of doing this?

Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97

1 Answers1

2

there are to ways on is you read the bmp file binary and you lock for the string but remember 3 bytes are one pixel or something like this

using System.Drawing;

Bitmap img = new Bitmap("*imagePath*");
for (int i = 0; i < img.GetWidth; i++)
{
    for (int j = 0; j < img.GetHeight; j++)
    {
        Color pixel = img.GetPixel(i,j);

        if (pixel == *your color*)
        {
            //do what you want to if you have found the pixel
        }
    }
} 

you only have to create your color to compare it but this shoudnot be an problem or? here some links how answer the question to. How can I read image pixels' values as RGB into 2d array?

Community
  • 1
  • 1
LFS96
  • 856
  • 1
  • 12
  • 23
  • so there is no other way of doing a range at once? For a reasonable sized picture would be 2.7 billion iterations just for a small baseline – user2665820 Jan 08 '14 at 15:05
  • no, i dont know an other way, but this is a fast way pics with 1024*1024 i can compare in 1 secend and faster – LFS96 Jan 10 '14 at 07:01