### Author Topic: Best practice for stretching an image?  (Read 882 times)

#### goofisd

• Newcomer
• Posts: 10
##### Best practice for stretching an image?
« on: 2018 September 26 08:45:27 »
This question can be asked in two ways.
1. What is the preferred method for stretching an image (linear stretch)?
2. Why are there so many tools in PI for stretching an image?

Is there a canonical method for linear stretching an image, or is there some sort of flowchart that helps you decide which tool to use?

Note: I know how to process images, and I am comfortable in knowing when to do the stretch in my processing workflow. This is not what I am asking. What I am asking is what are best practices for how to stretch.

« Last Edit: 2018 September 28 17:32:06 by goofisd »

#### ngc1535

• Posts: 274
##### Re: Best practice for stretching an image?
« Reply #1 on: 2018 September 26 16:47:49 »
Hi G,

The second question is a good one.

A permanent stretch (such as using HistogramTransformation) results in an image that is in general non-linear (an input vs output curve, the transfer function, is not a line). You maintain a linear image if you do not touch the midtones and only adjust the white and black points. However, the autostretch algorithm, for example, is a non-linear transfer function that is the most common way to display a good fraction of the available brightness values in an image in a "pleasing" way. This is made concrete (permanently stretched)  with HistrogramTransformation. So as to your #1 this is likely the preferred method for stretching a linear image (if that is what you meant to say).

The other question- as to the number of methods, deals with the fact there are different attributes of images that are affected by stretching. For example certain kinds of stretches (take ExponentialTransform via PIP) attempt to moderate the stretch in a way that dampens brightening the noise. Other stretches, say ArcSinhStretch, give a non-linear result that caters to chromatic attributes of an image. So the different ways of stretching an image deal with the fact that data have different attributes (noise, spatial structure, color, saturated/clipped values, quantinization issues...etc etc) that are affected. Interestingly the input data, therefore, can somewhat point the way towards which kinds of stretching algorithms are best.

This is a very high level answer (meaning no specifics)- but based on the questions..it seemed a good place to start.

#### goofisd

• Newcomer
• Posts: 10
##### Re: Best practice for stretching an image?
« Reply #2 on: 2018 September 28 17:31:44 »
Let me try this again.

I know I can do an STF->HT to stretch an image and make it non-linear. But, is this the best way to do this? Are the default settings for STF good for a final stretch?

What are the situations where the other tools to stretch an image are appropriate?

Or does everyone just sort of wing it and do what feels right in the moment?

#### sharkmelley

• PTeam Member
• Posts: 226
##### Re: Best practice for stretching an image?
« Reply #3 on: 2018 September 29 10:42:39 »
Quote from: goofisd
I know I can do an STF->HT to stretch an image and make it non-linear. But, is this the best way to do this? Are the default settings for STF good for a final stretch?

The default settings of STF are good for determining the range of data available in your image. However, I would never use it for a final image because it bleaches the colours.

In my opinion use MaskedStretch or ArcsinhStretch if you want to retain colour.  Or some other alternative.

Mark
Takahashi Epsilon 180ED
H-alpha modified Sony A7S
http://www.markshelley.co.uk/Astronomy/

#### msmythers

• PTeam Member
• PixInsight Jedi
• Posts: 1176
##### Re: Best practice for stretching an image?
« Reply #4 on: 2018 September 29 12:43:21 »
I want to give my 2 cents on the STF Auto settings usage. The default settings are aggressive. Some images this will be fine but for most they won't. I think there is a very good reason for the aggressive stretch that STF Auto shows. The very first usage for most will be directly after  integration. You are looking for artifacts and gradients and noise. Without the aggressive stretch those might not be as visible. Remember STF was never designed to be a final stretch. If it had I'm fairly sure Juan would have given it the ability to actually change the image in a permanent manner like HistogramTransformation, AutoHistogram or MaskStretch.

Now the other thing most users I believe have no idea of is you can change the settings of STF Auto. The user can save one set of parameters. They can also reset those to the default. This is how I use it. I have a much less agressive set of parameters that I use after inspection and corrections. This setting is one I determined that suited my images very well. It's no where near perfect as each image is different but I get a much better look at what I would like the image to be after I stretch it. Since it is a much less aggressive setting I generally use this as my initial stretch and then I can adjust in the non-linear phase of processing.

Here is a screen shot of the different settings.  The STF parameters on the left is the default and the right is my saved settings. Below is how to access the settings from the STF documentation. The documentation is old as you can now adjust more then 2 settings.

Mike