public Bitmap black_and_white(Bitmap b)
{
int A, B, C, c;
int limit = 110;
for (int i = 1; i < b.Height; i++) // loop for the image pixels height
{
for (int j = 1; j < b.Width; j++) // loop for the image pixels width
{
Color col;
col = b.GetPixel(j, i);

A = Convert.ToInt32(col.R);
B = Convert.ToInt32(col.G);
C = Convert.ToInt32(col.B);
if (A > limit || B > limit || C > limit)
c = 255;
else
c = 0;

if (c == 0)
b.SetPixel(j, i, Color.Black);
else
b.SetPixel(j, i, Color.White);

}
}
return b;
}

Advertisements