The Frequency Domain, without tears. Many slides borrowed from Steve Seitz

Similar documents
The Frequency Domain : Computational Photography Alexei Efros, CMU, Fall Many slides borrowed from Steve Seitz

The Frequency Domain. Many slides borrowed from Steve Seitz

Image Filtering, Edges and Image Representation

Slow mo guys Saccades.

Recap of Monday. Linear filtering. Be aware of details for filter size, extrapolation, cropping

CS 4495 Computer Vision. Frequency and Fourier Transforms. Aaron Bobick School of Interactive Computing. Frequency and Fourier Transform

CEE598 - Visual Sensing for Civil Infrastructure Eng. & Mgmt.

CSCI 1290: Comp Photo

Thinking in Frequency

Filtering, Frequency, and Edges

ECE Digital Image Processing and Introduction to Computer Vision

Frequency2: Sampling and Aliasing

Why does a lower resolution image still make sense to us? What do we lose? Image:

Taking derivative by convolution

Intelligent Visual Prosthesis

Image Processing 2. Hakan Bilen University of Edinburgh. Computer Graphics Fall 2017

ECE Digital Image Processing and Introduction to Computer Vision. Outline

Templates, Image Pyramids, and Filter Banks

Fourier Transform and Frequency Domain

Computational Photography

Fourier Transform and Frequency Domain

Frequency Filtering CSC 767

Image pyramids and frequency domain

Image Filtering. Slides, adapted from. Steve Seitz and Rick Szeliski, U.Washington

Today s lecture. Local neighbourhood processing. The convolution. Removing uncorrelated noise from an image The Fourier transform

6.869 Advances in Computer Vision. Bill Freeman, Antonio Torralba and Phillip Isola MIT Oct. 3, 2018

Computer Vision Lecture 3

Image Alignment and Mosaicing

ECE Digital Image Processing and Introduction to Computer Vision. Outline

Image Stitching II. Linda Shapiro CSE 455

Introduction to Computer Vision. 2D Linear Systems

Image Stitching II. Linda Shapiro EE/CSE 576

Multiscale Image Transforms

Subsampling and image pyramids

CS 3710: Visual Recognition Describing Images with Features. Adriana Kovashka Department of Computer Science January 8, 2015

CITS 4402 Computer Vision

Linear Operators and Fourier Transform

Additional Pointers. Introduction to Computer Vision. Convolution. Area operations: Linear filtering

Lecture 3: Linear Filters

Digital Image Processing COSC 6380/4393

Review Smoothing Spatial Filters Sharpening Spatial Filters. Spatial Filtering. Dr. Praveen Sankaran. Department of ECE NIT Calicut.

f (t) K(t, u) d t. f (t) K 1 (t, u) d u. Integral Transform Inverse Fourier Transform

Theory of signals and images I. Dr. Victor Castaneda

Lecture 3: Linear Filters

Dr. David A. Clifton Group Leader Computational Health Informatics (CHI) Lab Lecturer in Engineering Science, Balliol College

Lecture 04 Image Filtering

Wavelets and Multiresolution Processing

