|
X-shooter Pipeline Reference Manual 3.8.15
|
Go to the source code of this file.
Functions | |
| cpl_error_code | xsh_ksigma_clip (const cpl_image *, const int, const int, const int, const int, const double, const int, const double, double *, double *) |
| Apply kappa-sigma clipping on input image. | |
| cpl_error_code xsh_ksigma_clip | ( | const cpl_image * | img, |
| int | llx, | ||
| int | lly, | ||
| int | urx, | ||
| int | ury, | ||
| double | kappa, | ||
| int | nclip, | ||
| double | tolerance, | ||
| double * | kmean, | ||
| double * | kstdev | ||
| ) |
Apply kappa-sigma clipping on input image.
| img | Input image |
| llx | Lower left x position (FITS convention) |
| lly | Lower left y position (FITS convention) |
| urx | Upper right x position (FITS convention) |
| ury | Upper right y position (FITS convention) |
| kappa | Kappa value for the clipping |
| nclip | Number of clipping iterations |
| kmean | Mean after clipping (output) |
| kstdev | Stdev after clipping (output) |
This function applies an iterative kappa-sigma clipping on the image and returns mean and stdev after the clipping.
The function takes as a starting point the "standard" values of mean and stdev from cpl_stats.
On each iteration, the contribution of pixels outside the range [mean - kappa * stdev, mean + kappa * stdev] is removed, the values of mean and stdev are updated, and so are the limits of the range to be used in the next iteration as well.
The algorithm stops after nclip iterations or when the variation of the range between two consecutive iterations is smaller (absolute value) than the tolerance.
The effectiveness of this function resides on the way the update of the values of mean and stdev is done.
The contribution of a single pixel in variance can be removed as follows:
\sum_{i=1}^{N-1} (x_i - \overline{x}_{n-1})^2 = \sum_{i=1}^ N (x_i - \overline{x}_n )^2 - \frac{N}{N-1} \,( \, \overline{x}_n - x_{n} )^2
For further details on the mathematical aspects, please refer to DFS05126.
Possible #_cpl_error_code_ set in this function:
The values of kmean and kstdev is undefined on error.
Definition at line 150 of file xsh_ksigma_clip.c.
References kappa, llx, lly, nx, ny, tolerance, urx, and ury.