Presentation is loading. Please wait.

Presentation is loading. Please wait.

Example: Canny Edge Detection

Similar presentations


Presentation on theme: "Example: Canny Edge Detection"— Presentation transcript:

1 Example: Canny Edge Detection
note painted lines on road preserved, whereas others didn’t (Matlab automatically set thresholds) Computer Vision : CISC 4/689

2 More: facts and figures
The convolution of two Gaussians with variances {1}2 and {2}2 is {1}2+{2}2. This is same as consecutive smoothing with the two corresponding SD’s. Thus, generic formula is: i{i}2 Problem: A discrete appx. to a 1D Gaussian can be obtained by sampling g(x). In practice, samples are taken uniformly until the truncated values at the tails of the distribution are less than 1/1000 of the peak value. a) For =1, show that the filter is 7 pixels wide. Computer Vision : CISC 4/689

3 Computer Vision : CISC 4/689
Answer.. Lets pick (n+1) pixels from the center of kernel(including center). This way, total kernel size is 2n+1, n pixels on either side of origin. Exp(-{(n+1)2}/{22}) < 1/1000 So, n > 3.7 -1 n must be the nearest integer to 3.7 -0.5 For =1, n=3, 2n+1=7. Filter coefficients can be obtained as {-3,-2,-1,0,1,2,3} Computer Vision : CISC 4/689

4 Computer Vision : CISC 4/689
Choice of  The choice of  depends on the scale at which the image is to be displayed. Small values bring out edges at a fine scale, vice-versa. Noise is another factor to look into the selection, along with computational cost Computer Vision : CISC 4/689

5 Computer Vision : CISC 4/689
Some comparisons Zero-crossings easy to find than threshold Computer Vision : CISC 4/689

6 Computer Vision : CISC 4/689
Canny Many implementations of the Canny edge detector approximate this process by first convolving the image with a Gaussian to smooth the signal, and then looking for maxima in the first partial derivatives of the resulting signal (using masks similar to the Sobel masks). Thus we can convolve the image with 4 masks, looking for horizontal, vertical and diagonal edges. The direction producing the largest result at each pixel point is marked. Record the convolution result and the direction of the edge at each pixel. Computer Vision : CISC 4/689

7 Marr-Hildreth vs. Canny
Laplacian is isotropic, computationally efficient: single convolution, look for zero-crossing. (one way to explain zero-crossing is, if first derivative can be looked at as a function, its maximum will be its derivative=0). Canny being a directional operator (derivative in 4 or 3 directions), more costly, esp. due to hysterisis. Two derivatives -> more sensitive to noise Computer Vision : CISC 4/689

8 Computer Vision : CISC 4/689
Image Pyramids Observation: Fine-grained template matching expensive over a full image Idea: Represent image at smaller scales, allowing efficient coarse to-fine search Downsampling: Cut width, height in half at each iteration: from Forsyth & Ponce Computer Vision : CISC 4/689

9 Computer Vision : CISC 4/689
Gaussian Pyramid Let the base (the finest resolution) of an n-level Gaussian pyramid be defined as P0 = I. Then the ith level is reduced from the level below it by: Upsampling S"(I): Double size of image, interpolate missing pixels Upsample with interpolation to reconstruct DoG approximates Laplacian courtesy of Wolfram Computer Vision : CISC 4/689 Gaussian pyramid

10 Computer Vision : CISC 4/689
Laplacian Pyramids The tip (the coarsest resolution) of an n-level Laplacian pyramid is the same as the Gaussian pyramid at that level: Ln(I) = Pn(I) The ith level is expanded from the level above according to Li(I) = Pi(I) ¡ S"(Pi+1(I)) Synthesizing the original image: Get I back by summing upsampled Laplacian pyramid levels Upsample with interpolation to reconstruct DoG approximates Laplacian Computer Vision : CISC 4/689

11 Computer Vision : CISC 4/689
Laplacian Pyramid The differences of images at successive levels of the Gaussian pyramid define the Laplacian pyramid. To calculate a difference, the image at a higher level in the pyramid must be increased in size by a factor of four prior to subtraction. This computes the pyramid. The original image may be reconstructed from the Laplacian pyramid by reversing the previous steps. This interpolates and adds the images at successive levels of the pyramid beginning with the lowest level. Laplacian is largely uncorrelated, and so may be represented pixel by pixel with many fewer bits than Gaussian. courtesy of Wolfram Computer Vision : CISC 4/689

12 Computer Vision : CISC 4/689
Reconstruction Computer Vision : CISC 4/689

