Author Topic: Stars MISSING on Resample  (Read 4992 times)

Offline darkownt

  • PixInsight Enthusiast
  • **
  • Posts: 92
Stars MISSING on Resample
« on: 2012 April 11 18:36:34 »
Missing stars are circled in the TestStarDemo.jpg

Similar to problem mentioned in other thread regarding central peaks on resizing.  This one is about missing pixel information on resampling, not at all dependent upon being central.

Test star image 200x200 resized to 70x70.  TestStarDemo.jpg shows original and products of PI Bilinear, Cubic Spline, Cubic B-Spline, Auto, and using another program (PSP).  Colored circles indicate lost data in indicated resample image. 

Please note the lost stars are not faint, they are completely GONE, or missing from the resampled image.  ZERO "flux", "light", "illumination", "value" from the missing stars has survived the resampling.

Somehow PI auto kept all the stars (as did the other program PSP).  Cubic B-spline only lost edge stars, while bilinear and cubic spline discarded a very large number.

Any comments addressing what is happening here would be greatly appreciated.

Cheers
Colin

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Stars MISSING on Resample
« Reply #1 on: 2012 April 12 01:24:15 »
I guess this is just how resampling works. You are downsampling from 200x200 to 70x70, meaning roughly a 3:1 relationship in both dimensions. Bilinear interpolation http://en.wikipedia.org/wiki/Bilinear_interpolation works by taking the position of the target pixel, compute the corresponding coordinates of the source pixel that my have fractional parts, and then do a weighted interpolation of the 4 pixels that are in the neighborhood of computed coordinate. If the transformation from target to source pixel never visits the neighborhood of a star pixel, you will not see any trace of it in the result.

Other interpolation/resampling algorithms consider different size neighborhoods, which is the reason why stars do not get lost with them. A countermeasure for this are anti-aliasing algorithms http://en.wikipedia.org/wiki/Spatial_anti-aliasing (e.g. super sampling), but these all do have different pros and cons (e.g. runtime, making images fuzzy, ...), so what people use depends on the specific application.

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

Offline darkownt

  • PixInsight Enthusiast
  • **
  • Posts: 92
Re: Stars MISSING on Resample
« Reply #2 on: 2012 April 12 04:51:22 »
Hi Georg

Thank you very much for the reply.

I will introduce this post with a note to ponder: Imagine a 200x200 grid of light intensity impinging upon a final 70x70 IDEAL CCD of your optical equipment.  How would you want this final 70x70 DATA to be measured or sensed from the incoming 200x200 grid of actual light before storage as your one and ONLY ORIGINAL RAW file representing your observations that night?

For the purposes of this thread I am primarily concerned with the flux, or light intensity, color DATA etc. and NOT how pretty or aesthetic the appearance of the image.

I'm wondering then, if I am primarily concerned with MEASUREMENT of flux or light intensity, which method in PI best PRESERVES VALUE (INTENSITY) DATA which is present in EVERY pixel, so that the result is missing no value DATA.  It is obvious that spatial (frequency) data is lost due to a coarser spatial sampling grid, but that would just mean we have more light in each pixel.

EG.   Suppose 10 out of every 100 pixels in original DATA has a color value of say r=0.2, g=0.7, and b=0.8, while the rest are all black pixels.

Which (reducing) resampling algorithm(s) PRESERVES DATA such that the average value of the result (all pixels analyzed) is r= 0.2*0.1, g=0.7*0.1, and b=0.8*0.1?  I note that PixInsight Auto did OK.  Which one can I manually pick to ensure that the best results are obtained?

I know this may be a little different way of thinking about it but *sometimes* when I use PixInsight, I use PIXINSIGHT like an *OPTICAL INSTRUMENT*, the pixel data in PixInsight IS flux, or light intensity (other times I use it for visual *enhancement*).  I know it has been filtered, disturbed, spread, focused etc., by interstellar dust, turbulence in the earth's atmosphere, smog, lenses and mirrors and all the imperfections, finally to the spacially arranged grid of the CCD and the temporal and quantum fluctuation characteristics in the semiconductor material itself.  THIS RESULT finally gets to the last "instrument" in the chain (before making it pretty and showing it on the monitor), PixInsight.

So before "processing" for aesthetic purposes only, I am interested in translating the flux result once again... as mentioned above, imagine the 200x200 image is a grid of light impinging a sensor 70 x70... an IDEAL CCD captures all of the light which falls on it, no photon gets between the cracks.  Although real life CCDs can't do this, PixInsight IS my software CCD, it has a 200x200 pixel image impinging upon it, and somehow ENTIRE pixels can get between cracks.

