Showing posts with label opencv canny edge detection python. Show all posts
Showing posts with label opencv canny edge detection python. Show all posts

Saturday, January 30, 2021

Canny Edge Detection Opencv Python Source code

The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images.

Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed.

·         It has been widely applied in various computer vision systems.

·         Canny has found that the requirements for the application of edge detection on diverse vision systems are relatively similar.

·         Thus, an edge detection solution to address these requirements can be implemented in a wide range of situations.


Full Demo video on YouTube in the below link. 

Please don't forget to like, share and subscribe to the channel for related videos.

https://youtu.be/z2TkXY50ZLw

Full Source Code

# -*- coding: utf-8 -*-

"""

Created on Fri Jan 29 15:38:12 2021

@author: rarekindphdsolutions

"""

import cv2

import numpy as np

from matplotlib import pyplot as plt

img = cv2.imread('sample.jpg',0)

edges = cv2.Canny(img,100,200)

plt.imshow(img,cmap = 'gray')

plt.title('Gray Image'), plt.xticks([]), plt.yticks([])

plt.show()

plt.imshow(edges,cmap = 'gray')

plt.title('Edge Image'), plt.xticks([]), plt.yticks([])

plt.show()