Testing Class Material
This commit is contained in:
commit
05b1f6cdd5
85 changed files with 102796 additions and 0 deletions
|
@ -0,0 +1,24 @@
|
|||
import numpy as np
|
||||
from numpy.testing import assert_allclose
|
||||
|
||||
from noiser.noise import white_noise
|
||||
|
||||
|
||||
def test_white_noise():
|
||||
n_images, height, width = 201, 101, 102
|
||||
dtype = np.float32
|
||||
|
||||
# Create ``n_images`` identical image.
|
||||
base_image = np.random.rand(1, height, width, 3).astype(dtype) - 0.5
|
||||
images = np.repeat(base_image, n_images, axis=0)
|
||||
|
||||
std = 0.13
|
||||
noisy = white_noise(images, std=std)
|
||||
|
||||
# dtype and shape are preserved.
|
||||
assert noisy.dtype == dtype
|
||||
assert noisy.shape == images.shape
|
||||
|
||||
# Mean and std of noisy image match expectations.
|
||||
assert_allclose(images.mean(0), base_image[0], atol=1e-4)
|
||||
assert np.isclose((noisy - images).std(), std, atol=1e-4)
|
|
@ -0,0 +1,14 @@
|
|||
import numpy as np
|
||||
from numpy.testing import assert_array_equal
|
||||
|
||||
from noiser.utils import copy_image
|
||||
|
||||
|
||||
def test_copy_image():
|
||||
height, width = 101, 102
|
||||
dtype = np.float32
|
||||
|
||||
image = np.random.rand(height, width, 3).astype(dtype)
|
||||
copy = copy_image(image)
|
||||
assert_array_equal(copy, image)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue