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:
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.