コード例 #1
0
def process_image(image,
                  filters,
                  ROI=None,
                  return_predictions=False,
                  combine_results=False,
                  sort_filters=True):
    """Processes one image with process-function and returns the resulting value.
    """
    return qualipy.process(image, filters, ROI, return_predictions,
                           combine_results, sort_filters)
コード例 #2
0
def test_works_with_magic_thresholds():
    assert qualipy.process(TEST_IMG, [
        Framed() == 1,
        Pattern() > 0.3,
        HDR() >= 0.5,
        UnconventionalSize() <= 16 / 9.,
        Exposure() != 1,
        Highlights() < 0.1
    ]) == {
        TEST_IMG: False
    }
コード例 #3
0
def test_fails_for_invalid_images():
    with pytest.raises(TypeError):
        assert qualipy.process(0, [Framed()])
コード例 #4
0
def test_fails_for_invalid_amount_of_ROIs():
    with pytest.raises(ValueError):
        assert qualipy.process([TEST_IMG, TEST_IMG2], [Framed()],
                               [(0, 0, 100, 100)])
コード例 #5
0
def test_fails_for_invalid_length_ROI():
    with pytest.raises(TypeError):
        assert qualipy.process(TEST_IMG, [Framed()], (10, 10, 100))
コード例 #6
0
def test_works_correctly_for_multiple_ROIs():
    assert qualipy.process([TEST_IMG, TEST_IMG2], [Framed()],
                           [(0, 0, 100, 100), None])
コード例 #7
0
def test_works_correctly_for_valid_ROI():
    assert qualipy.process(TEST_IMG, [Framed()], (0, 0, 100, 100))
コード例 #8
0
def test_processes_single_image_correctly():
    assert qualipy.process(TEST_IMG, [Framed()])
コード例 #9
0
def test_returns_boolean_for_each_filter_when_not_combining_results():
    assert qualipy.process(TEST_IMG, [Framed()], None, False,
                           False)[TEST_IMG]['framed'] == 0.
コード例 #10
0
def test_returns_float_when_correct_parameter_is_set():
    assert qualipy.process(TEST_IMG, [Framed()], None,
                           True)[TEST_IMG]['framed'] == 0.
    assert qualipy.process(TEST_IMG, [Framed()], None, True,
                           False)[TEST_IMG]['framed'] == 0.
コード例 #11
0
def test_returns_False_when_some_filters_return_positive():
    assert qualipy.process(TEST_IMG2, [Framed(), Pattern()]) == {
        TEST_IMG2: False
    }
コード例 #12
0
def test_returns_True_when_all_filters_return_negative():
    assert qualipy.process(TEST_IMG, [Framed(), Pattern()])
コード例 #13
0
def test_images_exist_in_resulting_dict():
    res = qualipy.process([TEST_IMG, TEST_IMG2], [])
    assert TEST_IMG in res and TEST_IMG2 in res
コード例 #14
0
def test_processes_list_of_images_correctly():
    assert len(qualipy.process([TEST_IMG], [Framed()], None, True)) == 1
コード例 #15
0
def test_returns_true_for_no_filters():
    assert qualipy.process(TEST_IMG, []) == {TEST_IMG: True}
コード例 #16
0
 def get_prediction(path):
     return not qualipy.process(path, [filter])
コード例 #17
0
def test_ROI_can_be_None():
    assert qualipy.process(TEST_IMG, [Framed()], None)