Lecture 5. The Digital Fourier Transform. (Based, in part, on The Scientist and Engineer's Guide to Digital Signal Processing by Steven Smith)

I Chen Lin, Assistant Professor Dept. of CS, National Chiao Tung University. Computer Vision: 4. Filtering

ECG782: Multidimensional Digital Signal Processing

Reprinted from Proceedings of the Pattern Recognition and Information Processing Conference (pp ), Dallas, TX (1981).

Image Enhancement in the frequency domain. GZ Chapter 4

Reading. 3. Image processing. Pixel movement. Image processing Y R I G Q

Fast Local Laplacian Filters: Theory and Applications

Edges and Scale. Image Features. Detecting edges. Origin of Edges. Solution: smooth first. Effects of noise

Empirical Mean and Variance!

Digital Image Processing. Image Enhancement: Filtering in the Frequency Domain

Image preprocessing in spatial domain

Roadmap. Introduction to image analysis (computer vision) Theory of edge detection. Applications

Multiresolution image processing

Local Enhancement. Local enhancement

Lecture 8: Interest Point Detection. Saad J Bedros

COMP344 Digital Image Processing Fall 2007 Final Examination

Image Processing /6.865 Frédo Durand A bunch of slides by Bill Freeman (MIT) & Alyosha Efros (CMU)

Today s lecture. The Fourier transform. Sampling, aliasing, interpolation The Fast Fourier Transform (FFT) algorithm

Fourier Transform in Image Processing. CS/BIOEN 6640 U of Utah Guido Gerig (slides modified from Marcel Prastawa 2012)

6.003: Signals and Systems. Sampling and Quantization

Filtering and Edge Detection

Image Alignment and Mosaicing Feature Tracking and the Kalman Filter

Edge Detection. Introduction to Computer Vision. Useful Mathematics Funcs. The bad news

Fourier Transforms 1D

Colorado School of Mines Image and Multidimensional Signal Processing

Lecture 4 Filtering in the Frequency Domain. Lin ZHANG, PhD School of Software Engineering Tongji University Spring 2016

ECG782: Multidimensional Digital Signal Processing

Computer Vision Lecture 3

Local enhancement. Local Enhancement. Local histogram equalized. Histogram equalized. Local Contrast Enhancement. Fig 3.23: Another example

Multiresolution schemes

IMAGE ENHANCEMENT: FILTERING IN THE FREQUENCY DOMAIN. Francesca Pizzorni Ferrarese

Digital Image Processing

encoding without prediction) (Server) Quantization: Initial Data 0, 1, 2, Quantized Data 0, 1, 2, 3, 4, 8, 16, 32, 64, 128, 256

Vectors [and more on masks] Vector space theory applies directly to several image processing/ representation problems

GBS765 Electron microscopy

Module 4. Multi-Resolution Analysis. Version 2 ECE IIT, Kharagpur

Linear Diffusion and Image Processing. Outline

Gradient-domain image processing

Introduction to Linear Image Processing

Source Coding for Compression

Image Noise: Detection, Measurement and Removal Techniques. Zhifei Zhang

Lecture 7: Edge Detection

Multiresolution schemes

Review of Linear System Theory

Edge Detection. CS 650: Computer Vision

Digital Image Processing. Filtering in the Frequency Domain

TRACKING and DETECTION in COMPUTER VISION Filtering and edge detection

Image Enhancement: Methods. Digital Image Processing. No Explicit definition. Spatial Domain: Frequency Domain:

Stability of Recursive Gaussian Filtering for Piecewise Linear Bilateral Filtering

SEISMIC WAVE PROPAGATION. Lecture 2: Fourier Analysis

Edge Detection. Image Processing - Computer Vision

CSE 473/573 Computer Vision and Image Processing (CVIP)

Convolution Spatial Aliasing Frequency domain filtering fundamentals Applications Image smoothing Image sharpening

Transcription:

The Frequency Domain, without tears Many slides borrowed from Steve Seitz Somewhere in Cinque Terre, May 2005 CS194: Image Manipulation & Computational Photography Alexei Efros, UC Berkeley, Fall 2016

Salvador Dali Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln, 1976

A nice set of basis Teases away fast vs. slow changes in the image. This change of basis has a special name

Jean Baptiste Joseph Fourier (1768-1830) 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...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. Laplace Lagrange Legendre

A sum of sines Our building block: Asin(ωx +φ) Add enough of them to get any signal f(x) you want! How many degrees of freedom? What does each control? Which one encodes the coarse vs. fine structure of the signal?

Fourier Transform We want to understand the frequency ω of our signal. So, let s reparametrize the signal by ω instead of x: f(x) Fourier Transform F(ω) For every ω from 0 to inf, F(ω) holds the amplitude A and phase φ of the corresponding sine How can F hold both? A = ± R ω + I F(ω) F ( ω) = R( ω) + ii( ω) 2 2 ( ) ( ω) We can always go back: φ = Inverse Fourier Transform tan 1 Asin(ωx +φ) I( ω) R( ω) f(x)

Time and Frequency example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)

Time and Frequency example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t) = +

Frequency Spectra example : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t) = +

Frequency Spectra Usually, frequency is more interesting than the phase

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = + =

Frequency Spectra = A k = 1 1 sin(2 π kt ) k

Frequency Spectra

FT: Just a change of basis M * f(x) = F(ω) * =...

