ImageComponents.py
1.22 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
import sys
import cv2
import numpy as np
from matplotlib import pyplot as plt
def Corners():
image = None
while (image is None):
if sys.version_info >= (3, 0):
image = str(input('\tImage to use ? By default couleur.png \n'))
else:
image = str(raw_input('\tImage to use ? By default couleur.png \n'))
if not image:
image = 'couleur.png'
image = cv2.imread(str(image))
img = image.copy()
gray= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray, 5, 5, 0.15)
dst = cv2.dilate(dst, None)
img[dst>0.01*dst.max()] = [0,0,255]
cv2.imshow('dst', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
return
def Edges():
image = None
while (image is None):
if sys.version_info >= (3, 0):
image = str(input('\tImage to use ? By default couleur.png \n'))
else:
image = str(raw_input('\tImage to use ? By default couleur.png \n'))
if not image:
image = 'couleur.png'
image = cv2.imread(str(image))
img = image.copy()
edges = cv2.Canny(img, 100, 200)
plt.subplot(121),plt.imshow(img,cmap='gray')
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
return