•

# Photoshop Color Preserving Arcsinh Stretch

44 replies to this topic

### #1 sharkmelley

sharkmelley

Aurora

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

Posted 19 October 2017 - 05:56 PM

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   4834 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.

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:

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.

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.

Mark

Edited by sharkmelley, 19 October 2017 - 06:16 PM.

• Traveler, Midnight Dan, Racing Mike and 35 others like this

### #2 ChrisWhite

ChrisWhite

Fly Me to the Moon

• Posts: 7,374
• Joined: 28 Feb 2015
• Loc: Northeast USA

Posted 19 October 2017 - 06:32 PM

I don't use photoshop, but dude... thanks for all the effort you put into this stuff!

### #3 Tucker512

Tucker512

Ranger 4

• Posts: 346
• Joined: 30 Oct 2010
• Loc: Arizona

Posted 19 October 2017 - 06:34 PM

I just downloaded the curves and tried the technique.  Works great!  I have PixInsight too and recently downloaded the Arcsinh plugin.  But I still use Photoshop a lot of the time, so this is handy.  Thanks!

Scott

### #4 Traveler

Traveler

Soyuz

• Posts: 3,856
• Joined: 19 Aug 2007
• Loc: The Netherlands

Posted 19 October 2017 - 11:21 PM

Thanks Mark! I am playing with your curves presets in Photoshop CS2 right now this early morning. The presetcurves looks very similair as i do manually with curves adjustments btw.

A] Monchorme checked, R=33%, G=33% and B=33%. But what about the "Constant" value in the CS2 channelmixer menu? Does it has to be 0% or also set to 33%?

B] Besides and maybe a dumb question if i may, but why do you use a monochorme layer and not a Luminance channel layer?

### #5 sharkmelley

sharkmelley

Aurora

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

Posted 20 October 2017 - 12:38 AM

A] Monchorme checked, R=33%, G=33% and B=33%. But what about the "Constant" value in the CS2 channelmixer menu? Does it has to be 0% or also set to 33%?

B] Besides and maybe a dumb question if i may, but why do you use a monochorme layer and not a Luminance channel layer?

The constant value must be zero otherwise you are not obtaining a pure mix of RGB.  The weights can be played with, for instance R=30%, G=60% and B=10%.

I'm not claiming my approach is the only way of performing a colour preserving stretch - I'm not an expert, all I did was to convert a Math equation into layers of Photoshop!  If you can describe how to use an approach based on a Luminance channel layer instead then it could well be an easier way of achieving the same result.

Mark

Edited by sharkmelley, 20 October 2017 - 12:39 AM.

### #6 Tonk

Tonk

Cosmos

• Posts: 9,567
• Joined: 19 Aug 2004
• Loc: Leeds, UK, 54N

Posted 20 October 2017 - 01:05 PM

You can get round a lot of theses limitations of using the curves tool by writing a native PS DLL plugin via the PS native API. Here you can bypass the limitations of curves and other PS functions and work directly on the image data. Note that you can call on many native PS functions if they are suitable for what you need. There are some limitations in the matter of where the access to your custom tool will appear in the PS user interface. The commonest approach is to make your native plugin a "filter" and have it add to the "filter" menu. I have a FFT plugin that works this way.

Edited by Tonk, 20 October 2017 - 01:13 PM.

• sharkmelley and calypsob like this

### #7 ImNewHere

ImNewHere

Vanguard

• Posts: 2,299
• Joined: 29 Mar 2017
• Loc: Bremen (but really Lakeville), IN

Posted 21 October 2017 - 10:33 AM

I have an older version of PS, so not everything you show is available, but those curves are! Thanks! I just tried them and they are definitely part of my process now.

### #8 calypsob

calypsob

Fly Me to the Moon

• Posts: 6,934
• Joined: 20 Apr 2013
• Loc: Virginia

Posted 21 October 2017 - 10:47 PM

Mark this is awesome, I use PS for 90% of my processing and this is fantastic.  I get bummed because it seems PS gets less attention from astrophotography applications lately, this is a great addition o my work flow.  Thank you for your generous contribution.  I will definitely follow up with feedback the next time I process an image, tonight hopefully.