13 Computer Vision : CISC 4/689
Splining Build Laplacian pyramids LA and LB for A & B images Build a Gaussian pyramid GR from selected region R Form a combined pyramid LS from LA and LB using nodes of GR as weights: LS(I,j) = GR(I,j)*LA(I,j)+(1-GR(I,j))*LB(I,j) Collapse the LS pyramid to get the final blended image Computer Vision : CISC 4/689

14 Computer Vision : CISC 4/689
Splining (Blending) Splining two images simply requires: 1) generating a Laplacian pyramid for each image, 2) generating a Gaussian pyramid for the bitmask indicating how the two images should be merged, 3) merging each Laplacian level of the two images using the bitmask from the corresponding Gaussian level, and 4) collapsing the resulting Laplacian pyramid. i.e. GS = Gaussian pyramid of bitmask LA = Laplacian pyramid of image "A" LB = Laplacian pyramid of image "B" therefore, "Lout = (GS)LA + (1-GS)LB" Computer Vision : CISC 4/689

15 Example images from GTech
Image bit-mask image-2 Direct addition splining bad bit-mask choice Computer Vision : CISC 4/689

16 Computer Vision : CISC 4/689
Outline Corner detection RANSAC Computer Vision : CISC 4/689

17 Matching with Invariant Features
Darya Frolova, Denis Simakov The Weizmann Institute of Science March 2004 Computer Vision : CISC 4/689

18 Example: Build a Panorama
Computer Vision : CISC 4/689 M. Brown and D. G. Lowe. Recognising Panoramas. ICCV 2003

19 How do we build panorama?
We need to match (align) images Computer Vision : CISC 4/689

20 Matching with Features
Detect feature points in both images Computer Vision : CISC 4/689

21 Matching with Features
Detect feature points in both images Find corresponding pairs Computer Vision : CISC 4/689

22 Matching with Features
Detect feature points in both images Find corresponding pairs Use these pairs to align images Computer Vision : CISC 4/689

23 Matching with Features
Problem 1: Detect the same point independently in both images no chance to match! We need a repeatable detector Computer Vision : CISC 4/689

24 Matching with Features
Problem 2: For each point correctly recognize the corresponding one ? We need a reliable and distinctive descriptor Computer Vision : CISC 4/689

25 Computer Vision : CISC 4/689
More motivation… Feature points are used also for: Image alignment (homography, fundamental matrix) 3D reconstruction Motion tracking Object recognition Indexing and database retrieval Robot navigation … other Computer Vision : CISC 4/689

26 Computer Vision : CISC 4/689
Corner Detection Basic idea: Find points where two edges meet—i.e., high gradient in two directions “Cornerness” is undefined at a single pixel, because there’s only one gradient per point Look at the gradient behavior over a small window Categories image windows based on gradient statistics Constant: Little or no brightness change Edge: Strong brightness change in single direction Flow: Parallel stripes Corner/spot: Strong brightness changes in orthogonal directions Computer Vision : CISC 4/689

27 Corner Detection: Analyzing Gradient Covariance
Intuitively, in corner windows both Ix and Iy should be high Can’t just set a threshold on them directly, because we want rotational invariance Analyze distribution of gradient components over a window to differentiate between types from previous slide: The two eigenvectors and eigenvalues ¸1, ¸2 of C (Matlab: eig(C)) encode the predominant directions and magnitudes of the gradient, respectively, within the window Corners are thus where min(¸1, ¸2) is over a threshold courtesy of Wolfram Covariance is 1/n sum(1 to n) (xi-x’)(xi-x’)^t Computer Vision : CISC 4/689

28 Computer Vision : CISC 4/689
Contents Harris Corner Detector Description Analysis Detectors Rotation invariant Scale invariant Affine invariant Descriptors Computer Vision : CISC 4/689

29 Harris Detector: Mathematics
Taylor series: I(x+u,y+v) = I(x,y) +Ix(x,y)u+Iy(x,y)v+… Change of intensity for the shift [u,v]: Intensity Window function Shifted intensity or Window function w(x,y) = Gaussian 1 in window, 0 outside Computer Vision : CISC 4/689

30 Harris Detector: Mathematics
For small shifts [u,v] we have a bilinear approximation: where M is a 22 matrix computed from image derivatives: Computer Vision : CISC 4/689

31 Harris Detector: Mathematics
Intensity change in shifting window: eigenvalue analysis 1, 2 – eigenvalues of M If we try every possible orientation n, the max. change in intensity is 2 Ellipse E(u,v) = const 1 2 Computer Vision : CISC 4/689

