detection helps in the detection of major features of an image edges,lines,etc.
Mainly the edges in an image are detected in 2 ways:
- Points representing the local maxima or local minima of the first derivative
- Points representing the zero crossing of the second derivative.
Some of the edge filters available in OpenCV are:
1.Laplace Filter:
Laplace Operator is represented as:
The mask representing the Laplacian Operator can easily be derived by adding the double derivatives in both x and y directions as obtained from the Finite Difference Method. Taylor series approximation is done in order to find the double derivatives
0 | 1 | 1 |
1 | -4 | 1 |
0 | 1 | 0 |
The Laplacian Operator can detect edges in any direction.
import cv2 as cv
img= cv.LoadImage(‘pu-balls-452.jpg’)
cv.NamedWindow(‘True’,cv.CV_WINDOW_NORMAL)
cv.ShowImage(‘True’,img)
lap=cv.CreateImage(cv.GetSize(img),8,3)
cv.Laplace(img,lap,3)
cv.NamedWindow(‘laplacian kernel 3’,cv.CV_WINDOW_NORMAL)
cv.ShowImage(‘laplacian kernel 3’,lap)
cv.Laplace(img,lap,5)
cv.NamedWindow(‘laplacian kernel 5’,cv.CV_WINDOW_NORMAL)
cv.ShowIMage(‘laplacian kernel 5’,lap)
cv.WaitKey(20000)
cv.DestroyAllWindow()