Jump to content

  •  

CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.

Photo

Photoshop Color Preserving Arcsinh Stretch

  • Please log in to reply
44 replies to this topic

#26 Whirlpool51

Whirlpool51

    Vostok 1

  • -----
  • Posts: 102
  • Joined: 12 Sep 2012
  • Loc: Macclesfield, Cheshire, Great Britain.

Posted 11 October 2020 - 02:18 AM

I came across you're Curves preset tool whilst watching a YT processing tutorial.

 

I use PS CC and have added it to the pre-sets folder. Thank you for going to the trouble to provide astro imagers like me, with a handy tool that preserves colour.



#27 galacticinsomnia

galacticinsomnia

    Surveyor 1

  • *****
  • Posts: 1,734
  • Joined: 14 Aug 2020
  • Loc: Pacific Northwest - Oregon

Posted 11 October 2020 - 09:18 PM

Very cool and thank you for the share.


  • cobestluc likes this

#28 Anonymous Astronomer

Anonymous Astronomer

    Explorer 1

  • -----
  • Posts: 54
  • Joined: 22 Jun 2020
  • Loc: Timisoara, Romania

Posted 10 November 2020 - 10:30 AM

Thank you for all the effort. Seems very useful, especially for beginners like me.

I can't wait to try it.

Clear skies,

Vlad



#29 Mmouton77

Mmouton77

    Lift Off

  • -----
  • Posts: 2
  • Joined: 15 Feb 2020

Posted 10 November 2020 - 04:36 PM

Thank you for the tool. I've successfully unzipped the download into the Curves file in Photoshop 2020. All of them appear in my Curves drop down box except the 5 Arcsinh tools. Not sure if I'm doing something wrong. Any advice?



#30 sharkmelley

sharkmelley

    Aurora

  • *****
  • topic starter
  • Posts: 4,963
  • Joined: 19 Feb 2013
  • Loc: UK

Posted 11 November 2020 - 03:08 AM

Thank you for the tool. I've successfully unzipped the download into the Curves file in Photoshop 2020. All of them appear in my Curves drop down box except the 5 Arcsinh tools. Not sure if I'm doing something wrong. Any advice?

Try adding a curves layer with a default preset.  Once the curves layer has been added, double click the curves layer and try to edit the preset.  You may find that the arcsinh curves then appear in the list.

 

Mark



#31 Mmouton77

Mmouton77

    Lift Off

  • -----
  • Posts: 2
  • Joined: 15 Feb 2020

Posted 11 November 2020 - 04:47 AM

Try adding a curves layer with a default preset.  Once the curves layer has been added, double click the curves layer and try to edit the preset.  You may find that the arcsinh curves then appear in the list.

 

Mark

Great. That did it. I had to go to "Load curves presets..." and add them one at a time.

 

Thank you!!



#32 grkuntzmd

grkuntzmd

    Lift Off

  • -----
  • Posts: 23
  • Joined: 30 Nov 2018
  • Loc: Gainesville, FL, USA

Posted 21 December 2020 - 11:49 AM

I've converted these to use in GIMP (version 2.10). You can download them from my Google Drive: https://drive.google...QJ1?usp=sharing

 

