administrivia
play

Administrivia Homework 2 will be posted today Will be due Tue., - PowerPoint PPT Presentation

Administrivia Homework 2 will be posted today Will be due Tue., Feb. 23 before class Questions on CMPSCI 370: Intro to Computer Vision Linearity of light Image processing Color constancy [linear filtering] Hybrid


  1. Administrivia • Homework 2 will be posted today • Will be due Tue., Feb. 23 before class • Questions on CMPSCI 370: Intro to Computer Vision • Linearity of light Image processing • Color constancy [linear filtering] • Hybrid images — (today) University of Massachusetts, Amherst February 11, 2016 • Get started early Instructor: Subhransu Maji Slides credit: L. Lazebnik and others 2 Enhancing images Contrast stretching histogram • What can we do to “enhance” an image after it has already been digitized? • We can make the information that is there easier to visualize. • We can guess at data that is not there, but we cannot be sure, in general. before map this to 0 map this to 255 contrast enhancement deblurring after image source: wikipedia 3 4

  2. Motivation: Image de-noising Moving average • How can we reduce noise in a photograph? • Let’s replace each pixel with a weighted average of its neighborhood • The weights are called the filter • What are the weights for the average of a 3x3 neighborhood? 1 1 1 1 1 1 1 1 1 “box filter” Source: D. Lowe 5 6 Convolution Some properties • Let f be the image and g be the kernel. The output of • Linearity: filter( f 1 + f 2 ) = filter( f 1 ) + filter( f 2 ) convolving f with g is denoted f * g . • Scalars factor out: filter(k f 1 ) = k filter( f 1 ) ( f g )[ m , n ] f [ m k , n l ] g [ k , l ] ∑ ∗ = − − k , l f Convention: 
 kernel is “flipped” • MATLAB functions: conv2, filter2, imfilter Source: F. Durand 7 8

  3. Annoying details Annoying details What is the size of the output? What about near the edge? • the filter window falls off the edge of the image • MATLAB: filter2(g, f, shape ) or conv2(g, f, shape ) • need to extrapolate • shape = ‘full’: output size is sum of sizes of f and g • methods: • shape = ‘same’: output size is same as f - clip filter (black) • shape = ‘valid’: output size is difference of sizes of f and g - wrap around copy edge - reflect across edge - full same valid g g g g g g f f f g g g g g g Source: S. Marschner 9 10 Annoying details Practice with linear filters What about near the edge? • the filter window falls off the edge of the image • need to extrapolate • methods (MATLAB): - clip filter (black): imfilter(f, g, 0) - wrap around: imfilter(f, g, ‘circular’) copy edge: imfilter(f, g, ‘replicate’) - 0 0 0 ? - reflect across edge: imfilter(f, g, ‘symmetric’) 0 1 0 0 0 0 Original Source: S. Marschner Source: D. Lowe 11 12

  4. Practice with linear filters Practice with linear filters 0 0 0 0 0 0 ? 0 1 0 0 0 1 0 0 0 0 0 0 Original Original Filtered (no change) Source: D. Lowe Source: D. Lowe 13 14 Practice with linear filters Practice with linear filters 0 0 0 1 1 1 ? 0 0 1 1 1 1 0 0 0 1 1 1 Original Original Shifted left By 1 pixel Source: D. Lowe Source: D. Lowe 15 16

  5. Practice with linear filters Practice with linear filters 0 0 0 1 1 1 - ? 1 1 1 0 2 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 (Note that filter sums to 1) Original Original Blur (with a box filter) Source: D. Lowe Source: D. Lowe 17 18 Practice with linear filters Sharpening 0 0 0 1 1 1 - 0 2 0 1 1 1 0 0 0 1 1 1 Original Sharpening filter - Accentuates differences with local average Source: D. Lowe Source: D. Lowe 19 20

  6. Smoothing with box filter revisited Smoothing with box filter revisited • What’s wrong with this picture? • What’s wrong with this picture? • What’s the solution? • What’s the solution? • To eliminate edge effects, weight contribution of neighborhood pixels according to their closeness to the center “fuzzy blob” Source: D. Forsyth 21 22 Gaussian Kernel Gaussian Kernel σ = 2 with 30 x 30 σ = 5 with 30 x 30 kernel kernel • Constant factor at front makes volume sum to 1 (can be ignored when computing the filter values, as we should • Standard deviation σ : determines extent of smoothing renormalize weights to sum to 1 in any case) Source: C. Rasmussen Source: K. Grauman 23 24

  7. Choosing kernel width Choosing kernel width • Rule of thumb: set filter half-width to about 3 σ • The Gaussian function has infinite support, but discrete filters use finite kernels Matlab command fspecial(‘gaussian’, hsize, sigma) Source: K. Grauman 25 26 Gaussian vs. box filtering Noise • Salt and pepper noise : contains random occurrences of black and white pixels • Impulse noise: contains random occurrences of white pixels • Gaussian noise : variations in intensity drawn from a Gaussian normal distribution Source: S. Seitz 27 28

  8. 
 
 
 
 
 
 Gaussian noise Reducing Gaussian noise noise • Mathematical model: sum of many independent factors • Good for small standard deviations • Assumption: independent, zero-mean noise Smoothing with larger standard deviations suppresses noise, but also blurs the image Source: M. Hebert 29 30 Reducing salt-and-pepper noise Alternative idea: Median filtering • A median filter operates over a window by selecting the 3x3 5x5 7x7 median intensity in the window 
 What’s wrong with the results? • Is median filtering linear? Source: K. Grauman 31 32

  9. Median filter Median filter • What advantage does median filtering have over Gaussian Salt-and-pepper noise Median filtered filtering? • Robustness to outliers MATLAB: medfilt2(image, [h w]) Source: K. Grauman Source: M. Hebert 33 34 Sharpening revisited Sharpening filter I = blurry ( I ) + sharp ( I ) sharp ( I ) = I − blurry ( I ) What does blurring take away? = I ∗ e − I ∗ g σ = I ∗ ( e − g σ ) – = smoothed (5x5) detail original α Let’s add it back: + k = unit impulse Gaussian Laplacian of Gaussian original detail sharpened 35 36

  10. Application: Hybrid Images Gaussian Filter Laplacian Filter A. Oliva, A. Torralba, P.G. Schyns, 
 “Hybrid Images,” SIGGRAPH 2006 37 motorcycle and bicycle dolphin and car 39 40

Recommend


More recommend