Introduction to Computer Vision CS / ECE 181B  Handout #4 : Available this afternoon  Midterm: May 6, 2004  HW #2 due tomorrow  Ack: Prof. Matthew.

Slides:



Advertisements
Similar presentations
Computer Vision Lecture 7: The Fourier Transform
Advertisements

3-D Computational Vision CSc Image Processing II - Fourier Transform.
November 12, 2013Computer Vision Lecture 12: Texture 1Signature Another popular method of representing shape is called the signature. In order to compute.
Spatial Filtering (Chapter 3)
Fourier Transform (Chapter 4)
Pyramids and Texture. Scaled representations Big bars and little bars are both interesting Spots and hands vs. stripes and hairs Inefficient to detect.
Linear Filtering – Part II Selim Aksoy Department of Computer Engineering Bilkent University
School of Computing Science Simon Fraser University
Chapter 4 Image Enhancement in the Frequency Domain.
Convolution, Edge Detection, Sampling : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz.
CSCE 641 Computer Graphics: Image Sampling and Reconstruction Jinxiang Chai.
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F(  ) is the spectrum of the function.
CSCE 641 Computer Graphics: Image Sampling and Reconstruction Jinxiang Chai.
Immagini e filtri lineari. Image Filtering Modifying the pixels in an image based on some function of a local neighborhood of the pixels
Digital Image Processing Chapter 4: Image Enhancement in the Frequency Domain.
Image Enhancement in the Frequency Domain Part I Image Enhancement in the Frequency Domain Part I Dr. Samir H. Abdul-Jauwad Electrical Engineering Department.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Sampling Week 7, Fri 17 Oct 2003 p1 demos sampling.
Introduction to Computer Vision CS / ECE 181B Thursday, April 22, 2004  Edge detection (HO #5)  HW#3 due, next week  No office hours today.
2D Fourier Theory for Image Analysis Mani Thomas CISC 489/689.
Computer Vision - A Modern Approach Set: Pyramids and Texture Slides by D.A. Forsyth Scaled representations Big bars (resp. spots, hands, etc.) and little.
1 Images and Transformations Images by Pawan SinhaPawan Sinha.
Transforms: Basis to Basis Normal Basis Hadamard Basis Basis functions Method to find coefficients (“Transform”) Inverse Transform.
Digital Image Processing, 2nd ed. © 2002 R. C. Gonzalez & R. E. Woods Chapter 4 Image Enhancement in the Frequency Domain Chapter.
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5409 T-R 10:30am – 11:50am.
G52IIP, School of Computer Science, University of Nottingham 1 Image Transforms Fourier Transform Basic idea.
Topic 7 - Fourier Transforms DIGITAL IMAGE PROCESSING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
Chapter 2. Image Analysis. Image Analysis Domains Frequency Domain Spatial Domain.
Applications of Image Filters Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/04/10.
: Chapter 14: The Frequency Domain 1 Montri Karnjanadecha ac.th/~montri Image Processing.
Image Processing © 2002 R. C. Gonzalez & R. E. Woods Lecture 4 Image Enhancement in the Frequency Domain Lecture 4 Image Enhancement.
1 Chapter 5 Image Transforms. 2 Image Processing for Pattern Recognition Feature Extraction Acquisition Preprocessing Classification Post Processing Scaling.
Digital Filters. What have we seen so far?  So far we have seen… Box filterBox filter  Moving average filter  Example of a lowpass passes low frequenciespasses.
1 Lecture III Shobhit Niranjan Gaurav Gupta. 2 Convolution Definition: For discrete functions: Properties Commutativity Associativity Distributivity.
Image Processing Xuejin Chen Ref:
09/19/2002 (C) University of Wisconsin 2002, CS 559 Last Time Color Quantization Dithering.
Lecture 7: Sampling Review of 2D Fourier Theory We view f(x,y) as a linear combination of complex exponentials that represent plane waves. F(u,v) describes.
October 29, 2013Computer Vision Lecture 13: Fourier Transform II 1 The Fourier Transform In the previous lecture, we discussed the Hough transform. There.
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5403 T-R 3:00pm – 4:20pm.
Practical Image Processing1 Chap7 Image Transformation  Image and Transformed image Spatial  Transformed domain Transformation.
Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra.
Image processing Honza Černocký, ÚPGM. 1D signal 2.
Fourier Transform.
Image hole-filling. Agenda Project 2: Will be up tomorrow Due in 2 weeks Fourier – finish up Hole-filling (texture synthesis) Image blending.
Lecture 5: Fourier and Pyramids
Computer Graphics & Image Processing Chapter # 4 Image Enhancement in Frequency Domain 2/26/20161.
G52IIP, School of Computer Science, University of Nottingham 1 Image Transforms Basic idea Input Image, I(x,y) (spatial domain) Mathematical Transformation.
2D Fourier Transform.
Machine Vision Edge Detection Techniques ENT 273 Lecture 6 Hema C.R.
Spatial Filtering (Chapter 3) CS474/674 - Prof. Bebis.
Fourier Transform (Chapter 4) CS474/674 – Prof. Bebis.
Digital Image Processing Lecture 8: Fourier Transform Prof. Charlene Tsai.
Digital Image Processing , 2008
Miguel Tavares Coimbra
Sampling Week 7, Fri 17 Oct 2003 p1 demos sampling.
Jean Baptiste Joseph Fourier
The content of lecture This lecture will cover: Fourier Transform
Image Resampling & Interpolation
Linear Filters and Edges Chapters 7 and 8
- photometric aspects of image formation gray level images
Linear Filtering – Part II
Linear Filters and Edges Chapters 7 and 8
Image Enhancement in the
General Functions A non-periodic function can be represented as a sum of sin’s and cos’s of (possibly) all frequencies: F() is the spectrum of the function.
Fourier Transform.
Outline Linear Shift-invariant system Linear filters
Intensity Transformation
Lecture 4 Image Enhancement in Frequency Domain
Review and Importance CS 111.
Presentation transcript:

Introduction to Computer Vision CS / ECE 181B  Handout #4 : Available this afternoon  Midterm: May 6, 2004  HW #2 due tomorrow  Ack: Prof. Matthew Turk for the lecture slides.

April Additional Pointers See my ECE 178 class web page See the review chapters from Gonzalez and Woods (available on the 181b web) A good understanding of linear filtering and convolution is essential in developing computer vision algorithms. Topics I recommend for additional study (that I will not be able to discuss in detail during lectures)--> sampling of signals, Fourier transform, quantization of signals.

April Area operations: Linear filtering Point, local, and global operations –Each kind has its purposes Much of computer vision analysis starts with local area operations and then builds from there –Texture, edges, contours, shape, etc. –Perhaps at multiple scales Linear filtering is an important class of local operators –Convolution –Correlation –Fourier (and other) transforms –Sampling and aliasing issues

April Convolution The response of a linear shift-invariant system can be described by the convolution operation R ij  H i  u,j  v F uv u,v  Input image Convolution filter kernel Output image Convolution notations

April Convolution Think of 2D convolution as the following procedure For every pixel (i,j): –Line up the image at (i,j) with the filter kernel –Flip the kernel in both directions (vertical and horizontal) –Multiply and sum (dot product) to get output value R(i,j) (i,j)

April Convolution For every (i,j) location in the output image R, there is a summation over the local area F H R 4,4 = H 0,0 F 4,4 + H 0,1 F 4,3 + H 0,2 F 4,2 + H 1,0 F 3,4 + H 1,1 F 3,3 + H 1,2 F 3,2 + H 2,0 F 2,4 + H 2,1 F 2,3 + H 2,2 F 2,2 = -1*222+0*170+1* *173+0*147+2* *149+0*198+1*221 = 63

April Convolution: example x(m,n) h(m,n) m n m n h(-m, -n) h(1-m, n) y(1,0) =  k,l x(k,l)h(1-k, -l) = = m n y(m,n)= verify!

April Spatial frequency and Fourier transforms A discrete image can be thought of as a regular sampling of a 2D continuous function –The basis function used in sampling is, conceptually, an impulse function, shifted to various image locations –Can be implemented as a convolution

April Spatial frequency and Fourier transforms We could use a different basis function (or basis set) to sample the image Let’s instead use 2D sinusoid functions at various frequencies (scales) and orientations –Can also be thought of as a convolution (or dot product) Lower frequencyHigher frequency

April Fourier transform For a given (u, v), this is a dot product between the whole image g(x,y) and the complex sinusoid exp(-i2  (ux+vy)) –exp(i  ) = cos  + i sin  F(u,v) is a complete description of the image g(x,y) Spatial frequency components (u, v) define the scale and orientation of the sinusoidal “basis filters” –Frequency of the sinusoid: (u 2 +v 2 ) 1/2 –Orientation of the sinusoid:  = tan -1 (v/u)

April (u,v) – Frequency and orientation u v Increasing spatial frequency Orientation 

April (u,v) – Frequency and orientation u v Point represents: F(0,0) F(u 1,v 1 ) F(u 2,v 2 )

April Fourier transform The output F(u,v) is a complex image (real and imaginary components) –F(u,v) = F R (u,v) + i F I (u,v) It can also be considered to comprise a phase and magnitude –Magnitude: |F(u,v)| = [(F R (u,v)) 2 + (F I (u,v)) 2 ] 1/2 –Phase:  (F(u,v)) = tan -1 (F I (u,v) / F R (u,v)) u v (u,v) location indicates frequency and orientation F(u,v) values indicate magnitude and phase

April OriginalMagnitudePhase

April Low-pass filtering via FT

April High-pass filtering via FT Grey = zero Absolute value

April Fourier transform facts The FT is linear and invertible (inverse FT) A fast method for computing the FT exists (the FFT) The FT of a Gaussian is a Gaussian F(f * g) = F( f ) F( g ) F(f g) = k F( f ) * F( g ) F(  (x,y)) = 1 (See Table 7.1)

April Sampling and aliasing Analog signals (images) can be represented accurately and perfectly reconstructed is the sampling rate is high enough –≥ 2 samples per cycle of the highest frequency component in the signal (image) If the sampling rate is not high enough (i.g., the image has components over the Nyquist frequency) –Bad things happen! This is called aliasing –Smooth things can look jagged –Patterns can look very different –Colors can go astray –Wagon wheels can move backwards (temporal sampling)

April Examples

April Original

April Filtering and subsampling SubsampledFiltered then Subsampled

April Filtering and sub-sampling SubsampledFiltered then Subsampled

April Sampling in 1-D  D x(t) Time domain X(u) Frequency T s(t) x s (t) = x(t) s(t) =   x(kt)  (t-kT) s(t) 1/T X s (f)

April The bottom line High frequencies lead to trouble with sampling Solution: suppress high frequencies before sampling –Multiply the FT of the image with a mask that filters out high frequency, or… –Convolve with a low-pass filter (commonly a Gaussian)

April Filter and subsample So if you want to sample an image at a certain rate (e.g., resample a 640x480 image to make it 160x120), but the image has high frequency components over the Nyquist frequency, what can you do? –Get rid of those high frequencies by low-pass filtering! This is a common operation in imaging and graphics: –“Filter and subsample” Image pyramid: Shows an image at multiple scales –Each one a filtered and subsampled version of the previous –Complete pyramid has (1+log 2 N) levels (where N is image height or width)

April Image pyramid Level 1 Level 2 Level 3

April Gaussian pyramid

April Image pyramids Image pyramids are useful in object detection/recognition, image compression, signal processing, etc. Gaussian pyramid –Filter with a Gaussian –Low-pass pyramid Laplacian pyramid –Filter with the difference of Gaussians (at different scales) –Band-pass pyramid Wavelet pyramid –Filter with wavelets

April Gaussian pyramid Laplacian pyramid

April Wavelet Transform Example Original High pass - both High pass - horizontal High pass - vertical Low pass

April Pyramid filters (1D view) G(x) G 1 (x)- G 2 (x) G(x) sin(x)

April Spatial frequency The Fourier transform gives us a precise way to define, represent, and measure spatial frequency in images Other transforms give similar descriptions: –Discrete Cosine Transform (DCT) – used in JPEG –Wavelet transforms – very popular Because of the FT/convolution relationship –F(f * g) = F( f ) F( g ) –convolutions can be implemented via Fourier transforms! –f * g = F -1 { F( f ) F( g ) }  For large kernels, this can be much more efficient

April Convolution and correlation Back to convolution/correlation Convolution (or FT/IFT pair) is equivalent to linear filtering –Think of the filter kernel as a pattern, and convolution checks the response of the pattern at every point in the image –At each point, it is a dot product of the local image area with the filter kernel Conceptually, the image responds best to the pattern of the filter kernel (similarity) –An edge kernel will produce high responses at edges, a face kernel will produce high responses at faces, etc.

April Convolution and correlation For a given filter kernel, what image values really do give the largest output value? –All “white” – maximum pixel values What image values will give a zero output? –All zeros – or, any local “vector” of values that is perpendicular to the kernel “vector” F H F H k 9-dimensional vectors H · F = k || F || = ||H|| ||F|| cos  

April Image = vector = point An m by n image (or image patch) can be reorganized as a mn by 1 vector, or as a point in mn-dimensional space ab de c f abcdefabcdef ( a, b, c, d, e, f ) 2x3 image 6x1 vector 6-dimensional point 

April Correlation as a dot product ??? ?f1f1 f2f2 ?f4f4 f5f5 ?f7f7 f8f8 ??? ??? ??? f3f3 ?? f6f6 ?? f9f9 ?? ??? ??? h1h1 h2h2 h3h3 h4h4 h5h5 h6h6 h7h7 h8h8 h9h9 F H At this location, F*H equals the dot product of two 9-dimensional vectors f1f2f3f4f5f6f7f8f9f1f2f3f4f5f6f7f8f9 h1h2h3h4h5h6h7h8h9h1h2h3h4h5h6h7h8h9 dot = f T h =  f i h i

April Finding patterns in images via correlation Correlation gives us a way to find patterns in images –Task: Find the pattern H in the image F –Approach:  Convolve (correlate) H and F  Find the maximum value of the output image  That location is the “best match” –H is called a “matched filter” Another way: Calculate the distance d between the image patch F and the pattern H –d 2 =  (F i - H i ) 2 –Approach:  The location with minimum d 2 defines the best match –This is quite expensive F H d

April FixedAssume fixed (more or less) So minimizing d 2 is approximately equivalent to maximizing the correlation Correlation Minimize d 2

April Normalized correlation Problems with these two approaches: –Correlation responds “best” to an all “white” patch (maximum pixel values) –Both techniques are sensitive to scaling of the image Normalized correlation solves these problems F H k 9-dimensional vectors H · F = k || F || = ||H|| ||F|| cos   ??? ?f1f1 f2f2 ?f4f4 f5f5 ?f7f7 f8f8 ??? ??? ??? f3f3 ?? f6f6 ?? f9f9 ?? ??? ??? h1h1 h2h2 h3h3 h4h4 h5h5 h6h6 h7h7 h8h8 h9h9 F H

April Normalized correlation We don’t really want white to give the maximum output, we want the maximum output to be when H = F –Or when the angle  is zero Normalized correlation measures the angle  between H and F –What if the image values are doubled? Halved? –It is independent of the magnitude (brightness) of the image –What if the image values are doubled? Halved?  R is independent of the magnitude (brightness) of the image

April Normalized correlation Normalized correlation measures the angle  between H and F –What if the image values are doubled? Halved? –What if the template values are doubled? Halved? –Normalized correlation output is independent of the magnitude (brightness) of the image Drawback: More expensive than correlation –Specialized hardware implementations…