nabu.thirdparty.tomocupy_remove_stripe
source module nabu.thirdparty.tomocupy_remove_stripe
This file is a "GPU" (through cupy) implementation of "remove_all_stripe". The original method is implemented by Nghia Vo in the algotom project: https://github.com/algotom/algotom/blob/master/algotom/prep/removal.py The implementation using cupy is done by Viktor Nikitin in the tomocupy project: https://github.com/tomography/tomocupy/blame/main/src/tomocupy/remove_stripe.py then moved to https://github.com/tomography/tomocupy/blob/main/src/tomocupy/processing/remove_stripe.py
For now we can't rely on off-the-shelf tomocupy as it's not packaged in pypi, and compilation is quite tedious.
License follows.
Classes
-
DWTForward — Performs a 2d DWT Forward decomposition of an image
-
DWTInverse — Performs a 2d DWT Inverse reconstruction of an image
Functions
-
afb1d — 1D analysis filter bank (along one dimension only) of an image
-
sfb1d — 1D synthesis filter bank of an image Array
-
remove_stripe_fw — Remove stripes with wavelet filtering
-
remove_stripe_ti — Remove stripes with a new method by V. Titareno
-
remove_all_stripe — Remove all types of stripe artifacts from sinogram using Nghia Vo's approach :cite:
Vo:18
(combination of algorithm 3,4,5, and 6). -
remove_all_stripe_sinos — Same as remove_all_stripe(), but acting on sinograms
-
remove_all_stripe_pycuda — Nabu interface to tomocupy "remove_all_stripe". Processing is done in-place to save memory, meaning that the content of "array" will be overwritten.
source afb1d(x, h0, h1='zero', dim=-1)
1D analysis filter bank (along one dimension only) of an image
Parameters
-
x (array) : 4D input with the last two dimensions the spatial input
-
h0 (array) : 4D input for the lowpass filter. Should have shape (1, 1, — h, 1) or (1, 1, 1, w)
-
h1 (array) : 4D input for the highpass filter. Should have shape (1, 1, — h, 1) or (1, 1, 1, w)
-
dim (int) - dimension of filtering. d=2 is for a vertical filter (called — column filtering but filters across the rows). d=3 is for a horizontal filter, (called row filtering but filters across the columns).
Returns
-
lohi : lowpass and highpass subbands concatenated along the channel — dimension
source sfb1d(lo, hi, g0, g1='zero', dim=-1)
1D synthesis filter bank of an image Array
source class DWTForward(wave='db1')
Performs a 2d DWT Forward decomposition of an image
Parameters
-
wave : str — Which wavelet to use.
Methods
-
apply — Forward pass of the DWT.
source method DWTForward.apply(x)
Forward pass of the DWT.
Parameters
-
x : array — Input of shape :math:
(N, C_{in}, H_{in}, W_{in})
Returns
-
(yl, yh) — tuple of lowpass (yl) and bandpass (yh) coefficients. yh is a list of scale coefficients. yl has shape :math:
(N, C_{in}, H_{in}', W_{in}')
and yh has shape :math:list(N, C_{in}, 3, H_{in}'', W_{in}'')
. The new dimension in yh iterates over the LH, HL and HH coefficients.
Note
:math:H_{in}', W_{in}', H_{in}'', W_{in}''
denote the correctly
downsampled shapes of the DWT pyramid.
source class DWTInverse(wave='db1')
Performs a 2d DWT Inverse reconstruction of an image
Parameters
-
wave : str — Which wavelet to use.
Methods
source method DWTInverse.apply(coeffs)
Parameters
-
coeffs : yl, yh — tuple of lowpass and bandpass coefficients, where: yl is a lowpass array of shape :math:
(N, C_{in}, H_{in}', W_{in}')
and yh is a list of bandpass arrays of shape :math:list(N, C_{in}, 3, H_{in}'', W_{in}'')
. I.e. should match the format returned by DWTForward
Returns
-
Reconstructed input of shape — math:
(N, C_{in}, H_{in}, W_{in})
Note
:math:H_{in}', W_{in}', H_{in}'', W_{in}''
denote the correctly
downsampled shapes of the DWT pyramid.
source remove_stripe_fw(data, sigma, wname, level)
Remove stripes with wavelet filtering
source remove_stripe_ti(data, beta, mask_size)
Remove stripes with a new method by V. Titareno
source remove_all_stripe(tomo, snr=3, la_size=61, sm_size=21, dim=1)
Remove all types of stripe artifacts from sinogram using Nghia Vo's
approach :cite:Vo:18
(combination of algorithm 3,4,5, and 6).
Parameters
-
tomo : ndarray — 3D tomographic data.
-
snr : float — Ratio used to locate large stripes. Greater is less sensitive.
-
la_size : int — Window size of the median filter to remove large stripes.
-
sm_size : int — Window size of the median filter to remove small-to-medium stripes.
-
dim : {1, 2}, optional — Dimension of the window.
Returns
-
ndarray — Corrected 3D tomographic data.
source remove_all_stripe_sinos(sinos, snr=3, la_size=61, sm_size=21, dim=1)
Same as remove_all_stripe(), but acting on sinograms
source remove_all_stripe_pycuda(array, layout='radios', device_id=0, **kwargs)
Nabu interface to tomocupy "remove_all_stripe". Processing is done in-place to save memory, meaning that the content of "array" will be overwritten.
Parameters
-
array : pycuda.GPUArray — Stack of radios in the shape (n_angles, n_y, n_x), if layout == "radios" Stack of sinos in the shape (n_y, n_angles, n_x), if layout == "sinos".
Other Parameters
See parameters of 'remove_all_stripe