Unitary Transformation

Embed Size (px)

Citation preview

  • 7/29/2019 Unitary Transformation

    1/34

    ENEE631 Digital Image Processing (Spring'04)

    Unitary Trans forms

    Spring 04 Instructor: Min Wu

    ECE Department, Univ. of Maryland, College Park

    www.ajconline.umd.edu (select ENEE631 S04)

    [email protected]

    Based on ENEE631 Spring04Section 9

  • 7/29/2019 Unitary Transformation

    2/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [3]

    Image Trans form : A Revis i t

    With A Coding Perspect ive

    UM

    CPENEE631Slides(cr

    eatedbyM.Wu2004)

  • 7/29/2019 Unitary Transformation

    3/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [4]

    Why Do Transform s?

    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 as measurement E.g., blurred images, radiology images (medical and astrophysics)

    Often need inverse transform

    May need to get assistance from other transforms

    For efficient storage and transmission Pick a few representatives (basis)

    Just store/send the contribution from each basis

    UM

    CPENEE631Slides(cr

    eatedbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    4/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [5]

    Basic Process of Transform Coding

    UM

    CPENEE631Slides(cr

    eatedbyM.Wu2004)

    Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 8)

  • 7/29/2019 Unitary Transformation

    5/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [6]

    1-D DFT and Vecto r Form

    { z(n) } { Z(k) }n, k = 0, 1, , N-1

    WN= exp{ - j2/ N }~ complex conjugate of primitive Nth root of unity

    Vector form and interpretation for inverse transform

    z = kZ(k) akak= [ 1 WN

    -k WN-2k WN

    -(N-1)k]T/N

    Basis vectors

    akH

    = ak* T

    = [ 1 WNk

    WN2k

    WN(N-1)k

    ] /N

    Use akHas row vectors to construct a matrix F

    Z = F zz = F*TZ = F* Z

    F is symmetric (FT=F) and unitary (F-1 = FHwhere FH= F*T)

    1

    0

    1

    0

    )(1)(

    )(1

    )(

    N

    k

    nk

    N

    N

    n

    nk

    N

    WkZN

    nz

    WnzN

    kZ

    UMCP

    ENEE631Slides(createdbyM.Wu2001/2004)

  • 7/29/2019 Unitary Transformation

    6/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [7]

    Basis Vectors and Basis Images

    A basis for a vector space ~ a set of vectors

    Linearly independent ~ ai vi = 0 if and only if all ai=0 Uniquely represent every vector in the space by their linear combination

    ~ bi vi ( spanning set {vi} )

    Orthonormal basis

    Orthogonality ~ inner product = y*Tx= 0 Normalized length ~ ||x ||2 = = x*Tx= 1

    Inner product for 2-D arrays

    = m

    nf(m,n) g*(m,n) = G

    1

    *TF1 (rewrite matrix into vector)

    !! Dont 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 basisimages

    A vector space consists of a set of vectors, a

    field of scalars, a vector addition operation,

    and a scalar multiplication operation.

    UM

    CPENEE631Slides(cr

    eatedbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    7/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [8]

    1-D Unitary Trans form

    Linear invertible transform

    1-D sequence { x(0), x(1), , x(N-1) } as a vector

    y = A x andA is invertible

    Unitary matrix ~A-1 = A*T

    DenoteA*TasAH~ Hermitian

    x = A-1 y = A*Ty = ai*Ty(i)

    Hermitian of row vectors of A form a set of orthonormal basis vectorsai

    *T = [a*(i,0), , a*(i,N-1)] T

    Orthogonal matrix ~A-1 = AT

    Real-valued unitary matrixis also an orthogonal matrix

    Row vectors of real orthogonal matrix A form orthonormal basis vectors

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    8/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [9]

    Exercise Quest ion 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

    cossin

    sincos

    2

    1

    2

    1

    2

    1

    2

    1

    21

    32

    inv(A1) = [2,3; -1, 2]

    UMCP

    ENEE631Slides(createdbyM.Wu2001/2004)

  • 7/29/2019 Unitary Transformation

    9/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [10]

    Propert ies o f 1-D Unitary Trans formy = A x

    Energy Conservation ||y ||2 = ||x ||2

    || y ||2 = || Ax ||2= (Ax)*T(Ax)= x*TA*TA x = x*Tx = || x ||2

    Rotation

    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 coordinatesUMCP

    ENEE631Slides(crea

    tedbyM.Wu2001/2004)

  • 7/29/2019 Unitary Transformation

    10/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [11]

    Propert ies o f 1-D Unitary Transform (contd)

    Energy Compaction

    Many common unitary transforms tend to pack a large fraction of signalenergy into just a few transform coefficients

    Decorrelation

    Highly correlated input elements quite uncorrelated output coefficients

    Covariance matrix E[ ( yE(y) ) ( yE(y) )*T] small correlation implies small off-diagonal terms

    Example: recall the effect of DFT

    Question: What unitary transform gives the best compactionand decorrelation?

    => Will revisit this issue in a few lectures

    UMCP

    ENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    11/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [12]

    Review: 1-D Disc rete Cos ine Trans fo rm (DCT)

    Transform matrix C

    c(k,n) = (0) for k=0

    c(k,n) = (k) cos[(2n+1)/2N] for k>0

    Cis real and orthogonal

    rows ofCform orthonormal basis

    Cis not symmetric!

    DCT is not the real part of unitary DFT! See Assignment#3 related to DFT of a symmetrically extended signal

    Nk

    N

    N

    knkkZnz

    N

    knknzkZ

    N

    k

    N

    n

    2)(,

    1)0(

    2

    )12(cos)()()(

    2

    )12(cos)()()(

    1

    0

    1

    0

    UMCP

    ENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    12/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [13]

    Period ici ty Impl ied by DFT and DCT

    UM

    CPENEE631Slides(createdbyM.Wu2004)

    Figure is from slides at Gonzalez/ Woods DIP book website (Chapter 8)

  • 7/29/2019 Unitary Transformation

    13/34ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [14]

    Example of 1-D DCT

    100

    50

    0

    -50

    -100

    0 1 2 3 4 5 6 7

    n

    z(n)

    100

    50

    0

    -50

    -100

    0 1 2 3 4 5 6 7

    k

    Z(k)

    DCT

    From Ken Lams DCT talk 2001 (HK Polytech)

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    14/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [15]

    UM

    CPENEE631Slides(createdbyM.Wu2001)

    Example of 1-D DCT (contd)

    k

    Z(k)

    Transform coeff.

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    1.0

    0.0

    -1.0

    Basis vectors

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100

    100

    0

    -100u=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 Lams DCT talk 2001 (HK Polytech)

  • 7/29/2019 Unitary Transformation

    15/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [17]

    2-D DCT

    Separable orthogonal transform

    Apply 1-D DCT to each row, then to each column

    Y = C X CTX = CTY C = mn y(m,n) Bm,n

    DCT basis images:

    Equivalent to representan NxN image with a setof orthonormal NxNbasis images

    Each DCT coefficient

    indicates the contributionfrom (or similarity to) thecorresponding basis image

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    16/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [18]

    2-D Transfo rm : General Case

    A general 2-D linear transform {ak,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 N2 values to compute

    N2 terms in summation per output coefficient

    O(N4) for transforming an NxN image!

    ),(),(),(

    ),(),(),(

    1

    0

    1

    0

    ,

    1

    0

    1

    0,

    nmhlkynmx

    nmanmxlky

    N

    k

    N

    l

    lk

    N

    m

    N

    nlk

    UMCPENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    17/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [20]

    2-D Separable Unitary Trans form s

    Restrict to separable transform

    ak,l(m,n) = ak(m) bl(n) , denote this as a(k,m) b(l,n)

    Use 1-D unitary transform as building block

    {ak(m)}kand {bl(n)}lare 1-D complete orthonormal sets of basis vectors

    use as row vectors to obtain unitary matrices A={a(k,m)} & B={b(l,n)} Apply to columns and rows Y = A X BT

    often choose same unitary matrix asA andB (e.g., 2-D DFT)

    For square NxN imageA: Y = A X ATX = AHY A*

    For rectangular MxN imageA: Y = AMX ANT

    X = AMH

    Y AN*

    Complexity ~ O(N3)

    May further reduce complexity if unitary transf. has fast implementation

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    18/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [21]

    Basis Images

    X = AHY A* => x(m,n) = k

    l

    a*(k,m)a*(l,n) y(k,l)

    RepresentXwith NxN basis images weighted by coeff. Y

    Obtain basis image by setting Y={(k-k0, l-l0)} & getting X { a*(k0,m)a*(l0,n) }m,n in matrix form A*k,l= a*kal

    *T ~ a*kis kth column vector ofAH

    trasnf. coeff. y(k,l) is the inner product ofA*k,lwith the image

    Exercise

    Unitary transform or not? Find basis images

    Represent an image X with basis images

    (Jains e.g.5.1, pp137)

    2

    1

    2

    12

    1

    2

    1

    A

    43

    21X

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    19/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [22]

    UMCPENEE631Slides(cre

    atedbyM.Wu2001)

    Common Uni tary Transfo rms and Basis Images

    DFT DCT Haar transform K-L transform

    See also: Jains Fig.5.2 pp136

  • 7/29/2019 Unitary Transformation

    20/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [24]

    2-D DFT

    2-D DFT is Separable

    Y = F X FX = F* Y F*

    Basis images Bk,l= (ak)(al

    )T

    where ak= [ 1 WN-k WN

    -2k WN-(N-1)k]T/N

    1

    0

    1

    0

    1

    0

    1

    0

    ),(1

    ),(

    ),(1

    ),(

    N

    k

    N

    l

    mk

    N

    nl

    N

    N

    m

    N

    n

    mk

    N

    nl

    N

    WWlkYN

    nmX

    WWnmXN

    lkY

    UMCPENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    21/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [25]

    Summary and Review (1)

    1-D transform of a vector

    Represent an N-sample sequence as a vector in N-dimension vector space

    Transform Different representation of this vector in the space via different basis e.g., 1-D DFT from time domain to frequency domain

    Forward transform In the form of inner product Project a vector onto a new set of basis to obtain N coefficients

    Inverse transform Use linear combination of basis vectors weighted by transform coeff. to

    represent the original signal

    2-D transform of a matrix

    Rewrite the matrix into a vector and apply 1-D transform

    Separable transform allows applying transform to rows then columns

    UM

    CPENEE631Slides(createdbyM.Wu2001)

  • 7/29/2019 Unitary Transformation

    22/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [26]

    Summary and Review (1) contd

    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 orthonomal basis

    Used for representing the space via their linear combinations

    Many possible sets of basis and orthonomal basis

    Unitary transform on inputx ~ A-1 = A*T

    y = A xx = A-1 y = A*Ty = ai*Ty(i) ~ represented by basis vectors{ai

    *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(N4) computation

    Separable: Y = A X AT= (A X) AT ~ O(N3) computation Apply 1-D transform to all columns, then apply 1-D transform to rows

    UM

    CPENEE631Slides(createdbyM.Wu2001

    )

  • 7/29/2019 Unitary Transformation

    23/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [29]

    Optimal Trans form

    UM

    CPENEE631Slides(createdbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    24/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [30]

    Optimal Transform

    Recall: Why use transform in coding/compression?

    Decorrelate the correlated data

    Pack energy into a small number of coefficients

    Interested in unitary/orthogonal or approximate orthogonal transforms Energy preservation s.t. quantization effects can be better understood and

    controlled

    Unitary transforms weve dealt so far are data independent

    Transform basis/filters are not depending on the signals we are processing

    What unitary transform gives the best energy compactionand decorrelation?

    Optimal in a statistical sense to allow the codec works well with

    many images Signal statistics would play an important role

    UM

    CPENEE631Slides(createdbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    25/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [31]

    Review: Correlat ion A fter a Linear Trans form

    Consider an Nx1 zero-mean random vectorx

    Covariance (autocorrelation) matrixRx = E[ x xH]

    give ideas of correlation between elements

    Rxis a diagonal matrix for if all N r.v.s are uncorrelated

    Apply a linear transform tox: y= Ax

    What is the correlation matrix fory?

    Ry = E[ y yH] = E[ (Ax) (Ax)H] = E[ A x xHAH]

    = A E[ x xH] AH= A Rx

    AH

    Decorrelation: try to search forA that can produce a

    decorrelated y(equiv. a diagonal correlation matrix Ry)

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    26/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [32]

    K-L Transform (Princ ipal Component Analys is)

    Eigen decomposition of Rx: Rxuk= kuk

    Recall the properties of Rx Hermitian (conjugate symmetric RH= R);

    Nonnegative definite (real non-negative eigen values)

    Karhunen-Loeve Transform (KLT)

    y = UHx x = U y with U = [ u1, uN]

    KLT is a unitary transform with basis vectors in U being the

    orthonormalized eigenvectors of Rx

    UH Rx

    U = diag{1,

    2, ,

    N} i.e. KLT performs decorrelation

    Often order{ui} so that 12 N

    Also known as the Hotelling transform or

    the Principle Component Analysis (PCA)

    UMCPENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    27/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [33]

    Propert ies of K -L Trans form

    Decorrelation

    E[ y yH]= E[ (UHx) (UHx)H]= UHE[ x xH] U= diag{1, 2, , N}

    Note: Other matrices (unitary or nonunitary) may also decorrelate

    the transformed sequence [Jains e.g.5.7 pp166]

    Minimizing MSE under basis restriction

    If only allow to keep m coefficients for any 1m N, whats the

    best way to minimize reconstruction error?

    Keep the coefficients w.r.t. the eigenvectors of the first m largesteigenvalues

    Theorem 5.1 and Proof in Jains Book (pp166)

    UMCPENEE631Slides(crea

    tedbyM.Wu2001/20

    04)

  • 7/29/2019 Unitary Transformation

    28/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [34]

    KLT Basis Restr ic t ion

    Basis restriction

    Keep only a subset of m transform coefficients and then performinverse transform (1 m N)

    Basis restriction error: MSE between original & new sequences

    Goal: to find the forward and backward transform matricesto minimize the restriction error for each and every m

    The minimum is achieved by KLT arranged according to the

    decreasing order of the eigenvalues of R

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    29/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [35]

    K-L Transform for Images

    Work with 2-D autocorrelation function

    R(m,n; m,n)= E[ x(m, n) x(m, n) ] for all 0m, m, n, nN-1

    K-L Basis images is the orthonormalized eigenfunctions ofR

    Rewrite images into vector form (N2x1)

    Need solve the eigen problem forN2xN2 matrix! ~ O(N6)

    Reduced computation for separable R

    R(m,n; m,n)= r1(m,m) r2(n,n)

    Only need solve the eigen problem for twoNxNmatrices ~ O(N3)

    KLT can now be performed separably on rows and columns Reducing the transform complexity from O(N4) to O(N3)

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2001

    )

  • 7/29/2019 Unitary Transformation

    30/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [36]

    Pros and Cons of K -L Transform

    Optimality

    Decorrelation and MMSE for the same# of partial coeff.

    Data dependent

    Have to estimate the 2nd-order statistics to determine the transform

    Can we get data-independent transform with similar performance? DCT

    Applications

    (non-universal) compression pattern recognition: e.g., eigen faces

    analyze the principal (dominating) components

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2001

    )

  • 7/29/2019 Unitary Transformation

    31/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [37]

    Energy Compact ion of DCT vs. KLT

    DCT has excellent energy compaction

    for highly correlated data

    DCT is a good replacement for K-L

    Close to optimal for highly correlated data

    Not depend on specific data like K-L does

    Fast algorithm available

    [ref and statistics: Jains pp153, 168-175]

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    32/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [38]

    Energy Compaction of DCT vs. KLT (contd)

    Preliminaries

    The matrices R, R-1, and R-1 share the same eigen vectors

    DCT basis vectors are eigenvectors of a symmetric tri-diagonal matrixQc

    Covariance matrixR of 1st-order stationary Markov sequence with has an

    inverse in the form of symmetric tri-diagonal matrix

    DCT is close to KLT on 1st-order stationary Markov

    For highly correlated sequence, a scaled version ofR-1 approx. Qc

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2004

    )

  • 7/29/2019 Unitary Transformation

    33/34

    ENEE631 Digital Image Processing (Spring'04) Lec12 Unitary Transform [41]

    Summary and Review on Unitary Trans form

    Representation with orthonormal basis Unitary transform

    Preserve energy

    Common unitary transforms

    DFT, DCT, Haar, KLT

    Which transform to choose?

    Depend on need in particular task/application

    DFT ~ reflect physical meaning of frequency or spatial frequency

    KLT ~ optimal in energy compaction

    DCT ~ real-to-real, and close to KLTs energy compaction

    => A comparison table in Jains book Table 5.3

    UM

    CPENEE631Slides(c

    reatedbyM.Wu2001

    )

  • 7/29/2019 Unitary Transformation

    34/34