Slide credit Fei Fei Li.

Slides:



Advertisements
Similar presentations
Linear Filtering – Part II Selim Aksoy Department of Computer Engineering Bilkent University
Advertisements

Motion illusion, rotating snakes. Slide credit Fei Fei Li.
CS 691 Computational Photography Instructor: Gianfranco Doretto Frequency Domain.
Ted Adelson’s checkerboard illusion. Motion illusion, rotating snakes.
Computational Photography: Sampling + Reconstruction Connelly Barnes Slides from Alexei Efros and Steve Marschner.
Thinking in Frequency Computer Vision Brown James Hays Slides: Hoiem, Efros, and others.
Computer Vision University of Illinois Derek Hoiem
Linear Filtering – Part II Selim Aksoy Department of Computer Engineering Bilkent University
Computational Photography CSE 590 Tamara Berg Filtering & Pyramids.
Immagini e filtri lineari. Image Filtering Modifying the pixels in an image based on some function of a local neighborhood of the pixels
Lecture 1: Images and image filtering
Linear filtering. Overview: Linear filtering Linear filters Definition and properties Examples Gaussian smoothing Separability Applications Denoising.
CSCE 641 Computer Graphics: Fourier Transform Jinxiang Chai.
15-463: Computational Photography Alexei Efros, CMU, Fall 2011 Many slides from Steve Marschner Sampling and Reconstruction.
The Frequency Domain : Computational Photography Alexei Efros, CMU, Fall 2011 Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve.
CPSC 641 Computer Graphics: Fourier Transform Jinxiang Chai.
Lecture 2: Image filtering
Linear filtering.
The Frequency Domain : Computational Photography Alexei Efros, CMU, Fall 2008 Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve.
Computational Photography: Fourier Transform Jinxiang Chai.
Slides from Alexei Efros, Steve Marschner Filters & fourier theory.
Fourier Analysis : Rendering and Image Processing Alexei Efros.
CSC589 Introduction to Computer Vision Lecture 9 Sampling, Gaussian Pyramid Bei Xiao.
CSE 185 Introduction to Computer Vision Image Filtering: Frequency Domain.
Slide credit Fei Fei Li. Image filtering Image filtering: compute function of local neighborhood at each position Really important! – Enhance images.
Applications of Image Filters Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/04/10.
The Frequency Domain Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve Seitz CS194: Image Manipulation & Computational Photography Alexei.
Computer Vision James Hays Thinking in Frequency Computer Vision James Hays Slides: Hoiem, Efros, and others.
CSC589 Introduction to Computer Vision Lecture 7 Thinking in Frequency Bei Xiao.
CSE 185 Introduction to Computer Vision Image Filtering: Frequency Domain.
Templates and Image Pyramids Computational Photography Derek Hoiem, University of Illinois 09/03/15.
Linear Filters August 27 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Devi Parikh Disclaimer: Many slides have been borrowed from Kristen Grauman,
Thinking in Frequency Computational Photography University of Illinois Derek Hoiem 09/01/15.
Image Filtering Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/02/10.
Linear filtering. Motivation: Noise reduction Given a camera and a still scene, how can you reduce noise? Take lots of images and average them! What’s.
Recap of Monday linear Filtering convolution differential filters filter types boundary conditions.
Pixels and Image Filtering Computer Vision Derek Hoiem, University of Illinois 02/01/11 Graphic:
Image as a linear combination of basis images
CS 691B Computational Photography
Pixels and Image Filtering Computational Photography Derek Hoiem 08/26/10 Graphic:
Lecture 5: Fourier and Pyramids
Reconnaissance d’objets et vision artificielle
Linear filtering. Motivation: Image denoising How can we reduce noise in a photograph?
CSE 185 Introduction to Computer Vision Image Filtering: Spatial Domain.
Lecture 1: Images and image filtering CS4670/5670: Intro to Computer Vision Noah Snavely Hybrid Images, Oliva et al.,
The Frequency Domain, without tears
Prof. Adriana Kovashka University of Pittsburgh September 14, 2016
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Computer Vision Brown James Hays 09/16/11 Thinking in Frequency Computer Vision Brown James Hays Slides: Hoiem, Efros, and others.
Sampling, Template Matching and Pyramids
Slow mo guys – Saccades
Linear Filtering – Part II
Linear Filters T-11 Computer Vision University of Houston
Pixels and Image Filtering
Department of Computer Engineering
The Frequency Domain : Computational Photography
Lecture 1: Images and image filtering
Recap from Wednesday Spectra and Color Light capture in cameras and humans.
Sampling and Reconstruction
CSCE 643 Computer Vision: Image Sampling and Filtering
CSCE 643 Computer Vision: Thinking in Frequency
Motion illusion, rotating snakes
Linear filtering.
Lecture 5: Resampling, Compositing, and Filtering Li Zhang Spring 2008
Oh, no, wait, sorry, I meant, welcome to the implementation of 20th-century science fiction literature, or a small part of it, where we will learn about.
Linear Filtering CS 678 Spring 2018.
Department of Computer Engineering
Lecture 1: Images and image filtering
Thinking in Frequency Computational Photography University of Illinois
Templates and Image Pyramids
Presentation transcript:

