ImageComponents.py 1022 Bytes
import cv2
import numpy as np
from matplotlib import pyplot as plt

def Corners():
	image = None
	while (image is None):
		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):
		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