Author Topic: Image Integration - Question about Iteration  (Read 3454 times)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Image Integration - Question about Iteration
« on: 2009 December 29 16:21:40 »
Juan,

In the ImageIntegration process - you do not provide an entry field to control the number of iteration loops for any of the processes - some of which ARE obviously 'iterative'.

Is this simply because they are allowed to iterate until some conclusion is achieved? Or have you already empirically found an ideal number of loops necessary to give acceptable results?

Thanks in advance,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Image Integration - Question about Iteration
« Reply #1 on: 2010 January 03 11:58:52 »
Hi Niall,

No "iterations" parameter is necessary in my implementation. In the ImageIntegration process, iterative pixel rejection algorithms iterate until one of the following two conditions are satisfied:

- No further pixels can be rejected between two successive iterations.
- The set of pixels in the current stack contains less than three pixels.

For example, the following fragment has been copied directly from ImageIntegration's source code:

Code: [Select]
void RejectionEngine::SigmaClipRejectionThread::Run()
{
   for ( int i = startRow; i < endRow; ++i )
   {
      RejectionDataItem* r = E.R.DataPtr()[i];

      int n = E.N[i];
      if ( n < 3 )
         continue;

      Sort( r, r + n );

      for ( ;; )
      {
         float sigma = E.RejectionSigma( r, n );
         if ( 1 + sigma == 1 )
            break;

         float median = E.RejectionMedian( r, n );

         int nc = 0;

         if ( I.clipLow )
            for ( RejectionDataItem* d = r; ; ++d )
            {
               if ( (median - d->value)/sigma <= I.sigmaLow )
                  break;
               d->rejectLow = true, ++nc;
            }

         if ( I.clipHigh )
            for ( RejectionDataItem* d = r+(n-1); ; --d )
            {
               if ( (d->value - median)/sigma <= I.sigmaHigh )
                  break;
               d->rejectHigh = true, ++nc;
            }

         if ( nc == 0 )
            break;

         Sort( r, r + n );

         n -= nc;
         if ( n < 3 )
            break;
      }

      E.N.DataPtr()[i] = n;
   }
}

This snippet is my (multithreaded) implementation of sigma-clipping rejection. Note the two "if ( nc == 0 ) break;" and "if ( n < 3 ) break;" stop conditions that exit the iteration loop if no more pixels can be rejected or less than three pixels are left in the current stack, respectively.

Current iterative rejection algorithms are: sigma clipping, Winsorized sigma clipping, averaged sigma clipping, and CCD noise model.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: Image Integration - Question about Iteration
« Reply #2 on: 2010 January 03 12:13:00 »
As always Juan,

Thans for the clarification - I'll be able to paraphrase that information on the AAAImaging Yahoo Group - where folks have been struggling trying to eliminate aircraft trails present in a single frame, without adopting the simplistic approach of just excluding the offending frame - because there were so few frames available to stack in the first place !!

Cheers,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC