def test_vprewitt_horizontal(): """Vertical prewitt on a horizontal edge should be zero""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vprewitt(image) eps = .000001 assert (np.all(np.abs(result) < eps))
def test_vprewitt_horizontal(): """Vertical prewitt on a horizontal edge should be zero""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vprewitt(image) eps = .000001 assert (np.all(np.abs(result) < eps))
def test_vprewitt_vertical(): """Vertical prewitt on an edge should be a vertical line.""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vprewitt(image) # Fudge the eroded points j[np.abs(i) == 5] = 10000 assert (np.all(result[j == 0] == 1)) assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
def test_vprewitt_vertical(): """Vertical prewitt on an edge should be a vertical line""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vprewitt(image) # Fudge the eroded points j[np.abs(i) == 5] = 10000 assert (np.all(result[j == 0] == 1)) eps = .000001 assert (np.all(np.abs(result[np.abs(j) > 1]) < eps))
def test_vprewitt_vertical(): """Vertical prewitt on an edge should be a vertical line""" i, j = np.mgrid[-5:6, -5:6] image = (j >= 0).astype(float) result = F.vprewitt(image) # Fudge the eroded points j[np.abs(i) == 5] = 10000 assert (np.all(result[j == 0] == 1)) eps = .000001 assert (np.all(np.abs(result[np.abs(j) > 1]) < eps))
def test_vprewitt_horizontal(): """Vertical prewitt on a horizontal edge should be zero.""" i, j = np.mgrid[-5:6, -5:6] image = (i >= 0).astype(float) result = F.vprewitt(image) assert_allclose(result, 0)
def test_vprewitt_mask(): """Vertical prewitt on a masked array should be zero.""" np.random.seed(0) result = F.vprewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) assert_allclose(result, 0)
def test_vprewitt_zeros(): """Vertical prewitt on an array of all zeros.""" result = F.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert_allclose(result, 0)
def test_vprewitt_zeros(): """Vertical prewitt on an array of all zeros""" result = F.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0))
def vedges(self): """x=vedges(): returns a parameterization of the number of vertical edges versus total edges in an RGB image""" hprew=filter.hprewitt(self.gray) vprew=filter.vprewitt(self.gray) vfrac=vprew.sum()/(vprew.sum()+hprew.sum()) return vfrac
import scipy.misc from skimage import filter from scipy.misc.pilutil import Image # opening the image and converting it to grayscale a = Image.open('../Figures/steps1.png').convert('L') # performing vertical Prewitt b = filter.vprewitt(a) # b is converted from an ndarray to an image b = scipy.misc.toimage(b) b.save('../Figures/vprewitt_output.png')
def test_vprewitt_mask(): """Vertical prewitt on a masked array should be zero""" np.random.seed(0) result = F.vprewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) assert (np.all(result == 0))
def test_vprewitt_zeros(): """Vertical prewitt on an array of all zeros""" result = F.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool)) assert (np.all(result == 0))
def test_00_01_mask(self): """Vertical prewitt on a masked array should be zero""" np.random.seed(0) result = F.vprewitt(np.random.uniform(size=(10, 10)), np.zeros((10, 10), bool)) assert (np.all(result == 0))