def test_colour_cut(self): p = coord_path.build(coord_path.line((0, 0), (0, 0))) image = np.arange(27).reshape((3, 3, 3)) cp = cut.along_path(p,image, shape=(3, 3), centre=(0, 0)) cut_img = cp.next() assert_equal(cut_img.shape, (3, 3, 3)) assert_equal(cut_img[:], image[:])
def test_colour_cut(self): p = coord_path.build(coord_path.line((0, 0), (0, 0))) image = np.arange(27).reshape((3, 3, 3)) cp = cut.along_path(p, image, shape=(3, 3), centre=(0, 0)) cut_img = cp.next() assert_equal(cut_img.shape, (3, 3, 3)) assert_equal(cut_img[:], image[:])
def test_centre_cut(self): p = coord_path.build(coord_path.line((1, 1), (1, 1))) image = np.arange(12).reshape((4, 3)) cp = cut.along_path(p, image, shape=(3, 3)) cut_img = cp.next() assert_equal(cut_img.shape, (3, 3)) assert_array_almost_equal(cut_img, [[0, 1, 2], [3, 4, 5], [6, 7, 8]])
def test_centre_cut(self): p = coord_path.build(coord_path.line((1, 1), (1, 1))) image = np.arange(12).reshape((4,3)) cp = cut.along_path(p, image, shape=(3,3)) cut_img = cp.next() assert_equal(cut_img.shape, (3,3)) assert_array_almost_equal(cut_img, [[0, 1, 2], [3, 4, 5], [6, 7, 8]])
def add_line(img, c0, c1, col=[1., 0, 0]): p = cp.build(cp.line(c0, c1)) add_path(img, p, col)
def test_line(self): l = coord_path.line((0, 0), (0, 1)) c = [coord for coord in l] assert_array_equal(c[0], [0, 0]) assert_array_equal(c[-1], [0, 1]) assert (len(c) >= 2)
def test_dtype(self): p = coord_path.build(coord_path.line((0, 0), (0, 0))) image = np.arange(12).reshape((4, 3)).astype(np.uint8) cut_img = cut.along_path(p, image).next() assert_equal(image.dtype, cut_img.dtype)
def test_outside(self): p = coord_path.build(coord_path.line((4, 4), (4, 4))) image = np.arange(12).reshape((4, 3)) cp = cut.along_path(p,image,shape=(5, 5),centre=(0, 0)) list(cp)
def add_line(img,c0,c1,col=[1.,0,0]): p = cp.build(cp.line(c0,c1)) add_path(img,p,col)
def test_line(self): l = coord_path.line((0, 0), (0, 1)) c = [coord for coord in l] assert_array_equal(c[0], [0, 0]) assert_array_equal(c[-1], [0, 1]) assert(len(c) >= 2)
def test_outside(self): p = coord_path.build(coord_path.line((4, 4), (4, 4))) image = np.arange(12).reshape((4, 3)) cp = cut.along_path(p, image, shape=(5, 5), centre=(0, 0)) list(cp)