It is time to start looking at the processing of night photos. I’m going to start with the end of the workflow, as it’s simpler to explain.
I made a small Python script and a full app that will contain all the different tools that will be discussed in this series.
First, I want to say that I’m not going to tackle the problem of light pollution in this post. It requires its own discussion, as there are different ways to do it equations and estimations processes to address.
I’ll use the following image to show the results:

Exponential processing
The first step is to change the pixels values to enhance the stars luminosity. The main point is that except for the main stars, all the others will be not bright enough to be noticeable. So we need to use a function that will increase low values by a lot and just nudge the high values. So we can use with
, with pixel values normalized to 1. Here is a small graph with several values for
:

We can now apply this transform to each pixel of the image, which will lead to an image like the following one:

Obviously this is not a visually pleasing image, we need now to stretch the image.
Histogram stretch
Histogram stretch can be done manually, by selecting a value below which we force the value to 0 with the following formula: .
The trick is to find a good value for this threshold, and in an automated way if possible (this is why the image needs to be light depolluted first). One way is to create the histogram of a channel, and finding the maximum of the histogram. From this maximum, we select a fraction, for instance 50%. This means we want to find the bin where the histogram has 50% of the maximum. Once we have the bin, we have the threshold value and we can now apply the transform in an automated way.
This leads to the following result:

Conclusion
From a quite dull image, we can get a very more fulfilling photo, provided we don’t have too much noise nor light pollution. These two points are obviously the goal of the rest of the workflow we explained last time and will be explained here and in AstroStack.
