예제 #1
0
 def test_count_1_object_irregular(self):
     a = np.array([[0., 0., 0., 0., 0.], [0., 1., 1., 1., 0.],
                   [0., 1., 1., 1., 1.], [0., 1., 1., 1., 0.],
                   [0., 0., 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.]])
     assert_equal(count_objects(a), 1)
예제 #2
0
 def test_count_1_object_rectangle(self):
     a = np.array([[0., 0., 0., 0., 0.], [0., 1., 1., 1., 0.],
                   [0., 1., 1., 1., 1.], [0., 1., 1., 1., 0.],
                   [0., 0., 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.]])
     assert_equal(count_objects(a), 1)
예제 #3
0
 def test_count_objects_2_objects(self):
     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.]])
     assert_equal(count_objects(a), 2)
예제 #4
0
 def test_count_objects(self):
     a = np.zeros([6, 6], dtype=np.float64)
     assert_equal(count_objects(a), 0)
예제 #5
0
 def test_count_all_ones(self):
     a = np.ones([6, 6], dtype=np.int32)
     assert_equal(count_objects(a), 1)
예제 #6
0
 def test_count_1_object(self):
     a = np.zeros([6, 6], dtype=np.float64)
     a[1:-1, 1:-1] = 1
     assert_equal(count_objects(a), 1)