2012-07-25

Process an image pixel by pixel to check color on each pixel in C#

By using the below kind of code, we can read an image pixel by pixel and get the color on each.

Bitmap img = new Bitmap("image name here"); 
Color c;

for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
c = img.GetPixel(i, j);
if (c == Color.Black)
{
//Code here
}
else
{
//Code here
}
}
}


On that sample code, I’m checking the pixel color against Black color.

No comments: