Repository navigation
Histogram Matching
THEORY
Histogram Matching is a method used to restore degraded images using other images taken in the same scene but with the original or better colors. It remap the degraded image I, so that it has, as closely as possible, the same histogram as the target image J. This is done by matching percentiles. For this, we need the Cumulative Density Function of both images (CDF). We have to replace all occurrences for each value Gi, in image I, with the value Gj, from image J, whose percentile in J is bigger or equal to the percentiles of Gi in I. With this we construct a look up table(LUT). In summary:

The histogram matching can be done in 3 different ways:
- Luminance to Luminance ---> Histogram matching between the luminance of both images
- Band to Band ---> Each band of the RGB of the image I makes the histogram matching with the RGB of J.
- Luminance to Band ---> The luminance of the input image make the histogram matching with red, green and blue channels of J.
THE PROGRAM
When you access to L4. HistogramMatching, you have to chose your target image that has been loaded before. Then pick one of the three possible ways of computing the histogram matching, and pulse the Execute button.
Video
https://www.youtube.com/watch?v=xmhYNL103NY

THE CODE
Fist we have to create the variables for the images.
Function to compute the luminance
Inputs
- Image
Outputs
- The luminance of the image

Function to compute the CDF of an image
Inputs
- Image
Outputs
- The CDF of the image

Function to compute a Look Up Table from CDF
Inputs
- CDF of the degraded image
- CDF of the target image
Output
- The LUT for changing the values of I to have similar histogram to J's.

Option 1: Luminance to Luminance

Option 2: Band to Band
Option 3: Luminance to Band

EXAMPLE
We have this degraded image:

We have this target image:

Luminance to Luminance:

Band to Band:

Luminance to Band:
