How To Remove a Linear Color Gradient From An Image

STEVE333

Well-known member
Sometimes, when I am nearly finished processing an image, I find there is a color gradient present (probably caused by poor DBE on my part). The picture below shows an example of such an image.

Original Image.jpg


The image looks fine with the exception that the bottom of the image clearly has too much blue while the top of the image looks OK. What is needed is to remove some blue from the bottom of the image while leaving the top of the image unchanged. One approach is to remove a linear blue gradient from the image. This post will show how that can be done.

The image below shows an example of a linear red gradient (no green or blue in this image). The red gradient going from left to right has a value of zero on the left edge and a value of 0.5 on the right edge. This gradient would be used by subtracting it from an image that had too much red on the right side of the image.

Red_0.jpg


The gradient is actually smooth. The visible brightness transitions in the above image are caused by resampling the image and then saving it at low quality to reduce the image file size for this post. How can a gradient be defined?

A gradient is defined by two quantities:
(1) The direction in which the color gradient problem is increasing.
The picture below shows the coordinate system used to define the gradient direction. The red gradient shown in the picture above is at an angle of zero degrees. In the original image, at the top of this post, the color gradient problem increases in the direction toward the bottom of the image, i.e., at an angle of 270 deg..

Gradient Direction.jpg


(2) The magnitude of the gradient.
The magnitude of the gradient is the maximum value that the gradient increases to. The magnitude = 0.5 for the red linear gradient shown above.

Removing a Color Gradient
The original picture in this post had a blue gradient at an angle of 270 deg, i.e., that increases going towards the bottom of the picture. If that gradient can be removed the picture should look better! I have created a Process Icon that will remove a color gradient (the Process Icon can be downloaded using the link at the bottom of this post). The icon is used as follows:
  1. Open the process icon and then open the Symbols tab. There are three parameters that must be set to define the color gradient in your image: Chroma, Theta and M.
  2. Chroma defines the color of the gradient to be removed:
    • Red = 0
    • Green = 1
    • Blue = 2
    • For our example Chroma = 2 (blue).
  3. Theta defines the direction in which the required correction is increasing (0 - 359 deg)
    • For our example Theta = 270 deg.
  4. M defines the magnitude of the gradient to be removed.
    • Trial and error works well for this parameter. More on this below.
Once the parameters are set simply drag and drop the process icon blue triangle onto the image to be corrected. I typically start with M = 0.1 and see how the result looks. If the result isn't correct, then, simply use the Back arrow to go back to the original image and try a larger or smaller value for M depending on whether more or less color correction is needed.

I found that Chroma = 2, Theta = 270 and M = 0.15 produced a nice result for the original image in this example. The corrected image is shown below where the excess blue has been removed.

Repaired.jpg


I only use this process icon occasionally, but, really appreciate it when it is needed.

NOTE: A color gradient can be added to an image by using a negative value for M.

Link for process icon:
https://www.dropbox.com/s/yierhrrvobbz43p/Gradient Remover.xpsm?dl=0

Steve
 
Last edited:
I would have applied ABE (with function degree: 1, Correction: Subtraction) for this task.

Bernd
Thanks Bernd. I never realized that ABE could be applied to a nonlinear image. It produces almost the same result. Well done!!!

Steve
 
Back
Top