IFT: Just a change of basis M -1 * F(ω) = f(x) * =...

Finally: Scary Math

Finally: Scary Math not really scary: e i ω x is hiding our old friend: phase can be encoded by sin/cos pair = cos( ωx) + i sin( ωx) sin(ωx +φ) P cos( x) + Qsin( x) = Asin( x + φ) Α = ± P 2 + Q 2 φ = tan 1 P Q So it s just our signal f(x) times sine at frequency ω

Extension to 2D = Image as a sum of basis images

Extension to 2D in Matlab, check out: imagesc(log(abs(fftshift(fft2(im)))));

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

Man-made Scene

Can change spectrum, then reconstruct Local change in one domain, courses global change in the other

Low and High Pass filtering

The Convolution Theorem The greatest thing since sliced (banana) bread! The Fourier transform of the convolution of two functions is the product of their Fourier transforms F[ g h] = F[ g]f[ h] The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms 1 1 1 F [ gh] = F [ g] [ h] Convolution in spatial domain is equivalent to multiplication in frequency domain! F

2D convolution theorem example f(x,y) F(s x,s y ) * h(x,y) H(s x,s y ) g(x,y) G(s x,s y )

Filtering Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts? Gaussian Box filter

Fourier Transform pairs

Gaussian

Box Filter

Low-pass, Band-pass, High-pass filters low-pass: High-pass / band-pass:

Edges in images

What does blurring take away? original

What does blurring take away? smoothed (5x5 Gaussian)

High-Pass filter smoothed original

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

Unsharp mask filter f + α( f f g) = (1 + α) f α f g = f ((1 + α) e αg) image blurred image unit impulse (identity) unit impulse Gaussian Laplacian of Gaussian

Hybrid Images Gaussian Filter! A. Oliva, A. Torralba, P.G. Schyns, Hybrid Images, SIGGRAPH 2006 Laplacian Filter! unit impulse Gaussian Laplacian of Gaussian

Salvador Dali Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln, 1976

Band-pass filtering Gaussian Pyramid (low-pass images) Laplacian Pyramid (subband images) Created from Gaussian pyramid by subtraction

Laplacian Pyramid Need this! Original image How can we reconstruct (collapse) this pyramid into the original image?

Blending

Alpha Blending / Feathering + 1 0 1 0 I blend = αi left + (1-α)I right =

Affect of Window Size 1 left 1 0 right 0

Affect of Window Size 1 1 0 0

Good Window Size 1 0 Optimal Window: smooth but not ghosted

What is the Optimal Window? To avoid seams window = size of largest prominent feature To avoid ghosting window <= 2*size of smallest prominent feature Natural to cast this in the Fourier domain largest frequency <= 2*size of smallest frequency image frequency content should occupy one octave (power of two) FFT

What if the Frequency Spread is Wide FFT Idea (Burt and Adelson) Compute F left = FFT(I left ), F right = FFT(I right ) Decompose Fourier image into octaves (bands) F left = F left 1 + F left 2 + Feather corresponding octaves F left i with F right i Can compute inverse FFT and feather in spatial domain Sum feathered octave images in frequency domain Better implemented in spatial domain

Octaves in the Spatial Domain Lowpass Images Bandpass Images

Pyramid Blending 1 0 1 0 1 0 Left pyramid blend Right pyramid

Pyramid Blending

laplacian level 4 laplacian level 2 laplacian level 0 left pyramid right pyramid blended pyramid

Blending Regions

Laplacian Pyramid: Blending General Approach: 1. Build Laplacian pyramids LA and LB from images A and B 2. Build a Gaussian pyramid GR from selected region R 3. Form a combined pyramid LS from LA and LB using nodes of GR as weights: LS(i,j) = GR(I,j,)*LA(I,j) + (1-GR(I,j))*LB(I,j) 4. Collapse the LS pyramid to get the final blended image

Horror Photo david dmartin (Boston College)

Results from this class (fall 2005) Chris Cameron

Simplification: Two-band Blending Brown & Lowe, 2003 Only use two bands: high freq. and low freq. Blends low freq. smoothly Blend high freq. with no smoothing: use binary alpha

