Tweak page generation

This commit is contained in:
Matthias Bisping 2023-01-10 16:37:35 +01:00
parent a8708ffc56
commit caef416077
2 changed files with 8 additions and 5 deletions

View File

@ -27,7 +27,7 @@ def color_name(request):
return request.param
@pytest.fixture(params=["smooth", "coarse"])
@pytest.fixture(params=["smooth", "coarse", "neutral"])
def texture_name(request):
return request.param
@ -44,16 +44,19 @@ def color(color_name):
@pytest.fixture
def texture_fn(texture_name):
def texture_fn(texture_name, size):
if texture_name == "smooth":
return lambda image: cv.blur(image, (5, 5))
return lambda image: cv.blur(image, np.array(size) // 100)
elif texture_name == "coarse":
return lambda image: cv.filter2D(image, -1, np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]]))
elif texture_name == "neutral":
return lambda image: image
@pytest.fixture
def texture(texture_fn, size, color):
noise = np.random.rand(*size) * 255
noise = texture_fn(noise)
noise = color_shift_noise(noise, color)
noise = zero_out_below_threshold(noise, 0.1)
return Image.fromarray(noise.astype("uint8"))
@ -107,7 +110,7 @@ def zero_out_below_threshold(texture, threshold):
texture[:, :, 0] = (texture[:, :, 0] / texture[:, :, 0].max()) * 255
texture[:, :, 1] = (texture[:, :, 1] / texture[:, :, 1].max()) * 255
texture[:, :, 2] = (texture[:, :, 2] / texture[:, :, 2].max()) * 255
texture[:, :, 3] = 50
texture[:, :, 3] = 25
threshold_mask = texture[:, :, 0] >= threshold
texture[~threshold_mask] = [0, 0, 0, 0]

View File

@ -3,4 +3,4 @@ from cv_analysis.utils.display import show_image
def test_blank_page(blank_page):
pass
# show_image(blank_page)
show_image(blank_page)