I successfully removed the red from clue.bmp and got the light-blue mug shot on a white background.

Then I added another section of code to darken the blue (by reducing the blue and green values by half). It worked and turned the pale blue image into a nice dark image BUT it also somehow added all the red back into the image.

Here's my code. If anyone can see what I'm missing, I would be SOOOo grateful.

// if RED (OR WHITE) pixel, change to white (or leave white)
   if (triple.rgbtRed == 0xff)
               triple.rgbtBlue = 0xff;
               triple.rgbtGreen = 0xff;

//if NOT RED and NOT WHITE pixel (i.e. it's a PALE BLUE pixel)
  if (triple.rgbtRed != 0xff)          
              triple.rgbtBlue = triple.rgbtBlue/2;
              triple.rgbtGreen = triple.rgbtGreen/2;


1 Answer 1


This one will take some thought to fix. ;-) Think about what's happening. The first block of code turns red pixels to white by increasing the value of green and blue, not by altering the red level of pixels with red == FF.

The next block of code darkens any pixels where the red level is not FF by reducing the level of the green and blue components. But what would happen if the red level is high, but not FF? It would leave a high red level, but cut the green and blue in half. That would leave a lot of red pixels.

How you're going to incorporate that knowledge remains up to you. Maybe you should do a study of what levels the pixels are at. Maybe there's a trend that you could exploit? (Hint: Do you know what a histogram is?) Happy coding!

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thanks, i think where i went wrong was in not realizing that there was still a lot of super pale blue in the background and that was all going to turn black-ish with my second block of code.
    – harper10
    Commented Dec 6, 2016 at 7:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .