CR2RE Pipeline Reference Manual 1.6.2
Functions
Bad Pixel Mask via edge detection

Algorithm to detect bad-pixels and cosmic-rays hits on a single image like e.g. science frames. More...

Functions

hdrl_parameter * hdrl_lacosmic_parameter_create (double sigma_lim, double f_lim, int max_iter)
 Creates LaCosmic parameters object.
 
cpl_error_code hdrl_lacosmic_parameter_verify (const hdrl_parameter *param)
 Verify basic correctness of the LaCosmic parameters.
 
cpl_boolean hdrl_lacosmic_parameter_check (const hdrl_parameter *self)
 Check that the parameter is an LaCosmic parameter.
 
double hdrl_lacosmic_parameter_get_sigma_lim (const hdrl_parameter *p)
 Access the sigma_lim in the LaCosmic parameter.
 
double hdrl_lacosmic_parameter_get_f_lim (const hdrl_parameter *p)
 Access the f_lim in the LaCosmic parameter.
 
int hdrl_lacosmic_parameter_get_max_iter (const hdrl_parameter *p)
 Access the max_iter in the LaCosmic parameter.
 
cpl_parameterlist * hdrl_lacosmic_parameter_create_parlist (const char *base_context, const char *prefix, const hdrl_parameter *defaults)
 Create parameter list for the LaCosmic computation.
 
hdrl_parameter * hdrl_lacosmic_parameter_parse_parlist (const cpl_parameterlist *parlist, const char *prefix)
 Parse parameterlist to create input parameters for the LaCosmic.
 
cpl_mask * hdrl_lacosmic_edgedetect (const hdrl_image *ima_in, const hdrl_parameter *params)
 Detect bad-pixels / cosmic-rays on a single image.
 

Detailed Description

Algorithm to detect bad-pixels and cosmic-rays hits on a single image like e.g. science frames.

This routine determines bad-pixels on a single image via edge detection following the algorithm (LA-Cosmic) describe in van Dokkum, PASP,113,2001,p1420-27. The HDRL implementation does not use use error model as described in the paper but the error image passed to the function. Moreover we do several iterations and replace the detected bad pixels in each iteration by the information of the surrounding pixels.

The calculation is performed by calling the top-level function hdrl_lacosmic_edgedetect() and the parameters passed to this function can be created by calling hdrl_lacosmic_parameter_create().

Function Documentation

◆ hdrl_lacosmic_edgedetect()

cpl_mask * hdrl_lacosmic_edgedetect ( const hdrl_image *  ima_in,
const hdrl_parameter *  params 
)

Detect bad-pixels / cosmic-rays on a single image.

Parameters
ima_inThe input image
paramsLaCosmic computation parameters
Returns
Mask where all detected bad-pixels/cosmics-rays are marked as bad or NULL on error

This routine determines bad-pixels on a single image via edge detection following the algorithm (LA-Cosmic) describe in van Dokkum, PASP,113,2001,p1420-27. It was originally developed to detect cosmic ray hits but can also be used in the more general context of detecting bad pixels. The HDRL implementation does not use use error model as described in the paper but the error image passed to the function. Moreover we do several iterations with max_iter defining an upper limit for the number of iterations, i.e. the iteration stops if no new bad pixels are found or max_iter is reached. In each iteration we replace the detected cosmic ray hits by the median of the surroundings 5x5 pixels taking into account the pixel quality information. The input parameter sigma_lim and f_lim refer to $\sigma_{lim}$ and $f_{lim}$ as described in the paper mentioned above. The hdrl parameter passed to this routine is created by hdrl_lacosmic_parameter_create().

Note
Be aware that the implementation only detects positive bad pixels / cosmic ray hits, i.e. no "holes" in the image are detected, but in such a case the pixels surrounding the whole are marked as bad. Holes in the image can be introduced, if e.g. one subtracts a not cosmic-ray-cleaned image from another image.

Definition at line 348 of file hdrl_lacosmics.c.

References hdrl_image_get_error_const(), hdrl_image_get_image_const(), hdrl_image_get_mask_const(), hdrl_image_get_size_x(), hdrl_image_get_size_y(), and hdrl_lacosmic_parameter_verify().

Referenced by cr2res_calib_image().

◆ hdrl_lacosmic_parameter_check()

cpl_boolean hdrl_lacosmic_parameter_check ( const hdrl_parameter *  self)

Check that the parameter is an LaCosmic parameter.

