Professional Documents
Culture Documents
Sesion 7 8
Sesion 7 8
Edge detection
depth discontinuity
illumination discontinuity
intensity function
image (along horizontal scanline) first derivative
edges correspond to
extrema of derivative
Image gradient
f*g
d
( f g)
dx
d
• To find edges, look for peaks in ( f g)
dx
Derivative theorem of convolution
• Differentiation is convolution, and convolution
is associative: d ( f g ) f d g
dx dx
• This saves us one operation:
d
g
dx
d
f g
dx
Derivative of Gaussian filter
* [1 -1] =
x-direction y-direction
thresholding
Example
thinning
(non-maximum suppression)
Non-maximum suppression
At q, we have a
maximum if the
value is larger
than those at
both p and at r.
Interpolate to
get these
values.
Edge linking
original image
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('messi5.jpg',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()