This is a development version (0.26.1rc0.dev0) and may be unstable.Go to latest (0.26.1rc0.dev0+git20260530.b607368ff)
{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0 / skimage / restoration / j_invariant / calibrate_denoiser

function

skimage.restoration.j_invariant:calibrate_denoiser

source: /_skimage2/restoration/j_invariant.py:200

Signature

def calibrate_denoiser(image, denoise_function, denoise_parameters, *, stride = 4, approximate_loss = True, extra_output = False)

Summary

Calibrate a denoising function and return optimal J-invariant version.

Extended Summary

The returned function is partially evaluated with optimal parameter values set for denoising the input image.

Parameters

image : ndarray

Input data to be denoised (converted using img_as_float).

denoise_function : function

Denoising function to be calibrated.

denoise_parameters : dict of list

Ranges of parameters for denoise_function to be calibrated over.

stride : int, optional

Stride used in masking procedure that converts denoise_function to J-invariance.

approximate_loss : bool, optional

Whether to approximate the self-supervised loss used to evaluate the denoiser by only computing it on one masked version of the image. If False, the runtime will be a factor of stride**image.ndim longer.

extra_output : bool, optional

If True, return parameters and losses in addition to the calibrated denoising function

Returns

best_denoise_function : function

The optimal J-invariant version of denoise_function.

: If `extra_output` is True, the following tuple is also returned:
(parameters_tested, losses) : tuple (list of dict, list of int)

List of parameters tested for denoise_function, as a dictionary of kwargs Self-supervised loss for each set of parameters in parameters_tested.

Notes

The calibration procedure uses a self-supervised mean-square-error loss to evaluate the performance of J-invariant versions of denoise_function. The minimizer of the self-supervised loss is also the minimizer of the ground-truth loss (i.e., the true MSE error) [1]. The returned function can be used on the original noisy image, or other images with similar characteristics.

Increasing the stride increases the performance of best_denoise_function

at the expense of increasing its runtime. It has no effect on the runtime of the calibration.

Examples

from skimage import color, data
from skimage.restoration import denoise_tv_chambolle
import numpy as np
img = color.rgb2gray(data.astronaut()[:50, :50])
rng = np.random.default_rng()
noisy = img + 0.5 * img.std() * rng.standard_normal(img.shape)
parameters = {'weight': np.arange(0.01, 0.3, 0.02)}
denoising_function = calibrate_denoiser(noisy, denoise_tv_chambolle,
                                        denoise_parameters=parameters)
denoised_img = denoising_function(img)
✓

Aliases

  • skimage.restoration.calibrate_denoiser