Parameters
selfThe parameter to check
Returns
True or False

Definition at line 160 of file hdrl_lacosmics.c.

Referenced by hdrl_lacosmic_parameter_create_parlist(), and hdrl_lacosmic_parameter_verify().

◆ hdrl_lacosmic_parameter_create()

hdrl_parameter * hdrl_lacosmic_parameter_create ( double  sigma_lim,
double  f_lim,
int  max_iter 
)

Creates LaCosmic parameters object.

Parameters
sigma_limLimiting sigma for detection on the sampling image
f_limLimiting f factor for detection on the modified Laplacian image.
max_iterMaximum number of iterations
Returns
The LaCosmic parameters object. It needs to be deallocated with hdrl_parameter_delete()
See also
hdrl_lacosmic_edgedetect()
Note
For the algorithm see the paper of van Dokkum, PASP,113,2001,p1420-27.

Definition at line 112 of file hdrl_lacosmics.c.

Referenced by cr2res_calib_image(), and hdrl_lacosmic_parameter_parse_parlist().

◆ hdrl_lacosmic_parameter_create_parlist()

cpl_parameterlist * hdrl_lacosmic_parameter_create_parlist ( const char *  base_context,
const char *  prefix,
const hdrl_parameter *  defaults 
)

Create parameter list for the LaCosmic computation.

Parameters
base_contextbase context of parameter (e.g. recipe name)
prefixprefix of parameter, may be empty string
defaultsdefault values
Returns
parameterlist controlling the LaCosmic algorithm

base_context.prefix.sigma_lim base_context.prefix.f_lim base_context.prefix.max_iter The CLI aliases omit the base_context.

Definition at line 222 of file hdrl_lacosmics.c.

References hdrl_lacosmic_parameter_check(), hdrl_lacosmic_parameter_get_f_lim(), hdrl_lacosmic_parameter_get_max_iter(), and hdrl_lacosmic_parameter_get_sigma_lim().

◆ hdrl_lacosmic_parameter_get_f_lim()

double hdrl_lacosmic_parameter_get_f_lim ( const hdrl_parameter *  p)

Access the f_lim in the LaCosmic parameter.

Parameters
pThe LaCosmic parameter
Returns
The f_lim value

Definition at line 186 of file hdrl_lacosmics.c.

Referenced by hdrl_lacosmic_parameter_create_parlist().

◆ hdrl_lacosmic_parameter_get_max_iter()

int hdrl_lacosmic_parameter_get_max_iter ( const hdrl_parameter *  p)

Access the max_iter in the LaCosmic parameter.

Parameters
pThe LaCosmic parameter
Returns
The max_iter value

Definition at line 200 of file hdrl_lacosmics.c.

Referenced by hdrl_lacosmic_parameter_create_parlist().

◆ hdrl_lacosmic_parameter_get_sigma_lim()

double hdrl_lacosmic_parameter_get_sigma_lim ( const hdrl_parameter *  p)

Access the sigma_lim in the LaCosmic parameter.

Parameters
pThe LaCosmic parameter
Returns
The sigma_lim value

Definition at line 172 of file hdrl_lacosmics.c.

Referenced by hdrl_lacosmic_parameter_create_parlist().

◆ hdrl_lacosmic_parameter_parse_parlist()

hdrl_parameter * hdrl_lacosmic_parameter_parse_parlist ( const cpl_parameterlist *  parlist,
const char *  prefix 
)

Parse parameterlist to create input parameters for the LaCosmic.

Parameters
parlistparameter list to parse
prefixprefix of parameter name
Returns
Input parameters for the LaCosmic Computation

Reads a parameterlist in order to create LaCosmic parameters. Expects a parameterlist containing:

  • prefix.sigma_lim
  • prefix.f_lim
  • prefix.max_iter

Definition at line 276 of file hdrl_lacosmics.c.

References hdrl_join_string(), and hdrl_lacosmic_parameter_create().

◆ hdrl_lacosmic_parameter_verify()

cpl_error_code hdrl_lacosmic_parameter_verify ( const hdrl_parameter *  param)

Verify basic correctness of the LaCosmic parameters.

Parameters
paramLaCosmic parameters
Returns
CPL_ERROR_NONE if everything is ok, an error code otherwise

Definition at line 132 of file hdrl_lacosmics.c.

References hdrl_lacosmic_parameter_check().

Referenced by cr2res_calib_image(), and hdrl_lacosmic_edgedetect().