Presentation is loading. Please wait.

Presentation is loading. Please wait.

M. Wu: ENEE631 Digital Image Processing (Spring'09) Unitary Transform Spring ’09 Instructor: Min Wu Electrical and Computer Engineering Department, University.

Similar presentations


Presentation on theme: "M. Wu: ENEE631 Digital Image Processing (Spring'09) Unitary Transform Spring ’09 Instructor: Min Wu Electrical and Computer Engineering Department, University."— Presentation transcript:

1 M. Wu: ENEE631 Digital Image Processing (Spring'09) Unitary Transform Spring ’09 Instructor: Min Wu Electrical and Computer Engineering Department, University of Maryland, College Park   bb.eng.umd.edu (select ENEE631 S’09)   ENEE631 Spring’09 Lecture 10 (2/25/2009)

2 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [2] Overview Last Time: –MMSE Quantizer for non-uniform and uniform source –Companding: Quantizer with pre- and post- nonlinear transformation –Quantizer in predictive coding Today: –Vector vs. Scalar Quantizer –Revisit image transform from a coding and basis perspective => Unitary transform –DCT transform Logistics: (1) mid-term exam (2) Assign#3 to be posted UMCP ENEE631 Slides (created by M.Wu © 2004)

3 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [3] Recap: Scalar Quantizer Quantize one sample at a time Quantizer … quantization error … … … … Input/Output response Input x Output Q(x)

4 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [4] Recap: MMSE Quantizer Example – Gaussian Source Start with uniform quantizer Use iterative algorithm. optimum thresholds (red) and reconstruction values (blue) From B. Liu PU EE488 F’06 Truncated Gaussian N(0,1) with L=16 quantizer

5 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [5] Vector Quantization Encode a set of values together –Find the representative combinations –Encode the indices of combinations Scalar vs. Vector quantization –SQ is simpler in implementation –VQ allows flexible partition of coding cells –VQ could naturally explore the correlation between elements Stages to build vector quantizer – Codebook design – Encoder – Decoder From Bovik’s Handbook Sec.5.3 vector quantization of 2 elements UMCP ENEE631 Slides (created by M.Wu © 2001) scalar quantization of 2 elements Signal Sample-1 Signal Sample-2

6 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [6] Outline of Core Parts in VQ Design codebook –Optimization formulation is similar to MMSE scalar quantizer –Given a set of representative points u “Nearest neighbor” rule to determine partition boundaries –Given a set of partition boundaries u “Probability centroid” rule to determine representative points that minimizes mean distortion in each cell Search for codeword at encoder –Tedious exhaustive search –Design codebook with special structures to speed up encoding u E.g., tree-structured VQ Reference: A. Gersho and R. M. Gray, Vector Quantization and Signal Compression, Kluwer Publisher. R. M. Gray, ``Vector Quantization,'' IEEE ASSP Magazine, pp , April vector quantization of 2 elements UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

7 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [7] Recap: List of Compression Tools Lossless encoding tools –Entropy coding: Huffman, Arithmetic coding, Lemple-Ziv, … –Run-length coding Lossy tools for reducing bit rate –Quantization: scalar quantizer vs. vector quantizer –Truncations: discard unimportant parts of data Facilitating compression via Prediction –Convert the full signal to prediction residue with smaller dynamic range –Encode prediction parameters and residues with less bits –Be careful: use quantized version available to decoder when designing encoder Facilitating compression via Transforms –Transform into a domain with improved energy compaction UMCP ENEE631 Slides (created by M.Wu © 2004)

8 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [8] Image Transform: A Revisit With A Coding Perspective UMCP ENEE631 Slides (created by M.Wu © 2004)

9 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [9] Why Do Transforms? Fast computation –E.g., convolution vs. multiplication for filter with wide support Conceptual insights for various image processing –E.g., spatial frequency info. (smooth, moderate change, fast change, etc.) Obtain transformed data from measurement –E.g., blurred images, radiology images (medical and astrophysics) –Often need to perform an inverse transform to obtain the actual data For efficient storage and transmission –Pick a few “representatives” (basis) –Just store/send the major “contribution” from some basis image/vector => Examine a segment of signal samples together UMCP ENEE631 Slides (created by M.Wu © 2001)

10 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [10] Basic Process of Transform Coding UMCP ENEE631 Slides (created by M.Wu © 2004) Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 8)

11 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [11] Basis Vectors and Basis Images A basis for a vector space ~ a set of vectors that is –Linearly independent ~  a i v i = 0 if and only if all a i =0 –Uniquely represent every vector in the space by their linear combination ~  b i v i ( “spanning set” {v i } ) Orthonormal basis –Orthogonality ~ inner product = y *T x= 0 –Normalized length ~ || x || 2 = = x *T x= 1 Inner product for 2-D arrays – =  m  n f(m,n) g * (m,n) = G 1 *T F 1 (rewrite matrix into vector) u !! Don’t do FG ~ may not even be a valid operation for MxN matrices! 2D Basis Matrices (Basis Images) –Represent any images of the same size as a linear combination of basis images A vector space consists of a set of vectors, a field of scalars, a vector addition operation, and a scalar multiplication operation. UMCP ENEE631 Slides (created by M.Wu © 2001)

12 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [12] Standard / “Trivial” Basis Standard basis vectors Standard basis images 

13 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [13] Matrix/Vector Form of 1-D DFT { z(n) }  { Z(k) } n, k = 0, 1, …, N-1, W N = exp{ - j2  / N } ~ complex conjugate of primitive N th root of unity UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

14 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [14] Matrix/Vector Form of 1-D DFT (cont’d) { z(n) }  { Z(k) } n, k = 0, 1, …, N-1, W N = exp{ - j2  / N } “transform kernels” are complex exponentials Vector form and interpretation for inverse transform z =  k Z(k) a k where a k = [ 1, W N -k, W N -2k, … W N -(N-1)k ] T /  N Basis vectors   –a k H = a k * T = [ 1, W N k, W N 2k, … W N (N-1)k ] /  N Use a k H as row vectors to construct a matrix F Z = F z  z = F *T Z = F * Z –F is symmetric (F T =F) and unitary (F -1 = F H where F H = F *T )   UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

15 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [15] 1-D Unitary Transform Consider linear invertible transform –1-D sequence { x(0), x(1), …, x(N-1) } as a vector – y = A x and A is invertible Unitary matrix: A is unitary if A -1 = A *T = A H –Denote A *T as A H ~ “Hermitian” –x = A -1 y = A *T y =  a i *T y(i) –Hermitian of row vectors of unitary matrix A form a set of orthonormal basis vectors {a i *T } Think: how about column vectors of A? Orthogonal matrix ~ A -1 = A T –Real-valued unitary matrix is also an orthogonal matrix –Row vectors of real orthogonal matrix A form orthonormal basis vectors UMCP ENEE631 Slides (created by M.Wu © 2001)

16 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [16] Exercise: Is each matrix here unitary or orthogonal? –If yes, what are the basis vectors? 1: n; 2: y. inv(A3) = [2, –3; -1, 2]; Check A A’ = I ? UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

17 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [17] Exercise – Question for Today: Which is unitary or orthogonal? 2-D DFT –Write the forward and inverse transform –Express in terms of matrix-vector form –Find basis images inv(A1) = [2, –3; -1, 2] Check A A’ = I ? UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

18 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [18] Properties of 1-D Unitary Transform y = A x Energy Conservation: || y || 2 = || x || 2 Proof: || y || 2 = || Ax || 2 = (Ax) *T (Ax)= x *T A *T A x = x *T x = || x || 2 Interpretation: –The angles between vectors are preserved –A unitary transformation is a rotation of a vector in an N-dimension space, i.e., a rotation of basis coordinates UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

19 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [19] Properties of 1-D Unitary Transform (cont’d) Energy Compaction and Decorrelation –Many commonly used unitary transforms tend to pack a large fraction of signal energy into just a few transform coefficients –Highly correlated input elements  quite uncorrelated output coefficients u Covariance matrix E[ ( y – E(y) ) ( y – E(y) ) *T ] small correlation implies small off-diagonal terms Example: recall the effect of DFT Question: What unitary transform gives the best compaction and decorrelation? => Will revisit this issue UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

20 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [20] 1-D Discrete Cosine Transform (DCT) Linear transform matrix C c(k,n) =  (0) for k=0 c(k,n) =  (k) cos[  (2n+1)/2N] for k>0 => Compare “transform kernels” of DCT vs. DFT C is real and orthogonal – rows of C form an orthonormal basis – C is not symmetric! – DCT is not the real part of unitary DFT!  See Assignment#3 u related to DFT of a symmetrically extended signal UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

21 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [21] Periodicity Implied by DFT and DCT UMCP ENEE631 Slides (created by M.Wu © 2004) Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 8)