High frequency (λ < 2 pixels) 2-band Laplacian Stack Blending Low frequency (λ > 2 pixels)

Linear Blending

2-band Blending

Da Vinci and Peripheral Vision https://en.wikipedia.org/wiki/speculations_about_mona_lisa#smile

Leonardo playing with peripheral vision Livingstone, Vision and Art: The Biology of Seeing

Clues from Human Perception Early processing in humans filters for various orientations and scales of frequency Perceptual cues in the mid 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

Frequency Domain and Perception Campbell-Robson contrast sensitivity curve

Freq. Perception Depends on Color R G B

Lossy Image Compression (JPEG) Block-based Discrete Cosine Transform (DCT)

Using DCT in JPEG The first coefficient B(0,0) is the DC component, the average intensity The top-left coeffs represent low frequencies, the bottom right high frequencies

Image compression using DCT Quantize More coarsely for high frequencies (which also tend to have smaller values) Many quantized high frequency values will be zero Encode Filter responses Can decode with inverse dct Quantization table Quantized values

JPEG Compression Summary Subsample color by factor of 2 People have bad resolution for color Split into blocks (8x8, typically), subtract 128 For each block a. Compute DCT coefficients b. Coarsely quantize Many high frequency components will become zero c. Encode (e.g., with Huffman coding) http://en.wikipedia.org/wiki/ycbcr http://en.wikipedia.org/wiki/jpeg

Block size in JPEG Block size small block faster correlation exists between neighboring pixels large block better compression in smooth regions It s 8x8 in standard JPEG

JPEG compression comparison 89k 12k

Denoising Gaussian Filter Additive Gaussian Noise

Reducing Gaussian noise Smoothing with larger standard deviations suppresses noise, but also blurs the image Source: S. Lazebnik

Reducing salt-and-pepper noise by Gaussian smoothing 3x3 5x5 7x7

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

Median filter What advantage does median filtering have over Gaussian filtering? Robustness to outliers Source: K. Grauman

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

Median vs. Gaussian filtering 3x3 5x5 7x7 Gaussian Median

EXTRA SLIDES

A Gentle Introduction to Bilateral Filtering and its Applications Fixing the Gaussian Blur : the Bilateral Filter Sylvain Paris MIT CSAIL

Blur Comes from Averaging across Edges input * output * * Same Gaussian kernel everywhere.

Bilateral Filter [Aurich 95, Smith 97, Tomasi 98] No Averaging across Edges input * output * * The kernel shape depends on the image content.

Bilateral Filter Definition: an Additional Edge Term Same idea: weighted average of pixels. BF I] = new 1 W G not new new ( p q ) G ( I I ) [ p σ s σ r p q S p q I q normalization factor space weight range weight I

Illustration a 1D Image 1D image = line of pixels Better visualized as a plot pixel intensity pixel position

Gaussian Blur and Bilateral Filter Gaussian blur p q GB I = G [ ] p σ q S ( p q ) space I q space Bilateral filter [Aurich 95, Smith 97, Tomasi 98] q p space range 1 BF [ I] p = Gσ W s σ r p q S space normalization ( p q ) G ( I I ) p range q I q

This image cannot currently be displayed. Bilateral Filter on a Height Field 1 BF [ I] p = Gσ r W s σ p q S ( p q ) G ( I I ) p q I q p q output input reproduced from [Durand 02]

Space and Range Parameters BF 1 [ I] = p G r W p q S ( p q ) G ( I I ) σ s σ p q I q space σ s : spatial extent of the kernel, size of the considered neighborhood. range σ r : minimum amplitude of an edge

Influence of Pixels Only pixels close in space and in range are considered. space range p

Exploring the Parameter Space σ r = 0.1 σ r = 0.25 σ r = (Gaussian blur) input σ s = 2 σ s = 6 σ s = 18

Varying the Range Parameter σ r = 0.1 σ r = 0.25 σ r = (Gaussian blur) input σ s = 2 σ s = 6 σ s = 18

input

σ r = 0.1

σ r = 0.25

σ r = (Gaussian blur)

Varying the Space Parameter σ r = 0.1 σ r = 0.25 σ r = (Gaussian blur) input σ s = 2 σ s = 6 σ s = 18

input

σ s = 2

σ s = 6

σ s = 18