Loading...
Searching...
No Matches
High-level functions to compute detector features

## Functions

cpl_error_code | cpl_detector_interpolate_rejected (cpl_image *self)
| Interpolate any bad pixels in an image and delete the bad pixel map.
cpl_error_code | cpl_flux_get_bias_window (const cpl_image *bias_image, const cpl_size *zone_def, cpl_size ron_hsize, cpl_size ron_nsamp, double *bias, double *error)
| Compute the bias in a rectangle.
cpl_error_code | cpl_flux_get_noise_ring (const cpl_image *diff, const double *zone_def, cpl_size ron_hsize, cpl_size ron_nsamp, double *noise, double *error)
| Compute the readout noise in a ring.
cpl_error_code | cpl_flux_get_noise_window (const cpl_image *diff, const cpl_size *zone_def, cpl_size ron_hsize, cpl_size ron_nsamp, double *noise, double *error)
| Compute the readout noise in a rectangle.

## Detailed Description

Synopsis:
  #include "cpl_detector.h"

## Function Documentation

## cpl_detector_interpolate_rejected()

cpl_error_code cpl_detector_interpolate_rejected | ( | cpl_image * | self | ) |

Interpolate any bad pixels in an image and delete the bad pixel map.

Parameters

  self | The image to clean

Returns
  The _cpl_error_code_ or CPL_ERROR_NONE

The value of a bad pixel is interpolated from the good pixels among the 8 nearest. (If all but one of the eight neighboring pixels are bad, the interpolation becomes a nearest neighbor interpolation). For integer images the interpolation in done with floating-point and rounded to the nearest integer.

If there are pixels for which all of the eight neighboring pixels are bad, a subsequent interpolation pass is done, where the already interpolated pixels are included as source for the interpolation.

The interpolation passes are repeated until all bad pixels have been interpolated. In the worst case, all pixels will be interpolated from a single good pixel.

Possible _cpl_error_code_ set in this function:

- CPL_ERROR_NULL_INPUT if an input pointer is NULL
- CPL_ERROR_DATA_NOT_FOUND if all pixels are bad

References cpl_ensure_code, cpl_error_get_code(), CPL_ERROR_INVALID_TYPE, CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, cpl_image_accept_all(), cpl_image_get_bpm_const(), cpl_image_get_data(), cpl_image_get_size_x(), cpl_image_get_size_y(), cpl_image_get_type(), cpl_mask_get_data_const(), CPL_TYPE_DOUBLE, CPL_TYPE_DOUBLE_COMPLEX, CPL_TYPE_FLOAT, CPL_TYPE_FLOAT_COMPLEX, and CPL_TYPE_INT.

## cpl_flux_get_bias_window()

cpl_error_code cpl_flux_get_bias_window | ( | const cpl_image * | bias_image,
|  | const cpl_size * | zone_def,
|  | cpl_size | ron_hsize,
|  | cpl_size | ron_nsamp,
|  | double * | bias,
|  | double * | error )

Compute the bias in a rectangle.

Parameters

  bias_image | Input bias image
  zone_def | Zone where the bias is to be computed.
  ron_hsize | to specify half size of squares (<0 to use default)
  ron_nsamp | to specify the nb of samples (<0 to use default)
  bias | Output parameter: bias in the frame.
  error | Output parameter: error on the bias.

Returns
  CPL_ERROR_NONE on success or the relevant _cpl_error_code_ on error

See also
  cpl_flux_get_noise_window(), rand()

Note
  No calls to srand() are made from CPL

References CPL_ERROR_NONE.

## cpl_flux_get_noise_ring()

cpl_error_code cpl_flux_get_noise_ring | ( | const cpl_image * | diff,
|  | const double * | zone_def,
|  | cpl_size | ron_hsize,
|  | cpl_size | ron_nsamp,
|  | double * | noise,
|  | double * | error )

Compute the readout noise in a ring.

Parameters

  diff | Input image, usually a difference frame.
  zone_def | Zone where the readout noise is to be computed.
  ron_hsize | to specify half size of squares (<0 to use default)
  ron_nsamp | to specify the nb of samples (<0 to use default)
  noise | On success, *noise is the noise in the frame.
  error | NULL, or on success, *error is the error in the noise

Returns
  CPL_ERROR_NONE on success or the relevant _cpl_error_code_ on error

See also
  cpl_flux_get_noise_window(), rand()

Note
  No calls to srand() are made from CPL

The provided zone is an array of four integers specifying the zone to take into account for the computation. The integers specify a ring as x, y, r1, r2 where these coordinates are given in the FITS notation (x from 1 to nx, y from 1 to ny and bottom to top).

Possible _cpl_error_code_ set in this function:

- CPL_ERROR_NULL_INPUT if diff noise or zone_def is NULL
- CPL_ERROR_ILLEGAL_INPUT if the internal radius is bigger than the external one in zone_def
- CPL_ERROR_DATA_NOT_FOUND if an insufficient number of samples were found inside the ring

References cpl_bivector_delete(), cpl_bivector_get_x_data_const(), cpl_bivector_get_y_data_const(), cpl_ensure_code, CPL_ERROR_DATA_NOT_FOUND, CPL_ERROR_ILLEGAL_INPUT, CPL_ERROR_NONE, CPL_ERROR_NULL_INPUT, cpl_errorstate_get(), cpl_errorstate_is_equal(), cpl_errorstate_set(), cpl_image_get_size_x(), cpl_image_get_size_y(), cpl_image_get_stdev_window(), CPL_SIZE_FORMAT, cpl_vector_delete(), cpl_vector_get_median(), cpl_vector_get_stdev(), cpl_vector_new(), cpl_vector_set(), cpl_vector_unwrap(), and cpl_vector_wrap().

## cpl_flux_get_noise_window()

cpl_error_code cpl_flux_get_noise_window | ( | const cpl_image * | diff,
|  | const cpl_size * | zone_def,
|  | cpl_size | ron_hsize,
|  | cpl_size | ron_nsamp,
|  | double * | noise,
|  | double * | error )

Compute the readout noise in a rectangle.

Parameters

  diff | Input image, usually a difference frame.
  zone_def | Zone where the readout noise is to be computed.
  ron_hsize | to specify half size of squares (<0 to use default)
  ron_nsamp | to specify the nb of samples (<0 to use default)
  noise | Output parameter: noise in the frame.
  error | Output parameter: error on the noise.

Returns
  CPL_ERROR_NONE on success or the relevant _cpl_error_code_ on error

See also
  rand()

Note
  No calls to srand() are made from CPL

This function is meant to compute the readout noise in a frame by means of a MonteCarlo approach. The input is a frame, usually a difference between two frames taken with the same settings for the acquisition system, although no check is done on that, it is up to the caller to feed in the right kind of frame.

The provided zone is an array of four integers specifying the zone to take into account for the computation. The integers specify ranges as xmin, xmax, ymin, ymax, where these coordinates are given in the FITS notation (x from 1 to lx, y from 1 to ly and bottom to top). Specify NULL instead of an array of four values to use the whole frame in the computation.

The algorithm will create typically 100 9x9 windows on the frame, scattered optimally using a Poisson law. In each window, the standard deviation of all pixels in the window is computed and this value is stored. The readout noise is the median of all computed standard deviations, and the error is the standard deviation of the standard deviations.

Both noise and error are returned by modifying a passed double. If you do not care about the error, pass NULL.

Possible _cpl_error_code_ set in this function:

- CPL_ERROR_NULL_INPUT if diff or noise is NULL
- CPL_ERROR_ILLEGAL_INPUT if the specified window (zone_def) is invalid

References CPL_ERROR_NONE.