22 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [22] Example of 1-D DCT n n z(n) k k Z(k) DCT From Ken Lam’s DCT talk 2001 (HK Polytech) UMCP ENEE631 Slides (created by M.Wu © 2001)

23 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [23] UMCP ENEE631 Slides (created by M.Wu © 2001) Example of 1-D DCT (cont’d): N = 8 k Z (k) Transform coeff Basis vectors u=0 u=0 to 1 u=0 to 4 u=0 to 5 u=0 to 2 u=0 to 3 u=0 to 6 u=0 to 7 Reconstructions n z (n) Original signal From Ken Lam’s DCT talk 2001 (HK Polytech)

24 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [24] Fast DCT via FFT Define new sequence – reorder odd and even elements Split DCT sum into odd and even terms Other real-value fast algorithms UMCP ENEE631 Slides (created by M.Wu © 2001)

25 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [25] Relation between DCT and DFT – see assign#3

26 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [26] 2-D DCT Separable orthogonal transform –Apply 1-D DCT to each row, then to each column Y = C X C T  X = C T Y C =  m  n y(m,n) B m,n –Set y(m,n)=1 and rest as zeros to obtain basis image B m,n ~ outer product of C’s m th & n th rows DCT basis images: –Equivalent to represent an NxN image with a set of orthonormal NxN “basis images” –Each DCT coefficient indicates the contribution from (or similarity to) the corresponding basis image UMCP ENEE631 Slides (created by M.Wu © 2001)

