7.5.1. algotom.util.calibration
Module of calibration methods:
Correcting the non-uniform background of an image.
Binarizing an image.
Calculating the distance between two point-like objects segmented from two images. Useful for determining pixel-size in helical scans.
Find the tilt and roll of a parallel-beam tomography system given coordinates of a point-like object scanned in the range of [0, 360] degrees.
Functions:
|
Correct a non-uniform background of an image using the median filter. |
|
Correct a non-uniform background of an image using a Fourier Gaussian filter. |
|
Invert the contrast of a 2D binary array to make sure that a dot is white. |
|
Calculate threshold value based on Algorithm 4 in Ref. |
|
Binarize an image. |
|
Get size of binary dots given the option. |
|
Check if the size of a dot is in a range. |
|
Select dots having a certain size. |
|
Calculate the distance between two point-like objects segmented from two images. |
|
Fit an ellipse to a set of points. |
|
Find the tilt and roll of a parallel-beam tomography system given coordinates of a point-like object scanned in the range of [0, 360] degrees. |
- algotom.util.calibration.normalize_background(mat, size=51)[source]
Correct a non-uniform background of an image using the median filter.
- Parameters
mat (array_like) – 2D array.
size (int) – Size of the median filter.
- Returns
array_like – 2D array. Corrected image.
- algotom.util.calibration.normalize_background_based_fft(mat, sigma=5, pad=None, mode='reflect')[source]
Correct a non-uniform background of an image using a Fourier Gaussian filter.
- Parameters
mat (array_like) – 2D array.
sigma (int) – Sigma of the Gaussian.
pad (int) – Padding for the Fourier transform.
mode (str, list of str, or tuple of str) – Padding method. One of options : ‘reflect’, ‘edge’, ‘constant’. Full list is at: https://numpy.org/doc/stable/reference/generated/numpy.pad.html
- Returns
array_like – 2D array. Corrected image.
- algotom.util.calibration.invert_dot_contrast(mat)[source]
Invert the contrast of a 2D binary array to make sure that a dot is white.
- Parameters
mat (array_like) – 2D binary array.
- Returns
array_like – 2D array.
- algotom.util.calibration.calculate_threshold(mat, bgr='bright')[source]
Calculate threshold value based on Algorithm 4 in Ref. [1].
- Parameters
mat (array_like) – 2D array.
bgr ({“bright”, “dark”}) – To indicate the brightness of the background against image features.
- Returns
float – Threshold value.
References
- algotom.util.calibration.binarize_image(mat, threshold=None, bgr='bright', norm=False, denoise=True, invert=True)[source]
Binarize an image.
- Parameters
mat (array_like) – 2D array.
threshold (float, optional) – Threshold value for binarization. Automatically calculated using Algorithm 4 in Ref. [1] if None.
bgr ({“bright”, “dark”}) – To indicate the brightness of the background against image features.
norm (bool, optional) – Apply normalization if True.
denoise (bool, optional) – Apply denoising if True.
invert (bool, optional) – Invert the contrast if needed.
- Returns
array_like – 2D binary array.
References
- algotom.util.calibration.get_dot_size(mat, size_opt='max')[source]
Get size of binary dots given the option.
- Parameters
mat (array_like) – 2D binary array.
size_opt ({“max”, “min”, “median”, “mean”}) – Select options.
- Returns
dot_size (float) – Size of the dot.
- algotom.util.calibration.check_dot_size(mat, min_size, max_size)[source]
Check if the size of a dot is in a range.
- Parameters
mat (array_like) – 2D array.
min_size (float) – Minimum size.
max_size (float) – Maximum size.
- Returns
bool
- algotom.util.calibration.select_dot_based_size(mat, dot_size, ratio=0.01)[source]
Select dots having a certain size.
- Parameters
mat (array_like) – 2D array.
dot_size (float) – Size of the standard dot.
ratio (float) – Used to calculate the acceptable range. [dot_size - ratio*dot_size; dot_size + ratio*dot_size]
- Returns
array_like – 2D array. Selected dots.
- algotom.util.calibration.calculate_distance(mat1, mat2, size_opt='max', threshold=None, bgr='bright', norm=False, denoise=True, invert=True)[source]
Calculate the distance between two point-like objects segmented from two images. Useful for measuring pixel-size in helical scans (Ref. [1]).
- Parameters
mat1 (array_like) – 2D array.
mat2 (array_like) – 2D array.
size_opt ({“max”, “min”, “median”, “mean”}) – Options to select binary objects based on their size.
threshold (float, optional) – Threshold value for binarization. Automatically calculated using Algorithm 4 in Ref. [2] if None.
bgr ({“bright”, “dark”}) – To indicate the brightness of the background against image features.
norm (bool, optional) – Apply normalization if True.
denoise (bool, optional) – Apply denoising if True.
invert (bool, optional) – Invert the contrast if needed.
References
- algotom.util.calibration.fit_points_to_ellipse(x, y)[source]
Fit an ellipse to a set of points.
- Parameters
x (ndarray) – x-coordinates of the points.
y (ndarray) – y-coordinates of the points.
- Returns
roll_angle (float) – Rotation angle of the ellipse in degree.
a_major (float) – Length of the major axis.
b_minor (float) – Length of the minor axis.
xc (float) – x-coordinate of the ellipse center.
yc (float) – y-coordinate of the ellipse center.
- algotom.util.calibration.find_tilt_roll_based_linear_fit(x, y)[source]
Find the tilt and roll of a parallel-beam tomography system given coordinates of a point-like object scanned in the range of [0, 360] degrees. Uses a linear-fit-based approach [1].
- Parameters
x (ndarray) – x-coordinates of the points.
y (ndarray) – y-coordinates of the points.
- Returns
tilt (float) – Tilt angle in degree.
roll (float) – Roll angle in degree.
References
- algotom.util.calibration.find_tilt_roll_based_ellipse_fit(x, y)[source]
Find the tilt and roll of a parallel-beam tomography system given coordinates of a point-like object scanned in the range of [0, 360] degrees. Uses an ellipse-fit-based approach.
- Parameters
x (ndarray) – x-coordinates of the points.
y (ndarray) – y-coordinates of the points.
- Returns
tilt (float) – Tilt angle in degree.
roll (float) – Roll angle in degree.
- algotom.util.calibration.find_tilt_roll(x, y, method='ellipse')[source]
Find the tilt and roll of a parallel-beam tomography system given coordinates of a point-like object scanned in the range of [0, 360] degrees.
- Parameters
x (ndarray) – x-coordinates of the points.
y (ndarray) – y-coordinates of the points.
method ({“linear”, “ellipse”}) – Method for finding tilt and roll.
- Returns
tilt (float) – Tilt angle in degree.
roll (float) – Roll angle in degree.