Is there a difference between visual enhancement and scientific measurement resampling?  Maybe a difference in category, "flux preserving" sampling versus "visual enhanced" sampling?

In any case I also am trying to write a flux preserving, area based (IDEAL CCD) resampling script.  Any help would be appreciated.

Don't get me wrong, different resampling methods have different uses, but they are so different as to warrant some kind of WARNING or categorization.


cheers
Colin

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Stars MISSING on Resample
« Reply #3 on: 2012 April 12 05:24:02 »
Hi Colin,

if you want to retrieve flux information, you may want to use a CCD/focal length that oversamples the typcial star shapes considerably. Otherwise the light of your star might fall between the CCD cells (where the CCD is insensitive to light), and might disappear on your CCD as well. This is actually quite similar to what happens to you with the downsampling your are trying....

I am not familiar with the kind of resampling algorithms that you need for your kind of measurements. You may want to review the documentation (http://pixinsight.com/doc/tools/IntegerResample/IntegerResample.html, http://pixinsight.com/doc/tools/Resample/Resample.html, http://pixinsight.com/doc/docs/InterpolationAlgorithms/InterpolationAlgorithms.html) if something is suitable for your needs.

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

Offline darkownt

  • PixInsight Enthusiast
  • **
  • Posts: 92
Re: Stars MISSING on Resample
« Reply #4 on: 2012 April 12 06:56:26 »
Hi Georg:

I use multiple exposures to try to overcome the CCD failings.

As for the sofware side of it, I have to say I really like the pixel binning (average) of integer resampling since it does preseve everything.  Unfortunately resampling is restricted to integer factors.  I just need a non-integer equivalent for resampling ANY MxN into KxL.  A floating point area weighted average "binning".

When my pseudo-script is complete I'll post it with illustrations showing what it does... and see if I can get it into pixel math or a PJScript.  If anyone finds such a thing useful maybe I can recuit some help.

cheers
Colin

Offline darkownt

  • PixInsight Enthusiast
  • **
  • Posts: 92
Re: Stars MISSING on Resample
« Reply #5 on: 2012 June 25 09:54:19 »
Hi Everyone and Especially Juan:

Sorry for my rants about preserving intensity.  I get very "flustered" when what I am trying to do is not straightforward or results in something unexpected.

I have come to understand what I expected and what I was trying to do are simply not "proper" to astrophotography.  Much of what I said was probably completely wrong or extrememly unfair.  I apologize if any of what I said affected anyone adversely.

As for the algorithm, I have concluded what I need done is better served by PixelMath processing and have therefore given up on any algorithm for "intensity preserving" MXN to KXL binning.. 

Cheers
Colin

 

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Stars MISSING on Resample
« Reply #6 on: 2012 June 26 03:44:01 »
Hi Colin,

We are here to discuss, and I also tend to rave sometimes, so no need to apologize.

If you want to preserve the integrity of the data, including object flux and the statistical properties of the noise, the best thing you can do is to never interpolate it. High pass filters do not preserve flux, and low pass filters are horrible as general-purpose interpolation functions. Even if you find a good flux preserving kernel, you'll have to deal with smoothing and aliasing artifacts.

For example, in photometry applications (which we are working on now), images cannot be interpolated before they are measured. When we register the images, we compute the geometric transformations, but don't apply them to generate registered images by interpolation. We apply the transformations to find the objects on each frame, and we perform aperture photometry without any interpolation of the raw data. Hope this helps, but I don't know if a similar scheme can be applied to the specific problems that you are trying to solve.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Stars MISSING on Resample
« Reply #7 on: 2012 June 26 04:16:19 »
By the way, here is a brief explanation of the results achieved in your very interesting test:

- Bilinear and bicubic spline interpolations are not appropriate for geometric transformations involving strong size reductions. This is because the interpolation filter kernels used in these algorithms are too small (2x2 and 4x4 pixels, respectively) to sample the original data sufficiently in these cases. This causes severe aliasing errors, as Georg has pointed out.

- Cubic B-spline and Mitchell-Netravali (which is the 'Auto' algorithm in your example) use variable size interpolation filters, which adapt very well to strong size reductions.

- Although the weighted average algorithm has reproduced all of the original stars, some of them have been severely weakened, as in the rest of fixed-size interpolations. The weighted average implementation that you have used has coordinate accuracy problems, since some points are misplaced.

The best overall result is achieved with Mitchell-Netravali interpolation in this test. It has reproduced all the original points with good geometric accuracy and preservation of relative fluxes.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/