Convolution and Edge DetectionFourier spectrum Fun and games with spectraGaussian filteringMean vs. Gaussian filteringConvolutionThe Convolution TheoremFourier Transform pairs2D convolution theorem exampleEdges in imagesImage gradientEffects of noiseSolution: smooth firstDerivative theorem of convolutionLaplacian of Gaussian2D edge detection filtersMATLAB demoWhat does blurring take away?What does blurring take away?Edge detection by subtractionGaussian - image filterWhat is happening?Unsharp MaskingConvolution and Edge Detection15-463: Computational PhotographyAlexei Efros, CMU, Fall 2005Some slides from Steve SeitzFourier spectrumFun and games with spectra4Gaussian filteringA Gaussian kernel gives less weight to pixels further from the center of the windowThis kernel is an approximation of a Gaussian function:0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 9090909090 0 00 0 0 9090909090 0 00 0 0 9090909090 0 00 0 09009090900 00 0 0 9090909090 0 00 0 0 0 0 0 0 0 0 00 0 90 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 01212421215Mean vs. Gaussian filteringConvolutionRemember cross-correlation:A convolution operation is a cross-correlation where the filter is flipped both horizontally and vertically before being applied tothe image:It is written: Suppose H is a Gaussian or mean kernel. How does convolution differ from cross-correlation?The Convolution TheoremThe greatest thing since sliced (banana) bread!• The Fourier transform of the convolution of two functions is the product of their Fourier transforms• The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms• Convolution in spatial domain is equivalent to multiplication in frequency domain!]F[]F[]F[ hghg=∗][F][F][F111hggh−−−∗=Fourier Transform pairs2D convolution theorem example*f(x,y)h(x,y)g(x,y)|F(sx,sy)||H(sx,sy)||G(sx,sy)|Edges in imagesImage gradientThe gradient of an image: The gradient points in the direction of most rapid change in intensityThe gradient direction is given by:• how does this relate to the direction of the edge?The edge strength is given by the gradient magnitudeEffects of noiseConsider a single row or column of the image• Plotting intensity as a function of position gives a signalWhere is the edge?How to compute a derivative?Where is the edge? Solution: smooth firstLook for peaks inDerivative theorem of convolutionThis saves us one operation:Laplacian of GaussianConsider Laplacian of GaussianoperatorWhere is the edge? Zero-crossings of bottom graph2D edge detection filtersis the Laplacian operator:Laplacian of Gaussianderivative of GaussianGaussianMATLAB demog = fspecial('gaussian',15,2);imagesc(g)surfl(g)gclown = conv2(clown,g,'same');imagesc(conv2(clown,[-1 1],'same'));imagesc(conv2(gclown,[-1 1],'same'));dx = conv2(g,[-1 1],'same');imagesc(conv2(clown,dx,'same');lg = fspecial('log',15,2);lclown = conv2(clown,lg,'same');imagesc(lclown)imagesc(clown + .2*lclown)What does blurring take away?originalWhat does blurring take away?smoothed (5x5 Gaussian)Edge detection by subtractionsmoothed – originalWhy doesthis work?Gaussian - image filterLaplacian of GaussianGaussiandelta functionFFTWhat is happening?Unsharp Masking-==+
View Full Document