示例#1
0
def test_q6e_error_thrown_with_invalid_amount():
    img = imread(pathlib.Path() / 'samples' / 'rubiks-cube.jpg')

    with pytest.raises(ValueError):
        single_tone(img, 0, 0.5, -1.0)

    with pytest.raises(ValueError):
        single_tone(img, 0, 0.5, 2.0)
示例#2
0
def test_q6c_error_thrown_with_invalid_hue():
    img = imread(pathlib.Path() / 'samples' / 'rubiks-cube.jpg')

    with pytest.raises(ValueError):
        single_tone(img, -10, 0.5)

    with pytest.raises(ValueError):
        single_tone(img, 400, 0.5)
示例#3
0
def test_q6d_error_thrown_with_invalid_saturation():
    img = imread(pathlib.Path() / 'samples' / 'rubiks-cube.jpg')

    with pytest.raises(ValueError):
        single_tone(img, 0, -0.5)

    with pytest.raises(ValueError):
        single_tone(img, 0, 1.5)
示例#4
0
def test_q6a_perform_single_toning(tmp_path):
    img = imread(pathlib.Path() / 'samples' / 'rubiks-cube.jpg')
    out = single_tone(img, 45, 1, 0.5)  # tones with a yellow-ish colour
    imsave(tmp_path / 'single-tone.png', img_as_ubyte(out))
示例#5
0
def test_q6b_perform_single_toning_with_greyscale(tmp_path):
    img = imread(pathlib.Path() / 'samples' / 'rubiks-cube.jpg', as_gray=True)
    imsave(tmp_path / 'grey.png', img_as_ubyte(img))
    out = single_tone(img, 45, 1, 1.0)
    imsave(tmp_path / 'single-tone.png', img_as_ubyte(out))