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_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_2D(self): cut.along_path(None, None, shape=(3, 3, 3)).next()
def test_completely_outside(self): p = (50, 50) image = np.arange(12).reshape((4, 3)) cp = cut.along_path(p, image, shape=(5, 5), centre=(0, 0)) list(cp)
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)