• sharkmelley likes this

### #9 ImNewHere

ImNewHere

Vanguard

• Posts: 2,299
• Joined: 29 Mar 2017
• Loc: Bremen (but really Lakeville), IN

Posted 21 October 2017 - 10:57 PM

I have played with this today and I have to give a huge thank you to Mark on this! It is a permanent part of my workflow, and now I am wondering if I should even bother doing a trial with PI because I've been getting better and better at PS processing.

• Tonk and sharkmelley like this

### #10 jsmoraes

jsmoraes

Apollo

• Posts: 1,213
• Joined: 20 Nov 2014
• Loc: Vilatur, Saquarema, Rio de Janeiro, Brazil

Posted 22 October 2017 - 11:13 AM

Thank you for share it. Undoubtly it is a powerfull ressource.

• sharkmelley likes this

### #11 jag32

jag32

Apollo

• Posts: 1,075
• Joined: 30 May 2017

Posted 30 November 2017 - 10:58 PM

Really amazing thank you. Does this work with Photoshop CS5 for Mac or windows only?

### #12 jag32

jag32

Apollo

• Posts: 1,075
• Joined: 30 May 2017

Posted 30 November 2017 - 11:53 PM

I confirmed this DOES work for Photoshop on Mac!  The folder layout for Presets>Curves is the same as windows.

• sharkmelley likes this

### #13 AbPho

AbPho

Vostok 1

• Posts: 113
• Joined: 22 Jul 2013

Posted 01 December 2017 - 03:30 PM

Thanks Mark.  This is great and it works amazing on the image you provided.  I will try it on my next image (whenever that occurs).  I created an action to do this automatically for me.

PS: mac users place the curves files in your /Applications/Adobe Photoshop CS6/Presets/Curves directory.

I loaded some of my PixInsight integration.xsif files.  These curves turn that into a complete mess.  I have too much to learn about PixInsight still in order for it to be of any use to me.

Edited by AbPho, 01 December 2017 - 03:57 PM.

### #14 sharkmelley

sharkmelley

Aurora

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

Posted 02 December 2017 - 05:14 AM

I loaded some of my PixInsight integration.xsif files.  These curves turn that into a complete mess.  I have too much to learn about PixInsight still in order for it to be of any use to me.

Possibly you need to do a better background subtraction?

But in any case, if you are using PixInsight then definitely use the PixInsight ArcsinhStretch:

https://pixinsight.c...inhStretch.html

It's far easier to use

Mark

• calypsob likes this

### #15 Pete_xl

Pete_xl

Apollo

• Posts: 1,407
• Joined: 29 Jan 2015
• Loc: Germany

Posted 02 December 2017 - 05:23 AM

For me this method works fine in PS2018CC as a good tool for images that have already some contrast between DSOs and background. I use it as an early step in my workflow when there are not too many stars in the fov. I built me an action for this for my conveniance.

Thank you very much for sharing!

Edited by Pete_xl, 02 December 2017 - 05:23 AM.

• sharkmelley likes this

### #16 Rudy Pohl

Rudy Pohl

Ranger 4

• Posts: 350
• Joined: 27 Dec 2016

Posted 02 December 2017 - 06:52 AM

Hi Mark:

For some reason I only found this thread yesterday. I worked with the Curves presets as per your instructions they they worked wonderfully! Thanks so much for doing this and providing it to the community.

Best regards,
Rudy

• sharkmelley likes this

### #17 bobharmony

bobharmony

Viking 1

• Posts: 587
• Joined: 28 Oct 2017
• Loc: Connecticut, USA

Posted 02 December 2017 - 09:47 AM

I am going to have to give this a try.  I have been frustrated with what PS can produce on its own (or more likely with my understanding of the tools available).  I have been using StarTools lately, but miss the detailed control that PS provides.