To add them to GIMP, open an image and select Colors→Curves..., then click the small left arrow button to the right of the + button near the top of the dialog. Choose "Import Current Settings from File..." and import one of the curves (you'll need to do them one at a time). Click the + button and name the new curve "Arcsinh XX", where XX is the number after the name in the file.


Edited by grkuntzmd, 21 December 2020 - 11:50 AM.

  • sharkmelley, Nate1701 and Borodog like this

#33 Jcb1950etx

Jcb1950etx

    Lift Off

  • -----
  • Posts: 2
  • Joined: 11 Aug 2019

Posted 06 February 2021 - 01:51 PM

Hello, I am having trouble loading the arcsinh files.  I have managed to unzip them and I can see them in the Photoshop Plug-ins folder.  I do not see them in the Curves pull down.  I get an error message that it the wrong kind of file.

Running Windows 10.

Any suggestions?

Thanks



#34 sharkmelley

sharkmelley

    Aurora

  • *****
  • topic starter
  • Posts: 4,963
  • Joined: 19 Feb 2013
  • Loc: UK

Posted 06 February 2021 - 06:58 PM

Hello, I am having trouble loading the arcsinh files.  I have managed to unzip them and I can see them in the Photoshop Plug-ins folder.  I do not see them in the Curves pull down.  I get an error message that it the wrong kind of file.

Running Windows 10.

Any suggestions?

Thanks

Did you try putting them in the Presets\Curves folder as suggested in the original post?

 

Mark



#35 Jcb1950etx

Jcb1950etx

    Lift Off

  • -----
  • Posts: 2
  • Joined: 11 Aug 2019

Posted 07 February 2021 - 11:23 AM

Mark, got it thanks!  (New guy at this stuff - lot to learn).



#36 primeshooter

primeshooter

    Explorer 1

  • -----
  • Posts: 69
  • Joined: 19 Mar 2021

Posted 07 April 2021 - 08:36 AM

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:

attachicon.gifPS_Arcsinh_Curve.jpg

 

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: attachicon.gifPS_ArcsinhCurves.zip

 

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. 

  1. Open the image in Photoshop
  2. In the Layers menu right click Background layer and do Duplicate Layer.  Name this new layer "Grey".
  3. 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. 
  4. 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.
  5. 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"
  6. 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.]
  7. Click on the "Grey" layer and go to Layer->New_Adjustment_Layer->Curves to add a curves layer.  Load one of the Arcsinh curves.
  8. Click on the Curves layer and do Duplicate Layer.
  9. 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:

 

attachicon.gifPS_Arcsinh_Layers.jpg

 

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:

attachicon.gifPhotoshopCC_Arcsinh300.jpg

 

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.

 

Mark

Mark thanks for this, I am just a beginner but this curves set gets good results fast and keeps colour. Tell me this, why is it I cannot set my cache level to 1? I put it to 1, exit and re enter PS and it always goes to 2 (I had it at 8). Running a serious rig, 3900X 12 core, 128GB 3600 ram, so the problem isn't speed? Any ideas? I was on cache level 8, now at two and the banding is horrdendous, like a posterization at most zoom levels apart from around 100%. PS how do you do the sky glow subtraction before the stretch, are you just using RGB curves to line up the left sides of the peaks?

 

Can you explain how you do a subtraction before this part below -

 

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.


Edited by primeshooter, 07 April 2021 - 08:55 AM.


#37 sharkmelley

sharkmelley

    Aurora

  • *****
  • topic starter
  • Posts: 4,963
  • Joined: 19 Feb 2013
  • Loc: UK

Posted 09 April 2021 - 06:24 PM

Tell me this, why is it I cannot set my cache level to 1? I put it to 1, exit and re enter PS and it always goes to 2 (I had it at 8). 

I have the same problem. 

 

 

Can you explain how you do a subtraction

Use your favourite technique to make a layer consisting of background only (including gradients), then set the layer mode to "subtract"

 

Mark



#38 primeshooter

primeshooter

    Explorer 1

  • -----
  • Posts: 69
  • Joined: 19 Mar 2021

Posted 21 April 2021 - 09:27 AM

I have the same problem. 

 

 

Use your favourite technique to make a layer consisting of background only (including gradients), then set the layer mode to "subtract"

 

Mark

Thanks Mark. Is it best to keep it at 2 then for now? (I have a very powerful PC) What cache size do you recommend for a top of the line PC?

 

I take it you've not found out how to force it to 1?



#39 sharkmelley

sharkmelley

    Aurora

  • *****
  • topic starter
  • Posts: 4,963
  • Joined: 19 Feb 2013
  • Loc: UK

Posted 21 April 2021 - 10:50 AM

Thanks Mark. Is it best to keep it at 2 then for now? (I have a very powerful PC) What cache size do you recommend for a top of the line PC?

 

I take it you've not found out how to force it to 1?

No, I've not found a way to force the cache level to 1.  Cache level and cache size is a question for Adobe support.  I don't have the required expertise - I'm just a frustrated user.



#40 Steve OK