32 Harris Detector: Mathematics
2 Classification of image points using eigenvalues of M: “Edge” 2 >> 1 “Corner” 1 and 2 are large, 1 ~ 2; E increases in all directions 1 and 2 are small; E is almost constant in all directions “Edge” 1 >> 2 “Flat” region 1 Computer Vision : CISC 4/689

33 Harris Detector: Mathematics
Measure of corner response: (k – empirical constant, k = ) Computer Vision : CISC 4/689

34 Harris Detector: Mathematics
2 “Edge” “Corner” R depends only on eigenvalues of M R is large for a corner R is negative with large magnitude for an edge |R| is small for a flat region R < 0 R > 0 “Flat” “Edge” |R| small R < 0 1 Computer Vision : CISC 4/689

35 Computer Vision : CISC 4/689
Harris Detector The Algorithm: Find points with large corner response function R (R > threshold) Take the points of local maxima of R Computer Vision : CISC 4/689

36 Harris Detector: Workflow
Computer Vision : CISC 4/689

37 Harris Detector: Workflow
Compute corner response R Computer Vision : CISC 4/689

38 Harris Detector: Workflow
Find points with large corner response: R>threshold Computer Vision : CISC 4/689

39 Harris Detector: Workflow
Take only the points of local maxima of R Computer Vision : CISC 4/689

40 Harris Detector: Workflow
Computer Vision : CISC 4/689

41 Example: Gradient Covariances
Corners are where both eigenvalues are big from Forsyth & Ponce Detail of image with gradient covar- iance ellipses for 3 x 3 windows Full image Computer Vision : CISC 4/689

42 Example: Corner Detection (for camera calibration)
Computer Vision : CISC 4/689 courtesy of B. Wilburn

43 Example: Corner Detection
courtesy of S. Smith SUSAN corners Computer Vision : CISC 4/689

44 Harris Detector: Summary
Average intensity change in direction [u,v] can be expressed as a bilinear form: Describe a point in terms of eigenvalues of M: measure of corner response A good (corner) point should have a large intensity change in all directions, i.e. R should be large positive Computer Vision : CISC 4/689

45 Computer Vision : CISC 4/689
Contents Harris Corner Detector Description Analysis Detectors Rotation invariant Scale invariant Affine invariant Descriptors Computer Vision : CISC 4/689