27 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [27] 2-D DCT Separable orthogonal transform –Apply 1-D DCT to each row, then to each column Y = C X C T  X = C T Y C =  m  n y(m,n) B m,n –Set y(m,n)=1 and rest as zeros to obtain basis image B m,n ~ outer product of C’s m th & n th rows DCT basis images: –Equivalent to represent an NxN image with a set of orthonormal NxN “basis images” –Each DCT coefficient indicates the contribution from (or similarity to) the corresponding basis image UMCP ENEE631 Slides (created by M.Wu © 2001)

28 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [28] 2-D Transform: General Case A general 2-D linear transform with kernel {a k,l (m,n)} –y(k,l) is a transform coefficient for Image {x(m,n)} –{y(k,l)} is “Transformed Image” –Equiv to rewriting all from 2-D to 1-D and applying 1-D transform Computational complexity –N 2 values to compute –N 2 terms in summation per output coefficient –O(N 4 ) for transforming an NxN image! UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

29 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [29] 2-D Linear Transforms Image transform kernel {a k,l (m,n)} –y(k,l) is a transform coefficient for Image {x(m,n)} –{y(k,l)} is “Transformed Image” –Equiv to rewriting all from 2-D to 1-D and applying 1-D transform May generalize the transform (series expansion) from NxN to NxM a1 a2 a3 orth. proj. gives min. distance Orthonomality condition – – Assure any truncated expansion of the form will minimize sum of squared errors when y(k,l) take values as above Completeness condition – – assure zero error when taking full basis UMCP ENEE631 Slides (created by M.Wu © 2001)

