1 / 59

Linear Filters

Linear Filters. T-11 Computer Vision University of Houston Christophoros Nikou. Images and slides from: James Hayes, Brown University, Computer Vision course Svetlana Lazebnik, University of North Carolina at Chapel Hill, Computer Vision course

Albert_Lan
Télécharger la présentation

Linear Filters

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. Linear Filters T-11 Computer Vision University of Houston Christophoros Nikou Images and slides from: James Hayes, Brown University, Computer Vision course Svetlana Lazebnik, University of North Carolina at Chapel Hill, Computer Vision course D. Forsyth and J. Ponce. Computer Vision: A Modern Approach, Prentice Hall, 2011. R. Gonzalez and R. Woods. Digital Image Processing, Prentice Hall, 2008.

  2. Linear Filtering • Highlight the characteristic appearance of small groups of pixels (zebra strips, Dalmatian dog spots). • Reduce the effect of noise. • Find edges and other patterns (e.g. corner features).

  3. Linear Filtering

  4. Motivation: Noise Reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What’s the next best thing? Source: S. Seitz

  5. 1 1 1 1 1 1 1 1 1 “box filter” Moving Average • Let’s replace each pixel with a weighted average of its neighborhood. • The weights are called the filter kernel. • What are the weights for a 3x3 moving average? Source: D. Lowe

  6. Convolution 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  7. Image filtering 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  8. Image filtering 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  9. Image filtering 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  10. Image filtering 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  11. Image filtering 1 1 1 1 1 1 1 1 1 ? Credit: S. Seitz

  12. Image filtering 1 1 1 1 1 1 1 1 1 ? Credit: S. Seitz

  13. Image filtering 1 1 1 1 1 1 1 1 1 Credit: S. Seitz

  14. Key Properties • Linearity: filter(f1 + f2 ) = filter(f1) + filter(f2) • Shift invariance: same behavior regardless of pixel location: filter(shift(f)) = shift(filter(f)). • Theoretical result: any linear shift-invariant operator can be represented as a convolution. MATLAB: conv2 vs. filter2 (also imfilter)

  15. Key Properties (cont.) • Commutative: a * b = b * a • Conceptually no difference between filter and signal • Associative: a * (b * c) = (a * b) * c • Often apply several filters one after another: (((a * b1) * b2) * b3). • This is equivalent to applying one filter: a * (b1 * b2 * b3). • Distributes over addition: a * (b + c) = (a * b) + (a * c) • Scalars factor out: ka * b = a * kb = k (a * b) • Identity: unit impulse e = […, 0, 0, 1, 0, 0, …],a * e = a

  16. Implementation Details full same valid g g g g f f f g g g g g g g g

  17. Implementation Details (cont.) • What about image borders? • the filter window falls off the edge of the image • need to extrapolate • methods: • clip filter (black) • wrap around • copy edge • reflect across edge Source: S. Marschner

  18. Implementation Details (cont.) • 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’) • reflect across edge: imfilter(f, g, ‘symmetric’) Source: S. Marschner

  19. 0 0 0 0 1 0 0 0 0 Practice with Linear Filters ? Original Source: D. Lowe

  20. 0 0 0 0 1 0 0 0 0 Practice with Linear Filters Original Filtered (no change) Source: D. Lowe

  21. 0 0 0 1 0 0 0 0 0 Practice with Linear Filters ? Original Attention to the coordinates flip Source: D. Lowe

  22. 0 0 0 1 0 0 0 0 0 Practice with Linear Filters Original Shifted left By 1 pixel Source: D. Lowe

  23. 1 1 1 1 1 1 1 1 1 Practice with Linear Filters ? Original Source: D. Lowe

  24. 1 1 1 1 1 1 1 1 1 Practice with Linear Filters Original Blur (with a box filter) Source: D. Lowe

  25. 0 1 0 1 1 0 1 0 1 2 1 0 1 0 1 0 1 0 Practice with Linear Filters - ? (Note that filter sums to 1) Original Source: D. Lowe

  26. 0 1 0 1 1 0 1 0 1 2 1 0 1 0 1 0 1 0 Practice with Linear Filters - Original Sharpening filter • Accentuates differences with local average. Source: D. Lowe

  27. Sharpening Source: D. Lowe

  28. Smoothing with Box Filter Revisited • It doesn’t compare well with a defocused lens. • A single point of light viewed in a defocused lens looks like a fuzzy blob. • This is the point spread function (PSF) of acquisition systems. • Averaging gives a square. • This is a drawback yielding a block effect in the resulting image. Source: D. Forsyth

  29. Smoothing with Box Filter Revisited Source: D. Forsyth

  30. Smoothing with Box Filter Revisited • Better idea: to eliminate edge effects, weight contribution of neighborhood pixels according to their closeness to the center. “fuzzy blob”

  31. Gaussian Kernel • The constant factor is for normalization to 1 (it can be ignored, as we should re-normalize weights to sum to 1 in any case). 0.003 0.013 0.022 0.013 0.003 0.013 0.059 0.097 0.059 0.013 0.022 0.097 0.159 0.097 0.022 0.013 0.059 0.097 0.059 0.013 0.003 0.013 0.022 0.013 0.003 5 x 5,  = 1 Source: C. Rasmussen

  32. Selecting the Kernel Width • Gaussian filters have infinite support, but discrete filters use finite kernels. Source: K. Grauman

  33. Selecting the Kernel Width • Rule of thumb: set filter half-width at about 3σ. • Little effect if the standard deviation of the Gaussian is small • For larger standard deviation the average is biased to a consensus of the neighbors. • The noise disappears at the cost of some blurring. • Large standard deviations cause image detail to disappear along with the noise.

  34. Example: Smoothing with a Gaussian

  35. Mean vs Gaussian Filtering

  36. Gaussian Filters • Remove “high-frequency” components from the image (low-pass filter). • Convolution with itself is also Gaussian • Convolving twice with a Gaussian kernel of width σ is the same as convolving once with a kernel of width σ√2. • Separablekernel • Factorization into a product of two 1D Gaussians. Source: K. Grauman

  37. Separability of the Gaussian Filter The computational complexity becomes linear from square (per pixel). Source: D. Lowe

  38. Noise • Salt and pepper : contains random occurrences of black and white pixels. • Impulse: contains random occurrences of white pixels. • Gaussian : variations in intensity drawn from a Gaussian normal distribution Source: S. Seitz

  39. Gaussian Noise • Mathematical model: sum of many independent factors. • Good model for small standard deviations. • Assumption: independent, i.i.d, zero-mean. Source: M. Hebert

  40. Reducing Gaussian 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. Notice the overloading notation: Gaussian noise and Gaussian filter which both have standard deviations. Gaussian filters are good at suppressing Gaussian noise.

  41. Reducing Salt-and-Pepper Noise 3x3 5x5 7x7 • What’s wrong with the results?

  42. Alternative Idea: Median Filtering • A median filter operates over a window by selecting the median intensity in the window. • Is median filtering linear? Source: K. Grauman

  43. Median Filter • Advantage over Gaussian filtering. • Robustness to outliers. Source: K. Grauman

  44. Median Filter (cont.) Median filtered Salt-and-pepper noise Source: M. Hebert

  45. Median vs Gaussian Filtering 3x3 5x5 7x7 Gaussian Median

  46. = detail smoothed (5x5) original Let’s add it back: + α = original detail sharpened Sharpening Revisited What does blurring take away? –

  47. unit impulse Gaussian Laplacian of Gaussian Unsharp Mask Filter image unit impulse(identity) blurredimage

  48. Other non-linear filters • Weighted median (pixels further from center count less) • Clipped mean (ignoring few brightest and darkest pixels) • Bilateral filtering (weight by spatial distance and intensity difference) Bilateral filtering http://vision.ai.uiuc.edu/?p=1455

  49. Anisotropic Scaling • The symmetric Gaussian filter tends to blur out edges and consequently it merges structures near one another. • This suggests that smoothing should be differently at edge points (we will discuss edge detection in the next lecture in detail). • The idea is to estimate the gradient and orientation of the gradient and smooth in an oriented manner at large gradient amplitudes (edge-preserving smoothing). • P. Perona and J. Malik [ICCV 1990] noticed that this is equivalent to apply the diffusion equation to the image.

  50. Anisotropic Scaling (cont.) • The symmetric Gaussian filter tends to blur out edges and consequently it merges structures near one another. • With the initial condition: • Applying this equation iteratively smooths the image by diffusing the intensity of a pixel to its neighboring pixels and edges are not preserved.

More Related