Distortion correction


Data Structures

struct  _hawki_distortion_obj_function_args_

Functions

int hawki_distortion_apply_maps (cpl_imagelist *ilist, cpl_image **dist_x, cpl_image **dist_y)
 Apply the distortion correction.
double hawki_distortion_compute_rms (const cpl_table **ref_catalogues, const cpl_bivector *cat_offsets, const cpl_table *matching_sets, int ncats, hawki_distortion *distortion)
 This private function computes the rms, which is the objective function of the minimization algorithm.
int hawki_distortion_correct_alldetectors (cpl_image **ilist, const cpl_frame *frame_dist_x, const cpl_frame *frame_dist_y)
 Apply the distortion correction.
int hawki_distortion_correct_coords (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_pos_distcorr, double *y_pos_distcorr)
 Apply the distortion correction to one detector position.
cpl_image * hawki_distortion_correct_detector (cpl_image *image, cpl_image *dist_x, cpl_image *dist_y)
 Apply the distortion correction to one chip.
void hawki_distortion_delete (hawki_distortion *distortion)
 Deallocates a hawki_distortion structure.
double hawki_distortion_get_deque_stddev (cx_deque *deque)
 Compute the standard deviation of a deque.
int hawki_distortion_get_size_x (const hawki_distortion *distortion)
 Gives the dimension in X of the distortion solution.
int hawki_distortion_get_size_y (const hawki_distortion *distortion)
 Gives the dimension in Y of the distortion solution.
hawki_distortionhawki_distortion_grid_new (int detector_nx, int detector_ny, int grid_size)
 Allocate a new distortion solution.
int hawki_distortion_interpolate_distortion (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_dist, double *y_dist)
 Interpolates the distortion solution at a given position.
int hawki_distortion_inverse_correct_coords (const hawki_distortion *distortion, double x_pos, double y_pos, double *x_pos_distinvcorr, double *y_pos_distinvcorr)
 Apply the inverse distortion correction to one detector position.
hawki_distortionhawki_distortion_load (const cpl_frame *dist_x, const cpl_frame *dist_y, int idet)
 Loads the distortion solution for one detector.

Function Documentation

int hawki_distortion_apply_maps ( cpl_imagelist *  ilist,
cpl_image **  dist_x,
cpl_image **  dist_y 
)

Apply the distortion correction.

Parameters:
ilist the input image list (chips 1 2 3 4)
dist the distortion file
Returns:
0 if everything is ok, -1 otherwise

Definition at line 616 of file hawki_distortion.c.

References hawki_distortion_correct_detector().

double hawki_distortion_compute_rms ( const cpl_table **  ref_catalogues,
const cpl_bivector *  cat_offsets,
const cpl_table *  matching_sets,
int  ncats,
hawki_distortion distortion 
)

This private function computes the rms, which is the objective function of the minimization algorithm.

See also:
hawki_distortion_compute_solution

Definition at line 929 of file hawki_distortion.c.

References _hawki_distortion_obj_function_args_::distortion, and hawki_distortion_interpolate_distortion().

int hawki_distortion_correct_alldetectors ( cpl_image **  ilist,
const cpl_frame *  frame_dist_x,
const cpl_frame *  frame_dist_y 
)

Apply the distortion correction.

Parameters:
ilist the input image list (chips 1 2 3 4)
dist the distortion file
Returns:
0 if everything is ok, -1 otherwise

Definition at line 286 of file hawki_distortion.c.

References hawki_distortion_correct_detector(), hawki_distortion_delete(), and hawki_distortion_load().

int hawki_distortion_correct_coords ( const hawki_distortion distortion,
double  x_pos,
double  y_pos,
double *  x_pos_distcorr,
double *  y_pos_distcorr 
)

Apply the distortion correction to one detector position.

Parameters:
distortion the distortion solution
x_pos the X position in detector that we want to correct.
y_pos the Y position in detector that we want to correct.
x_pos_distcorr the X position in detector corrected from distortion
y_pos_distcorr the Y position in detector corrected from distortion
Returns:
0 if everything is ok, -1 otherwise
This function will interpolate the distortion solution (given in variable distortion,
See also:
hawki_distortion_new)

Definition at line 422 of file hawki_distortion.c.

References hawki_distortion_interpolate_distortion().

cpl_image* hawki_distortion_correct_detector ( cpl_image *  image,
cpl_image *  dist_x,
cpl_image *  dist_y 
)

Apply the distortion correction to one chip.

Parameters:
image the input image
dist the distortion table
Returns:
0 if everything is ok, -1 otherwise

Definition at line 370 of file hawki_distortion.c.

Referenced by hawki_distortion_apply_maps(), and hawki_distortion_correct_alldetectors().

void hawki_distortion_delete ( hawki_distortion distortion  ) 

Deallocates a hawki_distortion structure.

Parameters:
distortion The distortion to allocate

Definition at line 162 of file hawki_distortion.c.

References _hawki_distortion_::dist_x, and _hawki_distortion_::dist_y.

