nabu.thirdparty.tomocupy_remove_stripe module¶
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.
- nabu.thirdparty.tomocupy_remove_stripe.afb1d(x, h0, h1='zero', dim=-1)[source]¶
1D analysis filter bank (along one dimension only) of an image
- Parameters:
(array) (h1) –
(array) – h, 1) or (1, 1, 1, w)
(array) – h, 1) or (1, 1, 1, w)
(called (dim (int) - dimension of filtering. d=2 is for a vertical filter) – column filtering but filters across the rows). d=3 is for a horizontal filter, (called row filtering but filters across the columns).
- Returns:
lohi – dimension
- Return type:
lowpass and highpass subbands concatenated along the channel
- nabu.thirdparty.tomocupy_remove_stripe.sfb1d(lo, hi, g0, g1='zero', dim=-1)[source]¶
1D synthesis filter bank of an image Array
- class nabu.thirdparty.tomocupy_remove_stripe.DWTForward(wave='db1')[source]¶
Bases:
object
Performs a 2d DWT Forward decomposition of an image
- Parameters:
wave (str) – Which wavelet to use.
- apply(x)[source]¶
Forward pass of the DWT.
- Parameters:
x (array) – Input of shape \((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 \((N, C_{in}, H_{in}', W_{in}')\) and yh has shape \(list(N, C_{in}, 3, H_{in}'', W_{in}'')\). The new dimension in yh iterates over the LH, HL and HH coefficients.
Note
\(H_{in}', W_{in}', H_{in}'', W_{in}''\) denote the correctly downsampled shapes of the DWT pyramid.
- class nabu.thirdparty.tomocupy_remove_stripe.DWTInverse(wave='db1')[source]¶
Bases:
object
Performs a 2d DWT Inverse reconstruction of an image
- Parameters:
wave (str) – Which wavelet to use.
- apply(coeffs)[source]¶
- Parameters:
coeffs (yl, yh) – tuple of lowpass and bandpass coefficients, where: yl is a lowpass array of shape \((N, C_{in}, H_{in}', W_{in}')\) and yh is a list of bandpass arrays of shape \(list(N, C_{in}, 3, H_{in}'', W_{in}'')\). I.e. should match the format returned by DWTForward
- Returns:
Reconstructed input of shape \((N, C_{in}, H_{in}, W_{in})\)
Note
\(H_{in}', W_{in}', H_{in}'', W_{in}''\) denote the correctly downsampled shapes of the DWT pyramid.
- nabu.thirdparty.tomocupy_remove_stripe.remove_stripe_fw(data, sigma, wname, level)[source]¶
Remove stripes with wavelet filtering
- nabu.thirdparty.tomocupy_remove_stripe.remove_stripe_ti(data, beta, mask_size)[source]¶
Remove stripes with a new method by V. Titareno
- nabu.thirdparty.tomocupy_remove_stripe.remove_all_stripe(tomo, snr=3, la_size=61, sm_size=21, dim=1)[source]¶
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:
Corrected 3D tomographic data.
- Return type:
ndarray
- nabu.thirdparty.tomocupy_remove_stripe.remove_all_stripe_sinos(sinos, snr=3, la_size=61, sm_size=21, dim=1)[source]¶
Same as remove_all_stripe(), but acting on sinograms
- nabu.thirdparty.tomocupy_remove_stripe.remove_all_stripe_pycuda(array, layout='radios', device_id=0, **kwargs)[source]¶
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”.
'remove_all_stripe (See parameters of) –