0
Bitmap bmap = new Bitmap(B2);

int width = bmap.Width;
int height = bmap.Height;

for (int y = 0; y < height; y++)
{
    for (int x = 0; x < width; x++)
    {
        Color c = bmap.GetPixel(x, y);
        float h, s, b;
        h = c.GetHue();
        s = c.GetSaturation();
        b = c.GetBrightness();
    }
}

I wanted to filter out all the shades of yellow and then change it all to white. Then I have use HSB which makes it easier. Do I have to convert them back to RGB in order to use setPixel?

Ivan Gechev
  • 706
  • 3
  • 9
  • 21
Sauce
  • 3
  • 3
  • Do you mean you want to remove the yellow color in the whole photo? It would be great if you could attach the photo. – KeyvanSFX Dec 15 '22 at 09:10
  • 1
    Yes, bitmaps are in RGB, See [this question](https://stackoverflow.com/questions/3018313/algorithm-to-convert-rgb-to-hsv-and-hsv-to-rgb-in-range-0-255-for-both) for conversion code. While it is in C, it should be trivial to port to C# – JonasH Dec 15 '22 at 09:25
  • 1
    Or [this question for HSL <-> RGB](https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion) – JonasH Dec 15 '22 at 09:27
  • yes, i wanted to remove all the yellow color in the photo and change it to white. – Sauce Dec 15 '22 at 09:31
  • tq for your answer – Sauce Dec 15 '22 at 09:34

0 Answers0