Author Topic: Auto Histogram settings to replicate Auto STF?  (Read 5022 times)

Offline Phil Hart

  • Newcomer
  • Posts: 10
Auto Histogram settings to replicate Auto STF?
« on: 2015 May 10 23:05:27 »
I'm trying to batch process hundreds of images of Comet Lovejoy from the end of last year.

Using Automatic Background Extraction followed by Histogram Transformation using the AutoSTF settings yields very consistent looking images but to do that manually for each image is pretty painstaking.

However, when I try to replicate that appearance using the Auto Histogram function, which I can do easily as a batch process, I get some variability in the results. The closest I can get is using two passes:

1) First pass using Target Median Value of 0.7 for each of the individual channels to brighten up the image
2) Second pass clipping each channel at 0.8 and a Target Median Value of 0.2 for each channel.

On most images this gets a result similar to the AutoSTF appearance but in several cases it does not. Presumably the functions behind them are similar so there must be some combination of AutoHistogram settings that could replicate the AutoSTF result?

Alternatively, is there some way to take the AutoSTF settings and be able to apply those as a Histogram Transformation as part of a batch routine? (where the AutoSTF settings are worked out uniquely for each image in the sequence)?

It looks like FunTomas was experimenting with something similar in this thread:
http://pixinsight.com/forum/index.php?topic=2116.0

And Roger was after the same thing here:
http://www.iceinspace.com.au/forum/showthread.php?t=118778

I've attached two little images.. the first shows how consistent the Light frames are from one sub to the next. The next shows the random variation that occurs when I try to process using ABE and AutoHistogram. The AutoSTF>Histogram Transformation gives a consistent result without the occasionally different coloured backgrounds.

Phil



Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: Auto Histogram settings to replicate Auto STF?
« Reply #1 on: 2015 May 11 02:19:51 »
PixelMath allows these operations.
But i cannot imagine that a target median of 0.7 or 0.8
makes sense. O.8 is already nearly White.
Usually target median on a stretched image is around 0.12.
On a linear image it is much lower...
Let me know the real median you want for each channel i will post the PixelMath expression.
simplified like: 
targetmedian=0.12
$T - (targetmedian - med($T) )
         
Gerald

Offline Phil Hart

  • Newcomer
  • Posts: 10
Re: Auto Histogram settings to replicate Auto STF?
« Reply #2 on: 2015 May 11 02:39:54 »
Thanks for the reply Gerald.

I am trying to convert from linear to non-linear in the same way that Auto STF does (once the settings are copied to the Histogram Transformation tool). The target median in my second step is 0.2 which gives about the right end result. But I find that I need to really boost it high in step 1 to get the object brightness up before then clipping and adjusting the median back down. I've tried several of the other options in Auto Histogram but only target median seems to get me close to the results from Auto STF. The parameters that Auto STF is working to and the result it achieves seem different to that available anywhere else?

An Auto button on the Histogram Transformation tool that worked the same way as Auto STF would be ideal which I have seen others suggest.

cheers
Phil


Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: Auto Histogram settings to replicate Auto STF?
« Reply #3 on: 2015 May 11 11:24:05 »
Hi Phil!
Did not read your first post carefully.
So, i am still confused what you want to achieve.

My PixelMath idea was only to bring all images to the same median value still
in linear stage. Like a LinearFit
I have not experimented so far with AutoHistogramm

Gerald





Offline Phil Hart

  • Newcomer
  • Posts: 10
Re: Auto Histogram settings to replicate Auto STF?
« Reply #4 on: 2015 May 12 04:43:51 »
I found the parameters that Auto STF is working to (which you can see by CTRL clicking on the Auto STF button):

Shadows Clipping -2.8
Target Background 0.25
Boost Clipping factor 0.75
Boost background factor 2.00

What I'd love is a way to input those same target parameters in the Auto Histogram process.

Phil

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Auto Histogram settings to replicate Auto STF?
« Reply #5 on: 2015 May 12 07:55:22 »
Hi Phil and Gerald,

What you are looking for is a batch adaptive stretch. This can be implemented very easily with PixelMath and ImageContainer. The PM code is as follows:

Combined RGB/K expression:

c = min( max( 0, med( $T ) + C*1.4826*mdev( $T ) ), 1 );
mtf( mtf( B, med( $T ) - c ), max( 0, ($T - c)/~c ) )


Symbols:

C = -2.8,
B = 0.25,
c


This applies an unlinked adaptive stretch function, just as it has been implemented for the AutoStretch function in the STF tool. If you prefer a linked AutoStretch, the expression would be:

Combined RGB/K expression:

m = (med( $T[0] ) + med( $T[1] ) + med( $T[2] ))/3;
d = (mdev( $T[0] ) + mdev( $T[1] ) + mdev( $T[2] ))/3;
c = min( max( 0, m + C*1.4826*d ), 1 );
mtf( mtf( B, m - c ), max( 0, ($T - c)/~c ) )


Symbols:

C = -2.8,
B = 0.25,
c,
m,
d


Which can only be applied to color images. In both cases the constants B and C define, respectively, the target mean background and the shadows clipping point in sigma units, in the [0,1] range. You can define an ImageContainer with your images to apply this PixelMath instance as a batch process. Let me know if it helps.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Phil Hart

  • Newcomer
  • Posts: 10
Re: Auto Histogram settings to replicate Auto STF?
« Reply #6 on: 2015 May 13 05:56:07 »
Thanks so much for the reply Juan. That sounds like what I was hoping to achieve.

I'll give it a go when I'm back with my imaging PC next week and report back here for future reference.

Phil