Author Topic: Computing the Autocovariance in PI?  (Read 2675 times)

Offline jhayes_tucson

  • Newcomer
  • Posts: 19
Computing the Autocovariance in PI?
« on: 2016 March 06 10:06:47 »
PI has the ability to compute the power spectrum of an image (which can be really useful.)  I want to simply compute the auto covariance of an image to look at optimum dither distances for various detectors.  The auto covariance is just the inverse transform of the power spectrum so the functions provided in PI are really close!  The power spectrum is a real function but I can't set up an image with zero values that the inverse transform will take as the imaginary part.  Is there a simple way to do this?  (Maybe I'm just doing it wrong...?)

Thanks,
John

Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: Computing the Autocovariance in PI?
« Reply #1 on: 2016 March 06 14:40:57 »
If i understand you correctly what you want ?
Setting the "Magnitude" Image to Zero or similar with
PixelMath should do what you want.

You have to create first the Phase and the Magnitude file to get the right headers and than overwrite the Magnitude file for example with PixelMath to 0.0 or 0.001 ...

than
Write in PixelMath in RGB/K
0.0
and move the triangle of the process over the just before created Magnitude file.
Than use the inverse function

Gerald

Offline jhayes_tucson

  • Newcomer
  • Posts: 19
Re: Computing the Autocovariance in PI?
« Reply #2 on: 2016 March 06 15:58:33 »
Hi Gerald,
Thanks for the reply.  After some fooling around, I did eventually try something similar and got a result--that I don't quite understand.  At the risk of getting "too mathematical" let me explain:  If I compute the power spectrum (using the forward transform with the power spectrum checkbox checked) and then simply inverse transform the data using the original phase data, I get back to the original data...and that's not right!  PI must be doing something in the inverse transform to "undo" the power spectrum computation (which is the square modulus of the complex transformed data.)  The power spectrum computation produces a mathematically real function with no imaginary part so you can't just inverse transform this output to get back to the data.  So without knowing what PI is doing internally, I'm suspicious that the output that I'm seeing may not be correct. 

PI and everything about it is so rigorous mathematically that I figure someone around here must know the answer.  Being able to do Fourier calculations and filtering using the transform tools would be really nice (at least for those of us into stuff like that!)

Thanks again for your suggestion and for whatever other insight you can provide!

John

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Computing the Autocovariance in PI?
« Reply #3 on: 2016 March 07 14:48:01 »
To calculate what you want, use the trick Gerald propposed (modify the phase with PixelMath), but apply it to the phase data. Then use the iFFT.
FFT and iFFT may work with cartesian or phasorial data (i.e. real and imaginary, or magnitude and phase).
The reason that an arbitrary image may not work as the imaginary part is because this particular process uses some "tagging" of the fourier components, to identify which part it is, in which space, and linear factors involved. This is not the case when working at low level, with C++ code and the PCL. I guess that with PJSR things also should be more open and flexible.

If you want to know more about what this process is doing, you may check:
https://github.com/PixInsight/PCL/tree/master/src/modules/processes/Fourier
And, of course, you should check the PCL's FourierTransform class:
https://github.com/PixInsight/PCL/blob/master/include/pcl/FourierTransform.h

Regards,

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

Offline jhayes_tucson

  • Newcomer
  • Posts: 19
Re: Computing the Autocovariance in PI?
« Reply #4 on: 2016 March 07 15:01:01 »
Carlos,
Thanks a million for your help!  As you suggested, I'll take a look at the code to make sure that I understand what it is doing.
Best regards,
John