You are on page 1of 1

img = cv2.imread('Fig0438(a)(bld_600by600).

tif,0)

h, w = img.shape
horizontal = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]])
vertical = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]])
newhorizontallmage = np.zeros((h, w))
newverticallmage = np.zeros((h, w))
newgradientlmage = np.zeros((h, w))
for i in range(1, h - 1):
for j in range(1, w- 1):
horizontalGrad = (horizontal[0, 0] * img[i - 1, j - 1]) +1
(horizontal[0, 1] * img[i - 1, j]) +1
(horizontal[0, 2] * img[i - 1, j + 1]) + \
(horizontal[1, 0] * img[i, j - 1]) +1
(horizontal[1, 1] * img[i, j]) +1
(horizontal[1, 2] * img[i, j + 1]) +1
(horizontal[2, 0] * img[i + 1, j - 1]) +1
(horizontal[2, 1] * img[i + 1, j]) +1
(horizontal[2, 2] * img[i + 1, j + 1])

You might also like