-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhigh_pass_kernel.py
More file actions
48 lines (29 loc) · 1.1 KB
/
high_pass_kernel.py
File metadata and controls
48 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import matplotlib.pyplot as plt
import matplotlib.image as img
import numpy as np
import grayscale as gray
def multiply(new_image,matrix,image,i,j,color):
value = 0
x_range = len(matrix)
y_range = len(matrix[0])
for x in range(3):
for y in range(3):
new_image[i][j][0] += matrix[x][y]*image[i+x][j+y][0]
new_image[i][j][1] += matrix[x][y]*image[i+x][j+y][1]
new_image[i][j][2] += matrix[x][y]*image[i+x][j+y][2]
def edge_detect(image_name,image):
width,height = image.shape[:2]
matrix = np.array([[0,-1,0],[-1,4,-1],[0,-1,0]])
new_image = np.zeros([width-2,height-2,3])
#print(new_image)
grayimage = gray.convert(image,image_name)
for i in range(width-2):
for j in range(height-2):
multiply(new_image,matrix,grayimage,i,j,0)
plt.imshow(new_image)
plt.show()
if __name__ == "__main__":
print("\n\n This program is For detection of Edges using high pass Kernel \n\n")
image_name = input("Enter the Image name : ")
image = img.imread(image_name)
edge_detect(image_name,image)