High-Level Data Reduction Library 1.6.0
High-Level data reduction routines for ESO pipelines
Loading...
Searching...
No Matches
Bad Pixel Mask 2D Computation

Algorithms to detect bad pixels on a single image. More...

Collaboration diagram for Bad Pixel Mask 2D Computation:

Functions

hdrl_parameterhdrl_bpm_2d_parameter_create_filtersmooth (double kappa_low, double kappa_high, int maxiter, cpl_filter_mode filter, cpl_border_mode border, int smooth_x, int smooth_y)
 Creates BPM_2D Parameters object for HDRL_BPM_2D_FILTERSMOOTH.
 
hdrl_parameterhdrl_bpm_2d_parameter_create_legendresmooth (double kappa_low, double kappa_high, int maxiter, int steps_x, int steps_y, int filter_size_x, int filter_size_y, int order_x, int order_y)
 Creates BPM_2D Parameters object for HDRL_BPM_2D_LEGENDRESMOOTH.
 
cpl_error_code hdrl_bpm_2d_parameter_verify (const hdrl_parameter *param)
 Verify basic correctness of the BPM_2D parameters.
 
cpl_boolean hdrl_bpm_2d_parameter_check (const hdrl_parameter *self)
 Check that the parameter is a BPM_2D parameter.
 
cpl_filter_mode hdrl_bpm_2d_parameter_get_filter (const hdrl_parameter *p)
 Access the filter in the BPM_2D parameter.
 
cpl_border_mode hdrl_bpm_2d_parameter_get_border (const hdrl_parameter *p)
 Access the border in the BPM_2D parameter.
 
double hdrl_bpm_2d_parameter_get_kappa_low (const hdrl_parameter *p)
 Access the kappa_low in the BPM_2D parameter.
 
double hdrl_bpm_2d_parameter_get_kappa_high (const hdrl_parameter *p)
 Access the kappa_high in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_maxiter (const hdrl_parameter *p)
 Access the maxiter in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_steps_x (const hdrl_parameter *p)
 Access the steps_x in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_steps_y (const hdrl_parameter *p)
 Access the steps_y in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_filter_size_x (const hdrl_parameter *p)
 Access the filter_size_x in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_filter_size_y (const hdrl_parameter *p)
 Access the filter_size_y in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_order_x (const hdrl_parameter *p)
 Access the order_x in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_order_y (const hdrl_parameter *p)
 Access the order_y in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_smooth_y (const hdrl_parameter *p)
 Access the smooth_y in the BPM_2D parameter.
 
int hdrl_bpm_2d_parameter_get_smooth_x (const hdrl_parameter *p)
 Access the smooth_x in the BPM_2D parameter.
 
hdrl_bpm_2d_method hdrl_bpm_2d_parameter_get_method (const hdrl_parameter *p)
 Access the method in the BPM_2D parameter.
 
cpl_parameterlist * hdrl_bpm_2d_parameter_create_parlist (const char *base_context, const char *prefix, const char *method_def, const hdrl_parameter *filtersmooth_def, const hdrl_parameter *legendresmooth_def)
 Create parameter list for the BPM_2D computation.
 
hdrl_parameterhdrl_bpm_2d_parameter_parse_parlist (const cpl_parameterlist *parlist, const char *prefix)
 Parse parameter list to create input parameters for the BPM_2D.
 
cpl_mask * hdrl_bpm_2d_compute (const hdrl_image *img_in, const hdrl_parameter *params)
 Detect bad pixels on a single image with an iterative process.
 

Detailed Description

Algorithms to detect bad pixels on a single image.

The routines in this module can be used to detect bad pixels on a single image. The algorithm first smoothes the image by applying different methods. Then it subtracts the smoothed image and derives bad pixels by thresholding the residual image, i.e. all pixels exceeding the threshold are considered as bad.

The calculation is performed by calling the top-level function hdrl_bpm_2d_compute() and the parameters passed to this function can be created by calling hdrl_bpm_2d_parameter_create_filtersmooth() or hdrl_bpm_2d_parameter_create_legendresmooth(), depending on the method one would like to use.

Function Documentation

◆ hdrl_bpm_2d_compute()

cpl_mask * hdrl_bpm_2d_compute ( const hdrl_image img_in,
const hdrl_parameter params 
)

Detect bad pixels on a single image with an iterative process.

Parameters
img_ininput hdrl image
paramsBPM_2D computation parameters - see below
Returns
Bad pixel mask with the newly found bad pixels

