The Frequency Domain15-463: Computational PhotographyAlexei Efros, CMU, Fall 2011Somewhere in Cinque Terre, May 2005Many slides borrowed from Steve SeitzSalvador Dali“Gala Contemplating the Mediterranean Sea, which at 30 meters becomes the portrait of Abraham Lincoln”, 1976A nice set of basisThis change of basis has a special name…Teases away fast vs. slow changes in the image.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• there are some subtle restrictions...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.LaplaceLagrangeLegendreA sum of sinesOur building block: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?)+φωxAsin(Fourier TransformWe want to understand the frequency ω of our signal. So, let’s reparametrize the signal by ωinstead of x:)+φωxAsin(f(x)F(ωωωω)Fourier TransformF(ωωωω)f(x)Inverse Fourier TransformFor every ωfrom 0 to inf, F(ωωωω) holds the amplitude A and phase φ of the corresponding sine • How can F hold both? Complex number trick!)()()(ωωωiIRF+=22)()(ωωIRA +±=)()(tan1ωωφRI−=We can always go back:Time and Frequencyexample : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)Time and Frequencyexample : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)= +Frequency Spectraexample : g(t) = sin(2pf t) + (1/3)sin(2p(3f) t)= +Frequency SpectraUsually, frequency is more interesting than the phase= += Frequency Spectra= += Frequency Spectra= += Frequency Spectra= += Frequency Spectra= += Frequency Spectra= 11sin(2 )kA ktkπ∞=∑Frequency SpectraFrequency SpectraExtension to 2Din Matlab, check out: imagesc(log(abs(fftshift(fft2(im)))));Fourier analysis in imagesIntensity ImageFourier Imagehttp://sharp.bu.edu/~slehar/fourier/fourier.html#filteringSignals can be composed+ =http://sharp.bu.edu/~slehar/fourier/fourier.html#filteringMore: http://www.cs.unm.edu/~brayer/vision/fourier.htmlMan-made SceneCan change spectrum, then reconstructLow and High Pass filteringThe Convolution TheoremThe greatest thing since sliced (banana) bread!• The Fourier transform of the convolution of two functions is the product of their Fourier transforms• The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms• Convolution in spatial domain is equivalent to multiplication in frequency domain!]F[]F[]F[ hghg=∗][F][F][F111hggh−−−∗=2D convolution theorem example*f(x,y)h(x,y)g(x,y)|F(sx,sy)||H(sx,sy)||G(sx,sy)|Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts?Gaussian Box filterFilteringGaussianBox FilterFourier Transform pairsLow-pass, Band-pass, High-pass filterslow-pass:High-pass / band-pass:Edges in imagesWhat does blurring take away?originalWhat does blurring take away?smoothed (5x5 Gaussian)High-Pass filtersmoothed – originalBand-pass filteringLaplacian Pyramid (subband images)Created from Gaussian pyramid by subtractionGaussian Pyramid (low-pass images)Laplacian PyramidHow can we reconstruct (collapse) this pyramid into the original image?Need this!OriginalimageWhy Laplacian?Laplacian of GaussianGaussiandelta functionProject 1g: Hybrid Imageshttp://www.cs.illinois.edu/class/fa10/cs498dwh/projects/hybrid/ComputationalPhotography_ProjectHybrid.htmlGaussian Filter!Laplacian Filter!Project Instructions: A. Oliva, A. Torralba, P.G. Schyns, “Hybrid Images,” SIGGRAPH 2006Gaussianunit impulseLaplacian of GaussianEarly processing in humans filters for various orientations and scales of frequencyPerceptual cues in the mid frequencies dominate perceptionWhen we see an image from far away, we are effectively subsamplingitEarly Visual Processing: Multi-scale edge and blob filtersClues from Human PerceptionFrequency Domain and PerceptionFrequency Domain and PerceptionCampbellCampbell--Robson contrast sensitivity curveRobson contrast sensitivity curveUnsharp Masking400600800-==+ ααααFreq. Perception Depends on ColorRG BLossy 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 intensityThe top-left coeffs represent low frequencies, the bottom right – high frequenciesImage compression using DCTQuantize • More coarsely for high frequencies (which also tend to have smaller values)• Many quantized high frequency values will be zeroEncode• Can decode with inverse dctQuantization tableFilter responsesQuantized valuesJPEG Compression SummarySubsample color by factor of 2• People have bad resolution for colorSplit into blocks (8x8, typically), subtract 128For each blocka. Compute DCT coefficients forb. Coarsely quantize– Many high frequency components will become zeroc. Encode (e.g., with Huffman coding)http://en.wikipedia.org/wiki/YCbCrhttp://en.wikipedia.org/wiki/JPEGBlock 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 JPEGJPEG compression comparison89k 12kImage gradientThe gradient of an image: The gradient points in the direction of most rapid change in intensityThe gradient direction is given by:• how does this relate to the direction of the edge?The edge strength is given by the gradient magnitudeEffects of noiseConsider a single row or column of the image• Plotting intensity as a function of position gives a signalWhere is the edge?How to compute a derivative?Where is the edge? Solution: smooth firstLook for peaks inDerivative theorem of convolutionThis saves us one operation:Laplacian of GaussianConsider Laplacian of GaussianoperatorWhere is the edge?Zero-crossings of bottom graph2D edge detection filtersis the Laplacian operator:Laplacian of GaussianGaussian derivative of GaussianTry this in MATLABg = fspecial('gaussian',15,2);imagesc(g); colormap(gray);surfl(g)gclown = conv2(clown,g,'same');imagesc(conv2(clown,[-1
View Full Document