imgtools.restoration

Image restoration, including dehaze, deblur, and denoise.


Documents

imgtools.restoration.color_attenuation_dehaze(rgb: Tensor, patch_size: int = 3, beta: float = 1.0, t_min: float = 0.05, t_max: float = 1.0, percent: float = 0.1, guide_ksize: int = 43, guide_eps: float = 0.1)

Image dehazing by using color attenuation prior.

Parameters:
rgbtorch.Tensor

An RGB image with shape (*, C, H, W)

patch_sizeint, default=3

The neighborhood size for estimating the depth.

betafloat, default=1.0

_description_, by default 1.0

t_minfloat, default=0.05

The minimum of the transmission.

t_maxfloat, default=1.0

The maximum of the transmission.

percentfloat, default=0.1

The percentage for selecting data to estimate the atmospheric light.

guide_ksizeint, default=43

Kernel size for guided filetr to refine transmission.

guide_epsfloat, default=0.1

Epsilon for guided filetr to refine transmission.

Returns:
torch.Tensor

Dehazed RGB image with shape (*, 3, H, W).

Examples

>>> from imgtools import enhance
>>> res = enhance.dark_channel_dehaze(img)
imgtools.restoration.dark_channel_dehaze(rgb: Tensor, patch_size: int = 3, percent: float = 0.1, omega: float = 0.95, t_min: float = 0.4, guide_ksize: int = 43, guide_eps: float = 0.1)

Image dehazing by dark channel prior.

Parameters:
rgbtorch.Tensor

An RGB image in the range of [0, 1] with shape (*, 3, H, W).

patch_sizeint, default=3

Kernel size for computing dark channel.

percentfloat, default=0.1

The percentage for selecting data to estimate the atmospheric light.

omegafloat, default=0.95

Coefficient for preserving the haze. An lower value means more haze.

t_minfloat, default=0.4

Minimum of the transmission.

guide_ksizeint, default=43

Kernel size for guided filetr to refine transmission.

guide_epsfloat, default=0.1

Epsilon for guided filetr to refine transmission.

Returns:
torch.Tensor

Dehazed RGB image with shape (*, 3, H, W).

Examples

>>> from imgtools import enhance
>>> res = enhance.dark_channel_dehaze(img)
imgtools.restoration.estimate_noise_from_wavelet(hh: Tensor) float

Estimates the standard deviation of Gaussian noise from the highpass-highpass component of the wavelet decomposition.

Parameters:
hhtorch.Tensor

The highpass-highpass filtered image with shape (*, 1, H, W).

Returns:
float

The standard deviation of Gaussian noise in the image.

References

[1] D. L. Donoho and I. M. Johnstone, “Ideal spatial adaptation by wavelet

shrinkage,” Biometrika, vol. 81, no. 3, pp. 425-455, Sep. 1994

imgtools.restoration.estimate_noise_from_wavelet_2(hh: Tensor, maximum: float | int = 1.0) float

Estimates the standard deviation of Gaussian noise from the highpass-highpass component of the wavelet decomposition.

An advanced method of estimate_noise_from_wavelet, for details, see:

Parameters:
hhtorch.Tensor

The highpass-highpass filtered image in the range of [0, 1] with shape (*, 1, H, W).

maximumfloat | int, default=1.0

The maximum of the image.

Returns:
float

The standard deviation of Gaussian noise in the image.

References

[1] V. M. Kamble and K. Bhurchandi, “Noise Estimation and Quality

Assessment of Gaussian Noise Corrupted Images,” IOP Conference Series Materials Science and Engineering, vol. 331, p. 012019, Mar. 2018, doi: 10.1088/1757-899x/331/1/012019.