Wednesday, June 19, 2024

Histogram Matching...

As part of my experiments in astrophotography post-processing I noticed that - after applying a suitable non-linear stretch to the linear image data - the histograms of the stretched image had very similar shapes. As an example the histograms for an image of M42 are shown below.

M42 : Processed (Stretched) Image
The histograms for the luminance and the red, green and blue channels have been separately normalised to better show the similarity in shape. The relative amplitudes of the red, green and blue channels is shown below in the composite histogram plot.

Luminance

Red Channel

Green Channel

Blue Channel

Red, Green and Blue Channels Composite Plot


The original linear image as shown below where the pixel values are cramped down at the bottom end as shown in its luminance histogram.
M42: Original Unprocessed Linear Image
Original Linear Image Luminance Histogram
Implementing some way of modifying the data in the original linear image such that its histogram matches the shape and position of a stretched image histogram would be interesting. One way to do that is via "Histogram Matching" - the implementation of which will be described in the next post.