CrazyImpling
New Member
- Reaction score
- 3
How would I count the number of pixels that have the RGB value of 153, 184, 226 that are on the screen?
int count = 0;//Counter to count pixels
Bitmap b = new Bitmap("123.jpg");//Getting the image.
Color c;
//Looping over all pixels
for (int i = 0; i < b.Width; i++)
{
for (int j = 0; j < b.Height; j++)
{
c = b.GetPixel(i, j);//Get the current pixel.
if (c.R == 153 && c.G == 184 && c.B == 226)//Checking pixel
{
count++;//increase counter
//Do what ever you want, you have got the pixel that have
// R = 153 AND G = 184 AND B = 226
}
}
}