Tweak page generation
This commit is contained in:
parent
a8708ffc56
commit
caef416077
11
test/fixtures/page_generation/page.py
vendored
11
test/fixtures/page_generation/page.py
vendored
@ -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]
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user