Exemplo n.º 1
0
def test_count_1_object_rectangle():
    a = np.array(
      [[ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  1.,  1.,  0.],
       [ 0.,  1.,  1.,  1.,  0.],
       [ 0.,  1.,  1.,  1.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.]], dtype=np.int32)
    assert_equal(count_objects(a), 1)
Exemplo n.º 2
0
def test_count_objects_2_objects():
    a = np.array(
      [[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  1.,  1.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]], dtype=np.int32)
    assert_equal(count_objects(a), 2)
Exemplo n.º 3
0
def test_count_zero_objects():
    img = np.array([[0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.],
                    [0., 0., 0., 0., 0.], [0., 0., 0., 0., 0.]],
                   dtype=np.int32)
    assert (count_objects(img) == 0)
Exemplo n.º 4
0
def test_count_1_object():
    a = np.zeros([6, 6], dtype=np.int32)
    a[1:-1, 1:-1] = 1
    assert_equal(count_objects(a), 1)
Exemplo n.º 5
0
def test_count_all_ones():
    a = np.ones([6, 6], dtype=np.int32)
    assert_equal(count_objects(a), 1)
Exemplo n.º 6
0
def test_count_no_object():
    a = np.zeros([6, 6], dtype=np.int32)
    assert_equal(count_objects(a), 0)