1 / 52

Stanford CS223B Computer Vision, Winter 2005 Lecture 3 Filters and Features (with Matlab)

Stanford CS223B Computer Vision, Winter 2005 Lecture 3 Filters and Features (with Matlab). Sebastian Thrun, Stanford Rick Szeliski, Microsoft Hendrik Dahlkamp, Stanford [with slides by D Forsyth, D. Lowe, M. Polleyfeys, C. Rasmussen, G. Loy, D. Jacobs, J. Rehg, A, Hanson, G. Bradski,…] .

roza
Télécharger la présentation

Stanford CS223B Computer Vision, Winter 2005 Lecture 3 Filters and Features (with Matlab)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stanford CS223B Computer Vision, Winter 2005Lecture 3 Filters and Features (with Matlab) Sebastian Thrun, Stanford Rick Szeliski, Microsoft Hendrik Dahlkamp, Stanford [with slides by D Forsyth, D. Lowe, M. Polleyfeys, C. Rasmussen, G. Loy, D. Jacobs, J. Rehg, A, Hanson, G. Bradski,…]

  2. Assignment 1 FAQ • Compiling projects • cxcored.dll is the debug version of cxcore.dll, can be compiled from cxcore.dsp • Use template cvsample.dsp to get paths right • Taking the images • Assignment change: out-of-focus images no longer needed • Don’t print a border around the chessboard

  3. Assignment 1 FAQ • Corner finding • Supply correct parameters e.g. corner_count<>0 • Visualize corner ordering • How to verify results • Backproject scene corners into image • Use common sense: etc

  4. Stanford CS223B Computer Vision, Winter 2005Lecture 3 Filters and Features (with Matlab) Sebastian Thrun, Stanford Rick Szeliski, Microsoft Hendrik Dahlkamp, Stanford [with slides by D Forsyth, D. Lowe, M. Polleyfeys, C. Rasmussen, G. Loy, D. Jacobs, J. Rehg, A, Hanson, G. Bradski,…]

  5. Today’s Goals • Features 101 • Linear Filters and Edge Detection • Canny Edge Detector

  6. Today’s Question • What is a feature? • What is an image filter? • How can we find corners? • How can we find edges?

  7. What is a Feature? • Local, meaningful, detectable parts of the image

  8. Features in Computer Vision • What is a feature? • Location of sudden change • Why use features? • Information content high • Invariant to change of view point, illumination • Reduces computational burden

  9. (One Type of) Computer Vision Image 1 Image 2 Feature 1 Feature 2 : Feature N Feature 1 Feature 2 : Feature N Computer Vision Algorithm

  10. Where Features Are Used • Calibration • Image Segmentation • Correspondence in multiple images (stereo, structure from motion) • Object detection, classification

  11. What Makes For Good Features? • Invariance • View point (scale, orientation, translation) • Lighting condition • Object deformations • Partial occlusion • Other Characteristics • Uniqueness • Sufficiently many • Tuned to the task

  12. Today’s Goals • Features 101 • Linear Filters and Edge Detection • Canny Edge Detector

  13. What Causes an Edge? • Depth discontinuity • Surface orientation discontinuity • Reflectance discontinuity (i.e., change in surface material properties) • Illumination discontinuity (e.g., shadow) Slide credit: Christopher Rasmussen

  14. Quiz: How Can We Find Edges?

  15. Edge Finding 101 im = imread('bridge.jpg'); image(im); figure(2); bw = double(rgb2gray(im)); image(bw); gradkernel = [-1 1]; dx = abs(conv2(bw, gradkernel, 'same')); image(dx); colorbar; colormap gray [dx,dy] = gradient(bw); gradmag = sqrt(dx.^2 + dy.^2); image(gradmag); matlab colorbar colormap(gray(255)) colormap(default)

  16. Edge Finding 101 • Example of a linear Filter

  17. What is Image Filtering? Modify the pixels in an image based on some function of a local neighborhood of the pixels Some function

  18. Linear Filtering • Linear case is simplest and most useful • Replace each pixel with a linear combination of its neighbors. • The prescription for the linear combination is called the convolution kernel. kernel

  19. Linear Filter = Convolution I(.) I(.) I(.) I(.) I(.) I(.) I(.) I(.) I(.) g11 g12 g13 g23 g21 g22 g31 g32 g33 +g12I(i-1,j) +g13I(i-1,j+1) + g11I(i-1,j-1) + g22I(i,j) + g23I(i,j+1) + g21I(i,j-1) + g33I(i+1,j+1) g31I(i+1,j-1) + g32I(i+1,j) f (i,j) =

  20. Linear Filter = Convolution

  21. Filtering Examples

  22. Filtering Examples

  23. Filtering Examples

  24. Image Smoothing With Gaussian figure(3); sigma = 3; width = 3 * sigma; support = -width : width; gauss2D = exp( - (support / sigma).^2 / 2); gauss2D = gauss2D / sum(gauss2D); smooth = conv2(conv2(bw, gauss2D, 'same'), gauss2D', 'same'); image(smooth); colormap(gray(255)); gauss3D = gauss2D' * gauss2D; tic ; smooth = conv2(bw,gauss3D, 'same'); toc

  25. Smoothing With Gaussian Averaging Gaussian Slide credit: Marc Pollefeys

  26. Smoothing Reduces Noise The effects of smoothing Each row shows smoothing with gaussians of different width; each column shows different realizations of an image of gaussian noise. Slide credit: Marc Pollefeys

  27. Example of Blurring Image Blurred Image - =

  28. Edge Detection With Smoothed Images figure(4); [dx,dy] = gradient(smooth); gradmag = sqrt(dx.^2 + dy.^2); gmax = max(max(gradmag)); imshow(gradmag); colormap(gray(gmax));

  29. Scale Increased smoothing: • Eliminates noise edges. • Makes edges smoother and thicker. • Removes fine detail.

  30. The Edge Normal

  31. Displaying the Edge Normal figure(5); hold on; image(smooth); colormap(gray(255)); [m,n] = size(gradmag); edges = (gradmag > 0.3 * gmax); inds = find(edges); [posx,posy] = meshgrid(1:n,1:m); posx2=posx(inds); posy2=posy(inds); gm2= gradmag(inds); sintheta = dx(inds) ./ gm2; costheta = - dy(inds) ./ gm2; quiver(posx2,posy2, gm2 .* sintheta / 10, -gm2 .* costheta / 10,0); hold off;

  32. Separable Kernels

  33. Combining Kernels / Convolutions 0.0030 0.0133 0.0219 0.0133 0.0030 0.0133 0.0596 0.0983 0.0596 0.0133 0.0219 0.0983 0.1621 0.0983 0.0219 0.0133 0.0596 0.0983 0.0596 0.0133 0.0030 0.0133 0.0219 0.0133 0.0030

  34. Effect of Smoothing Radius 1 pixel 3 pixels 7 pixels

  35. Robert’s Cross Operator [ I(x, y) - I(x+1, y+1) ]2 + [ I(x, y+1) - I(x+1, y) ]2 1 0 0 -1 0 1 -1 0 + S = or | I(x, y) - I(x+1, y+1) | + | I(x, y+1) - I(x+1, y) | S =

  36. Sobel Operator Edge Magnitude = 2 2 S1 + S1 S1 tan-1 S2 Edge Direction = -1 -2 -1 0 0 0 1 2 1 -1 0 1 -2 0 2 -1 0 1 S1= S2 =

  37. The Sobel Kernel, Explained Sobel kernel is separable! Averaging done parallel to edge

  38. Sobel Edge Detector figure(6) edge(bw, 'sobel')

  39. Robinson Compass Masks 0 1 2 -1 0 1 -2 -1 0 1 2 1 0 0 0 -1 -2 -1 -1 0 1 -2 0 2 -1 0 1 2 1 0 1 0 -1 0 -1 -2 0 -1 -2 -1 0 -1 2 1 0 -1 -2 -1 0 0 0 1 2 1 1 0 -1 2 0 -2 1 1 -1 -2 -1 0 -1 0 1 0 1 2

  40. Claim Your Own Kernel! Frei & Chen

  41. Comparison (by Allan Hanson) • Analysis based on a step edge inclined at an angle q (relative to y-axis) through center of window. • Robinson/Sobel: true edge contrast less than 1.6% different from that computed by the operator. • Error in edge direction • Robinson/Sobel: less than 1.5 degrees error • Prewitt: less than 7.5 degrees error • Summary • Typically, 3 x 3 gradient operators perform better than 2 x 2. • Prewitt2 and Sobel perform better than any of the other 3x3 gradient estimation operators. • In low signal to noise ratio situations, gradient estimation operators of size larger than 3 x 3 have improved performance. • In large masks, weighting by distance from the central pixel is beneficial.

  42. Today’s Goals • Features 101 • Linear Filters and Edge Detection • Canny Edge Detector

  43. Canny Edge Detector figure(7) edge(bw, 'canny')

  44. Canny Edge Detection Steps: • Apply derivative of Gaussian • Non-maximum suppression • Thin multi-pixel wide “ridges” down to single pixel width • Linking and thresholding • Low, high edge-strength thresholds • Accept all edges over low threshold that are connected to edge over high threshold

  45. Non-Maximum Supression • Non-maximum suppression: • Select the single maximum point across the width of an edge.

  46. Linking to the Next Edge Point Assume the marked point is an edge point. Take the normal to the gradient at that point and use this to predict continuation points (either r or s).

  47. Edge Hysteresis • Hysteresis:A lag or momentum factor • Idea: Maintain two thresholds khigh and klow • Use khigh to find strong edges to start edge chain • Use klow to find weak edges which continue edge chain • Typical ratio of thresholds is roughly khigh/klow=2

  48. Canny Edge Detection (Example) gap is gone Strong + connected weak edges Original image Strong edges only Weak edges courtesy of G. Loy

  49. Canny Edge Detection (Example) Using Matlab with default thresholds

  50. Application: Road Finding • (add roadrunner video here)

More Related