-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_noiselevel.py
More file actions
executable file
·36 lines (23 loc) · 956 Bytes
/
test_noiselevel.py
File metadata and controls
executable file
·36 lines (23 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
from skimage import data
from noiselevel import NoiseLevelEstimation as nle
img = data.camera()
def test_convmtx2():
tt = nle.convmtx2(img, 11., 7.)
assert tt.shape == ((11-img.shape[0] + 1) * (7 - img.shape[1] + 1),11.*7.)
def test_noiselevel():
noise_levels = np.array([5., 10., 20., 42.])
n_levels = np.zeros_like(noise_levels)
n_patches = np.zeros_like(noise_levels)
for n in range(noise_levels.size):
noise = img + np.random.standard_normal(img.shape) * noise_levels[n]
output = nle(noise, patchsize=11, itr=5)
n_levels[n] = output.nlevel
n_patches[n] = output.num
assert np.abs(1-n_levels/noise_levels) < 0.1
assert n_patches > 10000.
def test_weaktexturemask():
noise_levels = 5
noise = img + np.random.standard_normal(img.shape) * noise_levels
output = nle(noise, patchsize=11, itr=5)
assert np.sum(output.mask)/output.mask.size < 1.0