def test_00_01_mask(self): """Prewitt on a masked array should be zero""" np.random.seed(0) result = F.prewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) eps = .000001 assert (np.all(np.abs(result) < eps))
def test_01_02_vertical(self): """Prewitt on a vertical edge should be a vertical line""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.prewitt(image) eps = .000001 j[np.abs(i) == 5] = 10000 assert (np.all(result[j == 0] == 1)) assert (np.all(np.abs(result[np.abs(j) > 1]) < eps))
def test_01_02_vertical(self): """Prewitt on a vertical edge should be a vertical line""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.prewitt(image) eps = .000001 j[np.abs(i)==5] = 10000 assert (np.all(result[j == 0] == 1)) assert (np.all(np.abs(result[np.abs(j) > 1]) < eps))
def test_01_01_horizontal(self): """Prewitt on an edge should be a horizontal line""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.prewitt(image) # Fudge the eroded points i[np.abs(j) == 5] = 10000 eps = .000001 assert (np.all(result[i == 0] == 1)) assert (np.all(np.abs(result[np.abs(i) > 1]) < eps))
def test_00_00_zeros(self): """Prewitt on an array of all zeros""" result = F.prewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0))