Lecture 5: Statistical models of images
Today • Review Fourier transforms • Image statistics • Texture synthesis
The Discrete Fourier transform The Discrete Fourier Transform (DFT) transforms a signal f[n] into F[u] as: Fourier coefficient for frequency u 1D image f [ n ] exp ( − 2 π j un N − 1 N ) ∑ F [ u ] = n =0
Examples From Szeliski 3.4
Examples array([1.+0.j, 1.+0.j, a = np.eye(8)[0] 1.+0.j, 1.+0.j, 1.+0.j, np.fft.fft(a) 1.+0.j, 1.+0.j, 1.+0.j])
Examples array([8.+0.j, 0.+0.j, a = np.ones(8) 0.+0.j, 0.+0.j, 0.+0.j, np.fft.fft(a) 0.+0.j, 0.+0.j, 0.+0.j])
2D Discrete Fourier Transform 2D Discrete Fourier Transform (DFT) transforms an image f [ n,m ] into F [ u,v ] as: f [ n , m ] exp ( − 2 π j ( M ) ) N − 1 M − 1 un N + vm ∑ ∑ F [ u , v ] = n =0 m =0
Examples What is the 2D FFT of a line?
Fourier transform in x direction -v +v
Full 2D Fourier transform -u -v +v +u
What is a “natural” image? “Natural” image “Fake” image Source: Torralba, Freeman, Isola
Source: Torralba, Freeman, Isola
Statistical modeling of images The pixel Source: Torralba, Freeman, Isola
Statistical modeling of images Assumptions : • Independence: All pixels are independent. • Stationarity: The distribution of pixel intensities does not depend on image location. Source: Torralba, Freeman, Isola
Fitting the model Counts Pixel intensity Source: Torralba, Freeman, Isola
Sampling new images Sample Source: Torralba, Freeman, Isola
Sampling new images Sample Doesn’t work very well! Source: Torralba, Freeman, Isola
Statistical modeling of images The pixel Source: Torralba, Freeman, Isola
Statistical modeling of images The pixel Another pixel Source: Torralba, Freeman, Isola
Δ = 2 Δ = 1 Δ = 10 Δ = 40 C horizontal vertical Δ Source: Torralba, Freeman, Isola
Gaussian model We want a distribution that captures the correlation structure typical of natural images. Let C be the covariance matrix of the image: Stationarity assumption: Symmetrical circulant matrix Diagonalization of circulant matrices: C = EDE T The eigenvectors are the Fourier basis The eigenvalues are the squared magnitude of the Fourier coefficients 2 D= 2 … Source: Torralba, Freeman, Isola
A remarkable property of natural images Power spectra fall off as Low spatial frequencies Spectra 1/ v a High spatial frequencies D. J. Field, "Relations between the statistics of natural images and the response properties of cortical cells," J. Opt. Soc. Am. A 4 , 2379- (1987) Source: Torralba, Freeman, Isola
Sampling new images Sample Fit the Gaussian image model to each of the images in the top row, then draw another random sample (with random phase), you get the bottom row. Source: Torralba, Freeman, Isola
Sampling new images Source: Torralba, Freeman, Isola
Doesn’t always work well! Source: Torralba, Freeman, Isola
Denoising Decomposition of a noisy image + = Source: Torralba, Freeman, Isola
Denoising Decomposition of a noisy image + = White Gaussian noise: N (0, σ n2 ) Natural image Find I(x,y) that maximizes the posterior (maximum a posteriory, MAP): x prior likelihood (Bayes’ theorem) Source: Torralba, Freeman, Isola
Denoising Decomposition of a noisy image + = White Gaussian noise: N (0, σ n2 ) Natural image Find I(x,y) that maximizes the posterior (maximum a posteriory, MAP): x prior likelihood x Source: Torralba, Freeman, Isola
Denoising x prior likelihood x The solution is: (note this is a linear operation) This can also be written in the Fourier domain, for constant A: Source: Torralba, Freeman, Isola
The truth: + = The estimated decomposition: = + Source: Torralba, Freeman, Isola
Statistical modeling of images A small neighborhood Source: Torralba, Freeman, Isola
[-1 1] = [-1, 1] h[m,n] f[m,n] g[m,n] Source: Torralba, Freeman, Isola
[-1 1] T = [-1, 1] T h[m,n] f[m,n] g[m,n] Source: Torralba, Freeman, Isola
Observation: Sparse filter response Source: Torralba, Freeman, Isola
Image Intensity histogram [1 -1] filter output [1 -1] output histogram Red – true pdf Black – best Gaussian fit
A model based on filter outputs A small neighborhood p ( h k ( x,y ) ) k All pixels and all outputs are independent Filter outputs Source: Torralba, Freeman, Isola
Sampling images Gaussian model Wavelet marginal model Source: Torralba, Freeman, Isola
Taking a picture… What the camera give us… How do we correct this? Slides R. Fergus
Deblurring Slides R. Fergus
Deblurring Slides R. Fergus
Deblurring Slides R. Fergus
Image formation process ⊗ = Blur kernel Blurry image Sharp image Input to algorithm Desired output Convolution Model is approximation operator
Multiple possible solutions Sharp image Blur kernel = ⊗ = ⊗ Blurry image = ⊗
Natural image statistics Characteristic distribution with heavy tails Histogram of image gradients Slides R. Fergus
Blury images have different statistics Histogram of image gradients Slides R. Fergus
Parametric distribution Histogram of image gradients Use parametric model of sharp image statistics Slides R. Fergus
Nonparametric image models
Texture Synthesis Source: A. Efros
Efros & Leung Algorithm non-parametric sampling p Input image Synthesizing a pixel • Assuming Markov property, compute P( p |N( p )) – Building explicit probability tables infeasible – Instead, we search the input image for all similar neighborhoods — that’s our pdf for p – To sample from this pdf, just pick one match at random Source: A. Efros
Some Details • Growing is in “onion skin” order – Within each “layer”, pixels with most neighbors are synthesized first – If no close match can be found, the pixel is not synthesized until the end • Using Gaussian-weighted SSD is very important – to make sure the new pixel agrees with its closest neighbors – Approximates reduction to a smaller neighborhood window if data is too sparse Source: A. Efros
Neighborhood Window input Source: A. Efros
Varying Window Size Increasing window size Source: A. Efros
Synthesis Results french canvas rafia weave Source: A. Efros
More Results white bread brick wall Source: A. Efros
Homage to Shannon Source: A. Efros
Hole Filling Source: A. Efros
Extrapolation Source: A. Efros
Summary • The Efros & Leung algorithm – Very simple – Surprisingly good results – Synthesis is easier than analysis! – …but very slow
Image Quilting [Efros & Freeman] non-parametric sampling p B Input image Synthesizing a block • Observation: neighbor pixels are highly correlated Idea: unit of synthesis = block • Exactly the same but now we want P( B |N( B )) • Much faster: synthesize all pixels in a block at once • Not the same as multi-scale!
block Input texture B1 B2 B1 B1 B2 B2 Neighboring blocks Minimal error Random placement constrained by overlap boundary cut of blocks
Minimal error boundary overlapping blocks vertical boundary 2 _ = overlap error min. error boundary
Our Philosophy • The “Corrupt Professor’s Algorithm”: – Plagiarize as much of the source image as you can – Then try to cover up the evidence • Rationale: – Texture blocks are by definition correct samples of texture so problem only connecting them together
Failures (Chernobyl Harvest)
Texture Transfer Constraint Texture sample
Recommend
More recommend