My biggest struggle with this (and my biggest issue with PS thus far is in the preparation steps.  Specifically "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" is a challenge in my LP-infested backyard.  I have used GradientXterminator to balance things out, which leaves me with a grey mess to work with.

In any case, thanks for working through this and providing the details.  I am going to attempt to fit it into my processing path.

Bob

### #18 calypsob

calypsob

Fly Me to the Moon

• Posts: 6,934
• Joined: 20 Apr 2013
• Loc: Virginia

Posted 02 December 2017 - 03:23 PM

These arc sin curves are awesome mark.  Ive been using mine for a few weeks and they are great in my post work flow.  I have Pi as well.  Yes its easier to setup in Pi, but I feel like I have more control in photoshop and I can see whats happening without having to apply/process/refresh like pixinsight. Once you have done this one or two times it is easy to get going in PS, I might even record an action to open the divide, grey group, and some empty curve layers.  Thanks for sharing this.

BTW how did you calculate these points in a spread sheet?

Edited by calypsob, 02 December 2017 - 03:25 PM.

### #19 sharkmelley

sharkmelley

Aurora

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

Posted 03 December 2017 - 12:14 PM

These arc sin curves are awesome mark.  Ive been using mine for a few weeks and they are great in my post work flow.  I have Pi as well.  Yes its easier to setup in Pi, but I feel like I have more control in photoshop and I can see whats happening without having to apply/process/refresh like pixinsight. Once you have done this one or two times it is easy to get going in PS, I might even record an action to open the divide, grey group, and some empty curve layers.  Thanks for sharing this.

BTW how did you calculate these points in a spread sheet?

I find the interactive preview window in PixInsight to be the easiest way because you see the effects of playing with the sliders in real time.  But everyone has their own preferences

The calculation of the curve was a very interesting problem.  I eventually solved it by working backwards from the final Arcsinh curve in an iterative manner from the final point backwards - building a curve that with a double lookup matched the Arcsinh curve as closely as possible.

Mark

### #20 nathmath

nathmath

Vostok 1

• Posts: 102
• Joined: 12 Oct 2015
• Loc: Wisconsin

Posted 24 October 2019 - 02:02 PM

Wasn't there a Photoshop Action for this somewhere to download? I reformatted my computer and forgot to save my actions

### #21 t_image

t_image

Gemini

• Posts: 3,499
• Joined: 22 Jul 2015

Posted 24 October 2019 - 02:09 PM

Wasn't there a Photoshop Action for this somewhere to download? I reformatted my computer and forgot to save my actions

Not a bad zombie to raise! Tis the season for zombies anyways

Do you mean these PS for the custom curves here that Mark made:

http://www.markshell...ng_stretch.html

### #22 nathmath

nathmath

Vostok 1

• Posts: 102
• Joined: 12 Oct 2015
• Loc: Wisconsin

Posted 24 October 2019 - 06:37 PM

Those are the curves, yes, but someone somewhere put all the steps together into one easy to use Action which was awesome.

### #23 t_image

t_image

Gemini

• Posts: 3,499
• Joined: 22 Jul 2015

Posted 25 October 2019 - 06:23 AM

Those are the curves, yes, but someone somewhere put all the steps together into one easy to use Action which was awesome.

you mean post #13:

.....I created an action to do this automatically for me.

### #24 nathmath

nathmath

Vostok 1

• Posts: 102
• Joined: 12 Oct 2015
• Loc: Wisconsin

Posted 25 October 2019 - 08:04 AM

Yes, good eye, I missed that! But I don't see where it's available to download the action, maybe I'll PM the poster.

### #25 richardhurst

richardhurst

Sputnik

• Posts: 36
• Joined: 07 May 2018

Posted 01 October 2020 - 09:06 AM

Just stumbled across this so would like to give it a try. Quick question as I've only used APP before. How do you stack all your .Fits files in the first place to then produce a .Tiff file. Do you still use APP to load all you Light/Dark/Flat frames etc then save as Tiff?? or do you use something like deep sky stacker?

Edited by richardhurst, 01 October 2020 - 09:29 AM.

## Recent Topics

 Cloudy Nights LLC Cloudy Nights Sponsor: Astronomics