High-Level Data Reduction Library: Bad Pixel Mask 2D Computation

High-Level Data Reduction Library 1.6.0 High-Level data reduction routines for ESO pipelines

Loading...
Searching...
No Matches
Functions
Bad Pixel Mask 2D Computation
Bad Pixel Detection

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

Collaboration diagram for Bad Pixel Mask 2D Computation:

## 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_in | input hdrl image
  params | BPM_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) 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 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

  self | The 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_low | Low kappa factor for thresholding algorithm
  kappa_high | High kappa factor for thresholding algorithm
  maxiter | Maximum number of iterations
  filter | filter mode
  border | border mode
  smooth_x | Smoothing kernel X size
  smooth_y | Smoothing 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_low | Low kappa factor for thresholding algorithm
  kappa_high | High kappa factor for thresholding algorithm
  maxiter | Maximum number of iterations
  steps_x | Number of sampling coordinates in x-dir
  steps_y | Number of sampling coordinates in y-dir
  filter_size_x | size of the median box in x-dir
  filter_size_y | size of the median box in y-dir
  order_x | order of polynomial in x-dir
  order_y | order 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_context | base context of parameter (e.g. recipe name)
  prefix | prefix of parameter, may be an empty string
  method_def | default used method
  filtersmooth_def | defaults for filtersmooth method
  legendresmooth_def | defaults 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  p | The 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

  parlist | parameter list to parse
  prefix | prefix 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

  param | BPM_2D parameters

Returns
  CPL_ERROR_NONE if everything is ok, an error code otherwise