Hello I am trying to eliminate all the orange tones of an image saved in a bitmap, I need to do OCR in the image with tesseract and the orange color of the scanned document seems to hinder the process producing errors in the text, I have tried removing the orange color I with photoshop, making the OCR and works perfectly, the main problem is that the pixels are not all of the same color, they are orange but in different shades
Bitmap modificar = new Bitmap("imagenamodificar.png");
for (int ycount2 = 0; ycount2 < modificar.Height; ycount2++)
{
for (int xcount2 = 0; xcount2 < modificar.Width; xcount2++)
{
if (modificar.GetPixel(xcount2, ycount2) == Color.Orange)
{
modificar.SetPixel(xcount2, ycount2, Color.White);
}
}
}
This code does absolutely nothing, the image remains identical.
Then it occurs to me to compare with the pixel (0,0) since it is always the color I want to eliminate.
Bitmap modificar = new Bitmap("imagenamodificar.png");
for (int ycount2 = 0; ycount2 < modificar.Height; ycount2++)
{
for (int xcount2 = 1; xcount2 < modificar.Width; xcount2++)
{
if (modificar.GetPixel(xcount2, ycount2) == modificar.GetPixel(0,0))
{
modificar.SetPixel(xcount2, ycount2, Color.White);
}
}
}
But the problem is that it only removes a small part, orange pixels remain because as I mentioned before, not all orange tones are the same, can someone think of something?