CR2RE Pipeline Reference Manual 1.6.8
Functions
Fringing

This module contains functions to derive and subtract a master-fringe image. More...

Functions

cpl_error_code hdrl_fringe_compute (hdrl_imagelist *ilist_fringe, const cpl_imagelist *ilist_obj, const cpl_mask *stat_mask, const hdrl_parameter *collapse_params, hdrl_image **master, cpl_image **contrib_map, cpl_table **qctable)
 Calculates the master fringe and contribution map based on the.
 
cpl_error_code hdrl_fringe_correct (hdrl_imagelist *ilist_fringe, const cpl_imagelist *ilist_obj, const cpl_mask *stat_mask, const hdrl_image *masterfringe, cpl_table **qctable)
 Scales and subtracts the master fringe from the images.
 

Detailed Description

This module contains functions to derive and subtract a master-fringe image.

Master-fringe computation

For the master-fringe estimation, the algorithm model the pixel intensity distribution in a given image as a mixture of two Gaussian distributions, whose means are the background and the fringe amplitudes, respectively:

Thus the density function $f(x)$ of the intensity of an individual pixel is modeled as follows

\[
f(x) = c_1\,e^{ -\frac{(x-\mu_1)^2}{2\sigma_1^2} }
+ c_2\,e^{ -\frac{(x-\mu_2)^2}{2\sigma_2^2} }.
\]

The means $\mu_1$ and $\mu_2$ ( $\mu_1 < \mu_2 = \mu_{1}+a$) are proportional to the background amplitude and the fringe pattern amplitude, respectively. These values are used for normalization of the background and fringe amplitudes before stacking.

The parameters of the two Gaussian components are estimated from the density function of the pixel intensities by a nonlinear least squares fit algorithm. The algorithm requires as its input an estimated density function. Such an estimate is calculated in a preprocessing step as a truncated Hermite series:

\[
f(x) \approx \sum_{n=0}^p \; c_n h_n\left(\frac{x - \mu}{\sigma}\right),
\]

where $h_n$ is the normalized Hermite function

\[
  h_n(x) = {\pi}^{-\frac14} \,
  2^{-\frac{n}{2}} (n!)^{-\frac12} \, (\-1)^n \, e^{\frac{x^2\!\!}{2}} \,
  \frac{d^n}{dx^n}\left( e^{-x^2} \right),
\]

$\mu$ and $\sigma$ are, respectively, the sample mean and the sample standard deviation of pixel intensities in the given image. The truncation parameter $p$ is found experimentally, $p = 20$ has been sufficient so far. The Hermite coefficients $c_n$ are computed as follows

\[
  c_n = \frac1{\sigma N}\; \sum_{i=1}^N h_n\left(\frac{I_i - \mu}{\sigma}\right),
\]

where the summation extends over all pixel intensities $I_1, \ldots,
I_{N}$, $N$ is the total number of pixels, and $n = 0, \ldots, p$.

The following image shows a truncated Hermite series and its approximation by a Gaussian mixture.

Master-fringe subtraction

For the master-fringe subtraction the algorithm computes fringe amplitudes for each individual image by a least squares fit of a linear combination of the estimated master-fringe and a constant background. Specifically, the $i$th fringe $F_i$ is estimated as

\[
F_{i} = a_{i}F + b_{i},
\]

where $F$ is the estimated stacked master-fringe, and $b_i$ is a constant representing the background. The unknown constants $a_i$ and $b_i$ are computed by a standard least squares fit preformed over the unmasked pixels.

Function Documentation

◆ hdrl_fringe_compute()

cpl_error_code hdrl_fringe_compute ( hdrl_imagelist *  ilist_fringe,
const cpl_imagelist *  ilist_obj,
const cpl_mask *  stat_mask,
const hdrl_parameter *  collapse_params,
hdrl_image **  master,
cpl_image **  contrib_map,
cpl_table **  qctable 
)

Calculates the master fringe and contribution map based on the.

Gaussian mixture model.

Parameters
ilist_fringeImage list from where to extract the fringes
ilist_objMasks with the objects of the single images (or NULL)
stat_maskStatic mask (or NULL)
collapse_paramsparameter controlling the collapse algorithm
masterreturned master fringe map
contrib_mapreturned contribution map of the master fringe map
qctablereturned table containing quality control information (or NULL)
Returns
the cpl error code in case of error or CPL_ERROR_NONE

The function calculates the master fringe and contribution maps of a list of (dithered) images. The background and fringe level are estimated as the mean values of a Gaussian mixture model to the image histogram. The histogram is approximated by a Hermite series before fitting the mixture model, in order to avoid possible problems with bin sizes.

The masks exclude the regions where the fringe is weak, and are essential for an accurate estimation of noisy images. The masks can be used to remove objects and bad regions from the fit as well: The algorithm combines the bad pixel map (from ilist_fringe), the object mask (from ilist_obj), and static mask (stat_mask) for the fringe computation itself, but uses only the combined bad pixel map and object mask for the final collapsing. This ensures that the master fringe is also calculated in regions excluded by the static mask.

Note
Please note, that the function directly works on the passed hdrl imagelist (ilist_fringe) in order to save memory thus modifying the imagelist
Error propagation: Please note, that the scaling factor derived and used in this function is considered to be noiseless, i.e. the associated error is supposed to be zero

Definition at line 160 of file hdrl_fringe.c.

References hdrl_image_div_scalar(), hdrl_image_get_image_const(), hdrl_image_get_mask(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_reject_from_mask(), hdrl_image_sub_scalar(), hdrl_imagelist_collapse(), hdrl_imagelist_get(), hdrl_imagelist_get_const(), and hdrl_imagelist_get_size().

◆ hdrl_fringe_correct()

cpl_error_code hdrl_fringe_correct ( hdrl_imagelist *  ilist_fringe,
const cpl_imagelist *  ilist_obj,
const cpl_mask *  stat_mask,
const hdrl_image *  masterfringe,
cpl_table **  qctable 
)

Scales and subtracts the master fringe from the images.

Parameters
ilist_fringeImage list from where to subtract the master fringe
ilist_objMasks with the objects of the single images (or NULL)
stat_maskStatic mask (or NULL)
masterfringemaster fringe to scale and subtract
qctabletable containing quality control information (or NULL)
Returns
the cpl error code in case of error or CPL_ERROR_NONE

The function subtracts a fringe correction image (master) from a set of input images (ilist_fringe). The amplitude of the fringes is computed for each input image and used to properly rescale the correction image before subtraction.

The masks exclude the regions where the fringe is weak, and are essential for an accurate scaling estimation of noisy images. The algorithm combines the bad pixel map (from ilist_fringe), the object mask (from ilist_obj), and static mask (stat_mask) for the scaling computation of the master fringe, but only uses the bad pixel map when subtracting the master-fringe. The object mask and static mask are ignored in this step. This ensures that the master fringe is properly subtracted (with error propagation) in all regions not affected by the bad pixel mask.

Note
Please note, that the function directly works on the passed hdrl imagelist (ilist_fringe) in order to save memory thus modifying the imagelist i.e. removing the fringes directly from the original imagelist (ilist_fringe)
Error propagation: Please note, that the scaling factor derived and used in this function is considered to be noiseless, i.e. the associated error is supposed to be zero

Definition at line 346 of file hdrl_fringe.c.

References hdrl_image_delete(), hdrl_image_duplicate(), hdrl_image_get_image_const(), hdrl_image_get_mask(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), hdrl_image_mul_scalar(), hdrl_image_sub_image(), hdrl_imagelist_get(), hdrl_imagelist_get_const(), and hdrl_imagelist_get_size().