Slide credit Fei Fei Li

Slide credit Fei Fei Li

Slide credit Fei Fei Li

Image filtering Image filtering: compute function of local neighborhood at each position Really important! Enhance images Denoise, resize, increase contrast, etc. Extract information from images Texture, edges, distinctive points, etc. Detect patterns Template matching

Example: box filter 1 Slide credit: David Lowe (UBC)

Image filtering 1 90 90 ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 90 10 ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 90 10 20 ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 90 10 20 30 ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 10 20 30 ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 10 20 30 ? ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 10 20 30 50 ? ones, divide by 9 Credit: S. Seitz

Image filtering 1 90 10 20 30 40 60 90 50 80 Credit: S. Seitz

Box Filter What does it do? Replaces each pixel with an average of its neighborhood Achieve smoothing effect (remove sharp features) 1 Slide credit: David Lowe (UBC)

Smoothing with box filter

Practice with linear filters 1 ? Original Source: D. Lowe

Practice with linear filters 1 Original Filtered (no change) Source: D. Lowe

Practice with linear filters 1 ? Original Source: D. Lowe

Practice with linear filters 1 Original Shifted left By 1 pixel Source: D. Lowe

Practice with linear filters - 2 1 ? (Note that filter sums to 1) Original Source: D. Lowe

Practice with linear filters - 2 1 Original Sharpening filter Accentuates differences with local average Source: D. Lowe

Sharpening Source: D. Lowe

Other filters -1 1 -2 2 Sobel Vertical Edge (absolute value)

Other filters -1 -2 1 2 Horizontal Edge (absolute value) Sobel 1 2 Questions at this point? Sobel Horizontal Edge (absolute value)

Filtering vs. Convolution g=filter f=image 2d filtering 2d convolution

Key properties of linear filters Linearity: filter(f1 + f2) = filter(f1) + filter(f2) Shift invariance: same behavior regardless of pixel location filter(shift(f)) = shift(filter(f)) Any linear, shift-invariant operator can be represented as a convolution f is image Source: S. Lazebnik

More properties 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 Source: S. Lazebnik

Important filter: Gaussian Weight contributions of neighboring pixels by nearness 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 5 x 5,  = 1 e^0 = 1, e^-1 = .37, e^-2 = .14, etc. Slide credit: Christopher Rasmussen

Smoothing with Gaussian filter

Smoothing with box filter

Gaussian filters Remove “high-frequency” components from the image (low-pass filter) Images become smoother Convolution with self is another Gaussian So can smooth with small-width kernel, repeat, and get same result as larger-width kernel would have Convolving two times with Gaussian kernel of width σ is same as convolving once with kernel of width σ√2 Separable kernel Factors into product of two 1D Gaussians Linear vs. quadratic in mask size Source: K. Grauman

Separability of the Gaussian filter Source: D. Lowe

Separability example * 2D convolution (center location only) The filter factors into a product of 1D filters: * = Perform convolution along rows: Followed by convolution along the remaining column: Source: K. Grauman

Separability Why is separability useful in practice? Because you can do it faster. Filtering an M-by-N image with a P-by-Q filter kernel requires roughly MNPQ multiplies and adds. With separable kernels, you can filter in two steps. The first step requires about MNP multiplies and adds. The second requires about MNQ multiplies and adds, for a total of MN(P + Q). Performance Advantage  PQ/(P+Q) The computational advantage of separable convolution versus nonseparable convolution is therefore: For a 9-by-9 filter kernel, that's a theoretical speed-up of 4.5.

Practical matters What about near the edge? 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

Practical matters What is the size of the output? MATLAB: filter2(g, f, shape) shape = ‘full’: output size is sum of sizes of f and g shape = ‘same’: output size is same as f shape = ‘valid’: output size is difference of sizes of f and g full same valid g g g g f f g f g g g g g g g Source: S. Lazebnik

Median filters A Median Filter operates over a window by selecting the median intensity in the window. What advantage does a median filter have over a mean filter? Is a median filter a kind of convolution? Better at salt’n’pepper noise Not convolution: try a region with 1’s and a 2, and then 1’s and a 3 © 2006 Steve Marschner • 37 Slide by Steve Seitz

