Before someone cries to me for not checking other messages, I already did it. I have a specific question about one of the methods that exist for converting an image to grayscale.
I read other posts on SO and basically copied Technique 3 (ColorMatrix) from a tutorial on this site . It works very, very fast.
The problem I am facing is that I need a clean BW image. (i.e. if the average (R, B, G)> 200 => white is still black). I implemented this straightforwardly, and actually it takes almost 10 times until the grayscale algorithm from the tutorial.
I am not a specialist in image processing, and I was wondering if there is a way to change a fragment from a tutorial to convert images to black and white. If not, any effective way could do.
EDIT:
Here's the code I'm using for black and white (without approaching the brain):
public Bitmap make_bw(Bitmap original) { Bitmap output = new Bitmap(original.Width, original.Height); for (int i = 0; i < original.Width; i++) { for (int j = 0; j < original.Height; j++) { Color c = original.GetPixel(i, j); int average = ((cR + cB + cG) / 3); if (average < 200) output.SetPixel(i, j, Color.Black); else output.SetPixel(i, j, Color.White); } } return output; }
source share