Author Topic: Blinking Script  (Read 87192 times)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Blink?
« Reply #15 on: 2010 May 07 01:44:10 »
Nikolay, this is absolutely fantastic!

What a nice piece of code. Congratulations, and thank you for sharing it. Can I include this script with the next PI release?

Quote
How to move a ImageWindow via script

You can't, right now. A future version of PJSR will include a Workspace object, which will provide management of windows, icons and workspaces.

Quote
or how to enable move it by user when JS Dialog is open?

Impossible, since dialogs are modal windows. This means that they capture the keyboard and mouse blocking the rest of PixInsight's GUI.

However, you really don't need to create and use a new image window. A much better solution would be, IMO, an integrated view such as the one that has been implemented in the StarHaloReducer script by  Juan M. Gómez, for example.

Keep up the excellent work!
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: Blink?
« Reply #16 on: 2010 May 07 02:11:30 »
Nikolay, this is absolutely fantastic! What a nice piece of code. Congratulations, and thank you for sharing it.
:-[

Quote
Can I include this script with the next PI release?
Yes, of course.

Quote
However, you really don't need to create and use a new image window. A much better solution would be, IMO, an integrated view such as the one that has been implemented in the StarHaloReducer script by  Juan M. Gómez, for example.
Yes, you a right... but I don't like to use HistogramTransformation. I hope you understand why...
I like to use ScreenTransferFunction. It's much much faster. So please teach me how to assign STF to parts of Dialog window.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Blink?
« Reply #17 on: 2010 May 07 03:37:11 »
Quote
I like to use ScreenTransferFunction. It's much much faster. So please teach me how to assign STF to parts of Dialog window.

A STF is just a histogram transformation. You can implement this feature in several ways:

- Read the current STF of a view with the View.stf property:

Array View.stf

This property is an array with 4 elements. Array elements correspond to red/gray, green, blue and luminance, respectively.

Each array item has the following layout:

[ m, c0, c1, r0, r1 ]

where:

m is the midtones balance
c0 is the shadows clipping point
c1 is the highlights clipping point
r0 is the shadows range extension (normally not used, you can ignore it)
r1 is the highlights range extension (normally not used, you can ignore t)

m, c0 and c1 are in the [0,1] range and c0 is guaranteed to be c0 <= c1. r0 is in the range [-10,0] and r1 in [+1,+10].

- Define your own STF parameters within your script. This would require three NumericControl controls to define the corresponding parameters m, c0 and c1.

- Implement an automatic stretch feature in your script. This is actually much easier than what may seem at first glance. You have the following data:

Number Image.median()
Number Image.avgDev()


These are the median and average deviation of an image, respectively, in the [0,1] range. The median can be interpreted as the position of the main histogram peak of the image over the horizontal axis of the histogram. The average deviation is a robust estimator of dispersion, which you can visualize as the width of the histogram peak. From these values, you can define an automatic shadows clipping point as a multiple of the average deviation toward the left of the peak. You can use also:

Number Image.stdDev()

which is the standard deviation, but average deviation is more robust (= immune to outliers, that is very high and very low pixel values in this case).

Instead of those Image methods, you can use the ImageStatistics object if you prefer it. If you have to calculate several statistical moments then ImageStatistics is more efficient because you get all of them in a single call.

To compute an automatic midtones balance, you should use this method:

Number Math.mtf( Number m, Number x )

which returns the resulting value after applying a midtones balance m to an input pixel value x. Using this method, you can find the value of m required to force a particular median value in the image. This is an efficient routine that performs a binary search for m:

Code: [Select]
function findMidtonesBalance( v0, v1, eps )
{
   if ( !eps )
      eps = 1.0e-5;
   else
      eps = Math.max( 1.0e-10, eps );

   var m0, m1;
   if ( v1 < v0 )
   {
      m0 = 0;
      m1 = 0.5;
   }
   else
   {
      m0 = 0.5;
      m1 = 1;
   }

   for ( ;; )
   {
      var m = 0.5*(m0 + m1);
      var v = Math.mtf( m, v1 );

      if ( Math.abs( v - v0 ) < eps )
         return m;

      if ( v < v0 )
         m1 = m;
      else
         m0 = m;
   }
}

This routine returns the required value m such that a call to:

Math.mtf( m, v1 )

will return v0 to within +/-eps tolerance. If you set v1 = median_of_image and v0 = desired_position_of_histogram_peak, then you can know the midtones balance m that achieves your automatic adjustment.

Once you know c0, m and c1=1, your histogram transformation is:

for all pixels
   if old_pixel < c0
      new_pixel := 0
   else
      new_pixel := mtf( m, (old_pixel - c0)/(1 - c0) )
   endif
endfor

Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline budguinn

  • PixInsight Addict
  • ***
  • Posts: 106
Re: Blink?
« Reply #18 on: 2010 May 07 05:58:42 »
Nikolay,

That worked like a charm...and it worked on 30 color debayered images....each at 75 meg.

Suggestions?
Can you control the speed of the blink?
Can you add two buttons?......next and previous?

This would allow a slower blink.....stop when you see a problem....then use the next and previous keys to isolate the "problem" image and make a note of it.

What a great group of folks.....ask for something and it is done.


Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: Blink?
« Reply #19 on: 2010 May 07 06:31:36 »
Juan, thank you for explanation.

A STF is just a histogram transformation.
Maybe, but STF I can apply one time per window. HT I must apply to every image.

But I not understand how apply STF to parts of Dialog window.

I can define STF (thank's you for Image.median() and other ). I can apply STF to ImageWindow via STF.executeOn(some.image, false).
But I not understand how to show some.image inside DialogWindow.ScrollBox.Graphics with STF.
Can you show me piece of JS code.


Can you control the speed of the blink?
Can you add two buttons?......next and previous?
Of course, I will try to add all what you want and maybe more. I just start learn PJSR, so be patient. I hope in near future the script will work like in MaximDL.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Blink?
« Reply #20 on: 2010 May 07 06:45:07 »
Quote
What a great group of folks.....ask for something and it is done.

That's because:
a) Juan has no social life :D
b) we do this because we have a lot of fun
c) PI's policy regarding the PCL and PJSR is to freely give the users the ability to create their own modules and scripts
d) we are lucky enough to have some very nice users, with great programming skills :D
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline budguinn

  • PixInsight Addict
  • ***
  • Posts: 106
