Applications Of Image Filters

Transcription

02/04/10Applications of Image FiltersComputer VisionCS 543 / ECE 549University of IllinoisDerek Hoiem

Review: Image filteringg[ , ]111111111h[.,.]f 00909000000000000000000000000000000000000h[m, n] f [k , l ] g[m k , n l ]k ,lCredit: S. Seitz

Image filteringg[ , ]111111111h[.,.]f 000000000009000000000000000000010h[m, n] f [k , l ] g[m k , n l ]k ,lCredit: S. Seitz

Image filteringg[ , ]111111111h[.,.]f 00000000000900000000000000000001020h[m, n] f [k , l ] g[m k , n l ]k ,lCredit: S. Seitz

Filtering in spatial domain* 10-120-210-1

Filtering in frequency domainFFTFFTInverse FFT

Sharpening revisited What does blurring take away?– detailsmoothed (5x5)originalLet’s add it back: αoriginal detailsharpened

Application: Hybrid Images A. Oliva, A. Torralba, P.G. Schyns,“Hybrid Images,” SIGGRAPH 2006

Application: Hybrid Images A. Oliva, A. Torralba, P.G. Schyns,“Hybrid Images,” SIGGRAPH 2006

Today’s class How to use filters for– Matching– Denoising– Anti‐aliasing Image representation with pyramids Texture– What is it?– How to represent it?

Matching with filters Goal: findin image

Matching with filters Goal: findin image Method 1: SSDInput1- sqrt(SSD)Threshold at 0.8

Matching with filters Goal: findin image Method 1: SSD Method 2: Normalized cross‐correlationInputNormalized X-CorrelationThreshold at 0.5

Noise Gaussian Additive NoiseNoisy Image

Gaussian noise Mathematical model: sum of many independentfactors Assumption: independent, zero‐mean noiseSource: M. Hebert

NoiseOriginalSalt and pepper noiseImpulse noiseGaussian noise Salt and peppernoise: containsrandom occurrencesof black and whitepixels Impulse noise:contains randomoccurrences of whitepixels Gaussian noise:variations inintensity drawn froma Gaussian normaldistributionSource: S. Seitz

DenoisingGaussianFilterAdditive Gaussian Noise

Reducing Gaussian noiseSmoothing with larger standard deviations suppresses noise, but also blurs theimageSource: S. Lazebnik

Reducing salt‐and‐pepper noise byGaussian smoothing3x35x57x7

Alternative idea: Median filtering A median filter operates over a window byselecting the median intensity in the window Is median filtering linear?Source: K. Grauman

Median filter What advantage does median filtering haveover Gaussian filtering?– Robustness to outliersSource: K. Grauman

Median filterSalt-and-pepper noiseMedian filtered MATLAB: medfilt2(image, [h w])Source: M. Hebert

Median vs. Gaussian filtering3x3GaussianMedian5x57x7

Subsampling by a factor of 2Throw away every other row andcolumn to create a 1/2 size image

Aliasing problem 1D example (sinewave):Source: S. Marschner

Aliasing problem 1D example (sinewave):Source: S. Marschner

Aliasing problem Sub‐sampling may be dangerous . Characteristic errors may appear:– “Wagon wheels rolling the wrong way inmovies”– “Checkerboards disintegrate in ray tracing”– “Striped shirts look funny on color television”Source: D. Forsyth

Aliasing in videoSlide by Steve Seitz

Aliasing in graphicsSource: A. Efros

Sampling and aliasing

Nyquist‐Shannon Sampling Theorem When sampling a signal at discrete intervals, thesampling frequency must be 2 fmax; fmax max frequency of the input signal. This will allows to reconstruct the originalperfectly from the sampled versionvvvgoodbad

Anti‐aliasingSolutions: Sample more often Get rid of all frequencies that are greaterthan half the new sampling frequency– Will lose information– But it’s better than aliasing– Apply a smoothing filter

Algorithm for downsampling by factor of 21. Start with image(h, w)2. Apply low‐pass filterim blur imfilter(image, fspecial(‘gaussian’, 7, 1))3. Sample every other pixelim small im blur(1:2:end, 1:2:end);

Anti‐aliasingForsyth and Ponce 2002

Subsampling without pre‐filtering1/21/4(2x zoom)1/8(4x zoom)Slide by Steve Seitz

Subsampling with Gaussian pre‐filteringGaussian 1/2G 1/4G 1/8Slide by Steve Seitz

Gaussian pyramidSource: Forsyth

Laplacian filterunit impulseGaussianLaplacian of GaussianSource: Lazebnik

Laplacian pyramidSource: Forsyth

Computing Gaussian/Laplacian PyramidCan we reconstruct the originalfrom the laplacian pyramid?http://sepwww.stanford.edu/ morgan/texturematch/paper html/node3.html

Related idea: 2d wavelets

2d WaveletsMatlab: wavemenu

Image representation Pixels: great for spatial resolution, poor access tofrequency Fourier transform: great for frequency, not for spatialinfo Pyramids/wavelets: balance between spatial andfrequency information

Major uses of image pyramids Compression Object detection– Scale search– Features Detecting stable interest points Registration– Course‐to‐fine

TextureSource: Forsyth

Texture and Materialhttp://www-cvr.ai.uiuc.edu/ponce grp/data/texture database/samples/

Texture and Orientationhttp://www-cvr.ai.uiuc.edu/ponce grp/data/texture database/samples/

Texture and Scalehttp://www-cvr.ai.uiuc.edu/ponce grp/data/texture database/samples/

What is texture? Regular or stochastic patterns caused bybumps, grooves, and/or markings

How can we represent texture? Measure frequencies at various orientationsand scales

Overcomplete representation: filter banksLM Filter BankCode for filter banks: www.robots.ox.ac.uk/ vgg/research/texclass/filters.html

Filter banks Process image with each filter and keepresponses (or squared/abs responses)

Representing texture Idea 1: take simple statistics (e.g., mean, std)of various absolute filter responses

Can you match the texture to theresponse?FiltersAB12C3Mean abs responses

Representing texture by mean absresponseFiltersMean abs responses

Representing texture Idea 2: take vectors of filter responses at each pixel andcluster them, then take histograms (more on in comingweeks)

Things to remember When matching using a filter, normalized crosscorrelation is preferred Use Gaussian or median filter for denoising Beware of aliasing – use lowpass filter to downsample Laplacian pyramids and wavelets providespatial/frequency information Filter banks provide overcomplete representation,good for modeling/recognizing texture

Next class Edges and lines

Questions

over Gaussian filtering? - Robustness to outliers Source: K. Grauman. Median filter Salt-and-pepper noise Median filtered. Source: M. Hebert MATLAB: medfilt2(image, [h w]) Median vs. Gaussian filtering 3x3 5x5. 7x7. Gaussian. Median. Throw away every other row and column to create a 1/2