Referenced by hawki_distortion_correct_alldetectors().

double hawki_distortion_get_deque_stddev ( cx_deque *  deque  ) 

Compute the standard deviation of a deque.

Returns:
The standard deviation

Definition at line 1176 of file hawki_distortion.c.

int hawki_distortion_get_size_x ( const hawki_distortion distortion  ) 

Gives the dimension in X of the distortion solution.

Parameters:
dist the distortion solution
Returns:
The dimension in X

Definition at line 251 of file hawki_distortion.c.

References _hawki_distortion_::dist_x.

int hawki_distortion_get_size_y ( const hawki_distortion distortion  ) 

Gives the dimension in Y of the distortion solution.

Parameters:
dist the distortion solution
Returns:
The dimension in Y

Definition at line 268 of file hawki_distortion.c.

References _hawki_distortion_::dist_x.

hawki_distortion* hawki_distortion_grid_new ( int  detector_nx,
int  detector_ny,
int  grid_size 
)

Allocate a new distortion solution.

Parameters:
detector_nx The dimensions in X of a HAWK-I detector
detector_nx The dimensions in Y of a HAWK-I detector
grid_size The number of points in the distortion grid
Returns:
The allocated distortion if everything is ok , NULL otherwise

Definition at line 131 of file hawki_distortion.c.

References _hawki_distortion_::dist_x, _hawki_distortion_::dist_y, _hawki_distortion_::x_cdelt, _hawki_distortion_::x_crval, _hawki_distortion_::y_cdelt, and _hawki_distortion_::y_crval.

int hawki_distortion_interpolate_distortion ( const hawki_distortion distortion,
double  x_pos,
double  y_pos,
double *  x_dist,
double *  y_dist 
)

Interpolates the distortion solution at a given position.

Parameters:
distortion the distortion solution
x_pos the X position in detector that we want to correct.
y_pos the Y position in detector that we want to correct.
x_dist the distortion in X at position x_pos, y_pos
y_dist the distortion in Y at position x_pos, y_pos
Returns:
0 if everything is ok, -1 otherwise
This private function uses the four reference points found in distortion closer to x_pos, y_pos. Then it weights each point with the 3rd power of the distance to the target pixel and uses a linear interpolation.

If this function is used in a multithread environment with a CPL version not thread-safe, there is no risk as long as these two premises are hold: -The caller must check if distortion->dist_x and distortion->dist_y are not null before calling this function, because this is check by cpl_image_get_size_x and cpl_image_get. -The caller must check in advance that the mask has all the points valid, because cpl_image_get checks for the validity of the pixel in the mask, if it is not valid, enters the error handling of CPL, which is not thread-safe, at least before CPL 5.2. The rest of the calls are read-only, so it should be safe.

Definition at line 525 of file hawki_distortion.c.

References _hawki_distortion_::dist_x, _hawki_distortion_::dist_y, _hawki_distortion_::x_cdelt, _hawki_distortion_::x_crval, _hawki_distortion_::y_cdelt, and _hawki_distortion_::y_crval.

Referenced by hawki_distortion_compute_rms(), hawki_distortion_correct_coords(), and hawki_distortion_inverse_correct_coords().

int hawki_distortion_inverse_correct_coords ( const hawki_distortion distortion,
double  x_pos,
double  y_pos,
double *  x_pos_distinvcorr,
double *  y_pos_distinvcorr 
)

Apply the inverse distortion correction to one detector position.

Parameters:
distortion the distortion solution
x_pos the X position in detector that we want to decorrect.
y_pos the Y position in detector that we want to decorrect.
x_pos_distcorr the X position in detector decorrected from distortion
y_pos_distcorr the Y position in detector decorrected from distortion
Returns:
0 if everything is ok, -1 otherwise
This function is the inverse function of hawki_distortion_correct_coords. WARNING: Although this is the "inverse" of hawki_distortion_correct_coords, applying this function to positions delivered by hawki_distortion_correct_coords will not provide the original positions back. We are simply not using the same position to interpolate the distortion table.

Definition at line 466 of file hawki_distortion.c.

References hawki_distortion_interpolate_distortion().

hawki_distortion* hawki_distortion_load ( const cpl_frame *  dist_x,
const cpl_frame *  dist_y,
int  idet 
)

Loads the distortion solution for one detector.

Parameters:
dist_x the image with distortion in X
dist_y the image with distortion in Y
idet the detector to read.
Returns:
The allocated distortion if everything is ok , NULL otherwise

Definition at line 181 of file hawki_distortion.c.

References _hawki_distortion_::dist_x, _hawki_distortion_::dist_y, hawki_get_ext_from_detector(), hawki_load_frame_detector(), _hawki_distortion_::x_cdelt, _hawki_distortion_::x_crval, _hawki_distortion_::y_cdelt, and _hawki_distortion_::y_crval.

Referenced by hawki_distortion_correct_alldetectors().


Generated on Thu Feb 17 17:13:08 2011 for HAWKI Pipeline Reference Manual by  doxygen 1.4.7