def test_colville_branchpoints(self, known_net): """Test branchpoints on colville skeleton.""" known_net.skeletonize() Iskel = known_net.Iskel Ipbs = im_utils.skel_branchpoints(Iskel) # make assertions assert np.max(Ipbs) == 1 assert np.min(Ipbs) == 0 assert np.sum(Ipbs) == 570
def test_brahma_branchpoints(self, known_river): """Tests branchpoints on brahma skeleton.""" known_river.skeletonize() Iskel = known_river.Iskel Ipbs = im_utils.skel_branchpoints(Iskel) # make assertions assert np.max(Ipbs) == 1 assert np.min(Ipbs) == 0 assert np.sum(Ipbs) == 1371
def test_plus(self): """Test a + configuration.""" I = np.zeros((5, 5)) I[:, 2] = 1 I[2, :] = 1 Ipbs = im_utils.skel_branchpoints(I) assert np.all(Ipbs == np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]))
def test_three_horiz(self): """Test 3 branchpoints in a row.""" I = np.zeros((5, 10)) I[2, :] = 1 I[1:4, 3:6] = 1 Ipbs = im_utils.skel_branchpoints(I) assert np.all(Ipbs == np.array( [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]))
def test_cross(self): """Test a x configuration.""" I = np.zeros((5, 5)) for i in range(0, 5): I[i, i] = 1 I[i, -(i + 1)] = 1 Ipbs = im_utils.skel_branchpoints(I) assert np.all(Ipbs == np.array([[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]))
def test_three_vert(self): """Test 3 branchpoints in a column.""" I = np.zeros((10, 5)) I[:, 2] = 1 I[3:6, 1:4] = 1 Ipbs = im_utils.skel_branchpoints(I) assert np.all(Ipbs == np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 0], [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]]))
def test_simple(self): """Simple branchpoint test.""" I = np.zeros((5, 5)) I[0:3, 2] = 1 I[3, 1] = 1 I[3, 3] = 1 I[4, 0] = 1 I[4, 4] = 1 Ipbs = im_utils.skel_branchpoints(I) assert np.all(Ipbs == np.array([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]))