The algorithm first smoothes the image by applying the methods described below. Then it subtracts the smoothed image and derives bad pixels by thresholding the residual image, i.e. all pixels exceeding the threshold are considered as bad. To compute the upper and lower threshold, it measures a robust rms (a properly scaled Median Absolute Deviation), which is then scaled by the parameter kappa_low and kappa_high. Furthermore, the algorithm is applied iteratively controlled by maxiter. During each iteration the newly found bad pixels are ignored. Please note, that the thresholding values are applied as median(residual-image) $\pm$ thresholds. This makes the algorithm more robust in the case that the methods listed below are not able to completely remove the background level, e.g due to an exceeding number of bad pixels in the first iteration.

Two methods are currently available to derive a smoothed version of the image:

  • Applying a filter like e.g. a median filter to the image. The filtering can be done by all modes currently supported by cpl and is controlled by the filter-type filter, the border-type border and by the kernel size in x and y, i.e. smooth_x and smooth_y. The corresponding BPM_2D parameter is created by hdrl_bpm_2d_parameter_create_filtersmooth()
  • Fitting a Legendre polynomial to the image of order order_x, in x and order_y in y direction. This method allows you to define steps_x $\times$ steps_y sampling points (the latter are computed as the median within a box of filter_size_x and filter_size_y) where the polynomial is fitted. This substantially decreases the fitting time for the Legendre polynomial. The corresponding BPM_2D parameter is created by hdrl_bpm_2d_parameter_create_legendresmooth()

◆ hdrl_bpm_2d_parameter_check()

cpl_boolean hdrl_bpm_2d_parameter_check ( const hdrl_parameter self)

Check that the parameter is a BPM_2D parameter.

Parameters
selfThe parameter to check
Returns
True or False

◆ hdrl_bpm_2d_parameter_create_filtersmooth()

hdrl_parameter * hdrl_bpm_2d_parameter_create_filtersmooth ( double  kappa_low,
double  kappa_high,
int  maxiter,
cpl_filter_mode  filter,
cpl_border_mode  border,
int  smooth_x,
int  smooth_y 
)

Creates BPM_2D Parameters object for HDRL_BPM_2D_FILTERSMOOTH.

Parameters
kappa_lowLow kappa factor for thresholding algorithm
kappa_highHigh kappa factor for thresholding algorithm
maxiterMaximum number of iterations
filterfilter mode
borderborder mode
smooth_xSmoothing kernel X size
smooth_ySmoothing kernel Y size
Returns
The BPM_2D parameters object. It needs to be deallocated with hdrl_parameter_delete()

The method creates a parameter for the method HDRL_BPM_2D_FILTERSMOOTH

See also
hdrl_parameter_delete()
hdrl_bpm_2d_compute()

◆ hdrl_bpm_2d_parameter_create_legendresmooth()

hdrl_parameter * hdrl_bpm_2d_parameter_create_legendresmooth ( double  kappa_low,
double  kappa_high,
int  maxiter,
int  steps_x,
int  steps_y,
int  filter_size_x,
int  filter_size_y,
int  order_x,
int  order_y 
)

Creates BPM_2D Parameters object for HDRL_BPM_2D_LEGENDRESMOOTH.

Parameters
kappa_lowLow kappa factor for thresholding algorithm
kappa_highHigh kappa factor for thresholding algorithm
maxiterMaximum number of iterations
steps_xNumber of sampling coordinates in x-dir
steps_yNumber of sampling coordinates in y-dir
filter_size_xsize of the median box in x-dir
filter_size_ysize of the median box in y-dir
order_xorder of polynomial in x-dir
order_yorder of polynomial in y-dir
Returns
The BPM_2D parameters object. It needs to be deallocated with hdrl_parameter_delete().

The method creates a hdrl parameter for the method HDRL_BPM_2D_LEGENDRESMOOTH

See also
hdrl_parameter_delete()
hdrl_bpm_2d_compute()

◆ hdrl_bpm_2d_parameter_create_parlist()

cpl_parameterlist * hdrl_bpm_2d_parameter_create_parlist ( const char *  base_context,
const char *  prefix,
const char *  method_def,
const hdrl_parameter filtersmooth_def,
const hdrl_parameter legendresmooth_def 
)

Create parameter list for the BPM_2D computation.