Steve OK

    Surveyor 1

  • -----
  • Posts: 1,881
  • Joined: 22 Sep 2007
  • Loc: OKC, OK

Posted 21 April 2021 - 11:45 AM

I have a question about step 3 in your instructions above.  Does the method you describe produce a different result than using Image>Mode>Grayscale?

 

Just curious!

 

Thanks for all your contributions, Mark!

 

Steve


Edited by Steve OK, 21 April 2021 - 11:45 AM.


#41 sharkmelley

sharkmelley

    Aurora

  • *****
  • topic starter
  • Posts: 4,963
  • Joined: 19 Feb 2013
  • Loc: UK

Posted 21 April 2021 - 12:20 PM

I have a question about step 3 in your instructions above.  Does the method you describe produce a different result than using Image>Mode>Grayscale?

That would work just fine!

 

Mark


  • Steve OK likes this

#42 primeshooter

primeshooter

    Explorer 1

  • -----
  • Posts: 69
  • Joined: 19 Mar 2021

Posted 22 April 2021 - 11:36 AM

No, I've not found a way to force the cache level to 1.  Cache level and cache size is a question for Adobe support.  I don't have the required expertise - I'm just a frustrated user.

Okay. Please post if you find a way. Do you recon i should leave it at two just now then?



#43 Igor_cheb

Igor_cheb

    Lift Off

  • -----
  • Posts: 18
  • Joined: 24 May 2021

Posted 12 June 2021 - 09:19 AM

I wonder if anyone has managed to reproduce this workflow in Affinity Photo?



#44 schmelly

schmelly

    Lift Off

  • -----
  • Posts: 1
  • Joined: 26 Sep 2021

Posted 26 September 2021 - 04:31 PM

Dear Mark,
first of all many thanks for your background information and guide on Arcsinh-based stretches!
 
As I do not own Photoshop I looked into a solution for Affinity Photo based on 1-dimensional lookup tables and "LUT" adjustment layers which appears working fine. I created a small open source Python script to compute appropriate LUTs in ".cube" format which you can find on GitHub here:

https://github.com/s...arcsinh_stretch (GitHub project)

https://github.com/s...lculate_luts.py (Python script)
 
If you would like to try this out by yourself I attached some pre-computed LUTs for different user-defined stretch factors: Attached File  luts.zip   33KB   3 downloads
It would be great if you could give me some feedback if I got the math right. Also, I would like to prepare a small guide on my GitHub projects - would it be fine with you if I refer & link to your forum and blog posts?

The overall setup is basically the same as your curves-based one in Photoshop. That is, we use the same b/w layer structure and apply the LUT adjustment layer (Layer -> New Adjustment Layer -> LUT) to the multiply-layer. In contrast to your curves presets applying a LUT once is sufficient. Cf. the following before/after screenshots on a simple black&white gradient:

 

before stretch

affinity-before-stretch.jpg

after stretch

affinity-after-stretch.jpg

 

LUTs can also be used in Gimp (as well as in Photoshop I believe). However, for Gimp you need to add LUT support by installing the open source G'MIC plugin: https://gmic.eu/
Afterward you can apply a LUT to a layer in GIMP (Filters -> G'MIC-Qt -> Colors -> Apply External CLUT). Cf. the following screenshot, also on a simple black&white gradient:

gimp-after-stretch.jpg

 

You can find my Affinity Photo and Gimp test files on GitHub as well:

https://github.com/s...ty-1.10.afphoto (Affinity Photo 1.10)

https://github.com/s...e-gimp-2.10.xcf (Gimp 2.10)

 

Kind regards

David


  • galacticinsomnia likes this

#45 Viktorious

Viktorious

    Vostok 1

  • -----
  • Posts: 176
  • Joined: 07 Sep 2019
  • Loc: Sweden

Posted 16 October 2021 - 04:15 AM

Just found this topic through a tutorial on YouTube. It didn't use the multiply and divide process though.

Tried stretching the old way and then as presented here. The result, wow, so much more color!

So just wanted to write a big thank you for this! 




CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.


Recent Topics






Cloudy Nights LLC
Cloudy Nights Sponsor: Astronomics