コード例 #1
0
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
def test_count_1_object_irregular():
    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
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
def test_count_1_object_rectangle():
    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
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
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.]])
    assert_equal(count_objects(a), 2)
コード例 #4
0
ファイル: script.py プロジェクト: cp192/cs4geos19
from scipy.ndimage import imread

from counting import count_objects

if __name__ == '__main__':
    img = imread('img/specimen_example.png', flatten=True) // 255
    count = count_objects(img)
    print('Number of objects:', count)
コード例 #5
0
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
def test_count_no_object():
    a = np.zeros([6, 6], dtype=np.float64)
    assert_equal(count_objects(a), 0)
コード例 #6
0
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
def test_count_all_ones():
    a = np.ones([6, 6], dtype=np.int32)
    assert_equal(count_objects(a), 1)
コード例 #7
0
ファイル: test_counting.py プロジェクト: cp192/cs4geos19
def test_count_1_object():
    a = np.zeros([6, 6], dtype=np.float64)
    a[1:-1, 1:-1] = 1
    assert_equal(count_objects(a), 1)