700 likes | 848 Views
Introduction to Computer Vision. Lecture 8 Dr. Roger S. Gaborski. Updates. Project Page Image Resizing by Image Carving http://www.youtube.com/watch?v=6NcIJXTlugc. GOAL: Locate the Fern. RECALL: MATLAB’s Edge Function. EDGE Find edges in intensity image.
E N D
Introduction to Computer Vision Lecture 8 Dr. Roger S. Gaborski Roger S. Gaborski
Updates • Project Page • Image Resizing by Image Carving http://www.youtube.com/watch?v=6NcIJXTlugc Roger S. Gaborski
GOAL: Locate the Fern Roger S. Gaborski
RECALL: MATLAB’s Edge Function EDGE Find edges in intensity image. EDGE takes an intensity or a binary image I as its input, and returns a binary image BW of the same size as I, with 1's where the function finds edges in I and 0's elsewhere. Sobel Prewitt Roberts Laplacian of Gaussian (LoG) Zero Crossing Canny Roger S. Gaborski
edge • edge function • [g,t] = edge( image, ‘prewitt’, T, dir ); Roger S. Gaborski
Prewitt [g,t] = edge( image, ‘prewitt’ ); Automatic threshold = .1088, both horizontal and vertical edges Roger S. Gaborski
Prewitt – Threshold = .05 Threshold = .05 Roger S. Gaborski
Prewitt – Threshold =.15 Threshold = .15 Roger S. Gaborski
Smoothing • Remove noise • Remove small details • Smoothing Kernel: a= 1/9 a a a a a a a a a • Increase center value to put more weight on the • center pixel Roger S. Gaborski
Consider a 2 D Gaussian for Smoothing Roger S. Gaborski
2D Gaussian Distribution • The two-dimensional Gaussian distribution is defined by: • From this distribution, can generate smoothing masks whose width depends upon the standard deviation, s: Roger S. Gaborski
i2 + j2 i2 + j2 W(i,j) = exp (- ) W(i,j) = k * exp (- ) 2 s2 2 s2 k Creating Gaussian Kernels • The mask weights are evaluated from the Gaussian distribution: • This can be rewritten as: Roger S. Gaborski
i2 + j2 W(i,j) = exp (- ) 2 s2 k Creating Gaussian Kernels • This can now be evaluated over a window of size nxn to obtain a kernel in which the (0,0) value is 1. • k is a scaling constant Roger S. Gaborski
j -3 -2 -1 0 1 2 3 -3 -2 -1 i 0 1 2 3 Example 2 • Choose s = 2. and n = 7, then: Roger S. Gaborski
7x7 Gaussian Filter Roger S. Gaborski
Key Point – if you were using a Gaussian function for smoothing (noise reduction) the value of will sigma determine how many points will be used in the smoothing operation Roger S. Gaborski
Sigma Determines Spread of Filter Variance, s2 = .25 Variance, s2 = 4.0 Roger S. Gaborski
imGray im = imread('IMGP1579.JPG'); imGray = rgb2gray(im); imGray = mat2gray(imGray, [0 255]); Roger S. Gaborski
31x31 Gaussian, Sigma = 4 Roger S. Gaborski
31x31 Gaussian, Sigma = 4Profile Roger S. Gaborski
Fern 31x31 Gaussian, Sigma=4 Roger S. Gaborski
63x63 Gaussian, Sigma =10 Roger S. Gaborski
63x63 Gaussian, Sigma = 10Profile Roger S. Gaborski
Fern 63x63 Gaussian, Sigma=10 Roger S. Gaborski
RECALL: Laplacian • Independent of edge orientation (finds edges in all orientations) • Combine 2 f(x,y)/ x2 and 2 f(x,y)/ y2 =4 f(x,y) - f(x-1,y) – f(x+1,y) – f(x,y-1) – f(x,y+1) • Second derivatives are sensitive to noise Roger S. Gaborski
Filter image with Gaussian to reduce noise Laplacian of the Gaussian Ñ2G is a circularly symmetric operator. LoG Roger S. Gaborski
LoG Also called the Mexican hat operator. Roger S. Gaborski
s2 Controls of the Size of the Filter s2 = 0.5 s2 = 2.0 Roger S. Gaborski
Human Visual System Receptive Field Approximation 17 x 17 5x5 Roger S. Gaborski
>> %H = FSPECIAL('log',HSIZE,SIGMA) >> LoG31=fspecial('log',31,4); >> imLoG31=conv2(imGray,LoG31); >> figure, imshow(imLoG31,[ ]),title('imLog31') Roger S. Gaborski
LoG (15x15, Sigma=1) Roger S. Gaborski
LoG (7x7, Sigma=1) Roger S. Gaborski
LoG (31x31, Sigma=4) Roger S. Gaborski
LoG (63x63, Sigma=10) Roger S. Gaborski
Edge Detection: abs(imLog7)>.1 Roger S. Gaborski
Building1 gray level image Roger S. Gaborski
LoG (7x7, sigma = 2) Roger S. Gaborski
LoG (15x15, sigma = 4) Roger S. Gaborski
Summarizing: Laplacian of Gaussian (LoG) • Gaussian function: h(r) = -exp(-r2/22) • Applying the Gaussian has a smoothing or blurring effect • Blurring depends on sigma • THEN Laplacian of Gaussian (Second Derivative) Roger S. Gaborski
Laplacian of Gaussian (LoG) • 2 h(r) = -[(r2 - 2)/ 4] exp-(r2/2 2) • Second derivative is linear operation Therefore: convolving an image with 2 h(r) is the same as first convolving first with smoothing filter (Gaussian) then computing Laplacian of result. • Edge are location of zero crossings Roger S. Gaborski
Implementation: Laplacian of Gaussian (LoG) • Syntax: [g] = edge(f, ‘log’, T, sigma); Ignores edges that are not stronger than T If T not provided, MATLAB automatically chooses T Roger S. Gaborski
Building What’s important?? Roger S. Gaborski
[g,t]=edge(im,'log',[ ],1); Roger S. Gaborski
[g,t]=edge(im,'log',[ ],2); Roger S. Gaborski
[g,t]=edge(im,'log',[ ],3) Roger S. Gaborski
Exploring the LoG Parameter Space [g, t] = edge(f, 'log',[],2); Default threshold, t= .918, sigma = 2 WHAT IF WE CHANGE SIGMA?? Roger S. Gaborski
t= .918 Sigma = 1 Sigma = 3 (more smoothing) Roger S. Gaborski
t = .500 Sigma = 1 Sigma = 3 Roger S. Gaborski
t = 1.500 Sigma = 1.0 Sigma = 3.0 Roger S. Gaborski
DoG • NOTE: Difference of Gaussians is an approximation to Laplacian of Gaussian Roger S. Gaborski