Adding Colour, With a Gradient Map Adjustment Layer
When an image has a colour cast there are a number of ways of restoring a reasonable white balance. The levels control and the photo filter are just two such methods.
The levels control can be used to increase the deficient colour. However, this will result in a histogram with a lot of gaps in it.
The photo filter can be used to add colour and it will produce a histogram with no gaps. However, it usually produces a somewhat low contrast results.
There are other methods but they each suffer from one or more of the above problems.
In a search for a method of producing an image with high contrast and also no gaps in the histogram, I came up with a method using the gradient map adjustment layer.
Description of the idea
Quite often an image is deficient in one or more colours. The task is to introduce those colours into that image. If the image has an area that should be white and isn’t then it is a relatively simple task to determine what colour is missing and that would add to the original to make white.
Inverting the image will produce an image consisting of the complementary colours to the original colours. The colour picker can then be used to “pick” the complementary colour to the colour that you would like to be white.

The two colour circles above are complementary to each other.
A colour is complementary to another colour when adding the brightness of one colour to the brightness of the other, for each of the primary colours red, green and blue, gives 255 for each colour i.e. white. e.g. If the original colour is Red=200, Green=100 and Blue=75 then the complementary colour is Red=55, Green=155 and Blue=185. Adding these two colours gives Red=255, Green=255 and Blue=255 which of course is white.
Selecting a colour and taking its inverse gives the colour that can be added to the original colour to give white.
If a gradient is produced in the gradient editor that goes from black to this complementary colour then it can be used to create an inverse image that is graded according to luminosity of the image in the complementary colour.
If this image and the original image are added together then the desired white area will be white. Hopefully, all other parts of the image will have the required proportion of the complementary colour added to remove the colour cast.
How to do it
Load an image that has a colour cast. Preferably choose one with an area that ought to be white.

Invert the image. Set the foreground colour to black then use the colour picker to set the background colour from the part of the inverted image that you want to be white. In the above case I chose part of the gown that the central figure is wearing.
Note; The colour picker should be set to selecting a 5 by 5 sample.

Invert the picture again to get back to the original.
Create a gradient map adjustment layer using the foreground to background preset. Either by selecting from the list accessed by clicking on the black and white circle on the layers pallet or by selecting Layer-New Adjustment Layer-Gradient Map from the menu. (See the Gradient Map note for more details.)


Above are the original image and the gradient map from black to the complementary colour of the white gown the main figure is wearing.
Set the blend mode of the gradient map layer to linear dodge.
Note
Originally I used a slightly different method. Instead of just a gradient map adjustment layer I used a copy of the image and grouped the adjustment layer with the copy then made the blending mode of the copy to be linear dodge. This more complicated process is unnecessary. The gradient map adjustment layer effectively creates its own copy which it blends with the image below.
Brightness correction
The area chosen to be white should now be near white. It is unlikely to be perfectly white at this stage because the brightness of the selected area is likely to be less than 100%.

(Long explanation. Say the selected area’s luminosity is only 90%. The gradient map we made above will map the inverse of the colour of this area to parts of the image that are 100% luminosity and only 90% of the required amount of the inverse colour to the areas that are 90% luminous. It follows that the area that is only 90% luminous is only getting 90% of the inverse colour needed to make it white. Fortunately this can be remedied by making the added inverse colour map to parts of the image that are only 90% bright.)
How to do it.
Double click on the gradient map to bring up its dialog box. Move the lower right hand slider to the left i.e. decrease the level at which the chosen inverse colour is mapped. This is like moving the right hand slider in the Levels adjustment layer. It effectively brightens the image, in this case the inverted image. Judge by eye when the brightness and the colour are more satisfactory.
What if there is no area that you want to be white?
If there is no area that should be white (or a colour cast is required for artistic reasons) then the adjustment in the gradient editor will have to be carried out using eye and hand.
Load the picture and create a gradient map adjustment layer with black for the foreground colour. Click on the right hand slider and bring up the colour picker for that slider. From now on you just have to play with the colours to achieve the effect you require.
Some experience with just playing with complementary colours will help as removing a colour cast involves adding the complementary colour. See the section on complementary colours.
There are many adjustments that can be made in the gradient map adjustment layer. The mapping can use different colours over areas of different luminosity so there is great scope for producing exactly the effect required.
What is the
difference between the gradient map adjustment and levels adjustment?
Increasing the amount of a particular colour be adjusting levels increases the colour that is already present. This can be done either by increasing the gamma or by decreasing the input maximum. If there is no blue in an area for example, then no amount of increasing levels in the blue channel will introduce any blue to that area.
Adding colour using the gradient adjustment layer as described actually adds colour, so blue can be added to areas that had no blue originally. This can present a problem. Consider an image containing one area that is deficient in blue compared with the original scene and another area that is the same luminosity in the image but in the original scene had little or no blue content. The amount of blue added to each area will be the same so that the second area will have too much blue. This can of course be rectified by simply shading the layer mask for the gradient map.
Different images will respond with greater or lesser effect to one or other of the two methods of adjusting colour. Sometimes levels will be better sometimes the gradient map adjustment layer will be better.
Brightness vs. Luminosity
I have said that the gradient map adjustment layer maps according to luminosity than to brightness.
What is luminosity?
Luminosity adjusts the value for intensity of light according to how colours are perceived. Blue is perceived as darker than red and red is perceived as darker than green. If you colour a square red with a colour value of 100 and then look at the histogram with luminosity chosen the value shown is 30, for green the resulting luminosity is 59 and for blue it is 11. If all three are added together i.e. grey with a value of (100,100,100) has a luminosity of 100 which is the sum of 30, 59 and 11. Luminosity is additive.
Normally this is not of interest unless one is converting to grey scale or using the gradient map. The shades that are produced are not related to brightness as shown in the HSB section of the colour picker but are more closely related to a luminosity value but not using the same conversion values as above.