30 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [30] 2-D Separable Unitary Transforms Focus our attention to separable transform – a k,l (m,n) = a k (m) b l (n), denote this as a(k,m) b(l,n) Use 1-D unitary transform as building block – {a k (m)} k and {b l (n)} l are 1-D complete orthonormal sets of basis vectors u use as row vectors to obtain unitary matrices A={a(k,m)} & B={b(l,n)} –Apply to columns and rows Y = A X B T u often choose same unitary matrix as A and B (e.g., 2-D DFT) For square NxN image A: Y = A X A T  X = A H Y A * –For rectangular MxN image A: Y = A M X A N T  X = A M H Y A N * Complexity ~ O(N 3 ) –May further reduce complexity if unitary transf. has fast implementation UMCP ENEE631 Slides (created by M.Wu © 2001)

31 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [31] Basis Images for Separable Transform X = A H Y A * => x(m,n) =  k  l a*(k,m)a*(l,n) y(k,l) –Represent X with NxN basis images weighted by coeff. Y –Obtain basis image by setting Y={  (k-k 0, l-l 0 )} and getting X  { a*(k 0,m)a*(l 0,n) } m,n  Basis image in matrix form A* k,l = a* k a l *T ~ a* k is k th column vector of A H  transf. coeff. y(k,l) is the inner product of the basis A* k,l with image X UMCP ENEE631 Slides (created by M.Wu © 2001)

32 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [32] Exercise on Basis Images For 2-D separable unitary transform: Y = A X A T => X = A H Y A * –Represent X with NxN basis images weighted by coeff. Y –Obtain basis image by setting Y={  (k-k 0, l-l 0 )} & getting X  In matrix form A* k,l = a* k a l *T ~ a* k is k th column vector of A H Exercise: –A is Unitary transform or not? –If so, find basis images –Represent an image X with basis images (Jain’s e.g.5.1, pp137: A’ [5, –1; – 2, 0] A; outer product of columns of A H : [1,1]’[1 1]/2, …) UMCP ENEE631 Slides (created by M.Wu © 2001)

33 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [33] Review and Exercise on Basis Images Exercise: –A is Unitary transform or not? –Find basis images –Represent an image X with basis images (Jain’s e.g.5.1, pp137: A’ [5, –1; – 2, 0] A; outer product of columns of A H : [1,1]’[1 1]/2, …) UMCP ENEE631 Slides (created by M.Wu © 2001)

34 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [34] Exercise: Unitary or not? –And find basis for the unitary matrix Find basis images and represent image X with basis images –X = A H Y A * (separable) => x(m,n) =  k  l a*(k,m)a*(l,n) y(k,l) u Represent X with NxN basis images weighted by coeff. Y  Obtain basis image { a*(k 0,m)a*(l 0,n) } m,n by setting Y={  (k-k 0, l-l 0 )} & getting X  In matrix form A* k,l = a* k a l *T ~ a* k is k th column vector of A *T ( a k T is k th row vector of A )  Transform coeff. y(k,l) is the inner product of A* k,l with the image Jain’s e.g.5.1, pp137 A’ [5 –1;-2 0] A : [1,1]’[1 1]/2, … (1.n; 2. y.) UMCP ENEE631 Slides (created by M.Wu © 2001)

35 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [35] Review: 2-D DFT Recall: 2-D DFT is Separable Y = F X F  X = F * Y F * –Basis images B k,l = (a k ) (a l ) T ~ outer product of two vectors where a k = [ 1 W N -k W N -2k … W N -(N-1)k ] T /  N UMCP ENEE631 Slides (created by M.Wu © 2001/2004)

36 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [36] Visualizing Fourier Basis Images Fourier basis uses complex exponentials –Their real and imaginary parts give smoothly varying sinusoidal patterns in different frequencies and orientations exp[ j 2  (ux + vy) ] = cos[2  (ux + vy)] + j sin[2  (ux + vy)] v Real (cos) part Imaginary (sin) part (u, v)(1, 0)(0, 5)(1, 1) Figures from Mani Thomas U.Del CISC489/689 2D FT

