bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / restoration / _denoise / denoise_tv_chambolle
function
skimage.restoration._denoise:denoise_tv_chambolle
source: /dev/scikit-image/src/skimage/restoration/_denoise.py :490
Signature
def denoise_tv_chambolle ( image , weight = 0.1 , eps = 0.0002 , max_num_iter = 200 , * , channel_axis = None ) Summary
Perform total variation denoising in nD.
Extended Summary
Given , a noisy image (input data), total variation denoising (also known as total variation regularization) aims to find an image with less total variation than , under the constraint that remain similar to . This can be expressed by the Rudin--Osher--Fatemi (ROF) minimization problem:
where is a positive parameter. The first term of this cost function is the total variation; the second term represents data fidelity. As , the total variation term dominates, forcing the solution to have smaller total variation, at the expense of looking less like the input data.
This code is an implementation of the algorithm proposed by Chambolle in [1] to solve the ROF problem.
Parameters
image: ndarrayInput image to be denoised. If its dtype is not float, it gets converted with img_as_float.
weight: float, optionalDenoising weight. It is equal to . Therefore, the greater the
weight, the more denoising (at the expense of fidelity toimage).eps: float, optionalTolerance for the stop criterion (compares to absolute value of relative difference of the cost function ): The algorithm stops when .
max_num_iter: int, optionalMaximal number of iterations used for the optimization.
channel_axis: int or None, optionalIf
None, the image is assumed to be grayscale (single-channel). Otherwise, this parameter indicates which axis of the array corresponds to channels.
Returns
u: ndarrayDenoised image.
Notes
Make sure to set the channel_axis parameter appropriately for color images.
The principle of total variation denoising is explained in [2]. It is about minimizing the total variation of an image, which can be roughly described as the integral of the norm of the image gradient. Total variation denoising tends to produce cartoon-like images, that is, piecewise-constant images.
Examples
2D example on astronaut image:from skimage import color, data img = color.rgb2gray(data.astronaut())[:50, :50] rng = np.random.default_rng() img += 0.5 * img.std() * rng.standard_normal(img.shape) denoised_img = denoise_tv_chambolle(img, weight=60)✓
x, y, z = np.ogrid[0:20, 0:20, 0:20] mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2 mask = mask.astype(float) rng = np.random.default_rng() mask += 0.2 * rng.standard_normal(mask.shape) res = denoise_tv_chambolle(mask, weight=100)✓
See also
- denoise_tv_bregman
Perform total variation denoising using split-Bregman optimization.
Aliases
-
skimage.restoration.denoise_tv_chambolle