|
6 | 6 | #This script can be used for edge-detection without the use of any inbuilt openCV libraries
|
7 | 7 | #Here the sobel filter is applied after blurring the image.
|
8 | 8 |
|
9 |
| -kernelblur = np.array([1/16,1/8,1/16,1/8,1/4,1/8,1/16,1/8,1/16]).reshape(3,3) |
10 |
| -kernelsobelX = np.array([-1,-2,-1,0,0,0,1,2,1]).reshape(3,3) |
| 9 | +kernelblur = np.array([1/16, 1/8, 1/16, 1/8, 1/4, 1/8, 1/16, 1/8, 1/16]).reshape(3, 3) |
| 10 | +kernelsobelX = np.array([-1, -2, -1, 0, 0, 0, 1, 2, 1]).reshape(3, 3) |
11 | 11 | kernelsobelY = kernelsobelX.transpose()
|
12 | 12 |
|
13 | 13 | def convolute(img, kernel, height, width):
|
@@ -64,8 +64,8 @@ def sobel(img):
|
64 | 64 | resultant = []
|
65 | 65 | for i in range(height-1):
|
66 | 66 | for j in range(width-1):
|
67 |
| - in_x = pow(convoluted_X[i,j] ,2) |
68 |
| - in_y = pow(convoluted_Y[i,j] , 2) |
| 67 | + in_x = pow(convoluted_X[i, j], 2) |
| 68 | + in_y = pow(convoluted_Y[i, j], 2) |
69 | 69 | gradient = sqrt(in_x + in_y)
|
70 | 70 | reusultant.append(grad)
|
71 | 71 | resultant = np.array(resultant).reshape(height-1, width-1)
|
|
0 commit comments