The ArcsinhStretch and the MaskedStretch
We previously went over the HistogramTransformation process, which is one way of stretching linear data so our eye can see the detail in an image. For those mathematically inclined, the eye has a roughly logarithmic response to light, so the linear data must be transformed so our eye can see it.
The HistogramTransformation process uses something called a Midtones Transfer Function (MTF) do make this transformation. Fortunately for those not mathematically inclined, it is rather easy to understand what it does. Wherever you place the Midtone Balance slider, that location is going to be transformed to the value .5 The Shadows Clipping Slider will define what is 0 and the Highlights Clipping Slider will define what is 1. A smooth constantly increase curve is then drawn between those points. For those interested, the math behind this is in the documentation for the process. One thing you may be interested to learn is that the MTF is not a gamma function.
We previously went over the HistogramTransformation process, which is one way of stretching linear data so our eye can see the detail in an image. For those mathematically inclined, the eye has a roughly logarithmic response to light, so the linear data must be transformed so our eye can see it.
The HistogramTransformation process uses something called a Midtones Transfer Function (MTF) do make this transformation. Fortunately for those not mathematically inclined, it is rather easy to understand what it does. Wherever you place the Midtone Balance slider, that location is going to be transformed to the value .5 The Shadows Clipping Slider will define what is 0 and the Highlights Clipping Slider will define what is 1. A smooth constantly increase curve is then drawn between those points. For those interested, the math behind this is in the documentation for the process. One thing you may be interested to learn is that the MTF is not a gamma function.
Now if you think about it, there are many possible curves that always increase between 0 and 1. The MTF used in the HistogramTransformation process is only one such curve. It is a useful one because it is relatively easy to understand what you are doing. But there are other curves that have interesting properties. One such curve is defined by a arcsinh function.
I'm not going to go into the math behind this function. For those mathematically inclined, you can read about the Arcsinh function on Wikipedia. And then you can read about how that function is used in this transformation by selected the document button (the blue button that looks like a page with the upper right corner turned) on the ArcsinhStretch interface.
For our purposes, this function has a couple of interesting properties:
The first property makes the ArcsinhStretch very useful when working with color data. The second property is very useful when working with luminosity data.
I'm not going to go into the math behind this function. For those mathematically inclined, you can read about the Arcsinh function on Wikipedia. And then you can read about how that function is used in this transformation by selected the document button (the blue button that looks like a page with the upper right corner turned) on the ArcsinhStretch interface.
For our purposes, this function has a couple of interesting properties:
- ArcsinhStretch preserves color as you stretch
- Stars tend to look less bloated after an ArcsinhStretch compared to a HistogramTransformation
The first property makes the ArcsinhStretch very useful when working with color data. The second property is very useful when working with luminosity data.
Enough of the theory. Lets actually use the ArcsinhStretch on the data. Bring in the luminosity data that you DynamicCropped and then saved earlier. I called mine L_dynamicCrop. This data should be linear. Also bring up the ArcsinhStretch process.
Using this process is pretty simple. Press the Real-Time Preview button (the unfilled blue circle). Then move the Stretch factor slider to start revealing data. The data will look very washed out because we haven't moved the black point. (What HistogramTransformation calls the Shadows Clipping Point). In the Real-Time Preview section of the interface, press the Estimate Black Point button. Make sure the "Highlight values clipped to zero" box is checked. You will then see many many little white dots that show portions of the image that have been clipped. Using the "Black point fine Adjustment slider" (the second slider under the "Black point" label, move that slider to the left until all or almost all of those dots disappear. I would suggest making them all disappear. Then finish moving the Stretch factor slider to stretch the image to taste. You may find you do want to clip the blacks slightly for better contrast. Just fine tune things with the "Black point fine adjustment slider".
When you are happy with your settings, go ahead and "Apply" the settings to the image. Feel free to save this if you wish.
If you were to compare similarly stretched images, one with a ArcsinhStretch and one stretched with HistogramTransformation, you would discover the stars are somewhat more compact (less bloated) in the version done with ArcsinhStretch. Here, I have done this with the tutorial image.
If you were to compare similarly stretched images, one with a ArcsinhStretch and one stretched with HistogramTransformation, you would discover the stars are somewhat more compact (less bloated) in the version done with ArcsinhStretch. Here, I have done this with the tutorial image.
The Bright Nebulae in the two images are fairly similar but the Dark Nebulae are a bit better defined in the ArcsinhStretch. The stars are less bloated in the ArcsinhStretch (look at the bright star in the upper right of the image).
That seems like all gravy (assuming you like gravy) but there is a potential downside. Certain kinds of artifacts can be made more obvious when looking at the stars at high zoom. Also, the way a star increase in brightness is somewhat different. A HistogramTransformation leads to stars that look almost spherical, but ArcsinhStretch can lead to stars that look almost conical. That is especially true after other processing such as Deconvolution, which we will go into later. Just be aware for now that the stretch you select can affect how the stars appear, especially when looked at full size or zoomed in even further.
That seems like all gravy (assuming you like gravy) but there is a potential downside. Certain kinds of artifacts can be made more obvious when looking at the stars at high zoom. Also, the way a star increase in brightness is somewhat different. A HistogramTransformation leads to stars that look almost spherical, but ArcsinhStretch can lead to stars that look almost conical. That is especially true after other processing such as Deconvolution, which we will go into later. Just be aware for now that the stretch you select can affect how the stars appear, especially when looked at full size or zoomed in even further.
Another important way of stretching data uses the MaskedStretch process. We will go into masks in more depth later as they are a very important concept. The quick version is that a mask is an image that controls how a process is applied to the pixels in another image. Where the mask is really bright, the process will have a strong affect. And where the mask is dark, the process will have a very weak affect. The MaskedStretch uses masks internally to control the stretching of an image. Instead of stretching an image just once or twice, it normally does it many times. How many times depends on the "Iterations" setting, which defaults to 100.
In the image above, I have opened my luminsity data that I saved after the DynamicCrop. I have then done a STF (Screen Transfer Function) or the data so I could see what is in it.
I'm now going to introduce the idea of a Preview. This is a rectangular region you can draw on an image. That rectangular area can be used a number of ways. For example, I used one above when comparing how a star was stretched using ArcsinhStretch vs HistogramTransformation. A preview area can be used ahead of time to see how a process will affect part of an image. This is sometimes very handy when tuning the settings for a process. A preview area can also be used to define a Region of Interest (RoI). And a preview area can be used by some processes as a reference for something.
In the case of the MaskedStretch, preview areas can be used to define a Background reference. And they can also be used to define a Region of Interest. We will often use the capability to define a background when doing a MaskedStretch.
The ability to define a Region of Interest for the MaskedStretch is rather less useful but can help in exceptional cases. Essentially it allows using the defined region instead of the image as a whole to determine the mean intensity used when doing the stretch.
To create a preview select the image on which you wish to define a Preview. Then hold down the Alt button [ALT] and at the same time press the "n" key. Once you have done the [Alt]n key combination you should be able to click and drag on the image to create a rectangular preview area.
You will notice in the image above the preview area I drew for my background is pretty small. Sometimes it is useful to zoom in on part of the image while placing your preview. This is what I did. Preferably you want it in an area with no stars, although the lower and upper limit sliders for the Background reference will help tune the stars out if you do have them.
I'm now going to introduce the idea of a Preview. This is a rectangular region you can draw on an image. That rectangular area can be used a number of ways. For example, I used one above when comparing how a star was stretched using ArcsinhStretch vs HistogramTransformation. A preview area can be used ahead of time to see how a process will affect part of an image. This is sometimes very handy when tuning the settings for a process. A preview area can also be used to define a Region of Interest (RoI). And a preview area can be used by some processes as a reference for something.
In the case of the MaskedStretch, preview areas can be used to define a Background reference. And they can also be used to define a Region of Interest. We will often use the capability to define a background when doing a MaskedStretch.
The ability to define a Region of Interest for the MaskedStretch is rather less useful but can help in exceptional cases. Essentially it allows using the defined region instead of the image as a whole to determine the mean intensity used when doing the stretch.
To create a preview select the image on which you wish to define a Preview. Then hold down the Alt button [ALT] and at the same time press the "n" key. Once you have done the [Alt]n key combination you should be able to click and drag on the image to create a rectangular preview area.
You will notice in the image above the preview area I drew for my background is pretty small. Sometimes it is useful to zoom in on part of the image while placing your preview. This is what I did. Preferably you want it in an area with no stars, although the lower and upper limit sliders for the Background reference will help tune the stars out if you do have them.
Again it bears mentioning that I have done a regular STF [ctrl]a in order to make faint stars more visible when placing my preview for the Background reference.
Once you have your Background reference set, undo your STF stretch (Screen Transfer Function). One way of doing that is right clicking on the image and a menu will come up. Select Screen Transfer Functions->Reset STF. [ctrl]F12 serves as a shortcut if you have your function keys activated on your keyboard.
Another slider we are going to talk about is the very important Target background slider. This slider will determine how much the image is stretched. In particular it sets the mean value of the background after the stretch is completed.
Finally, there is the clipping fraction. This will define what fraction of the pixels in the image will be set entirely black. It performs much the same function as the various controls in the Histogram Transformation that control the Shadows Highlight Clipping. My own feeling is the default of this is almost always higher than I like. I would back this off by at least a factor of ten.
One unfortunate aspect of the MaskedStretch process is that no Real-Time preview is available. You can use a Preview area to see how the stretch will affect just part of the image but I normally don't bother because the process is normally reasonably fast. Here is a stretch using almost all defaults except we have used the Background reference preview that we created. You can either "Apply" the MaskedStretch using the Blue Square button, or you can drag the "New Instance" button that looks like a blue triangle over the image.
Once you have your Background reference set, undo your STF stretch (Screen Transfer Function). One way of doing that is right clicking on the image and a menu will come up. Select Screen Transfer Functions->Reset STF. [ctrl]F12 serves as a shortcut if you have your function keys activated on your keyboard.
Another slider we are going to talk about is the very important Target background slider. This slider will determine how much the image is stretched. In particular it sets the mean value of the background after the stretch is completed.
Finally, there is the clipping fraction. This will define what fraction of the pixels in the image will be set entirely black. It performs much the same function as the various controls in the Histogram Transformation that control the Shadows Highlight Clipping. My own feeling is the default of this is almost always higher than I like. I would back this off by at least a factor of ten.
One unfortunate aspect of the MaskedStretch process is that no Real-Time preview is available. You can use a Preview area to see how the stretch will affect just part of the image but I normally don't bother because the process is normally reasonably fast. Here is a stretch using almost all defaults except we have used the Background reference preview that we created. You can either "Apply" the MaskedStretch using the Blue Square button, or you can drag the "New Instance" button that looks like a blue triangle over the image.
Again, note the lack of star bloat compared to the HistogramTransformation. On the other hand, star shapes are even less spherical than with ArcsinhStretch.
Perhaps you are unhappy with how the MaskedStretch turned out. Since we don't have a Real-Time Preview, that is easy to occur. You can undo processes in PixInsight by using the undo button in the upper left of the PixInsight interface. You can also use the [ctrl]z keyboard shortcut.
I'm going to redo the stretch this time, using a much smaller Clipping fraction. I am also going to lower the background.
I'm going to redo the stretch this time, using a much smaller Clipping fraction. I am also going to lower the background.
Why would I use a stretch that clearly isn't enough? Sometimes I like to combine a MaskedStretch with a HistogramTransformation. That way I get less star bloat than a pure HistogramTransformation stretch but somewhat more natural stars than a pure MaskedStretch.
This technique of sometimes doing things in multiple stages is a powerful one and at times can give much more control over the final result than doing things in one big bang. That is especially true when you can sometimes mix processes like we did here.
One final point. You may be tempted to lower the number of iterations, especially if you have an older, slower machine. Just be aware that setting it too low can lead to artifacts like these:
One final point. You may be tempted to lower the number of iterations, especially if you have an older, slower machine. Just be aware that setting it too low can lead to artifacts like these:
For the image above I deliberately set my Iterations too low at 10. This led to artifacts where I get stars with a bright ring, a dark ring, and then a bright center. A iterations value of 100 will normally be sufficient to avoid these artifacts.