Computer Vision (7) -- Canny

Canny's goal is to find an optimal edge detection algorithm. The meaning of optimal edge detection is:
Good Detection - Algorithms are able to identify as many actual edges in the image as possible.
Good localization - The identified edges are as close as possible to the actual edges in the actual image.
Minimal Response - Edges in the image should only be identified once, and possible image noise should not be identified as edges.
To meet these requirements Canny uses variational methods , a method of finding functions that satisfy a specific function. Optimal detection is expressed using the sum of four exponential terms, but it is very close to the first derivative of the Gaussian function .
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
import numpy as np

image = cv2.imread( "./imgs/2.jpg" )

gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)

wide = cv2.Canny(gray, 30 , 100 )
tight = cv2.Canny(gray, 180 , 240 )

f,(a1,a2) = plt.subplots( 1 , 2 , figsize = ( 200 , 200 ))
a1.set_title( "wide" )
a1.imshow(wide, cmap = 'gray' )
a2.set_title( "tight" )
a2.imshow(tight, cmap = 'gray' )
plt.show()

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326799220&siteId=291194637