Comparison: salt and pepper noise © 2006 Steve Marschner • 38 Slide by Steve Seitz

Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts? Box filter Things we can’t understand without thinking in frequency

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

Why do we get different, distance-dependent interpretations of hybrid images? Slide: Hoiem

Why does a lower resolution image still make sense to us Why does a lower resolution image still make sense to us? What do we lose? Image: http://www.flickr.com/photos/igorms/136916757/ Slide: Hoiem

Thinking in terms of frequency

Jean Baptiste Joseph Fourier (1768-1830) ...the manner in which the author arrives at these equations is not exempt of difficulties and...his analysis to integrate them still leaves something to be desired on the score of generality and even rigour. had crazy idea (1807): Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies. Don’t believe it? Neither did Lagrange, Laplace, Poisson and other big wigs Not translated into English until 1878! But it’s (mostly) true! called Fourier Series there are some subtle restrictions Laplace Legendre Lagrange

A sum of sines Our building block: Add enough of them to get any signal g(x) you want!

Frequency Spectra example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t) = + Slides: Efros

Frequency Spectra

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra =

Example: Music We think of music in terms of frequencies at different magnitudes Slide: Hoiem

Other signals We can also think of all kinds of other signals the same way xkcd.com

Fourier analysis in images Intensity Image Fourier Image http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering

Signals can be composed + = http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering More: http://www.cs.unm.edu/~brayer/vision/fourier.html

Fourier Transform Fourier transform stores the magnitude and phase at each frequency Magnitude encodes how much signal there is at a particular frequency Phase encodes spatial information (indirectly) For mathematical convenience, this is often notated in terms of real and complex numbers Amplitude: Phase:

Computing the Fourier Transform Continuous Discrete k = -N/2..N/2 Fast Fourier Transform (FFT): NlogN

The Convolution Theorem The Fourier transform of the convolution of two functions is the product of their Fourier transforms Convolution in spatial domain is equivalent to multiplication in frequency domain!

Properties of Fourier Transforms Linearity Fourier transform of a real signal is symmetric about the origin The energy of the signal is the same as the energy of its Fourier transform See Szeliski Book (3.4)

Filtering in spatial domain -1 1 -2 2 * =

Filtering in frequency domain FFT FFT = Inverse FFT Slide: Hoiem

Filtering Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts? Gaussian Box filter Things we can’t understand without thinking in frequency

Gaussian

Box Filter

Sampling Why does a lower resolution image still make sense to us? What do we lose? Image: http://www.flickr.com/photos/igorms/136916757/

Subsampling by a factor of 2 Throw away every other row and column 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 in movies” “Checkerboards disintegrate in ray tracing” “Striped shirts look funny on color television” Source: D. Forsyth

Aliasing in video Slide by Steve Seitz

Aliasing in graphics Source: A. Efros

Sampling and aliasing

Nyquist-Shannon Sampling Theorem When sampling a signal at discrete intervals, the sampling frequency must be  2  fmax fmax = max frequency of the input signal This will allows to reconstruct the original perfectly from the sampled version v v v good bad

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

Algorithm for downsampling by factor of 2 Start with image(h, w) Apply low-pass filter im_blur = imfilter(image, fspecial(‘gaussian’, 7, 1)) Sample every other pixel im_small = im_blur(1:2:end, 1:2:end);

Anti-aliasing Forsyth and Ponce 2002

Subsampling without pre-filtering 1/2 1/4 (2x zoom) 1/8 (4x zoom) Slide by Steve Seitz

Subsampling with Gaussian pre-filtering Slide by Steve Seitz

Why does a lower resolution image still make sense to us Why does a lower resolution image still make sense to us? What do we lose? Image: http://www.flickr.com/photos/igorms/136916757/

Why do we get different, distance-dependent interpretations of hybrid images?

Salvador Dali invented Hybrid Images? “Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976

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

Clues from Human Perception Early processing in humans filters for various orientations and scales of frequency Perceptual cues in the mid-high frequencies dominate perception When we see an image from far away, we are effectively subsampling it Early Visual Processing: Multi-scale edge and blob filters

Hybrid Image in FFT Hybrid Image Low-passed Image High-passed Image

Perception Why do we get different, distance-dependent interpretations of hybrid images? ?

Things to Remember Sometimes it makes sense to think of images and filtering in the frequency domain Fourier analysis Can be faster to filter using FFT for large images (N logN vs. N2 for auto-correlation) Images are mostly smooth Basis for compression Remember to low-pass before sampling

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