Exemple #1
0
def test_two_connectivity():
    # fmt: off
    expected = cp.array([[0, 0, 0, 1, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0]],
                        bool)
    # fmt: on
    observed = remove_small_objects(test_image, min_size=7, connectivity=2)
    assert_array_equal(observed, expected)
Exemple #2
0
def test_uint_image():
    # fmt: off
    labeled_image = cp.array(
        [[2, 2, 2, 0, 1], [2, 2, 2, 0, 1], [2, 0, 0, 0, 0], [0, 0, 3, 3, 3]],
        dtype=cp.uint8)
    expected = cp.array(
        [[2, 2, 2, 0, 0], [2, 2, 2, 0, 0], [2, 0, 0, 0, 0], [0, 0, 3, 3, 3]],
        dtype=cp.uint8)
    # fmt: on
    observed = remove_small_objects(labeled_image, min_size=3)
    assert_array_equal(observed, expected)
Exemple #3
0
def test_negative_input():
    negative_int = cp.random.randint(-4, -1, size=(5, 5))
    with pytest.raises(ValueError):
        remove_small_objects(negative_int)
Exemple #4
0
def test_float_input():
    float_test = cp.random.rand(5, 5)
    with pytest.raises(TypeError):
        remove_small_objects(float_test)
Exemple #5
0
def test_single_label_warning():
    # fmt: off
    image = cp.array([[0, 0, 0, 1, 0], [1, 1, 1, 0, 0], [1, 1, 1, 0, 0]], int)
    # fmt: on
    with expected_warnings(['use a boolean array?']):
        remove_small_objects(image, min_size=6)
Exemple #6
0
def test_in_place():
    image = test_image.copy()
    observed = remove_small_objects(image, min_size=6, in_place=True)
    assert_equal(observed is image, True,
                 "remove_small_objects in_place argument failed.")