Parameters
base_contextbase context of parameter (e.g. recipe name)
prefixprefix of parameter, may be an empty string
method_defdefault used method
filtersmooth_defdefaults for filtersmooth method
legendresmooth_defdefaults for legendresmooth method Creates a parameter list with the BPM_2D parameters:
  • base_context.prefix.method
  • base_context.prefix.legendre.kappa-low
  • base_context.prefix.legendre.kappa-high
  • base_context.prefix.legendre.maxiter
  • base_context.prefix.legendre.steps-x
  • base_context.prefix.legendre.steps-y
  • base_context.prefix.legendre.filter-size-x
  • base_context.prefix.legendre.filter-size-y
  • base_context.prefix.legendre.order-x
  • base_context.prefix.legendre.order-y
  • base_context.prefix.filter.kappa-low
  • base_context.prefix.filter.kappa-high
  • base_context.prefix.filter.maxiter
  • base_context.prefix.filter.filter
  • base_context.prefix.filter.border
  • base_context.prefix.filter.smooth-x
  • base_context.prefix.filter.smooth-y The CLI aliases omit the base_context.

◆ hdrl_bpm_2d_parameter_get_border()

cpl_border_mode hdrl_bpm_2d_parameter_get_border ( const hdrl_parameter p)

Access the border in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The border

◆ hdrl_bpm_2d_parameter_get_filter()

cpl_filter_mode hdrl_bpm_2d_parameter_get_filter ( const hdrl_parameter p)

Access the filter in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The filter

◆ hdrl_bpm_2d_parameter_get_filter_size_x()

int hdrl_bpm_2d_parameter_get_filter_size_x ( const hdrl_parameter p)

Access the filter_size_x in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The filter_size_x

◆ hdrl_bpm_2d_parameter_get_filter_size_y()

int hdrl_bpm_2d_parameter_get_filter_size_y ( const hdrl_parameter p)

Access the filter_size_y in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The filter_size_y

◆ hdrl_bpm_2d_parameter_get_kappa_high()

double hdrl_bpm_2d_parameter_get_kappa_high ( const hdrl_parameter p)

Access the kappa_high in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The kappa_high

◆ hdrl_bpm_2d_parameter_get_kappa_low()

double hdrl_bpm_2d_parameter_get_kappa_low ( const hdrl_parameter p)

Access the kappa_low in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The kappa_low

◆ hdrl_bpm_2d_parameter_get_maxiter()

int hdrl_bpm_2d_parameter_get_maxiter ( const hdrl_parameter p)

Access the maxiter in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The maxiter

◆ hdrl_bpm_2d_parameter_get_method()

hdrl_bpm_2d_method hdrl_bpm_2d_parameter_get_method ( const hdrl_parameter p)

Access the method in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The method

◆ hdrl_bpm_2d_parameter_get_order_x()

int hdrl_bpm_2d_parameter_get_order_x ( const hdrl_parameter p)

Access the order_x in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The order_x

◆ hdrl_bpm_2d_parameter_get_order_y()

int hdrl_bpm_2d_parameter_get_order_y ( const hdrl_parameter p)

Access the order_y in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The order_y

◆ hdrl_bpm_2d_parameter_get_smooth_x()

int hdrl_bpm_2d_parameter_get_smooth_x ( const hdrl_parameter p)

Access the smooth_x in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The smooth_x

◆ hdrl_bpm_2d_parameter_get_smooth_y()

int hdrl_bpm_2d_parameter_get_smooth_y ( const hdrl_parameter p)

Access the smooth_y in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The smooth_y

◆ hdrl_bpm_2d_parameter_get_steps_x()

int hdrl_bpm_2d_parameter_get_steps_x ( const hdrl_parameter p)

Access the steps_x in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The steps_x

◆ hdrl_bpm_2d_parameter_get_steps_y()

int hdrl_bpm_2d_parameter_get_steps_y ( const hdrl_parameter p)

Access the steps_y in the BPM_2D parameter.

Parameters
pThe BPM_2D parameter
Returns
The steps_y

◆ hdrl_bpm_2d_parameter_parse_parlist()

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

Parse parameter list to create input parameters for the BPM_2D.

Parameters
parlistparameter list to parse
prefixprefix of parameter name
Returns
Input parameters for the BPM_2D computation

Reads a parameter list in order to create BPM_2D parameters.

Expects a parameter list containing:

  • prefix.method
  • prefix.legendre.kappa-low
  • prefix.legendre.kappa-high
  • prefix.legendre.maxiter
  • prefix.legendre.steps-x
  • prefix.legendre.steps-y
  • prefix.legendre.filter-size-x
  • prefix.legendre.filter-size-y
  • prefix.legendre.order-x
  • prefix.legendre.order-y
  • prefix.filter.kappa-low
  • prefix.filter.kappa-high
  • prefix.filter.maxiter
  • prefix.filter.filter
  • prefix.filter.border
  • prefix.filter.smooth-x
  • prefix.filter.smooth-y

◆ hdrl_bpm_2d_parameter_verify()

cpl_error_code hdrl_bpm_2d_parameter_verify ( const hdrl_parameter param)

Verify basic correctness of the BPM_2D parameters.

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