7.2.3. algotom.prep.correction

Module of correction methods in the preprocessing stage:

  • Flat-field correction.

  • Distortion correction.

  • MTF deconvolution.

  • Tilted sinogram generation.

  • Tilted 1D intensity-profile generation.

  • Beam hardening correction.

  • Sinogram upsampling.

Functions:

flat_field_correction(proj, flat, dark[, ...])

Perform flat-field correction with options to remove zinger artifacts and/or stripe artifacts.

unwarp_projection(proj, xcenter, ycenter, ...)

Apply distortion correction to a projection image using the polynomial backward model (Ref.

unwarp_sinogram(data, index, xcenter, ...)

Unwarp sinogram [:,index.:] of a 3D tomographic dataset or a hdf/nxs object.

unwarp_sinogram_chunk(data, start_index, ...)

Unwarp chunk of sinograms [:, start_index: stop_index, :] of a 3D tomographic dataset or a hdf/nxs object.

mtf_deconvolution(mat, window, pad)

Deconvolve a projection-image using division in the Fourier domain.

generate_tilted_sinogram(data, index, angle, ...)

Generate a tilted sinogram of a 3D tomographic dataset or a hdf/nxs object.

generate_tilted_sinogram_chunk(data, ...)

Generate a chunk of tilted sinograms of a 3D tomographic dataset or a hdf/nxs object.

generate_tilted_profile_line(mat, index, angle)

Generate a tilted horizontal intensity-profile of an image.

generate_tilted_profile_chunk(mat, ...)

Generate a chunk of tilted horizontal intensity-profiles of an image.

non_linear_function(intensity, q, n[, opt])

Function used to define the response curve.

beam_hardening_correction(mat, q, n[, opt])

Correct the grayscale values of a normalized image using a non-linear function.

upsample_sinogram(sinogram, scale[, center, ...])

Upsample a sinogram-image along angular direction based on the double-wedge filter (Ref.

algotom.prep.correction.flat_field_correction(proj, flat, dark, ratio=1.0, use_dark=True, **options)[source]

Perform flat-field correction with options to remove zinger artifacts and/or stripe artifacts.

Parameters
  • proj (array_like) – 3D or 2D array. Projection images or a sinogram image.

  • flat (array_like) – 2D or 1D array. Flat-field image or a single row of it.

  • dark (array_like) – 2D or 1D array. Dark-field image or a single row of it.

  • ratio (float) – Ratio between exposure time used for recording projections and exposure time used for recording flat field.

  • use_dark (bool) – Subtracting dark field if True.

  • options (dict, optional) – Apply a zinger removal method and/or ring removal methods. E.g option1={“method”: “dezinger”, “para1”: 0.001, “para2”: 1}, option2={“method”: “remove_stripe_based_sorting”, “para1”: 15, “para2”: 1}

Returns

array_like – 3D or 2D array. Corrected projections or corrected sinograms.

algotom.prep.correction.unwarp_projection(proj, xcenter, ycenter, list_fact)[source]

Apply distortion correction to a projection image using the polynomial backward model (Ref. [1]).

Parameters
  • proj (array_like) – 2D array. Projection image.

  • xcenter (float) – Center of distortion in x-direction.

  • ycenter (float) – Center of distortion in y-direction.

  • list_fact (list of float) – Polynomial coefficients of the backward model.

Returns

array_like – 2D array. Distortion corrected.

References

[1] : https://doi.org/10.1364/OE.23.032859

algotom.prep.correction.unwarp_sinogram(data, index, xcenter, ycenter, list_fact, **option)[source]

Unwarp sinogram [:,index.:] of a 3D tomographic dataset or a hdf/nxs object.

Parameters
  • data (array_like or hdf object) – 3D array.

  • index (int) – Index of the sinogram.

  • xcenter (float) – Center of distortion in x-direction.

  • ycenter (float) – Center of distortion in y-direction.

  • list_fact (list of float) – Polynomial coefficients of the backward model.

  • option (list or tuple of int) – To extract subset data along axis 0 from a hdf object. E.g option = (start, stop, step)

Returns

array_like – 2D array. Distortion-corrected sinogram.

algotom.prep.correction.unwarp_sinogram_chunk(data, start_index, stop_index, xcenter, ycenter, list_fact, **option)[source]

Unwarp chunk of sinograms [:, start_index: stop_index, :] of a 3D tomographic dataset or a hdf/nxs object.

Parameters
  • data (array_like or hdf object) – 3D array.

  • start_index (int) – Starting index of sinograms.

  • stop_index (int) – Stopping index of sinograms.

  • xcenter (float) – Center of distortion in x-direction.

  • ycenter (float) – Center of distortion in y-direction.

  • list_fact (list of float) – Polynomial coefficients of the backward model.

  • option (list or tuple of int) – To extract subset data along axis 0 from a hdf object. E.g option = [start, stop, step]

Returns

array_like – 3D array. Distortion corrected.

algotom.prep.correction.mtf_deconvolution(mat, window, pad)[source]

Deconvolve a projection-image using division in the Fourier domain. Window can be determined using the approach in Ref. [1].

Parameters
  • mat (array_like) – 2D array. Projection image.

  • window (array_like) – 2D array. MTF function.

  • pad (int) – Padding width to reduce the side effects of the Fourier transform.

Returns

array_like – 2D array. Deconvolved image.

References

[1] : https://doi.org/10.1117/12.2530324

algotom.prep.correction.generate_tilted_sinogram(data, index, angle, **option)[source]

Generate a tilted sinogram of a 3D tomographic dataset or a hdf/nxs object.

Parameters
  • data (array_like or hdf object) – 3D array.

  • index (int) – Index of the sinogram.

  • angle (float) – Tilted angle in degree.

  • option (list or tuple of int) – To extract subset data along axis 0 from a hdf object. E.g option = (start, stop, step)

Returns

array_like – 2D array. Tilted sinogram.

algotom.prep.correction.generate_tilted_sinogram_chunk(data, start_index, stop_index, angle, **option)[source]

Generate a chunk of tilted sinograms of a 3D tomographic dataset or a hdf/nxs object.

Parameters
  • data (array_like or hdf object) – 3D array.

  • start_index (int) – Starting index of sinograms.

  • stop_index (int) – Stopping index of sinograms.

  • angle (float) – Tilted angle in degree.

  • option (list or tuple of int) – To extract subset data along axis 0 from a hdf object. E.g option = (start, stop, step)

Returns

array_like – 3D array. Chunk of tilted sinograms.

algotom.prep.correction.generate_tilted_profile_line(mat, index, angle)[source]

Generate a tilted horizontal intensity-profile of an image.

Parameters
  • mat (array_like) – 2D array.

  • index (int) – Index of the line.

  • angle (float) – Tilted angle in degree.

Returns

array_like – 1D array.

algotom.prep.correction.generate_tilted_profile_chunk(mat, start_index, stop_index, angle)[source]

Generate a chunk of tilted horizontal intensity-profiles of an image.

Parameters
  • mat (array_like) – 2D array.

  • start_index (int) – Starting index of lines.

  • stop_index (int) – Stopping index of lines.

  • angle (float) – Tilted angle in degree.

Returns

array_like – 2D array.

algotom.prep.correction.non_linear_function(intensity, q, n, opt=True)[source]

Function used to define the response curve.

Parameters
  • intensity (float) – Values stay in the range of [0; 1]

  • q (float) – Positive number.

  • n (float) – Positive number. Must larger than 1.

  • opt (bool) – True: Curve more to values closer to 1.0. False: Curve more to values closer to 0.0

Returns

float

algotom.prep.correction.beam_hardening_correction(mat, q, n, opt=True)[source]

Correct the grayscale values of a normalized image using a non-linear function.

Parameters
  • mat (array_like) – Normalized projection image or sinogram image.

  • q (float) – Positive number. Recommended range [0.005, 50].

  • n (float) – Positive number. Must larger than 1.

  • opt (bool) – True: Curve towards 0.0. False: Curve towards 1.0.

Returns

array_like – Corrected image.

algotom.prep.correction.upsample_sinogram(sinogram, scale, center=0, sino_type='180', iteration=1, pad=50)[source]

Upsample a sinogram-image along angular direction based on the double-wedge filter (Ref. [1]).

Parameters
  • sinogram (array_like) – 2D array. Sinogram image.

  • scale (int) – Upscale 2n_x time. E.g. 2, 4, 6.

  • center (float, optional) – Center-of-rotation. No need for a 360-sinogram.

  • sino_type ({“180”, “360”}) – Sinogram type : 180-degree or 360-degree.

  • iteration (int, optional) – Number of iteration for the double-wedge filter.

  • pad (int, optional) – Padding width for FFT.

Returns

array_like – Upsampled sinogram.