Image Transforms Content l l l Overview Convolution



![Image Transform Concept T[] Image Transform Concept T[]](https://slidetodoc.com/presentation_image_h/1dc08c4803f55d028afb847f4680fbd5/image-4.jpg)
![Image Transform Concept T[] Image Transform Concept T[]](https://slidetodoc.com/presentation_image_h/1dc08c4803f55d028afb847f4680fbd5/image-5.jpg)






































































































- Slides: 107
Image Transforms 主講人:虞台文
Content l l l Overview Convolution Edge Detection – – l l Hough Transforms Geometric Transforms – – l Gradients Sobel operator Canny edge detector Laplacian Affine Transform Perspective Transform Histogram Equalization
Image Transforms Overview
Image Transform Concept T[]
Image Transform Concept T[]
Image Transforms Convolution
g(x, y) is known as convolution kernel. Image Convolution
g(x, y) is known as convolution kernel. Image Convolution height 2 h + 1 width 2 w + 1
g(x, y) is known as convolution kernel. Image Convolution height 2 h + 1 width 2 w + 1
Some Convolution Kernels
Open. CV Implementation Image Filter void cv. Filter 2 D( const Cv. Arr* src, Cv. Arr* dst, const Cv. Mat* kernel, Cv. Point anchor=cv. Point(-1, -1) );
Deal with Convolution Boundaries void cv. Copy. Make. Border( const Cv. Arr* src, Cv. Arr* dst, Cv. Point offset, int bordertype, Cv. Scalar value=cv. Scalar. All(0) );
Image Transforms Edge Detection
Edge Detection l Convert a 2 D 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
Edge Types Step Edges Roof Edge Line Edges
Real Edges I Noisy and Discrete! x l We want an Edge Operator that produces: – – – Edge Magnitude Edge Orientation High Detection Rate and Good Localization
Derivatives of Image in 1 D image gradient Laplacian l Edges can be characterized as either: – – local extrema of I(x) zero-crossings of 2 I(x)
2 D-Image Gradient
2 D-Image Gradient l Gives the direction of most rapid change in intensity l Gradient direction: l Edge strength:
Classification of Points T l Non-zero edge width To precisely locate the edge, we need to thin. l Ideally, edges should be only one point thick.
The Sobel Operators 0 1 1 2 1 -2 0 0 0 -1 0 1 -1 -2 -1 -1 -2 0 2 1 1 2 3 2 1 -2 -3 0 3 2 2 3 5 3 2 -3 -5 0 5 3 0 0 0 -2 -3 0 3 2 -2 -3 -5 -3 -2 -1 -2 0 2 1 -1 -2 -3 -2 -1 Sobel (3 x 3): Sobel (5 x 5): Good Localization Noise Sensitive Poor Detection -1 Poor Localization Less Noise Sensitive Good Detection
Open. CV Implementation The Sobel Operators void cv. Sobel( const Cv. Arr* src, Cv. Arr* dst, int xorder, int yorder, int aperture_size = 3 );
Open. CV Implementation The Scnarr Operator void cv. Sobel( const Cv. Arr* src, Cv. Arr* dst, int xorder, int yorder, int aperture_size = 3 ); aperture_size CV_SCHARR
Demonstration
Exercise Download Test Program
Effects of Noise Consider a single row or column of the image e h t s i e r Whe dge?
Solution: Smooth First
Solution: Smooth First e h t s i e r Whe edge?
Gaussian: Derivative Theorem of Convolution
saves us one operation. Derivative Theorem of Convolution
Optimal Edge Detection: Canny l Assume: – Linear filtering Additive iid Gaussian noise – Good Detection – Good Localization – Single Response – l An "optimal" edge detector should have: Filter responds to edge, not noise. detected edge near true edge. one per edge.
Optimal Edge Detection: Canny l Based on the first derivative of a Gaussian l Detection/Localization trade-off – – More smoothing improves detection And hurts localization.
Stages of the Canny algorithm l Noise reduction Size of Gaussian filter l l l Finding the intensity gradient of the image Non-maximum suppression Tracing edges through the image and hysteresis thresholding High threshold Low threshold
Parameters of Canny algorithm l Noise reduction – l l l 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
Open. CV Implementation The Canny Operator void cv. Canny( const Cv. Arr* img, Cv. Arr* edges, double low. Thresh, double high. Thresh, int aperture. Size = 3 );
Example: Canny Edge Detector Download Test Program
Review: Derivatives of Image in 1 D image gradient Laplacian l Edges can be characterized as either: – – local extrema of I(x) zero-crossings of 2 I(x)
Laplacian l A scalar isotropic. l Edge detection: Find all points for which 2 I(x, y) = 0 l No thinning is necessary. l Tends to produce closed edge contours.
Laplacian
Discrete Laplacian Operators
Open. CV Implementation The Discrete Laplacian Operators void cv. Laplace( const Cv. Arr* src, Cv. Arr* dst, int aperture. Size = 3 );
Example
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
Laplacian for Image Sharpening
Example: Laplacian for Image Sharpening Sharpened Image
Laplacian of Gaussian (Lo. G) Gaussian:
Some Lo. G Convolution Kernels
by Laplacian Example: Lo. G for Edge Detection by Lo. G
Image Transforms Hough Transforms
Goal of Hough Transforms l l A technique to isolate the curves of a given shape / shapes in a given image Classical Hough Transform – l can locate regular curves like straight lines, circles, parabolas, ellipses, etc. Generalized Hough Transform – can be used where a simple analytic description of feature is not possible
HT for Line Detection A line in xy-plane is a point in mb-plane. y b (m, b) x m
A line in xy-plane is a point in mb-plane. HT for Line Detection All lines passing through a point in xy-plane is a line in mb-plane. y b (m 2, b 2) (m 1, b 1) (m 3, b 3) x m
A line in xy-plane is a point in mb-plane. All lines passing through a point in xy-plane is a line in mb-plane. HT for Line Detection Given a point in xy-plane, we draw a line in mb-plane. y b (m 2, b 2) (m 1, b 1) (m 3, b 3) x m
A line in xy-plane is a point in mb-plane. Given a point in xy-plane, we draw a line in mb-plane. HT for Line Detection A line in xy-plane is then transformed in to a set of lines in mb-plane, which intersect at a common point. y b (m, b) x m
A line in xy-plane is a point in mb-plane. Given a point in xy-plane, we draw a line in mb-plane. HT for Line Detection ? e l b a t ? i t u n s e n ntatio implem How to e r p e r b m s I se A line in xy-plane is then transformed in to a set of lines in mb-plane, which intersect at a common point. y b (m, b) x m
HT Line Detection by -representation A line in xy-plane is a point in -plane. y ( , ) x
A line in xy-plane is a point in -plane. HT Line Detection by -representation All lines passing through a point in xy-plane is a curve in -plane. y 3 4 3 2 4 2 1 1 x
A line in xy-plane is a point in -plane. All lines passing through a point in xy-plane is a curve in -plane. HT Line Detection by -representation Given a point in xy-plane, we draw a curve in -plane. y 3 4 3 2 4 2 1 1 x
A line in xy-plane is a point in -plane. Given a point in xy-plane, we draw a curve in -plane. HT Line Detection by -representation A line in xy-plane is then transformed in to a set of curves in -plane, which intersect at a common point. y ( , ) x
A line in xy-plane is a point in -plane. Given a point in xy-plane, we draw a curve in -plane. A line in xy-plane is then transformed in to a set of curves in -plane, which intersect at a common point. HT Line Detection by -representation
Open. CV Implementation Hough Line Transform Cv. Seq* cv. Hough. Lines 2( Cv. Arr* image, void* line_storage, int method, double rho, double theta, int threshold, double param 1 = 0, double param 2 = 0 );
Example: Hough Line Transform Download Test Program
Hough Circle Transform Circle equation: r y b x image space a parameter space
g n i m u s n o c e m i t & e v i t c e f f e n i t s o C Hough Circle Transform Circle equation: r y b x image space a parameter space
Hough Gradient Method Circle equation: Parametric form: y x image space
Hough Gradient Method The value of can be obtained Circle equation: from the edge detection process. Parametric form: y x image space
Hough Gradient Method Circle equation: l y l l l x image space l Quantize the parameter space for the parameters a and b. Zero the accumulator array M(a, b). Compute the gradient magnitude G(x, y) and angle (x, y). For each edge (x 0, y 0) point in G(x, y), increment all points in the accumulator array M(a, b) along the line Local maxima in the accumulator array correspond to centers of circles in the image.
Open. CV Implementation Hough Circle Transform Cv. Seq* cv. Hough. Circles( Cv. Arr* image, void* circle_storage, int method, double dp, double min_dist, double param 1=100, double param 2=100 int min_radius=0, int max_radius=0 );
Example: Hough Circle Transform Download Test Program
Image Transforms Geometric Transforms
Geometric Transforms Stretch, Shrink, Warp, and Rotate
Scaling , Rotation, Translation Scaling Rotation Translation
Scaling , Rotation + Translation Scaling + Translation Rotation + Translation
Homogeneous Coordinate
Scaling , Rotation + Translation Scaling + Translation 2 3 matrix Rotation + Translation 2 3 matrix
Affine Transformation l An affine transformation is any transformation that can be expressed in the form of a matrix multiplication followed by a vector addition. – In Open. CV the standard style of representing such a transformation is as a 2 -by-3 matrix. 2 3 matrix
Affine Transformation
Get. Affine. Transform
Get Affine Transform
Get 2 D Rotation Matrix
Warp. Affine
Get. Quadrangle. Sub. Pix
Download Test Program Example: Affine Transform
Get. Quadrangle. Sub. Pix
Sparse Affine Transformation
Perspective Transform
Perspective Transform
Perspective Transform
Affine Transform vs. Perspective Transform Affine Transform: Perspective Transform:
Get Perspective Transform
Warp. Perspective
Sparse Perspective Transformation
Image Transforms Histogram Equalization
Graylevel Histogram of Image
Goal of Histogram Equalization
Goal of Histogram Equalization Image Enhancement
Method Graylevel Remapping y X x f. Y(y) f. X(x) 0 Y 1 x 0 1 y
Probability Theory y X pdf cdf x Y
Example: Gaussian
Example: Gaussian
Demonstration
Open. CV Implementation
Example Download Test Program











































































