Re: Blink?
« Reply #21 on: 2010 May 07 06:47:38 »
Can you control the speed of the blink?
Can you add two buttons?......next and previous?
Of course, I will try to add all what you want and maybe more. I just start learn PJSR, so be patient. I hope in near future the script will work like in MaximDL.


Patient?......you want me to be patient?.....it's been almost a full day since I made this request.  How long does a guy have to wait for many, many hours of code and development work?

Well, ok.... ;D

This is really slick, Nikolay.....thank-you

bud

Offline Harry page

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1458
    • http://www.harrysastroshed.com
Re: Blink?
« Reply #22 on: 2010 May 07 11:23:01 »
Hi

Many thanks for doing this and look forward to the new and improved


Harry
Harry Page

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: Blink?
« Reply #23 on: 2010 May 07 21:40:12 »
Hi, I am happy to introduce one more Animator zero generation. See attachment. :)

Don't forget to use mouse wheel.

PS About dark rectangle - I hope, in near future, it will grow to PhotoshopSC4 Navigator. ::)
But now it's only black rectangle. ;D

PS2 I am sorry for buttons and style. I'll fix it only after the basic controls will be written.

PS3 Niall Saunders, thank you for that post: http://pixinsight.com/forum/index.php?topic=1896.msg11759#msg11759
I printed it and use it as a step by step instructions.

PS4 script deleted - below there are new version.
« Last Edit: 2010 May 08 09:06:49 by NKV »

Offline budguinn

  • PixInsight Addict
  • ***
  • Posts: 106
Re: Blink?
« Reply #24 on: 2010 May 07 22:10:11 »
Nikolay,

That is very slick....this gives me more capability on blinking than any of my other processing programs......very nice.

thank-you

bud guinn

Offline Harry page

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1458
    • http://www.harrysastroshed.com
Re: Blink?
« Reply #25 on: 2010 May 07 23:14:05 »
Hi

Yes much improved, and thanks for your work  :D

The only thing I dont like is that the new created view cannot be moved and you cannot control other processes like I cannot close STF when the new image is behind the STF panel  ;)

Again many thanks

Harry
Harry Page

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: Blink?
« Reply #26 on: 2010 May 07 23:29:47 »
The only thing I dont like is that the new created view cannot be moved and you cannot control other processes like I cannot close STF when the new image is behind the STF panel  ;)
I absolutely agree with you. It's very inconvenient. But Juan promised to solve the problem in next version of PI. See this post: http://pixinsight.com/forum/index.php?topic=1895.msg11741#msg11741

If you have idea how to... just say how. Maybe possible by script temporary hide other processes windows? How? Thanks.

Offline budguinn

  • PixInsight Addict
  • ***
  • Posts: 106
Re: Blink?
« Reply #27 on: 2010 May 08 06:41:00 »
Hi Nikolay,

This is working nice.....I think once we play with it we might have some more ideas, but as it is it gives a very good way to quickly check the originals, but also the stacked images.

As to hiding the windows or giving access to others.  It will probably need to to be added into the main program as one of the processes.
At that time it would be nice to have it as part of many of the other processes....such as the alignment process.  Load the images....click the blink button....examined the images....pick the ones to exclude and then align......then blink again...zoom in to see the alignment up close and personal.

I would think this would be fairly easy to implement now that the heavy lifting has been done by you.  (don't you just love how some one like me, with not a clue, tells the programmers how easy it would be to implement something?)

again, thanks,

bud

Offline NKV

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 677
Re: Blink?
« Reply #28 on: 2010 May 08 09:02:59 »
Thank you bud. In next step I will implement list of files (for marking reference / removing bad / ect operation).
But now... Second edition.  :D

Photoshop Navigator implemented. ;)

Add: Script deleted. New version below.
« Last Edit: 2010 May 23 10:18:56 by NKV »

Offline Harry page

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1458
    • http://www.harrysastroshed.com
Re: Blink?
« Reply #29 on: 2010 May 08 09:30:20 »
Hi

Well it just gets better


Harry
Harry Page