4.4.1. discorpy.post.postprocessing
Module of postprocessing methods:
Correct distortion for a line of dots or an image.
Generate unwarped slices of a 3D dataset.
Calculate the residual of undistorted dots.
Functions:

Unwarp lines of dotcentroids using a forward model. 

Unwarp lines of dotcentroids using a backward model. 

Unwarp an image using a backward model. 

Unwarp an image using a forward model. 

Generate an unwarped slice [:,index.:] of a 3D dataset, i.e. one unwarped sinogram of a 3D tomographic data. 

Generate a chunk of unwarped slices [:,start_index: stop_index, :] used for tomographic data. 

Calculate the distances of unwarped dots (on each horizontal line) to each fitted straight line which is used to assess the straightness of unwarped lines. 

Calculate the distances of unwarped dots (on each vertical line) to each fitted straight line which is used to assess the straightness of unwarped lines. 

Check if the distortion is significant or not. 

Apply perspective correction to lines. 


 discorpy.post.postprocessing.unwarp_line_forward(list_lines, xcenter, ycenter, list_fact)[source]
Unwarp lines of dotcentroids using a forward model.
 Parameters:
list_lines (list of 2D arrays) – List of the coordinates of dotcentroids on each line.
list_fact (list of floats) – Polynomial coefficients of the forward model.
 Returns:
list_ulines (list of 2D arrays) – List of the unwarped coordinates of dotcentroids on each line.
 discorpy.post.postprocessing.unwarp_line_backward(list_lines, xcenter, ycenter, list_fact)[source]
Unwarp lines of dotcentroids using a backward model. The method finds the coordinates of undistorted points from the coordinates of distorted points using numerical optimzation.
 Parameters:
list_lines (list of 2D arrays) – List of the coordinates of dotcentroids on each line.
list_fact (list of floats) – Polynomial coefficients of the backward model.
 Returns:
list_ulines (list of 2D arrays) – List of the unwarped coordinates of dotcentroids on each line.
 discorpy.post.postprocessing.unwarp_image_backward(mat, xcenter, ycenter, list_fact, order=1, mode='reflect')[source]
Unwarp an image using a backward model.
 Parameters:
mat (array_like) – 2D array.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
list_fact (list of float) – Polynomial coefficients of the backward model.
order (int, optional.) – The order of the spline interpolation.
mode ({‘reflect’, ‘gridmirror’, ‘constant’, ‘gridconstant’, ‘nearest’,) – ‘mirror’, ‘gridwrap’, ‘wrap’}, optional To determine how to handle image boundaries.
 Returns:
array_like – 2D array. Distortioncorrected image.
 discorpy.post.postprocessing.unwarp_image_forward(mat, xcenter, ycenter, list_fact)[source]
Unwarp an image using a forward model. Should be used only for assessment due to the problem of vacant pixels.
 Parameters:
mat (float) – 2D array.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
list_fact (list of floats) – Polynomial coefficients of the forward model.
 Returns:
array_like – 2D array. Distortioncorrected image.
 discorpy.post.postprocessing.unwarp_slice_backward(mat3D, xcenter, ycenter, list_fact, index)[source]
Generate an unwarped slice [:,index.:] of a 3D dataset, i.e. one unwarped sinogram of a 3D tomographic data.
 Parameters:
mat3D (array_like) – 3D array. Correction is applied along axis 1.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
list_fact (list of floats) – Polynomial coefficients of a backward model.
index (int) – Index of the slice
 Returns:
array_like – 2D array. Distortioncorrected slice.
 discorpy.post.postprocessing.unwarp_chunk_slices_backward(mat3D, xcenter, ycenter, list_fact, start_index, stop_index)[source]
Generate a chunk of unwarped slices [:,start_index: stop_index, :] used for tomographic data.
 Parameters:
mat3D (array_like) – 3D array. Correction is applied along axis 1.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
list_fact (list of floats) – Polynomial coefficients of a backward model.
start_index (int) – Starting index of slices.
stop_index (int) – Stopping index of slices.
 Returns:
array_like – 3D array. Distortioncorrected slices.
 discorpy.post.postprocessing.calc_residual_hor(list_ulines, xcenter, ycenter)[source]
Calculate the distances of unwarped dots (on each horizontal line) to each fitted straight line which is used to assess the straightness of unwarped lines.
 Parameters:
list_ulines (list of 2D arrays) – List of the coordinates of dotcentroids on each unwarped horizontal line.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
 Returns:
array_like – 2D array. Each element has two values: 1) Distance of a dot to the center of distortion; 2) Distance of this dot to the nearest fitted straight line.
 discorpy.post.postprocessing.calc_residual_ver(list_ulines, xcenter, ycenter)[source]
Calculate the distances of unwarped dots (on each vertical line) to each fitted straight line which is used to assess the straightness of unwarped lines.
 Parameters:
list_ulines (list of 2D arrays) – List of the coordinates of dotcentroids on each unwarped vertical line.
xcenter (float) – Center of distortion in xdirection.
ycenter (float) – Center of distortion in ydirection.
 Returns:
array_like – 2D array. Each element has two values: 1) Distance of a dot to the center of distortion; 2) Distance of this dot to the nearest fitted straight line.
 discorpy.post.postprocessing.check_distortion(list_data)[source]
Check if the distortion is significant or not. If the number of dots having the residual greater than 1 pixel is greater than 15% of the total number of dots, there’s distortion.
 Parameters:
list_data (array_like) – List of [radius, residual] of each dot.
 Returns:
bool
 discorpy.post.postprocessing.correct_perspective_line(list_lines, list_coef)[source]
Apply perspective correction to lines.
 Parameters:
list_lines (list of 2Darrays) – List of the (y,x)coordinates of points on each line.
list_coef (list of floats) – Coefficients of the forwardmapping matrix.
 Returns:
list_clines (list of 2D arrays) – List of the corrected (y,x)coordinates of points on each line.
 discorpy.post.postprocessing.correct_perspective_image(mat, list_coef, order=1, mode='reflect', map_index=None)[source]
 Parameters:
mat (array_like) – 2D array. Image for correction.
list_coef (list of floats) – Coefficients of the backwardmapping matrix.
order (int, optional.) – The order of the spline interpolation.
mode ({‘reflect’, ‘gridmirror’, ‘constant’, ‘gridconstant’, ‘nearest’,) – ‘mirror’, ‘gridwrap’, ‘wrap’}, optional To determine how to handle image boundaries.
map_index (array_like) – Indices for mapping. Generated if None is given.
 Returns:
array_like – Corrected image.