1.1k likes | 1.43k Vues
Image Transforms. 主講人:虞台文. Content. Overview Convolution Edge Detection Gradients Sobel operator Canny edge detector Laplacian Hough Transforms Geometric Transforms Affine Transform Perspective Transform Histogram Equalization. Image Transforms. Overview. Image Transform Concept.
E N D
Image Transforms 主講人:虞台文
Content • Overview • Convolution • Edge Detection • Gradients • Sobel operator • Canny edge detector • Laplacian • Hough Transforms • Geometric Transforms • Affine Transform • Perspective Transform • Histogram Equalization
Image Transforms Overview
Image Transforms Convolution
g(x,y)is known as convolution kernel. Image Convolution
g(x,y)is known as convolution kernel. Image Convolution height2h + 1 width2w + 1
g(x,y)is known as convolution kernel. Image Convolution height2h + 1 width2w + 1
OpenCV Implementation Image Filter void cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, CvPoint anchor=cvPoint(-1, -1) );
Deal with Convolution Boundaries void cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, int bordertype, CvScalar value=cvScalarAll(0) );
Image Transforms Edge Detection
Edge Detection • Convert a 2D image into a set of curves • Extracts salient features of the scene • More compact than pixels
Origin of Edges surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity Edges are caused by a variety of factors
How can you tell that a pixel is on an edge? Edge Detection
Step Edges Line Edges Roof Edge Edge Types
I x Real Edges • We want an Edge Operator that produces: • Edge Magnitude • Edge Orientation • High Detection Rate and Good Localization Noisy and Discrete!
Derivatives of Image in 1D • Edges can be characterized as either: • local extrema of I(x) • zero-crossings of 2I(x) 1D image gradient Laplacian
2D-Image Gradient • Gives the direction of most rapid change in intensity • Gradient direction: • Edge strength:
To precisely locate the edge, we need to thin. Ideally, edges should be only one point thick. T Non-zero edge width Classification of Points
The Sobel Operators Good Localization Noise Sensitive Poor Detection Sobel (3 x 3): Sobel (5 x 5): Poor Localization Less Noise Sensitive Good Detection
OpenCV Implementation The Sobel Operators void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size = 3 );
OpenCV Implementation The Scnarr Operator void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size = 3 ); aperture_size CV_SCHARR
Exercise Download Test Program
Effects of Noise Consider a single row or column of the image Where is the edge?
Solution: Smooth First Where is the edge?
Gaussian: Derivative Theorem of Convolution
Derivative Theorem of Convolution saves us one operation.
Optimal Edge Detection: Canny • Assume: • Linear filtering • Additive iidGaussian noise • An "optimal" edgedetector should have: • Good Detection Filter responds to edge, not noise. • Good Localization detected edge near true edge. • Single Response one per edge.
Optimal Edge Detection: Canny • Based on the first derivative of a Gaussian • Detection/Localization trade-off • More smoothing improves detection • And hurts localization.
Stages of the Canny algorithm • Noise reduction Size of Gaussian filter • Finding the intensity gradient of the image • Non-maximum suppression • Tracing edges through the image and hysteresisthresholding High threshold Low threshold
Parameters of Canny algorithm • Noise reduction • Size of Gaussian filter • Finding the intensity gradient of the image • Non-maximum suppression • Tracing edges through the image and hysteresis thresholding • High threshold • Low threshold
OpenCV Implementation The Canny Operator void cvCanny( const CvArr* img, CvArr* edges, double lowThresh, double highThresh, int apertureSize = 3 );
Example: Canny Edge Detector Download Test Program
Review:Derivatives of Image in 1D • Edges can be characterized as either: • local extrema of I(x) • zero-crossings of 2I(x) 1D image gradient Laplacian
Laplacian • A scalar isotropic. • Edge detection: Find all points for which 2I(x, y) = 0 • Nothinning is necessary. • Tends to produce closed edge contours.
OpenCV Implementation The Discrete Laplacian Operators void cvLaplace( const CvArr* src, CvArr* dst, int apertureSize = 3 );
Laplician for Edge Detection Find zero-crossing on the Laplacian image.
Zero Crossing Detection There is a little bug in the above algorithm. Try to design your own zero-crossing detection algorithm.
Example:Laplician for Edge Detection Download Test Program
Example:Laplacian for Image Sharpening Sharpened Image
Laplacian of Gaussian (LoG) Gaussian: