Author Topic: Gradient HDR compression  (Read 21696 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Gradient HDR compression
« Reply #15 on: 2011 June 06 09:08:14 »
...BTW, I liked the numerical accuracy of this solver :) I would choose that over the double speed of multigrid methods. Note that there are other papers

I agree. Accuracy is more important than speed here. I understand that a direct solver would have complexity O(n*log n), while a multigrid solver would have O(n), with n being imageWidth*imageHeight. See ftp://ftp.umiacs.umd.edu/pub/aagrawal/ICCV07Course/AmitSection3.pdf, slide 41. Quite acceptable.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #16 on: 2011 June 06 09:37:08 »
Direct solvers are O(n^2) ;) fast solvers ate O(n log n)

Anyway, i'll try to get this done today :) cross your fingers :D
Regards,

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

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Gradient HDR compression
« Reply #17 on: 2011 June 06 11:45:46 »
Here is another processing example, based on data that Harry kindly provided. A single application of the module nicely highlighted the nebulosity in the M81/82 area, while not burning out the galaxies. Harry said that the dark area on the left may be caused by a flat fielding error.

Very nice, I did not know this about M81/82....

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: Gradient HDR compression
« Reply #18 on: 2011 June 06 12:08:01 »
that's the integrated flux nebula in our own milky way! very nice, looking forward to trying this tool.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #19 on: 2011 June 06 14:43:37 »
Juan, Georg, etc

I'm having some problems getting the DCT and DCT-1... here is my code for a row DCT and then its invertion:

Code: [Select]

      int w = img.Width();
      int h = img.Height();
      int w1 = RealFFT::OptimizedLength( RoundI(w) );
   
      Generic2DImage<P1> temp( w1, h );
      temp.Zero();
      for (int j = 0; j < h; j++)
      {
typename GenericRealFFT<P2>::vector v( 0.0 , w1 );
typename GenericRealFFT<P2>::complex_vector c( 0.0 , w1 );
GenericRealFFT<P2> F(w1);
for (int i = 0; i < w; i++)
  v[i] = img.Pixel(i,j,0);
F(*c,*v);
for (int i = 0; i < w1; i++)
  temp.Pixel(i,j,0) = c[i].Real();
      }

      for (int j = 0; j < h; j++)
      {
typename GenericFFT<P2>::complex_vector v( 0.0 , w1 );
typename GenericFFT<P2>::complex_vector c( 0.0 , w1 );
GenericFFT<P2> F( w1 );
for (int i = 0; i < w1; i++)
  c[i] = temp.Pixel(i,j,0);
F( *v, *c, PCL_FFT_BACKWARD );
for (int i = 0; i < w; i++)
  img.Pixel(i,j,0) = v[i].Real();
      }


It is not working... :P Any ideas?
Regards,

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

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #20 on: 2011 June 06 17:16:14 »
Well... obviously I was wrong about the real part of the FFT... anyway, I've implemented a DCT II-III pair, and trying to solve the laplacian inversion process. If we make it work, then we shall optimize the DCT part :)
Regards,

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

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #21 on: 2011 June 06 18:35:51 »
If any of you want to try to make the solver work, here is what I have right now...
Regards,

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

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Gradient HDR compression
« Reply #22 on: 2011 June 07 01:18:18 »
Hi Carlos,
most likely there will be no time for this today on my schedule. I found this code http://www.umiacs.umd.edu/~aagrawal/software.html (see "C Implementation (.NET build) of 2D Poisson Solver using Neumann Boundary Conditions") which to my eyes looks similar to what you need to do. However, it is using FFTW, not PI...

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Gradient HDR compression
« Reply #23 on: 2011 June 07 01:28:57 »
Quote
it is using FFTW, not PI...

And where's the problem with this? PCL has a very good FFT implementation based on the KISS FFT library, which is one of the best ones available.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Gradient HDR compression
« Reply #24 on: 2011 June 07 02:02:38 »
Juan,
no problem with using PI here ...  :) you only have to translate the code in  http://www.umiacs.umd.edu/~aagrawal/software.html into PI type calls.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #25 on: 2011 June 07 08:33:57 »
Juan, while we are at it... why don't you implement the DCT and DST, both 1D and 2D? Isn't it already implemented via KISS FFT somewhere?
Regards,

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

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #26 on: 2011 June 07 15:12:06 »
Well, now it is working. I'm still having some artificial gradients left, that can be negligible for some images, and visible in others... :S strange thing.

Right now I'm using naive DCT implementations,  O(n^2). Once Juan (or another more skilled than me) implements fast DCT/DST transforms, I may change the code to use it.


Regards,

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

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: Gradient HDR compression
« Reply #27 on: 2011 June 08 14:15:46 »
Problem of the gradients solved ;) Just needed to add a small zero padding. I'll pack everything tonight, and upload a new module and solver.
Pending tasks:
- Modify the rescaling function to display the modified image. I'll need to write something very similar to what is included in HDRWT.
- Check the color adjustment function. I'm working with grayscale images right now, since the corrected luminance does not fit well again. Maybe a better rescalation improves things, and then I'll be able to play with the color correction algorithm.

- Use Fast DCTs instead of direct DCTs. This should improve speed performance significatively. Also the code is highly parallelizable, so Juan will have a lot to say there ;)
Regards,

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

Offline Harry page

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1458
    • http://www.harrysastroshed.com
Re: Gradient HDR compression
« Reply #28 on: 2011 June 08 14:21:45 »
Hi

Ok I am starting to dribble  ;D


Harry
Harry Page

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Gradient HDR compression
« Reply #29 on: 2011 June 08 15:50:47 »
Quote
Use Fast DCTs instead of direct DCTs. This should improve speed performance significatively. Also the code is highly parallelizable, so Juan will have a lot to say there

The obvious choice would be FFTW, but it is GPL and the cost of a commercial license (or 'non-free license' as they euphemistically call it) was above 7000 USD the last time I asked. So FFTW is discarded, unless you are going to release all of your code under GPL. Even then I'd ask the FFTW guys first because they probably don't want you to use their code in a PI module.

I'm looking for a good DCT implementation released under a BSD or MIT license, to integrate it with PCL. I've found this one which looks good; other suggestions welcome, of course.

Quote
Right now I'm using naive DCT implementations,  O(n^2). Once Juan (or another more skilled than me) implements fast DCT/DST transforms, I may change the code to use it.

As happens with the DFT, The DCT is separable. This means that the DCT of a 2D function is equivalent to performing the 1D DCT of each row followed by the 1D DCTs of the resulting columns. This reduces the complexity to O(2N) with respect to the naive implementation, which is O(N^2) as you know.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/