algotom.post.postprocessing

Module of methods in the postprocessing stage: - Get statistical information of reconstructed images or a dataset. - Downsample 2D, 3D array, or a dataset. - Rescale 2D, 3D array or a dataset to 8-bit or 16-bit data-type. - Removing ring artifacts in a reconstructed image by transform back and forth between the polar coordinates and the Cartesian coordinates.

Functions:

get_statical_information(mat[, percentile, …])

Get statical information of an image.

get_statical_information_dataset(input_[, …])

Get statical information of a dataset.

downsample(mat, cell_size[, method])

Downsample an image.

downsample_dataset(input_, output, cell_size)

Downsample a dataset.

rescale(mat[, nbit, minmax])

Rescale a 32-bit array to 16-bit/8-bit data.

rescale_dataset(input_, output[, nbit, …])

Rescale a dataset to 8-bit or 16-bit data-type.

remove_ring_based_fft(mat[, u, n, v, sort])

Remove ring artifacts in the reconstructed image by combining the polar transform and the fft-based method.

remove_ring_based_wavelet_fft(mat[, level, …])

Remove ring artifacts in a reconstructed image by combining the polar transform and the wavelet-fft-based method (Ref.

algotom.post.postprocessing.downsample(mat, cell_size, method='mean')[source]

Downsample an image.

Parameters
  • mat (array_like) – 2D array.

  • cell_size (int or tuple of int) – Window size along axes used for grouping pixels.

  • method ({“mean”, “median”, “max”, “min”}) – Downsampling method.

Returns

array_like – Downsampled image.

algotom.post.postprocessing.downsample_dataset(input_, output, cell_size, method='mean', key_path=None)[source]

Downsample a dataset. This can be a folder of tif files, a hdf file, or a 3D array.

Parameters
  • input_ (str, array_like) – It can be a folder path to tif files, a hdf file, or 3D array.

  • output (str, None) – It can be a folder path, a hdf file path, or None (memory consuming).

  • cell_size (int or tuple of int) – Window size along axes used for grouping pixels.

  • method ({“mean”, “median”, “max”, “min”}) – Downsampling method.

  • key_path (str, optional) – Key path to the dataset if the input is the hdf file.

Returns

array_like or None – If output is None, returning an 3D array.

algotom.post.postprocessing.get_statical_information(mat, percentile=(5, 95), denoise=False)[source]

Get statical information of an image.

Parameters
  • mat (array_like) – 2D array. Projection image, sinogram image, or reconstructed image.

  • percentile (tuple of floats) – Tuple of (min_percentile, max_percentile) to compute. Must be between 0 and 100 inclusive.

  • denoise (bool, optional) – Enable/disable denoising before extracting statistical information.

Returns

  • gmin (float) – The minimum value of the data array.

  • gmax (float) – The maximum value of the data array.

  • min_percent (float) – The first computed percentile of the data array.

  • max_percent (tuple of floats) – The last computed percentile of the data array.

  • mean (float) – The mean of the data array.

  • median (float) – The median of the data array.

  • variance (float) – The variance of the data array.

algotom.post.postprocessing.get_statical_information_dataset(input_, percentile=(5, 95), skip=5, denoise=False, key_path=None)[source]

Get statical information of a dataset. This can be a folder of tif files, a hdf file, or a 3D array.

Parameters
  • input_ (str, hdf file, or array_like) – It can be a folder path to tif files, a hdf file, or a 3D array.

  • percentile (tuple of floats) – Tuple of (min_percentile, max_percentile) to compute. Must be between 0 and 100 inclusive.

  • skip (int) – Skipping step of reading input.

  • denoise (bool, optional) – Enable/disable denoising before extracting statistical information.

  • key_path (str, optional) – Key path to the dataset if the input is the hdf file.

Returns

  • gmin (float) – The global minimum value of the data array.

  • gmax (float) – The global maximum value of the data array.

  • min_percent (float) – The global min of the first computed percentile of the data array.

  • max_percent (tuple of floats) – The global min of the last computed percentile of the data array.

  • mean (float) – The mean of the data array.

  • median (float) – The median of the data array.

  • variance (float) – The mean of the variance of the data array.

algotom.post.postprocessing.remove_ring_based_fft(mat, u=20, n=8, v=1, sort=False)[source]

Remove ring artifacts in the reconstructed image by combining the polar transform and the fft-based method.

Parameters
  • mat (array_like) – Square array. Reconstructed image

  • u (int) – Cutoff frequency.

  • n (int) – Filter order.

  • v (int) – Number of rows (* 2) to be applied the filter.

  • sort (bool, optional) – Apply sorting (Ref. [2]) if True.

Returns

array_like – Ring-removed image.

References

1

https://doi.org/10.1063/1.1149043

2

https://doi.org/10.1364/OE.26.028396

algotom.post.postprocessing.remove_ring_based_wavelet_fft(mat, level=5, size=1, wavelet_name='db9', sort=False)[source]

Remove ring artifacts in a reconstructed image by combining the polar transform and the wavelet-fft-based method (Ref. [1]).

Parameters
  • mat (array_like) – Square array. Reconstructed image

  • level (int) – Wavelet decomposition level.

  • size (int) – Damping parameter. Larger is stronger.

  • wavelet_name (str) – Name of a wavelet. Search pywavelets API for a full list.

  • sort (bool, optional) – Apply sorting (Ref. [2]) if True.

Returns

array_like – Ring-removed image.

References

1

https://doi.org/10.1364/OE.17.008567

2

https://doi.org/10.1364/OE.26.028396

algotom.post.postprocessing.rescale(mat, nbit=16, minmax=None)[source]

Rescale a 32-bit array to 16-bit/8-bit data.

Parameters
  • mat (array_like)

  • nbit ({8,16}) – Rescaled data-type: 8-bit or 16-bit.

  • minmax (tuple of float, or None) – Minimum and maximum values used for rescaling.

Returns

array_like – Rescaled array.

algotom.post.postprocessing.rescale_dataset(input_, output, nbit=16, minmax=None, skip=None, key_path=None)[source]

Rescale a dataset to 8-bit or 16-bit data-type. The dataset can be a folder of tif files, a hdf file, or a 3D array.

Parameters
  • input_ (str, array_like) – It can be a folder path to tif files, a hdf file, or 3D array.

  • output (str, None) – It can be a folder path, a hdf file path, or None (memory consuming).

  • nbit ({8,16}) – Rescaled data-type: 8-bit or 16-bit.

  • minmax (tuple of float, or None) – Minimum and maximum values used for rescaling. They are calculated if None is given.

  • skip (int or None) – Skipping step of reading input used for getting statistical information.

  • key_path (str, optional) – Key path to the dataset if the input is the hdf file.

Returns

array_like or None – If output is None, returning an 3D array.