httomolibgpu.misc.denoise#
Module for data denoising. For more detailed information see Denoising methods:
- httomolibgpu.misc.denoise.non_local_means(data: <cp.ndarray>, h: float = 0.01, search_radius: int = 2, patch_radius: int = 1, num_neighbours: int = 0, full_3d: bool = True) <cp.ndarray>[source]#
Denoise images or volumes with Gaussian-weighted non-local means on the GPU.
A 3D input uses volumetric search windows and patches by default. Set full_3d=False to process independent 2D images along axis 0. See Non-local means denoising.
- Parameters:
data (cp.ndarray) – CuPy float32 image (y, x) or a volume (z, y, x).
h (float) – Positive, finite smoothing strength in input intensity units. Larger values give more smoothing. No intensity rescaling is applied. The Gaussian-weighted squared patch differences are summed, not averaged, so the appropriate h also depends on patch_radius.
search_radius (int) – Non-negative half-width of the square or cubic search window. Defaults to 2 (a 5 by 5 by 5 window in 3D).
patch_radius (int) – Non-negative half-width of the comparison patch. Its Gaussian has sigma equal to patch_radius. Defaults to 1 (a 3 by 3 by 3 patch in 3D). Zero compares individual pixels.
num_neighbours (int) – Number of strongest non-self matches to average, plus the centre pixel with weight one. Zero uses all matches. A positive value must not exceed (2 * search_radius + 1)**D - 1, where D is three for full 3D processing and two otherwise. Near boundaries, fewer neighbours may be available.
full_3d (bool) – Use 3D search windows and patches for a volume. Defaults to True. False processes each data[z, :, :] slice independently. A 2D input always uses 2D processing, with either value of this flag.
- Returns:
C-contiguous float32 array.
- Return type:
cp.ndarray
- Raises:
TypeError – If data is not a CuPy array, or a parameter has an invalid type.
ValueError – If shape, dtype, or a parameter value is invalid.
- httomolibgpu.misc.denoise.total_variation_PD(data: <cp.ndarray>, regularisation_parameter: float | int = 1e-05, iterations: int = 1000, isotropic: bool = True, nonnegativity: bool = False, lipschitz_const: float | int = 8.0, gpu_id: int = 0, half_precision: bool = False) <cp.ndarray>[source]#
Primal Dual algorithm for non-smooth convex Total Variation functional [4]. See more in Total Variation denoising (PD).
- Parameters:
data (cp.ndarray) – Input CuPy 3D array of float32 data type.
regularisation_parameter (float, int) – Regularisation parameter to control the level of smoothing. Defaults to 1e-05.
iterations (int) – The number of iterations. Defaults to 1000.
isotropic (bool) – Choose between isotropic or anisotropic TV norm. Defaults to isotropic.
nonnegativity (bool) – Enable non-negativity in iterations. Defaults to False.
lipschitz_const (float,int) – Lipschitz constant to control convergence. Defaults to 8.
gpu_id (int) – GPU device index to perform processing on. Defaults to 0.
half_precision (bool) – Perform faster computation in half-precision with a very minimal sacrifice in quality. Defaults to False.
- Returns:
TV-PD filtered 3D CuPy array in float32 data type.
- Return type:
ndarray
- Raises:
ValueError – If the input array is not float32 data type.
- httomolibgpu.misc.denoise.total_variation_ROF(data: <cp.ndarray>, regularisation_parameter: float | int = 1e-05, iterations: int = 3000, time_marching_parameter: float = 0.001, gpu_id: int = 0, half_precision: bool = False) <cp.ndarray>[source]#
Total Variation using Rudin-Osher-Fatemi (ROF) [12] explicit iteration scheme to perform edge-preserving image denoising. This is a gradient-based algorithm for a smoothed TV term which requires a small time marching parameter and a significant number of iterations. See more in Total Variation denoising (ROF).
- Parameters:
data (cp.ndarray) – Input CuPy 3D array of float32 data type.
regularisation_parameter (float) – Regularisation parameter to control the level of smoothing. Defaults to 1e-05.
iterations (int) – The number of iterations. Defaults to 3000.
time_marching_parameter (float) – Time marching parameter, needs to be small to ensure convergence. Defaults to 0.001.
gpu_id (int) – GPU device index to perform processing on. Defaults to 0.
half_precision (bool) – Perform faster computation in half-precision with a very minimal sacrifice in quality. Defaults to False.
- Returns:
TV-ROF filtered 3D CuPy array in float32 data type.
- Return type:
ndarray
- Raises:
ValueError – If the input array is not float32 data type.