Monday, July 31, 2017

Canny Edge Detection in OpenCV

https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_canny/py_canny.html

sudo apt-get install python-tk
pip install opencv_python
pip install numpy
pip install matplotlib

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('output_3032.png',0)
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()

$ python ../canny3.py 


No comments:

Post a Comment