First Attempt
In the previous post which described automatically stretching via matching (using Cumulative Distribution Functions - CDFs) to mathematically generated red, green and blue channel histograms, mention was made of perhaps using existing good examples of the same object to provide a set of red, green and blue histograms.
I am interested how far the post-processing of Seestar S50 images can be automated. Accordingly, some code was written to implement the histogram matching function using good example images as shown below.
Histogram Matching to an Existing Good Example Image - Before Matching |
In this application the FITS observation file that is to be 'stretched' by histogram matching is loaded into the large image box. In the above picture the original linear image is shown. Then an example of an existing good stretched image of the same subject is loaded (the small image box top-left). Typically this might be images from the 'net from professional or amateur sources.
The application then calculates histograms of both the observation image file and the example stretched image file. After calculating CDFs from each histogram, the original linear image is re-mapped such that its histogram matches the good example image histogram.
The results of that process is shown below.
Histogram Matching to an Existing Good Example Image - After Matching |
If we compare this result with the result from the previous post where the matching was done to a mathematically generated (via equations) as shown below (ignore the rotation), we can see that the above result has taken on the 'look' of the example image and is a better result as a consequence.
Comparison Result from Using a Mathematically Generated Histogram for Matching |
If we choose a different example image which has a different 'look' and repeat the process we get the result as shown below.
Histogram Matching to a Different Existing Example Image (more blue) |
A further example uses an example image which has a completely different 'look'...
Histogram Matching to Radically Different 'Look' Example Image |
In this example image there is more red and green and so the result of histogram matching takes on that 'look'. Other features to note is that for this M42 image, the detail around the trapezium in the result images matching the detail in the example images. Where the trapezium detail is prominent in the example image, likewise it is prominent in the result. So - not only is the colouring of the example image adopted, but also the stretch curve shape.
I am pretty pleased with this result - which, once again, is better than I expected. Some notes...
- In the above results absolutely no manual tweaking is done. Just load in the observation file and the example image file and hit 'GO'. So - the above results - as far as processing is concerned - are obtained 100 % automatically.
- No spatial information is transferred from the example image (i.e., no matching of individual pixels is done). The spatial information is lost in the histogram calculation. It is simply the statistics (histogram and CDF) which are matched.
- The example images - used to match the observation image histogram to - are typically generated by a different camera (sensor), different post-processing applications, etc, and so the matching cannot be exact.
- Likewise - the exposure times for the example images is likely to be much longer (or the result of a larger aperture lens) and so the signal-to-noise ratios for the Seestar S50 images to be matched are likely to be much lower. Some compensation for this effect might be possible.
Further experimentation will be conducted to explore how far this technique can be extended.