Having written ArcsinhStretch for PixInsight I've now worked out how to apply a color-preserving stretch in Photoshop.
Essentially the image must be multiplied by a stretched version of its luminance and then divided by the unstretched version of the luminance. That is fairly straightforward to set up as layers.
But achieving the right stretch was a big problem. Photoshop's curves are very limiting - they allow only 16 (x,y) points which must be integers in the range 0-255 and x-points cannot be closer than 4 units apart. There simply isn't the granularity to accurately define a powerful stretch curve such as Arcsinh (Hyperbolic Arcsine). Then I hit upon a solution - it is possible to define a curve that when applied twice gives the correct Arcsinh shape. So I designed and built a set of these curves using a spreadsheet.
Here's an example:
The above curve is not an Arcsinh curve itself but will give an Arcsinh curve with a stretch factor of 300 when applied twice in succession. Every single point on the curve has been carefully calculated in a spreadsheet.
I have calculated and built a set of five curves: Arcsinh10, Arcsinh30, Arcsinh100, Arcsinh300, Arcsinh1000 which give stretch factors of 10x, 30x, 100x, 300x, 1000x. Arcsinh100 is probably the most useful one in general. You would use the same Arcsinh100 curve in both layers to achieve a stretch of 100x. It is quite possible to "mix and match" them - for instance using Arcsinh100 in one layer and Arcsinh300 in the other layer would give a stretch somewhere between 100x and 300x.
If you want to use these curves I'm making them freely available here: PS_ArcsinhCurves.zip 914bytes 3056 downloads
You need to unzip them into the relevant Photoshop folder. On my Windows machine that is C:\Users\Mark\AppData\Roaming\Adobe\Adobe Photoshop CC 2015\Presets\Curves but if you don't know where your own folder is, just try to save any arbitrary curve and notice which folder Photoshop is using.
So here are some brief instructions on how to use them. Firstly you need to start with a 16-bit linear (i.e. unstretched) image (e.g. from DeepSkyStacker) which has the correct white balance and has had the background skyglow subtracted. An 8-bit image is too limiting and 24-bit image cannot use Curves in Photoshop. Use Photoshop Levels to adjust the Black Point as far as it will go without clipping data and also set the White Level.
- Open the image in Photoshop
- In the Layers menu right click Background layer and do Duplicate Layer. Name this new layer "Grey".
- Click on the "Grey" layer and go to Image->Adjustments->ChannelMixer. Click on Monochrome and set the source channels to be 33% each then hit OK. This converts the layer to grey.
- Right click the "Grey" layer and do Duplicate Layer. Name this new layer "Grey Divide" as a helpful hint to the role it will play.
- Click on the "Grey" layer; add a group; move the "Grey" layer into the group and set the blend mode of the group to "Multiply"
- For the "Grey Divide" layer set the blend mode to "Divide". [Note: if you don't have Divide as a blend option then set the blend mode to "Colour Dodge" and do Image->Adjustments->Invert on the "Grey Divide" layer because an inverted Colour Dodge is the same as a Divide.]
- Click on the "Grey" layer and go to Layer->New_Adjustment_Layer->Curves to add a curves layer. Load one of the Arcsinh curves.
- Click on the Curves layer and do Duplicate Layer.
- Optionally add a "Levels" layer between the 2 curves layers and adjust the black point if you think you need some extra background subtraction.
Your layers should now look like this:
Unfortunately it is possible that the resulting image is a complete posterized mess. This is an annoying "feature" of Photoshop. Try viewing it at a scale of 66% or above to make it appear correctly.
Alternatively, to make images appear without posterization at all zoom scales do Edit->Preferences->Performance and set Cache Levels to 1. Close and restart Photoshop for the change to take effect. Unfortunately now when you perform operations such as curves etc you'll notice a slight delay in the image updating because setting Cache to 1 slows down the screen redraw. But at least now what you see is what you get.
If you want a practice image you can download this one of NGC7000: https://drive.google...G9NSmluX00/view
This is what you should see at the end using Arcsinh300 for a 300x stretch:
The curves I have built work fine even on an old version of Photoshop such as Photoshop CS2. But CS2 does not have a "Divide" layer blend mode so you have to use the "Invert layer and use Colour Dodge" trick in step 6 above.
Edited by sharkmelley, 19 October 2017 - 06:16 PM.