46 Tracking: compression of video information
Harris response (uses criss-cross gradients) Dinosaur tracking (using features) Dinosaur Motion tracking (using correlation) Final Tracking (superimposed) Courtesy: ( This figure displays results of feature detection over the dinosaur test sequence with the algorithm set to extract the 6 most "interesting" features at every image frame.  It is interesting to note that although no attempt to extract frame-to-frame feature correspondences was made, the algorithm still extracts the same set of features at every frame.  This will be useful very much in feature tracking. Computer Vision : CISC 4/689

47 Computer Vision : CISC 4/689
One More.. Office sequence Office Tracking Computer Vision : CISC 4/689

48 Harris Detector: Some Properties
Rotation invariance Ellipse rotates but its shape (i.e. eigenvalues) remains the same Corner response R is invariant to image rotation Computer Vision : CISC 4/689

49 Harris Detector: Some Properties
Partial invariance to affine intensity change Only derivatives are used => invariance to intensity shift I  I + b Intensity scale: I  a I R x (image coordinate) threshold Computer Vision : CISC 4/689

50 Harris Detector: Some Properties
But: non-invariant to image scale! All points will be classified as edges Corner ! Computer Vision : CISC 4/689

51 Harris Detector: Some Properties
Quality of Harris detector for different scale changes -- Correspondences calculated using distance (and threshold) -- Improved Harris is proposed by Schmid et al -- repeatability rate is defined as the number of points repeated between two images w.r.t the total number of detected points.  Repeatability rate: # correspondences # possible correspondences Imp.Harris uses derivative of Gaussian instead of standard template used by Harris et al. Computer Vision : CISC 4/689 C.Schmid et.al. “Evaluation of Interest Point Detectors”. IJCV 2000

52 Computer Vision : CISC 4/689
Contents Harris Corner Detector Description Analysis Detectors Rotation invariant Scale invariant Affine invariant Descriptors Computer Vision : CISC 4/689

53 detect the same interest points regardless of image changes
We want to: detect the same interest points regardless of image changes Computer Vision : CISC 4/689

54 Computer Vision : CISC 4/689
Models of Image Change Geometry Rotation Similarity (rotation + uniform scale) Affine (scale dependent on direction) valid for: orthographic camera, locally planar object Photometry Affine intensity change (I  a I + b) Computer Vision : CISC 4/689

55 Computer Vision : CISC 4/689
Contents Harris Corner Detector Description Analysis Detectors Rotation invariant Scale invariant Affine invariant Descriptors Computer Vision : CISC 4/689

56 Rotation Invariant Detection
Harris Corner Detector Computer Vision : CISC 4/689 C.Schmid et.al. “Evaluation of Interest Point Detectors”. IJCV 2000

57 Computer Vision : CISC 4/689
Contents Harris Corner Detector Description Analysis Detectors Rotation invariant Scale invariant Affine invariant Descriptors Computer Vision : CISC 4/689

58 Scale Invariant Detection
Consider regions (e.g. circles) of different sizes around a point Regions of corresponding sizes will look the same in both images Computer Vision : CISC 4/689

59 Scale Invariant Detection
The problem: how do we choose corresponding circles independently in each image? Computer Vision : CISC 4/689

60 Scale Invariant Detection
Solution: Design a function on the region (circle), which is “scale invariant” (the same for corresponding regions, even if they are at different scales) Example: average intensity. For corresponding regions (even of different sizes) it will be the same. For a point in one image, we can consider it as a function of region size (circle radius) f region size Image 1 f region size Image 2 scale = 1/2 Computer Vision : CISC 4/689

61 Scale Invariant Detection
Common approach: Take a local maximum of this function Observation: region size, for which the maximum is achieved, should be invariant to image scale. Important: this scale invariant region size is found in each image independently! f region size Image 1 f region size Image 2 scale = 1/2 s1 s2 Computer Vision : CISC 4/689

62 Scale Invariant Detection
A “good” function for scale detection: has one stable sharp peak f region size bad f region size Good ! f region size bad For usual images: a good function would be the one with contrast (sharp local intensity change) Computer Vision : CISC 4/689

63 Scale Invariant Detection
Functions for determining scale Kernels: (Laplacian) (Difference of Gaussians) where Gaussian Note: both kernels are invariant to scale and rotation Computer Vision : CISC 4/689

64 Scale Invariant Detectors
x y  Harris   Laplacian  Harris-Laplacian1 Find local maximum of: Harris corner detector in space (image coordinates) Laplacian in scale SIFT (Lowe)2 Find local maximum of: Difference of Gaussians in space and scale scale x y  DoG  1 K.Mikolajczyk, C.Schmid. “Indexing Based on Scale Invariant Interest Points”. ICCV D.Lowe. “Distinctive Image Features from Scale-Invariant Keypoints”. Accepted to IJCV 2004 Computer Vision : CISC 4/689

65 Computer Vision : CISC 4/689
Harris Laplacian Characteristic Scale: Given a point in an image, compute the function responses for several factors sn The characteristic scale is the local max. of the function (can be more than one). Easy to look for zero-crossings of 2nd derivative than maxima. The ratio of the scales, at which the extrema were found for corresponding points in two rescaled images, is equal to the scale factor between the images. Then what..? Computer Vision : CISC 4/689

66 Computer Vision : CISC 4/689
Harris-Laplacian Existing methods search for maxima in the 3D representation of an image (x,y,scale). A feature point represents a local maxima in the surrounding 3D cube and its value is higher than a threshold. THIS (Harris-Laplacian) method uses Harris function first, then selects points for which Laplacian attains maximum over scales. First, prepare scale-space representation for the Harris function. At each level, detect interest points as local maxima in the image plane (of that scale) – do this by comparing 8-neighborhood. (different from plain Harris corner detection) Second, use Laplacian to judge if each of the candidate points found on different levels, if it forms a maximum in the scale direction. (check with n-1 and n+1) Computer Vision : CISC 4/689

67 Scale Invariant Detectors
Experimental evaluation of detectors w.r.t. scale change Repeatability rate: # correspondences # possible correspondences (points present) Computer Vision : CISC 4/689 K.Mikolajczyk, C.Schmid. “Indexing Based on Scale Invariant Interest Points”. ICCV 2001

68 Scale Invariant Detection: Summary
Given: two images of the same scene with a large scale difference between them Goal: find the same interest points independently in each image Solution: search for maxima of suitable functions in scale and in space (over the image) Methods: Harris-Laplacian [Mikolajczyk, Schmid]: maximize Laplacian over scale, Harris’ measure of corner response over the image SIFT [Lowe]: maximize Difference of Gaussians over scale and space Computer Vision : CISC 4/689


Download ppt "Example: Canny Edge Detection"

Similar presentations


Ads by Google