def test_wavelet_threshold(): rstate = np.random.RandomState(1234) img = astro_gray sigma = 0.1 noisy = img + sigma * rstate.randn(*(img.shape)) noisy = np.clip(noisy, 0, 1) # employ a single, user-specified threshold instead of BayesShrink sigmas with expected_warnings([PYWAVELET_ND_INDEXING_WARNING]): denoised = _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=sigma) psnr_noisy = peak_signal_noise_ratio(img, noisy) psnr_denoised = peak_signal_noise_ratio(img, denoised) assert_(psnr_denoised > psnr_noisy) # either method or threshold must be defined with testing.raises(ValueError): _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=None) # warns if a threshold is provided in a case where it would be ignored with expected_warnings( ["Thresholding method ", PYWAVELET_ND_INDEXING_WARNING]): _wavelet_threshold(noisy, wavelet='db1', method='BayesShrink', threshold=sigma)
def test_wavelet_threshold(): rstate = np.random.RandomState(1234) img = astro_gray sigma = 0.1 noisy = img + sigma * rstate.randn(*(img.shape)) noisy = np.clip(noisy, 0, 1) # employ a single, user-specified threshold instead of BayesShrink sigmas with expected_warnings([PYWAVELET_ND_INDEXING_WARNING]): denoised = _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=sigma) psnr_noisy = compare_psnr(img, noisy) psnr_denoised = compare_psnr(img, denoised) assert_(psnr_denoised > psnr_noisy) # either method or threshold must be defined with testing.raises(ValueError): _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=None) # warns if a threshold is provided in a case where it would be ignored with expected_warnings(["Thresholding method ", PYWAVELET_ND_INDEXING_WARNING]): _wavelet_threshold(noisy, wavelet='db1', method='BayesShrink', threshold=sigma)
def test_wavelet_threshold(): rstate = np.random.RandomState(1234) img = astro_gray sigma = 0.1 noisy = img + sigma * rstate.randn(*(img.shape)) noisy = np.clip(noisy, 0, 1) # employ a single, uniform threshold instead of BayesShrink sigmas denoised = _wavelet_threshold(noisy, wavelet='db1', threshold=sigma) psnr_noisy = compare_psnr(img, noisy) psnr_denoised = compare_psnr(img, denoised) assert_(psnr_denoised > psnr_noisy)
def test_wavelet_threshold(): rstate = np.random.RandomState(1234) img = astro_gray sigma = 0.1 noisy = img + sigma * rstate.randn(*(img.shape)) noisy = np.clip(noisy, 0, 1) # employ a single, uniform threshold instead of BayesShrink sigmas denoised = _wavelet_threshold(noisy, wavelet='db1', threshold=sigma) psnr_noisy = compare_psnr(img, noisy) psnr_denoised = compare_psnr(img, denoised) assert_(psnr_denoised > psnr_noisy)
def test_wavelet_threshold(): rstate = np.random.default_rng(1234) img = astro_gray sigma = 0.1 noisy = img + sigma * rstate.standard_normal(img.shape) noisy = np.clip(noisy, 0, 1) # employ a single, user-specified threshold instead of BayesShrink sigmas denoised = _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=sigma) psnr_noisy = peak_signal_noise_ratio(img, noisy) psnr_denoised = peak_signal_noise_ratio(img, denoised) assert psnr_denoised > psnr_noisy # either method or threshold must be defined with pytest.raises(ValueError): _wavelet_threshold(noisy, wavelet='db1', method=None, threshold=None) # warns if a threshold is provided in a case where it would be ignored with expected_warnings(["Thresholding method "]): _wavelet_threshold(noisy, wavelet='db1', method='BayesShrink', threshold=sigma)