# Making an item that is not the brightest in a photo look white

Imagine you have a photo where there is something that you know is white, but is not the brightest thing in the photo, What’s your technique for making sure that white object is white? Let’s not limit this to any one program…answers for any program should help someone.

Desaturate then smooth or brighten for taste?

Let’s further imagine that the bright item (say a sunset or fireworks) is the star of the show, but the white area that is not part of the bright item occupies a part of the image and you don’t want it to have some funky blue or yellow cast in that area making the entire image look questionable.

(Yes, I do have a low quality cell phone image in mind that I don’t want to share here)

You can colour-balance the entire image so the white object is a neutral gray in the image. This is done by multiplying the RGB channels by factors so they are equal for the white object.

Next problem: I’m not sure if you want the white object, that wasn’t the “brightest thing in the photo” to be exactly white (so it becomes the brightest object, or one of the brightest objects). If so, then divide the entire image by the brightness of the white object. It will become white, and other brighter objects will be clipped.

Either or both of these operations could be masked, of course.

That’s the destination.

If you want the maths, it works like this:

1. Find the mean of the red, green and blue channels in the area you want to make gray. We’ll call these mR, mG and mB.

2. Find the mean lightness of the same area. We’ll call that mL.

3. For every pixel in the image:

3a. Multiply the red channel by mL/mR.
3b. Multiply the green channel by mL/mG.
3c. Multiply the blue channel by mL/mB.

That’s it. The operation can be done in linear colorspace or in an exact power colorspace such as AdobeRGB. For sRGB which is a linear-plus-power colorspace the result will not be exactly accurate, but you wouldn’t notice any problem.

There are other methods that may be useful. Instead of multiplying, we can raise to a power. This will change some mid-tone but will have less effect on lighter colours.

2 Likes

Perfect, thanks @snibgo.

Depending on the algorithm and your parameters, dehaze or retinex could address this problem. The widely implemented dark channel prior dehaze takes into consideration bright light sources like the sun, artificial or specular lights by ignoring them. It would instead choose another patch that it would consider white or grey and attempt to make it whitish.

In my problem image, I did use haze removal, but didn’t do anything with retinex. Thanks. I’l check it out.

It may not work but my point is that these methods in theory should address stuff like this. Whether a given implementation or algorithm from a research paper can or cannot is another question.