CR2RE Pipeline Reference Manual 1.6.8
Functions
Bad Pixel Mask 2D Computation

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

Functions

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.
 
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.
 
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_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.
 
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()

Definition at line 1136 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_verify(), and hdrl_image_get_image_const().

◆ 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

Definition at line 301 of file hdrl_bpm_2d.c.

Referenced by hdrl_bpm_2d_parameter_create_parlist(), and hdrl_bpm_2d_parameter_verify().

◆ 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()

Definition at line 137 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_verify().

Referenced by hdrl_bpm_2d_parameter_parse_parlist().

◆ 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()

Definition at line 191 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_verify().

Referenced by hdrl_bpm_2d_parameter_parse_parlist().

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

Definition at line 798 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_check(), and hdrl_join_string().

◆ 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

Definition at line 327 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 313 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 411 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 425 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 355 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 341 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 369 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 495 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 439 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 453 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 481 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 467 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 383 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 397 of file hdrl_bpm_2d.c.

◆ 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

Definition at line 896 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_create_filtersmooth(), hdrl_bpm_2d_parameter_create_legendresmooth(), and hdrl_join_string().

◆ 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

Definition at line 232 of file hdrl_bpm_2d.c.

References hdrl_bpm_2d_parameter_check().

Referenced by hdrl_bpm_2d_compute(), hdrl_bpm_2d_parameter_create_filtersmooth(), and hdrl_bpm_2d_parameter_create_legendresmooth().