37 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [37] 8x8 DFT Basis Images Figures from John Woods’ book.

38 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [38] Summary and Review 1-D transform of a vector –Represent an N-sample sequence as a vector in N-dimension vector space –Transform u Different representation of this vector in the space via different basis u e.g., 1-D DFT from time domain to frequency domain –Forward transform u In the form of inner product u Project a vector onto a new set of basis to obtain N “coefficients” –Inverse transform u Use linear combination of basis vectors weighted by transform coefficents to represent the original signal 2-D transform of a matrix –Generally can rewrite the matrix into a long vector & apply 1-D transform –Separable transform allows applying transform to rows then columns UMCP ENEE631 Slides (created by M.Wu © 2001)

39 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [39] Summary and Review (cont’d) Vector/matrix representation of 1-D & 2-D sampled signal –Representing an image as a matrix or sometimes as a long vector Basis functions/vectors and orthonormal basis –Used for representing the space via their linear combinations –Many possible sets of basis and orthonormal basis Unitary transform on input x ~ A -1 = A *T –y = A x  x = A -1 y = A *T y =  a i *T y(i) ~ represented by basis vectors {a i *T } –Rows (and columns) of a unitary matrix form an orthonormal basis General 2-D transform and separable unitary 2-D transform –2-D transform involves O(N 4 ) computation –Separable: Y = A X A T = (A X) A T ~ O(N 3 ) computation u Apply 1-D transform to all columns, then apply 1-D transform to rows –For non-square image of size MxN: Y = A MxM X A T NxN ; basis images MxN UMCP ENEE631 Slides (created by M.Wu © 2001)

40 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [40] Summary of Today’s Lecture Unitary transform and properties –Basis vectors and Basis images DCT transform Next time: putting together … –Transform coding and JPEG compression standard Readings –Gonzalez’s 3/e book 8.1; 8.2.1, , (till before motion); ; 8.2.8; –Jain’s book (on unitary transform) –To read more: Woods’ book 4.2, 4.3, 4.5 UMCP ENEE631 Slides (created by M.Wu © 2004)

41 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [41] Clarifications “Dimension” –Dimension of a signal ~ # of index variables u audio and speech is 1-D signal, image is 2-D, video is 3-D –Dimension of a vector space ~ # of basis vectors in it Eigenvalues of unitary transform –All eigenvalues have unit magnitude (could be complex valued)  By definition of eigenvalues ~ A x = x  By energy preservation of unitary ~ || A x || = ||x|| –Eigenvalues here are different from the eigenvalues in K-L transform u K-L concerns the eigen of covariance matrix of random vector –Eigenvectors ~ we generally consider the orthonormalized ones

42 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [42] Summary of Today’s Lecture Optimal bit allocation Optimal transform - KLT Next Lecture: –Video coding Readings on Wavelet –Results on rate-distortion theory: Jain’s book Section 2.13 u Further exploration – Tutorial on rate-distortion by Ortega-Ramchandran in IEEE Sig. Proc. Magazine, Nov. 98 –KLT: Jain’s book 2.9, 5.6, 5.11, 5.14, (further exploration – 5.12, 5.13) UMCP ENEE631 Slides (created by M.Wu © 2004)

43 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [43] UMCP ENEE631 Slides (created by M.Wu © 2001) Common Unitary Transforms and Basis Images DFTDCT Haar transform K-L transform See also: Jain’s Fig.5.2 pp136

44 M. Wu: ENEE631 Digital Image Processing (Spring'09) Lec10 – Unitary Transform [44] Hadamard Transform From Mani Thomas U.Del CISC489/689 2D FT


Download ppt "M. Wu: ENEE631 Digital Image Processing (Spring'09) Unitary Transform Spring ’09 Instructor: Min Wu Electrical and Computer Engineering Department, University."

Similar presentations


Ads by Google