Max Denoise [repack] -

return np.clip(denoised, 0, 1) if name == " main ": import matplotlib.pyplot as plt from skimage import data, img_as_float

# Apply maximal denoising denoised = max_denoise(noisy, sigma=0.2, h=1.5) max denoise

# 2. Wavelet hard thresholding (removes residual high-frequency noise) coeffs = pywt.wavedec2(denoised, wavelet, level=4) if denoised.ndim == 2 else \ pywt.wavedec(denoised, wavelet, level=4) return np

# Add strong synthetic noise noisy = random_noise(original, mode='gaussian', var=0.04) noisy = random_noise(noisy, mode='s&p', amount=0.05) # extra salt & pepper var=0.04) noisy = random_noise(noisy

if denoised.ndim == 2: coeffs = list(coeffs) coeffs[1:] = threshold_coeffs(coeffs[1:], threshold) denoised = pywt.waverec2(coeffs, wavelet) else: coeffs = list(coeffs) coeffs[1:] = threshold_coeffs(coeffs[1:], threshold) denoised = pywt.waverec(coeffs, wavelet)

# 3. Strong Bilateral filter (smooths while keeping edges) denoised = denoise_bilateral(denoised, sigma_color=0.3, sigma_spatial=5, multichannel=(image.ndim==3))