Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Image Processing Part I: Vector Spaces and Basis Vectors Math Review Towards Fourier Transform • Linear Spaces • Change of Basis • Cosines and Sines • Complex Numbers 1 2 Basis Vectors Orthonormal Basis Vectors • A given vector value is represented with respect to a coordinate system. • A coordinate system is defined by a set of linearly independent vectors forming the system basis. • Any vector value is represented as a linear sum of the basis vectors. • If the basis vectors are mutually orthogonal and are unit vectors, the vectors form an orthonormal basis. • Example: The standard basis is orthonormal: V1=(1 0 0 0 …) V2=(0 1 0 0 …) V3=(0 0 1 0 …) …. a= 0.5 *v1+1*v2≡ (0.5 , 1)v V2=(0 1) v1 a • v1, v2 are basis vectors • The representation of a with respect to this basis is (0.5,1) (a1 ,a2) a2 a v2 a1 3 V1=(1 0) 4 1 Change of Basis u2 Signal (Image) Transforms (a1 ,a2)v = (a3 ,a4)u v2 av 1. Basis Functions. u1 a4 a3 2. Method for finding the transform coefficients given a signal. v1 Given a vector av, represented in orthonormal basis {vi} , what is the representation of av in a different orthonormal basis {ui}? 3. Method for finding the signal given the transform coefficients. a u (i) = a v , u i a v = ∑ a u(i) u i i where c, b = c T b = ∑ c(i )b (i ) i 5 6 The Orthonormal Standard Basis The Orthonormal Hadamard Basis Wave Number 0 Wave Number 0 N = 16 1 N = 16 2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 12 13 Standard Basis Functions 14 15 7 8 2 Hadamard Transform Standard Basis New Basis Grayscale Image Transformed Image spatial Coordinate Finding the transform coefficients Signal: X = [ 2 1 6 1] standard Hadamard Basis: Transform Coordinate T0 = [ 1 1 1 1 ] /2 T1 = [ 1 1 -1 -1 ] /2 T2 = [ 1 -1 -1 1 ] /2 Standard Basis: T3 = [ 1 -1 1 -1 ] /2 [ 2 1 6 1 ]standard= Hadamard Coefficients: 2[ 1 0 0 0 ] + 1[ 0 1 0 0 ] + 6[ 0 0 1 0 ] + 1[ 0 0 0 1 ] a0 = <X,T0 > = < [ 2 1 6 1 ] , [ 1 1 1 1 ] > /2 = 5 a1 = <X,T1 > = < [ 2 1 6 1 ] , [ 1 1 -1 -1 ] > /2 = -2 Hadamard Transform: a2 = <X,T2 > = < [ 2 1 6 1 ] , [ 1 -1 -1 1 ] > /2 = -2 [ 2 1 6 1 ]standard = = a3 = <X,T3 > = < [ 2 1 6 1 ] , [ 1 -1 1 -1 ] > /2 = 5 [ 1 1 1 1 ]/2 + -2 [ 1 1 -1 -1 ] /2 + Signal: -2 [ 1 -1 -1 1 ] /2 + 3 [ 1 -1 1 -1 ] /2 ≡ [ 5 -2 -2 3 ] 3 [ 2 1 6 1] Standard ≡ [ 5 -2 -2 3 ] Hadamard Hadamard 9 10 Transforms: Change of Basis – 2D Images Reconstructing the Image from the transform coefficients Y = [ 5 -2 -2 3 ] Hadamard Y Coordinate Hadamard Basis: T0 = [ 1 1 1 1 ] /2 T1 = [ 1 1 -1 -1 ] /2 T2 = [ 1 -1 -1 1 ] /2 T3 = [ 1 -1 1 -1 ] /2 Grayscale Image X Coordinate V Coordinates Transform: Transformed Image U Coordinates Reconstruction; Σ Y(i),Ti = The coefficients are arranged in a 2D array. 5 [ 1 1 1 1 ]/2 + -2 [ 1 1 -1 -1 ] /2 + -2 [ 1 -1 -1 1 ] /2 + 3 [ 1 -1 1 -1 ] /2 = [ 2 1 6 1 ]standard 11 12 3 Transforms: Change of Basis Hadamard Basis Functions Standard Basis: [ 2 1 6 1 ] [ ] [ ] [ ] [ ] 1 0 = 2 0 0 + 1 0 1 + 6 0 0 0 0 0 0 + 1 1 0 0 1 Hadamard Transform: [ 2 1 6 1 ] [ ] ≡ size = 8x8 1 1 = 5 1 1 /2 [ 5 3 -2 -2 + -2 ] [ ]+ [ ] 1 1 -1 -1 /2 -2 1 -1 -1 1 /2 +3 [ ] 1 -1 1 -1 /2 Hadamard White = +1 Black = -1 13 14 Finding the transform coefficients X = Signal: [ 2 1 6 1 ] Standard Basis: standard [ ] [ ] New Basis: [ ]/2 [ ]/2 T11 = 1 1 1 1 1 1 T21 = -1 -1 [ [ ]/2 [ ]/2 T12 = T22 = 1 -1 1 -1 2 1 6 1 ] coefficients 1 -1 1 0 0 1 0 0 0 0 [ ] [ ] 0 0 0 0 1 0 0 1 Standard -1 1 Basis Elements Signal: X = a11T11 +a12T12 + a21T21 + a22T22 Hadamard Transform: New Coefficients: a11 = a12 = a21 = a22 = <X,T11 > = <X,T21 > = <X,T22 > = <X,T12 > = X ≡ sum(sum(X.*T11)) = sum(sum(X.*T21)) = sum(sum(X.*T22)) = sum(sum(X.*T12)) = [ 5 3 -2 -2 ] 5 -2 -2 3 5 3 -2 -2 [ ] coefficients [ ] [ ] Hadamard 1 1 1 -1 1 1 /2 1 -1 /2 [ ] [ ] 1 1 1 -1 -1 -1 /2 -1 1 /2 Hadamard new Basis Elements 15 16 4 Continuous images/signals f(x): Part II: Sines and Cosines 1) The number of Basis Elements Bi is ∞. f (x) = ∫ aiBi(x) di i 2) The dot product: ∫ f(x)Bi(x) dx <f(x),Bi(x)> = x 17 18 Wavelength and Frequency of Sine/Cosin sin(x ) 1 1 x sin(θ θ) θ cos(θ θ) 2π 1 sin(2x ) 1 sin(x ) x 1 2π/2 x sin(kx ) 2π 1 x – The wavelength of sin(x) is 2π . 2π / k – The frequency is 1/(2π) . 19 20 5 – Changing Amplitude: – Define K=2πω A sin(2πωx ) A sin(2πωx ) 1 x x 1 ω – Changing Phase: A sin(2πωx + φ ) – The wavelength of sin(2πωx) is 1/ω . – The frequency is ω . x ϕ 2πω 21 22 Sine vs Cosine Sine vs Cosine sin(x) = cos(x) with a phase shift of π/2. sin(x) + cos(x) = sin(x) scaled by 2 with a phase shift of π/4. } 3 sin(kx) + 4 cos(kx) = sin(kx) with amplitude scaled by 5 and phase shift of 0.3π π/2 sin(x) + cos(x) = ? 3 sin(kx) 4 cos(kx) 5 sin(kx + 0.3π) 23 24 6 Part III: Complex Numbers Combining Sine and Cosine If we add a Sine wave to a Cosine wave with the same frequency we get a scaled and shifted (Co-) Sine wave with the same frequency: a sin (kx ) + b cos (kx ) = R sin (kx + φ ) b where R = a 2 + b 2 and φ = tan −1 a (prove it!) What is the result if a=0? What is the result if b=0? tan(φ) 25 26 Complex Numbers Imaginary • Conjugate of Z is Z*: (a,b) b – Cartesian rep. (a + ib)* = a - ib The Complex Plane θ a Imaginary • Two kind of representations for a point (a,b) in the complex plane R where i 2 = −1 θ – The Polar representation: Z = Re iθ a + ib = Reiθ b – The Cartesian representation: Z = a + ib (Reiθ)* = Re-iθ – Polar rep. Real -θ (Complex exponential) a Real R -b • Conversions: – Polar to Cartesian: Re = R cos(θ ) + iR sin(θ ) – Cartesian to Polar a + ib = a 2 + b 2 ei tan a − ib = Re − iθ iθ −1 (b / a ) 27 28 7 Algebraic operations: The (Co-) Sinusoid eiθ = cos(θ) + i sin(θ) • addition/subtraction: (a + ib) + (c + id) = (a + c) + i(b + d) • The (Co-)Sinusoid as complex exponential: • multiplication: cos(x ) = Real(eix ) (a + ib )(c + id ) = (ac − bd ) + i(bc + ad) sin(x ) = Imag(eix ) Aeiα Beiβ = ABei (α + β ) • inner Product: Or e ix + e −ix 2 ix e − e −ix sin (x ) = 2i ( a + ib), (c + id ) = (a + ib )* (c + id ) = (a − ib )( c + id ) cos(x ) = <Aeiα,Beiβ> = Ae-iαBeiβ = ABei(β-α) • norm: a + ib = (a + ib ) (a + ib ) = a 2 + b 2 ∗ 2 Reiθ = (Reiθ ) Reiθ = Re − iθ Reiθ = R 2 2 ∗ • What about generalization? S sin(kx) + C cos(kx) = ? 29 30 Scaling and phase shifting can be represented as a multiplication with Z = Re iθ cos(kx) Rcos(kx+θ) sin(kx) Rsin(kx+θ) eikx Rei(kx+θ) We saw that : S sin(kx) + C cos(kx) = R sin(kx + θ) where R = 2 S +C 2 −1 and θ = tan C (S) R sin (kx + θ) = Imag( R e iθ e ikx ) = Imag( Z e ikx ) = Reiθ eikx R sin (kx + θ ) = 21i ( R eiθ eikx − R e −iθ e −ikx ) = Zeikx = 21i ( Z eikx − Z * e −ikx ) 31 32 8 The 1D Continuous Fourier Transform S sin(kx) + C cos(kx) = R sin(kx + θ) The Continuous Fourier Transform finds the F(ω) given the (cont.) signal f(x): R sin (kx + θ) = Imag(R e e ) iθ ikx = Imag( Z eikx ) F (ω ) = ∫ f(x) e − i 2 πω x dx x R sin (kx + θ ) = 1 2i ( R eiθ eikx − R e −iθ e −ikx ) Bω(x)=ei2πωx is a complex wave function for each ω . = 21i ( Z eikx − Z * e −ikx ) The Inverse Continuous Fourier Transform composes a signal f(x) given F(ω): f(x) = ∫ F (ω ) e i 2 πω x dω ω 33 34 9 34