Digital Image Processing_advanced Course

download Digital Image Processing_advanced Course

of 240

Transcript of Digital Image Processing_advanced Course

  • 7/31/2019 Digital Image Processing_advanced Course

    1/240

    Digital Image Processing

    Transforms Advanced level

  • 7/31/2019 Digital Image Processing_advanced Course

    2/240

    Transforms Advanced level

    Until now we considered discrete sinusoidal transforms. This concept should be familiar to someone that has BSc in

    electrical engineering.

    However, there are numerous other transforms developed

    in the last 10 or 20 years that have found applications innumerous research areas.

    Digital image processing is attractive application for thesetransforms.

    Here, we will give and brief overview of advanced leveltransforms used in digital image processing.

  • 7/31/2019 Digital Image Processing_advanced Course

    3/240

    Digital image profile

    Typical profile of the digital image (along singleimage line) is given below.

    We can assume that im age has almost constant values w it hsmall variat ions in several neighbor pixels and aft er t hat w ehave abrupt changes of lum inance.

    For image fi l tering it is import ant t hat image energy is

    concentrated in t he smallest t ransformation coeff icients.Similar proper t y is desirable for image compression.

  • 7/31/2019 Digital Image Processing_advanced Course

    4/240

  • 7/31/2019 Digital Image Processing_advanced Course

    5/240

    Need for rectangular wavetransform

    When we are performing 2D sinusoidal wave transformon profile of digital image (see slide 3) we need largenumber of coefficients to accurately describe abruptpoints since it is very difficult to represent abruptchanges with smooth functions.

    Then several discrete rectangular wave transforms aredeveloped based on rectangular shaped periodicfunctions.

    We will introduce some of them on several forthcoming

    slides.

  • 7/31/2019 Digital Image Processing_advanced Course

    6/240

    Hadamard transform

    Here, we will introduce the Hadamard transform forN=2n samples. There are some alternative forms ofHadamard transform for other number of samples.

    Hadamard transform derivation begins with matrix:

    2

    1 1

    1 1

    =

    Hadamard transform for N=2 is defined withtransformation matrix:

    2 2

    1

    2= H

  • 7/31/2019 Digital Image Processing_advanced Course

    7/240

    Hadamard transform

    Hadamard transform of larger dimensions can be definedusing recursively as:

    1N N

    N= H where / 2 / 2

    / 2 / 2

    N N

    N

    N N

    =

    Example forN=8:

    H8 12 2

    1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 11 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1

    0

    7

    3

    41

    6

    2

    5

    =

    L

    N

    MMMM

    MMMMMM

    M

    O

    Q

    PPPP

    PPPPPP

    P

    Number on t heend of each rowis number ofsign changes in

    the row ( f rom 1to 1 and viceversa).

  • 7/31/2019 Digital Image Processing_advanced Course

    8/240

    Walsh ordering

    Very often instead of the Hadamard transform we areusing reordered form of the Hadamard transform (thisreordering is called Walsh ordering and sometimes thecorresponding transform is called the Walsh transform).

    Reordering is performed in such manner that on the top ofthe transform matrix is put the row of the Hadamardtransform matrix with the smallest number of sign changes(from 1 to -1 and from -1 to 1) and below rows are

    ordered in increasing order of sign changes. Hadamard and Walsh transforms are equivalent to each

    other but the Walsh transform order has analogy with thesinusoidal transform with respect to increasing of

    frequencies represented with corresponding coefficients.

  • 7/31/2019 Digital Image Processing_advanced Course

    9/240

    Walsh matrix - Example

    1 1 1 1 1 1 1 1 0

    1 1 1 1 1 1 1 1 1

    1 1 1 1 1 1 1 1 2

    1 1 1 1 1 1 1 1 31

    1 1 1 1 1 1 1 1 42 21 1 1 1 1 1 1 1 5

    1 1 1 1 1 1 1 1 6

    1 1 1 1 1 1 1 1 7

    Walsh transform matrix forN=8.

    Your task (maybe it is not quite

    simple) is to determine the inverseWalsh transform.

    The simpler task is to graphicallyrepresent basis function of the

    Hadamard and Walsh transforms.

    Several alternative rectangular transforms are reviewed intextbook. Here, we will due to its importance just mention theHaar expansion.

  • 7/31/2019 Digital Image Processing_advanced Course

    10/240

    Columns of the Walsh matrix

    Columns of t he Walsh matr ixare quit e similar t o t hesinusoidal function used insinusoidal t ransform s(expansions).

    funct ion on frequency 0

    funct ion on frequency 1

    .

    .

    .

    fr equency gradually increases

  • 7/31/2019 Digital Image Processing_advanced Course

    11/240

    Haar transform

    Definition of the Haar transform is not quite simple.Consider integer k defined in domain 0 k N-1. It can bewritten as: k= 2p+q-1.

    Integers p and q are selected in such a manner that p isthe largest integer that satisfy 2p k.

    Values ofk represents rows of the Haar transform matrix(here the first row has index 0, next one has index 1while the last one has the index N-1).

    The second index (corresponding to columns) is denoted

    with i and this index is also defined within the range0 i N-1.

    Now we can defined x as x = i / N.

  • 7/31/2019 Digital Image Processing_advanced Course

    12/240

    Haar transform

    There is direct relationship between x and column indexi.

    Elements in rows of the Haar transform are denoted ashk(x) where k is row index described on the previous

    slide. These vectors are defined as:

    h xN

    0

    1( ) =

    / 2

    / 2

    1 1/ 22

    2 2

    1 1/ 2( ) 2

    2 2

    0 elsewhere

    p

    p p

    p

    k p p

    q qx

    q qh x x

    N

  • 7/31/2019 Digital Image Processing_advanced Course

    13/240

    Haar transform - Example

    In order to understand the Haar transform and role of(p,q) we give as an example matrix for N=8 and we givevalues of (p,q) next to each row.

    1 1 1 1 1 1 1 1(0,0)

    1 1 1 1 1 1 1 1 (0,1)

    2 2 2 2 0 0 0 0 (1,1)

    (1, 2)1 0 0 0 0 2 2 2 2

    (2,1)8 2 2 0 0 0 0 0 0(2,2)0 0 2 2 0 0 0 0

    (2,3)0 0 0 0 2 2 0 0

    (2,4)0 0 0 0 0 0 2 2

    =

    Hr

    There is naturalquest ion how itlooks like theinverse mat rix int his case?

  • 7/31/2019 Digital Image Processing_advanced Course

    14/240

    Haar transform (p,q)

    Lets try to understand roles of (p,q) in transform. Obviously, p corresponds to power of elements

    represented in matrix rows. This value is called thescale.

    Coefficient q define position on non-zero elements in therows. Then it is called posit ion or shif t .

    Haar transform will be used later for introducing quite

    important concept ofwavelets and then we will explaindetails about this transform.

  • 7/31/2019 Digital Image Processing_advanced Course

    15/240

    Haar trans. 2 and 4-samples

    Assume that we have 4 samples and assume that wetry to transform these 4 samples using HT for 2samples. Then this transform will perform operation

    on the first pair of samples and after that on thesecond pair of samples. Results of operations appliedto pairs of samples are submitted in upper and lowerlines.

    x(0)

    x(1)HTN=2

    (0) (0) 2 / 2 (1) 2 / 2y x x= +(1) (0) 2 / 2 (1) 2 / 2y x x=

    Haar t ransformer for N= 2 iscreated in such manner t han onebranch is used to peek up tw oadjacent samples and t o addthem (w ith some mult iple) w hi lethe second branch is used t o

    subt ract adj acent samples.

  • 7/31/2019 Digital Image Processing_advanced Course

    16/240

    Haar trans. 2 and 4-samples

    In order to get the HT for N=4 samples we can notethat lower line already produces 2 samples of theoutput while we have to apply the HT for N=2 forupper line.

    x(n), n=0,1,2,3 HTN=2

    (0) 2 / 2 (1) 2 / 2, (2) 2 / 2 (3) 2 / 2x x x x+ +

    (0) 2 / 2 (1) 2 / 2, (2) 2 / 2 (3) 2 / 2x x x x

    x(n), n=0,1,2,3 HTN=2

    HTN=2

    y(0)

    y(1)

    y(2), y(3)

  • 7/31/2019 Digital Image Processing_advanced Course

    17/240

    Haar transf. N=8

    Haar transform for larger number of samples can beobtained in similar manner. For example for N=8:

    x(n), n=0,...,7 HTN=2

    HTN=2

    HTN=2

    y(0)

    y(1)

    y(2), y(3)

    y(4), y(5), y(6), y(7)

  • 7/31/2019 Digital Image Processing_advanced Course

    18/240

    Haar transf. Conclusion

    It can be observed that lower lines of the Haartransform are not used for further processing.

    For self learning session students should try to realizethe inverse Haar transformer.

    The Haar transform follows general logic of theimage in transform domain. Namely, in the imagemore interesting things are on the lower frequencieswhere the high amount of energy is concentrated

    than on higher frequencies. Then it is more importantto process samples on low than on high frequencies.

  • 7/31/2019 Digital Image Processing_advanced Course

    19/240

    Haar transf. Basis images

    low frequenciesw it h image energy

    high f requenciesw it h image details

    Basis imagesfor N=8.

  • 7/31/2019 Digital Image Processing_advanced Course

    20/240

    Optimal transform

    The Haar transform will be used for introduction of veryimportant class of transforms called wavelets. Thesetransforms have slightly different logic behind with respectto the introduced transforms. They are appropriate for

    digital image processing since energy of images is hiddenon low frequencies while details are on high frequencies.

    Before we proceed with wavelet transform description wewant to address the question what the ideal (optimal)

    transform would be for us? Based on introduced facts we can conclude that the best

    transform would be the one concentrating the signalenergy in the smallest number of transformation

    coefficients.

  • 7/31/2019 Digital Image Processing_advanced Course

    21/240

    Optimal transform

    Assume that we have transform with transformation matrixA. Then transformation can be written as:

    X=A x Introduce important concept ofeigenvalues and

    eigenvectors of matrix A. Eigenvalues i are solution of equation:

    Let solutions of this equation be: i, i=1,...,N. These solutions are called eigenvalues.

    | | 0

    =A IUnit y matr ix of t he same

    dimensions as matr ix A

  • 7/31/2019 Digital Image Processing_advanced Course

    22/240

    Eigenvalues

    For a given i we should determine vector v isatisfying:Aq i= iq i

    It is easy to show that under given conditions (wheni is solution of previously defined equation) thereare infinite number of vectors satisfying thisequation.

    We can limit number of solutions to 1 bynormalization of vector q i in such a way that its

    amplitude (square root of sum of squares of vectorelements) is equal to 1, | | q i| | = 1.

  • 7/31/2019 Digital Image Processing_advanced Course

    23/240

  • 7/31/2019 Digital Image Processing_advanced Course

    24/240

    Eigenvalues matrix

    It holds: QTAQ= Q QT= A

    Determine cross-correlation of transform X:CXX= E{ XX

    T} = E{ AxxTAT} = AE{ xxT} AT

    CXX= AcxxAT

    For self -exercise review basicmat rix operat ions.

    cross-correlat ion m atr ixof signal

    Energy concentrated in transform can be connected with energy ofmatrix CXX and this energy has the smallest loss when CXX is a diagonal

    matrix.

  • 7/31/2019 Digital Image Processing_advanced Course

    25/240

    Ideal transform

    It is easy to conclude that ideal matrix CXX isproduced when A is matrix of eigenvalues ofcxx.

    When cxx is known we can determine idealtransform ofA as a matrix of eigenvalues.

    It can be shown that when we use just M the largesttransformation coefficients of vector obtained meansquared error is equal to:

    1

    N

    i

    i M

    MSE= +

    = eigenvalues corresponding t ot runcated coeff icient s, i.e.,sum of t he smallest N-Meigenvalues

  • 7/31/2019 Digital Image Processing_advanced Course

    26/240

    Ideal transform

    It can be shown that this transform produces thesmallest MSE when we take M transformationcoefficients.

    This transform is called the Karhunen-Loeve (KL) andit represents ideal transform that is goal for

    compression and filtering applications. Why we are not using the KL? The answer is quite simple. The KL requires

    calculation of the auto-correlation matrix and

    eigenvalues. Both of these operations are quitedemanding.

  • 7/31/2019 Digital Image Processing_advanced Course

    27/240

    Eigenvalues in digital images

    It would be great that the KL be applicable in digitalimages since most of images have structure that wouldproduces extremely small number of significanteigenvalues while huge number corresponds tocomponents of insignificant energy.

    Fortunately, the DCT approaches to the KL transformfor numerous practical images!!!!

    This is the reason why one of the most common image

    compression standards is based on the DCT.

  • 7/31/2019 Digital Image Processing_advanced Course

    28/240

    Eigenvalues - Examples

    We will review steps in calculation of eigenvalues byhand and how it can be implemented in MATLAB.

    The following matrix is given:

    1 2 1

    3 1 0

    1 0 1

    =

    R

    I n MATLABR= [ 1 2 -1;3 1 0;1 0 -1]

    3 2

    1 2 1

    det( ) 3 1 0 6 6

    1 0 1

    = = + + +

    R

    I n MATLABkar_j ed= poly(A)

  • 7/31/2019 Digital Image Processing_advanced Course

    29/240

    Eigenvalues - Examples

    There are no direct approach for solving polynomialequation of higher order but to use numerical means.

    Then it is quite usable MATLAB function eig(R) thatproduces eigenvalues.

    In our case eigenvalues are:13.337 2,3-1.168 j0.658. Determine now one of the eigenvectors by hand.

    It is eigenvector corresponding to the first eigenvalue

    1.

  • 7/31/2019 Digital Image Processing_advanced Course

    30/240

    Eigenvalues - Examples

    For this eigenvalue holds:11

    21

    31

    2.337 2 1

    3 2.337 0

    1 0 4.337

    q

    q

    q

    =

    0

    q31=q11/4.337=0.231q11 q21=3/2.337q11=1.284q11

    It is easy to prove that this expression satisfy the first

    equation (accuracy is limited by small error in rounding)that is not independent on the other two.

    -2.337q11+2q21-q31=0

  • 7/31/2019 Digital Image Processing_advanced Course

    31/240

    Eigenvalues - Example

    Then the corresponding eigenvector is [q11, 1.284q11,0.231q11]. This vector can be normalized to modulo 1:

    Then the eigenvector is [0.608,0.781,0.140].

    MATLAB function can perform this in quite simple manner:

    2 2 2 2

    11 11 11 11(1.284 ) (0.231 ) 2.702 1q q q q+ + = =

    11 0.608q =

    [ Q,L] = eig([ 1 2 -1;3 1 0;1 0 -1] )matrix of

    eigenvectors

    diagonal matr ix of

    eigenvalues

  • 7/31/2019 Digital Image Processing_advanced Course

    32/240

    Eigenvalues - Example The KL transform can be calculated for line of image as:

    clearIm=imread('cameraman.tif');A=double(Im(180,:));A=A(113:142);

    A=A-mean(A);[KL,L]=eig(A'*A) In numerous cases just one eigenvalue corresponds to

    the most of the image energy and from entire matrix inthe KL transform it is enough to memorize just severaltransformation coefficients (eigenvalues). However, thisshould be paid with calculation complexity and withmemorizing eigenvectors for this transform (KL is signaldependent).

  • 7/31/2019 Digital Image Processing_advanced Course

    33/240

    Wavelet transform

    Now, we can consider the Haar transform realized forN=8:

    x(n), n=0,...,7 HTN=2

    HTN=2

    HT

    N=2

    y(0)

    y(1)y(2), y(3)

    y(4), y(5), y(6), y(7)

    We noted t hat in t he low er branches t here are no import ant component s and weare not processing t hese branches fur t her. Then the Haar t ransform mat rix haslarge number of zero coeff icient s in t ransform ation matr ix.

  • 7/31/2019 Digital Image Processing_advanced Course

    34/240

    Wavelet with Haar wavelet

    The first decomposition stage can be illustrated in thefollowing manner.

    g(n)

    h(n)

    g(n) has impulse response

    and 0 for other n

    (0) 2 / 2g = (1) 2 / 2g =

    h(n) has impulse response

    and 0 for other n

    (0) 2 / 2h =

    (1) 2 / 2h =

    x(n)

    x(n)* g(n)

    x(n)* h(n)

    2

    2

    xg(2n)

    xh(2n)

    Circuit f ordecimation(downsampling).I t t akes evensamples of inpu tsignal.

  • 7/31/2019 Digital Image Processing_advanced Course

    35/240

    Haar wavelet

    In upper branch we have samples:

    while in the lower branch we have

    0

    (2 ) (2 1)( )

    2

    x n x nx n

    + +=

    1

    (2 ) (2 1)( )

    2

    x n x nx n

    +=

    n=[0,N/2-1)

    n=[0,N/2-1)

    How input (original) signal can be reconstructed?

  • 7/31/2019 Digital Image Processing_advanced Course

    36/240

    Signal reconstruction from theHaar wavelet

    Let the first step in the procedure be upsampling defined as:

    In the next step we are putting both signals through the same

    filters as in the first stage (g(n) and h(n)). Finally, thesesignals should be summed.

    Output of g(n) filter in upper branch is signal with samples:[(x(0)+x(1))/2,(x(0)+x(1))/2],

    [(x(2)+x(3))/2,(x(2)+x(3))/2]... In lower branch we have: [(x(0)-x(1))/2,(-x(0)+x(1))/2],

    [(x(2)-x(3))/2,(-x(2)+x(3))/2]...

    (2 ) ( ) (2 1) 0 0,1i i ix n x n x n i= + = =

  • 7/31/2019 Digital Image Processing_advanced Course

    37/240

    Haar Wavelet - Scheme Decomposition (analysis) and reconstruction (synthesis) in

    the case of the wavelet transform with Haar wavelet canbe given as.

    g(n)

    h(n)

    x(n)2

    2

    Point t hat separat e analysisand synt hesis stage.

    2

    2

    g(n)

    h(n)

    +

    x(n)

    There is a question why this transform is performed?

  • 7/31/2019 Digital Image Processing_advanced Course

    38/240

    Need for wavelet transform

    In upper branch we are performing lowpass filtering withlowpass filter that average samples.

    Highpass filtering is performed in lower branch.

    This corresponds to the spectral characteristic of digital

    images: different amounts of energy on low and highfrequencies.

    Since low frequency region has huge amount of energywe are performing further decomposition of this part.

  • 7/31/2019 Digital Image Processing_advanced Course

    39/240

    Wavelet transform indecomposition

    For exercise create system that performs synthesis of inputsignal from this decomposition.

    In practice after wavelet decomposition we perform filteringof coefficients corrupted by noise or compression of signalwith removing from visual quality point of view un-important coefficients.

    Then output signal is different from the input signal.

    g(n)

    h(n)

    2

    2

    g(n)

    h(n)

    2

    2

    g(n)

    h(n)

    2

    2

    Element s on higher f requencies arecalled details.

    elements on low er frequencies are

    called scale (analysis part or r oughpart)

  • 7/31/2019 Digital Image Processing_advanced Course

    40/240

    General wavelet transform

    The Haar wavelet was the first wavelet transform.

    This wavelet (Haar) is good for modeling functionswith abrupt changes in the considered interval.

    For slower variations this transform is not the best

    one. Can we construct the wavelet transform that is

    suitable for other slower variations in signal, i.e.,constructed using alternative filtering functions.

    Model of general wavelet transform will beconsidered within this and the next lecture.

  • 7/31/2019 Digital Image Processing_advanced Course

    41/240

    Model of wavelet transformer

    We are interested in conditions that should be satisfied withfilters h0(n) , h1(n) , g0(n) and g1(n) , in order that inputsignal be the same as the output one.

    It is obvious that filters h0(n) and h1(n) should contain allfrequencies in order that we can reconstruct signal at theoutput.

    h0(n)

    h1(n)

    2

    2

    2

    2

    g0(n)

    g1(n)

    +x(n)

  • 7/31/2019 Digital Image Processing_advanced Course

    42/240

    Filters in spectral domain

    The simplest method forfilter bank analysis isusing the Z-transform.

    |H0( )| |H1( )|

    low

    frequencieshigh

    frequencies

    ( ) ( ) n

    n

    X z x n z

    =

    =

    ( ) (2 )dx n x n=

    1/ 2 1/ 21

    ( ) [ ( ) ( )]2dX z X z X z= + Z-t ransform ofdow nsampling circuit :

    For upsampling circuit:( / 2) 0,2,4,...

    ( )0 elsewhere

    u

    x n nx n

    ==

    2( ) ( )uX z X z=

    Check!

  • 7/31/2019 Digital Image Processing_advanced Course

    43/240

    Wavelet filters design

    At the output of the wavelet system(aft er relat ively

    simple mathematical derivat ions) we obtain:

    0 0 1 1

    0 0 1 1

    1

    ( ) [ ( ) ( ) ( ) ( )] ( )2

    1[ ( ) ( ) ( ) ( )] ( )

    2

    X z G z H z H z G z X z

    G z H z H z G z X z

    = +

    + +

    it should beequal to 1

    it should be 0

    Assuming that we know h0(n) and h1(n)equation for determination of the g0(n)and g1(n) in the Z-domain is:

    10

    01

    ( )( ) 2

    ( )( ) det( ( ))m

    H zG z

    H zG z z

    =

    H

  • 7/31/2019 Digital Image Processing_advanced Course

    44/240

    Wavelet filters design

    Denote:0 0

    1 1

    ( ) ( )( )

    ( ) ( )m

    H z H zz

    H z H z

    =

    H

    Assume that det(Hm(z))=z-(2k+1) (delay only) and for =2we obtain:

    0 1

    1

    1 0

    ( ) ( 1) ( )

    ( ) ( 1) ( )

    n

    n

    g n h n

    g n h n+

    =

    = For =-2 it follows:10 1

    1 0

    ( ) ( 1) ( )

    ( ) ( 1) ( )

    n

    n

    g n h n

    g n h n

    +=

    =

  • 7/31/2019 Digital Image Processing_advanced Course

    45/240

    Wavelet filters design

    Under introduced assumptions it holds:0 0 1 1( ) ( ) ( ) ( ) ( )P z G z H z G z H z= =

    Further we obtain:0 0 0 0( ) ( ) ( ) ( ) 2G z H z G z H z+ =

    Calculating the inverse Z-transform it follows:

    0 0 0 0( ) ( ) ( 1) ( ) ( ) 2 ( )n

    k k

    g k h n k g k h n k k

    = =

    + =

    This relationship represents the condition that should besatisfied by wavelet filters in time domain.

    In the next lecture we will conclude design of waveletfilters, some comments related to the 2D wavelets will begiven and standard usage of wavelets explained.

  • 7/31/2019 Digital Image Processing_advanced Course

    46/240

    For self-exercise Write program for realization of the Hadamard and Walsh

    transforms. Determine inverse of the Walsh and Hadamard transforms. To

    which group they belong? Repeat the same procedure for theHaar transform.

    Assume that we have signal of dimensions 8x8 with non-zero

    coefficients x(1,2)=2, x(3,1)=1 and x(5,6)=1. Calculate theHadamard, Haar and Walsh transforms of this signal. For NxM=8x8 determine basis images for (p,q)=(1,2),

    (p,q)=(3,3) and (p,q)=(6,7). Proj ect for self-exercise.Application of the Hadamard

    transform in realization of the special purpose Hamming codes -Reed-Muller codes. Write program for the Hadamard and other rectangular

    transforms of digital image. When image dimensions are notpower of 2 realize transforms with zero-padded signal.

  • 7/31/2019 Digital Image Processing_advanced Course

    47/240

    For self-exercise Give hardware realization of the inverse Haar transformers. For filters used in the Haar transform (or Haar wavelet)

    determine spectral response. Since these filters have only 2non-zero samples of the impulse response perform the zero-padding for obtaining clear results.

    Details of the eigenvalues decomposition and the KL transform

    in signal processing could be learnt in details from the book: M. R. Stoji, M. S. Stankovi, R. S. Stankovi: Diskretne

    transformacije u primjeni, Nauka, 1993 (strana 119).

    For mini-project. Study singular value decomposition and caseswhen it can be used. Try to find proper references while

    wikipedia can be used as a starting point in search related tothis topic.

  • 7/31/2019 Digital Image Processing_advanced Course

    48/240

    For self-exercise Write program that perform Wavelet Haar decomposition of the

    signal of the given length (power of 2) given number of times(for example 3 times) in such a manner that in each stage ofdecomposition it is performed on lowpass signal.

    Give graphical presentation of the signal decomposition usingthe wavelet transform. Wavelet decomposition is performed 3

    times on the lowpass part. Give corresponding synthesis stage. Assume that in the lowpass branch of the wavelet we have ideal

    cut-off filter with cut-off frequency equal to half of the maximalfrequency that corresponds to the sampling theorem. Determinefilter for highpass branch and corresponding filters on thesynthesis side. What is the main difference between this andthe system with Haar wavelet?

  • 7/31/2019 Digital Image Processing_advanced Course

    49/240

    For self-exercise Prove formulas for Z-transform of the downsampling and upsampling

    circuit. Signal x(n) is transformed with downsampling and after that with

    upsampling circuit. Determine output of this system in time and Z-domain.

    Haar transform is determined. Try to determine methods for calculation ofthe Wavelet-Haar coefficients from the Haar transform.

    Haar transform and wavelet with Haar filter are defined with the samebasic goal. Determine difference between these two transforms?

    Determine relationship between transform coefficients in the Hadamardand the Walsh transform?

    Mini-project. Consider several real images with their transforms (DFT,

    DCT, DHT and introduced rectangular ones). For each transformdetermine how many coefficients are kept in 50%, 70%, 80%, 90%,95%, 98%, 99%, 99.5%, 99.9% of the signal power. Which of introducedtransform is the best in each considered case?

  • 7/31/2019 Digital Image Processing_advanced Course

    50/240

    For self-exercise Repeat previous experiments when image is divided in blocks 2nx2n.

    Consider possibility to remove transformation coefficients that havesmall energy in function of n and used transforms. Can you make someconsistent conclusion?

    Apply the wavelet-Haar decomposition on various images and try torepeat analysis from the previous two problems in this case formapplication of this transform in data compression.

    Mini-project. Study wavelets starting from the continuous time form.For this research start from the textbook.

  • 7/31/2019 Digital Image Processing_advanced Course

    51/240

    Digital Image Processing

    Wavelet transformFiltering of digital images - Intro

  • 7/31/2019 Digital Image Processing_advanced Course

    52/240

    Filters used in wavelet transform

    We have proven that filters used in the wavelettransform should satisfy:

    0 0 1 1

    0 0 1 1

    ( ) ( ) ( ) ( ) 2

    ( ) ( ) ( ) ( ) 0

    G z H z H z G z

    G z H z H z G z

    + =

    + =

    Under previously described conditions (filtersproduce pure time-delay) it holds:

    0 0 1 1( ) ( ) ( ) ( ) ( )P z G z H z G z H z= =

    0 0 0 0( ) ( ) ( ) ( ) 2G z H z G z H z+ =

    0 0 1 0 0 1( ) ( ) ( ) ( ) ( ) ( ) 0G z H z G z G z H z G z + =

  • 7/31/2019 Digital Image Processing_advanced Course

    53/240

    Filters in wavelet transform

    Inverse Z-transform of the first expression is:

    0 0 0 0( ) ( ) ( ) ( ) 2G z H z G z H z+ =

    0 0 0 0( ), (2( ) (2 ) ( ))k

    g k h n k g k h n k n

    = = =

    0 1 0 1( ) ( ) ( ) ( ) 0H z G z H z G z + =

    0 0 0 0( ) ( ) ( 1) ( ) ( ) 2 ( )n

    k k

    g k h n k g k h n k n

    = = + =

    It can be written as:

    ( ) ( ) ,k

    x k y k x y

    =

    =I nner product .

  • 7/31/2019 Digital Image Processing_advanced Course

    54/240

    Filters in wavelet transform

    Similarly it can be proven that:

    1 1( ), (2 ) ( )g k h n k n = 0 1( ), (2 ) 0g k h n k =

    We can summarized these relationships as: t he w avelet f i l t ersshould sat isfy t he follow ing relat ionship in t he timedomain:

    1 0( ), (2 ) 0g k h n k =

    (2 ), ( ) ( ) ( ), , {0,1}i jh n k g k i j n i j = =

  • 7/31/2019 Digital Image Processing_advanced Course

    55/240

    Filters in wavelet transform

    When the following:

    (2 ), ( ) ( ) ( ), , {0,1}i jh n k h k i j n i j = =

    holds we have orthogonal wavelets (the same typeof wavelets used in analysis and synthesis stages).

    Next we will discuss the realization of the wavelettransforms for 2D signals and after that we will givesome program realizations.

  • 7/31/2019 Digital Image Processing_advanced Course

    56/240

    2D Wavelets

    How to perform wavelet decomposition for 2Dsignals?

    In the same way as a generalization of all 1Dtransforms to 2D transforms we can perform

    operation separately along rows and columns ofimages.

    Therefore, we will perform wavelet transform alongcolumns (or rows) followed by wavelet transformsalong rows (or columns).

  • 7/31/2019 Digital Image Processing_advanced Course

    57/240

    2D Wavelet transforms

    h0(n)

    h1(n)

    2

    2

    x(n,m)

    applying f i l t ers tocolumns

    t aking elements oneven positionsfrom each column

    h0(m)

    h1(m)

    2

    2

    h0(m)

    h1(m)

    2

    2

    applying f i l ters t o row s

    t aking elements oneven posit ions fr omeach row

    a(n,m)

    dH(n,m)

    dV(n,m)

    dD(n,m)

  • 7/31/2019 Digital Image Processing_advanced Course

    58/240

    2D Wavelet - Comments a(n,m) is low-pass image (sometimes called coarse

    image). Notation a comes from the fact that it is productof analysis side of the wavelet transformers. In the nextstages we can proceed with its analysis using wavelettransform.

    Images dV(n,m), dH(n,m) and dD(n,m) are called detailsin horizontal, vertical and diagonal directions respectively,These images are commonly not subject to furtherdecomposition.

    Note that these images have dimensions N/2XN/2 andtotal dimension of data is not changed by this procedure.

    What is the advantage of wavelet transforms and how torealize it?

  • 7/31/2019 Digital Image Processing_advanced Course

    59/240

    Wavelet realization

    Very often instead of realization of the wavelet transform byusing definition, numerous scientists use well-developedsoftware tools.

    We will use the MATLAB Wavelet Toolbox but on the Internetit is possible to find alternative tools and MATLAB toolboxes.

    This is quite comprehensive and complicated toolbox and wewill not consider all its possibilities but we will just concentrateon several features that can illustrate our theory in step-by-step manner.

    Note that there are single step functions in MATLAB toolboxable to perform very sophisticated operations. User shouldonly learn how to use these functions and knowledge aboutwavelets is not required. This is popular for usage but it issource of numerous mistakes in practice.

  • 7/31/2019 Digital Image Processing_advanced Course

    60/240

    Wavelet Toolbox The most important recent contributions to the Wavelet

    Transform is given by Donoho and it is possible to find allMATLAB functions related to his research on his web-site.

    For a brevity we will present the wavelet transform in step-by-step manner without giving all details. Only on several placeswe will describe useful shortcuts that can be used in

    procedures. The first useful function has a format:

    [LD,HD,LS,HS] = wfilters('haar') Output of this function are wavelet function used in

    decomposition (analysis) stage LD and HD (lowpass andhighpass filters) as well as those used in synthesis stage LS andHS.

    Argument of this function is used wavelet type. Here we usethe Haar wavelet but there are numerous alternativepredefined wavelet functions.

  • 7/31/2019 Digital Image Processing_advanced Course

    61/240

    Wavelet filters Instead of abrupt Haar wavelets we can use more smooth

    functions such as the Daubechies class of wavelet functionscalleddbnwhere n is integer that can be selected withinrange from n=1 to n=45 (db1is in fact the Haar wavelet).Here, it will be useddb23.

    Analysis stage can be performed using convolution of signalwith corresponding wavelet functions:clearx=wnoise(1,10);[LD,HD,LS,HS]=wfilters('db23');

    xl=conv2(x,LD,'same');xh=conv2(x,HD,'same');

    Test signal

    Filtering with corresponding filters

    (parameter same is introduced inorder that obtained signals havethe same length as an originalsignal the first argument. Un-required part of the signal is

    truncated).

    conv for 1D convolutionhas no argument same

  • 7/31/2019 Digital Image Processing_advanced Course

    62/240

    Decimation and reconstruction

    xdl=xl(1:2:length(xl));

    xdh=xh(1:2:length(xl));

    xul=zeros(1,2*length(xdl));

    xuh=zeros(1,2*length(xdl));

    xul(2:2:length(xul))=xdl;

    xuh(2:2:length(xul))=xdh;

    xr=conv2(xul,LS,'same')+conv2(xuh,HS,'same');

    Decimation

    Upsampling

    Filtering in the highpass and lowpass lines.

    Reconstructed signal

  • 7/31/2019 Digital Image Processing_advanced Course

    63/240

    Wavelet transform - Comments

    In the previous example we performed meaningless

    operation: signal is decomposed and after thatreconstructed. Note that before the reconstruction stage lowpass part

    can be decomposed several times.

    Instead of showing the advantages of the wavelettransform on 1D we will do it on example of 2D signals. Here, we will use function dwt2 (there is similar function

    dwt for 1D signals) for decomposition that can perform

    it in more efficient manner than in the previous examplewhere realization is performed in step-by-step manner.

  • 7/31/2019 Digital Image Processing_advanced Course

    64/240

    Wavelet transform of images After reading image cameraman.tifwe perform three steps of

    decomposition (wavelet transform is performed three times on lowpasspart of image).clear

    x=imread('cameraman.tif');

    [ca,ch,cv,cd] = dwt2(x,'db1','mode','sym');

    [caa,cah,cav,cad]=dwt2(ca,'db1','mode','sym');

    [caaa,caah,caav,caad]=dwt2(caa,'db1','mode','sym');

    Slika=[caaa,caah;caav,caad];

    Slika=[Slika,cah;cav,cad];

    WavTransf=[Slika,ch;cv,cd];

    Wavelet transform of image

  • 7/31/2019 Digital Image Processing_advanced Course

    65/240

    Wavelet transform of imageExample

    Wavelet transform has

    the same dimensionslike image but hugenumber of wavelettransform pixels isclose to 0. It meansthat we can neglectmany of them and that

    we can reconstructimage with highaccuracy.

  • 7/31/2019 Digital Image Processing_advanced Course

    66/240

    Image Reconstruction - ExampleIn image reconstruction

    we use 17% of thelargest waveletcoefficients (according toabsolute value). This is

    basis image and imagesrepresenting edges,details and similarelements.

    Reconstruction isperformed using idwt2command.

  • 7/31/2019 Digital Image Processing_advanced Course

    67/240

    Image reconstructionReconstructed

    Cameraman based on17% of wavelet coefficients.

    Due to the described

    properties the wavelettransform has numerousapplication. Some of themwill be given on next slides.

  • 7/31/2019 Digital Image Processing_advanced Course

    68/240

    Wavelet transform application Here, we will present two the most important applications of

    the wavelet transform. The first one is compression. It is clear that for relatively

    small number of wavelet coefficients has significant energy.It means that only small number of coefficients has

    importance for visual image quality. Wavelets are note usedalone for compression but they are combined with othercompressing strategies (for example RLE, Huffman etc) butthe wavelets are basis for some compression standards (forexample JPEG 2000). Furthermore, the wavelet transform

    based compression is quite suitable since it can be applied indifferent manners for different channel state. For noisychannel with small capacity we are sending base imagewithout details but for better conditions in the channels weare sending images with details.

  • 7/31/2019 Digital Image Processing_advanced Course

    69/240

    Application in denoising Assume that image is corrupted in channel or during acquisition process

    (for example medical images obtained using ultrasound devices could bevery noisy). It can be proved that noise in various wavelet coefficients is(almost) mutually independent and it is uniformly distributed (for relativelylarge number of decomposition steps) on all wavelet coefficients. Then wecan perform filtering independently for each coefficients. Two groups of

    techniques are developed using wavelets: hard thresholding (allcoefficients below the threshold are set to zero and in reconstruction areused for reconstruction (threshold is determined based on estimated noisevariance)); soft thresholding (small wavelet coefficients are attenuatedproportionally more than large ones).

    Obtained wavelet-based results are the last word of science in denoisingapplications. It is quite difficult to be better than wavelets in this area interms of quality of imaging and speed.

  • 7/31/2019 Digital Image Processing_advanced Course

    70/240

    Wavelet toolbox There are additional wavelet applications.

    Check wavelet toolbox and demo programwavedemo.

    There are single step functions in the toolbox forsignal filtering.

    For example, check function wden with itsparameters.

    Note that this function is used for the 1D denoising

    and also see denoising 2D images.

  • 7/31/2019 Digital Image Processing_advanced Course

    71/240

    Drawbacks of wavelets When signal subject of transform is dominantly on low

    frequencies with only details and edges of highfrequencies the wavelet transform is close to idealanalysis, synthesis, filtering and compression tool.

    Digital images are commonly this signals of type and

    today wavelet transform is quite commonly used in thedigital image processing field. However, when relatively large energy is concentrated

    on high frequencies or when we have abrupt changes offrequencies in the signal, wavelet transforms are not

    ideal tools.

  • 7/31/2019 Digital Image Processing_advanced Course

    72/240

    Optical interferograms These signals are not quite common in digital images but they

    exists.

    One of these signals are optical intereferograms commonlycaused by mistakes in design of optical communicationchannels or due to diffraction in optical microscopy (optical orlaser microscopes are cheaper than electronic counterparts but

    they suffer from several drawbacks including interferograms).

    Inteferogram: test example.

    Wavelet transform is not suitable foranalysis and filtering of such signals.

  • 7/31/2019 Digital Image Processing_advanced Course

    73/240

    TF (S/SF) Transforms

    Time-frequency t ransforms are designed for analysis of

    1D signals with high frequency content.

    The most important TFRs are: Short -t ime Fourier t ransform (STFT) ;

    Wigner dist r ibut ion (WD) . For multidimensional signals, multidimensional generalization

    of these transforms are used (sometimes calledSpace/Spatial-Frequency representations).

    We described several representations from this group in thetextbook and here from the brevity reasons we will skip them.

  • 7/31/2019 Digital Image Processing_advanced Course

    74/240

    I mage f i l ter ing The most important part of our course is related to image

    filtering and reconstruction. Under filtering we assume obtaining some image features (for

    example in communications signal carrier of informationmodulated on some frequency).

    Filtering in digital images is commonly assumed to bedenoising operation.

    The goal of denoising process is obtaining signal as close aspossible to original image.

    In addition we will consider in a brief manner image

    reconstruction for images corrupted by noise and distortedwith some deterministic form of distortions.

  • 7/31/2019 Digital Image Processing_advanced Course

    75/240

    Spectral image characteristics

    Recall several information related to the image spectral

    characteristics. The 2D DFT of images is highly concentrated around origin

    (0,0) and it decreases rapidly with frequency increasing.

    Filters in the frequency domain can be divided in fourgroups: Lowpass filters that remove frequencies away from the origin.

    Commonly, frequency response of these filters is symmetric aroundthe origin;

    Highpass filters remove signal components around origin infrequency domain;

    Bandpass filters allows frequency in the band between lowest andthe highest frequencies;

    Stopband filters remove frequency band.

  • 7/31/2019 Digital Image Processing_advanced Course

    76/240

    Spectral characteristics of images

    Before we define these filters we will perform a

    simple experiment. Consider image Cameraman .

    Perform lowpass filtering with 17x17 frequencysamples around the origin and perform highpassfiltering for a region outside this zone.

    Results of this rough filtering scheme are given onthe next slide.

  • 7/31/2019 Digital Image Processing_advanced Course

    77/240

    Spectral characteristics of image

    Lowpass filtered image is almost non-usable whilehighpass filtered counterpart is dark but recognizable(to be honest for better visualization we increased

    energy of highpass image).

    Here, energy

    of lowpassimage islargerapproximately18 times!!!

  • 7/31/2019 Digital Image Processing_advanced Course

    78/240

    Spectral characteristics of images

    Conclusion: The largest amount of energy is concentrated on low

    frequencies, but it represents just image luminance andvisually not so important part of image.

    Small energy on high frequency corresponds to visually very

    important image features such as edges and details.

    This is the reason why filtering of digital images arequite complicated task and one of reasons forintroducing the wavelet transform.

  • 7/31/2019 Digital Image Processing_advanced Course

    79/240

    Filters in frequency domain Filters in the frequency domain can be defined as

    (here w e give them in analog form but it can be discretized inst raightforw ard manner):

    1 22 11 22

    1

    (2

    ( ( ,) ))

    )

    , , ( H d dn Xf m

    =

    f i l t ered im age

    2D DFT oforiginal image

    frequency responseof f i l t er

    Filtering can be performed for denosingpurposed, for removing distortions and/or forobtaining some important features from

    digital images.

  • 7/31/2019 Digital Image Processing_advanced Course

    80/240

    Filters in frequency domain

    Here, we will give the simplest filter types in frequency

    domain with value 1 in pass region and 0 in stop region.These filters are called cut-off filters. In addition, we willassume rectangular filter forms. This is just examples andmore advanced filter forms (smooth) are commonly used inpractice.

    1 1 2 2

    1 2

    1 | | | |( , )

    0 elsewhere

    H

    =

    Lowpass filter.

  • 7/31/2019 Digital Image Processing_advanced Course

    81/240

    Filters in frequency domain

    For exercise, determine stopband filter and filters withcircle shape impulse responses.

    In addition determine filters with the shape of theHanning window function in the pass part of thefrequency response.

    1 1 2 2

    1 2

    0 | | | |( , ) 1 elsewhereH

    = High-frequency filter.

    11 1 12 21 2 22

    1 2

    1 | | | |

    ( , ) 0 elsewhereH

    = Bandpass filter.

  • 7/31/2019 Digital Image Processing_advanced Course

    82/240

    Convolution and filtering

    Up to now introduced filters are linear.

    Linear space invariant filters can be realized in bothfrequency and space domain. Realization in spacedomain by using convolution:

    0 0

    0 0 0 0 ( , ( , ) ( , ) (( * *, )) , )

    n

    m

    m

    nx n n m mh n m h n m x n mf n m = =2D fil t er im pulse response.

    Why we call this 2D filter impulse

    response and how it is connectedwith H(1,2)?

    2D convolut ion.

    Determine 2D impulse response of introduced filtering functions.

  • 7/31/2019 Digital Image Processing_advanced Course

    83/240

    Convolution or FFT There are two alternatives for determination of the

    linear space invariant systems outputs: convolutionor FFT in frequency domain.

    What to use? The simpler technique.

    At the first glance it is convolution in the spacedomain but in depth analysis can show that it is notthe case in general.

    Let image x(n,m) has dimensions NxM and letimpulse response h(n,m) has dimensions N1xM1.

    Convolution result has dimensions(N+N1-1)x(M+M1-1). Why?

  • 7/31/2019 Digital Image Processing_advanced Course

    84/240

    Convolution or FFT Under assumption that impulse response has smaller

    duration than image for filtering using convolution isrequired: (N+N1-1)x(M+M1-1)xM1xN1 additions and the samenumber of multiplications.

    For the FFT-based realization it is required 3 FFTs (for filter

    response, input signal and inverse for output signal). Theseoperations require:(N+N1-1)x(M+M1-1)log2(N+N1-1)x(M+M1-1)

    Number of pixels at the

    filter output.

    Number of operation forsingle pixels.

    All signals are properly zero-padded in order to avoid

    aliasing.

  • 7/31/2019 Digital Image Processing_advanced Course

    85/240

    Convolution or FFT In the FFT-based realization we need additional

    (N+N1-1)x(M+M1-1) multiplications X(1,2)H(1,2). In order that realization using convolution is simpler

    it is required to hold:(N+N1-1)x(M+M1-1)xM1xN1 |ey(n,m)| and when we want todetect edge along y-axis it is required that:|ey(n,m)|>|ex(n,m)|.

    In addition, it is required that local maximum be largerth dj t l f d t t i

  • 7/31/2019 Digital Image Processing_advanced Course

    211/240

    than adjacent samples of detector response incorresponding directions:

    |ex(n,m)|>|ex(n-1,m)| and |ex(n,m)|>|ex(n+1,m)| fordetection of edge in x-axis direction or|ey(n,m)|>|ey(n,m-1)| and |ey(n,m)|>|ey(n,m+1)| foredge detection in direction of y-axis.

    Direction of edge Obviously, determination of the detection threshold is

    quite complex issue. Even threshold setup can be

    different for various detectors. There is a problem of estimating direction of edges.

    h k b d d (S b l )

  • 7/31/2019 Digital Image Processing_advanced Course

    212/240

    For the mask based detectors (Sobel, Prewitt etc) wehave detector responses for x and y coordinates.There is possibility to estimate edge direction basedon ex(n,m) and ey(n,m) as

    ( , )

    ( , ) arctan ( , )

    y

    x

    e x y

    x y e x y

    =

    Kirch detectors Kirch designed additional masks for detection of edges

    in other directions. For example detector that is

    sensitive to edges in directions of x, y-axes and axesthat are giving angles of/4 and 3/4 with respect tomain axes can be designed using 4 matrices:

  • 7/31/2019 Digital Image Processing_advanced Course

    213/240

    main axes can be designed using 4 matrices:

    1 1 10 0 0

    1 1 1

    1 0 11 0 1

    1 0 1

    0 1 1

    1 0 1

    1 1 0

    1 1 0

    1 0 1

    0 1 1

    Direction of edge is determined using the largestdetector response produced with these matrices.

  • 7/31/2019 Digital Image Processing_advanced Course

    214/240

    Laplace detector The logic behind the Laplace detector is quite

    different than the mask-based detectors.

    The Laplace differential operator is defined as:

    2 1( ) ( ) [ ( 1 ) ( 1 ) ( 1) ( 1)]f n m f n m f n m f n m f n m f n m + + + + +

  • 7/31/2019 Digital Image Processing_advanced Course

    215/240

    ( , ) ( , ) [ ( 1, ) ( 1, ) ( , 1) ( , 1)]4

    f n m f n m f n m f n m f n m f n m + + + + +

    Edge (abrupt change in luminance) can be detected as zeroin the Laplace operator (position with zero-crossing).

    o X

    If red is equal to 100 and green 50 Laplace detectorresponse for pixel X is: 100-350/4>0 while for o: 50-250/4

  • 7/31/2019 Digital Image Processing_advanced Course

    216/240

    There are numerous (more or less acceptable techniques)for removing noise in edge detection process. One of them

    is to calculate local variance of pixels in local neighborhood:2

    2

    2

    1( , ) ( , ) ( , )

    (2 1)

    n M n M

    k n M l n M

    n m f k l f n mM

    + +

    = =

    = +

    local neighborhood

    Laplace detector - drawbacks In the previous relation holds:

    The Laplace detector introduces threshold ofvariance For small variance we assume that edge is

    2

    1( , ) ( , )

    (2 1)

    n M m M

    k n M l m M

    f n m f k l

    M

    + +

    = =

    =

    +

  • 7/31/2019 Digital Image Processing_advanced Course

    217/240

    variance. For small variance we assume that edge isnot detected (image is almost constant) while for

    large variance and zero-crossing we assume thatedge is detected.

    There is alternative that region where edges can bedetected be calculated based on difference:

    ( , ) max { ( , )} min { ( , )}A Aw n m f n m f n m=

    Maxim al and m inimal luminance inlocal neighborhood

    When w(n,m) is larger than athreshold we assume thatedge is detected.

    Laplace-Gauss detector A technique for reducing noise influence in the Laplace

    detector is filtering of image or detector response with

    Gaussian filter (Gaussian blur). Both operations are linearand they can change order without affecting results.

    Obtained detector is in literature called LoG (Laplacian of

  • 7/31/2019 Digital Image Processing_advanced Course

    218/240

    Obtained detector is in literature called LoG (Laplacian ofGaussian).

    Matrix in the Gaussian is given in the shape:

    2 2 2( , ) exp( ( ) / 2 )h n m n m= +

    LoG detector The most common matrix for LoG detector is:

    0 0 1 0 0

    0 1 2 1 0

    1 2 16 2 1

    However, for various valuesof follows different matrixfor LoG but given matrix is

  • 7/31/2019 Digital Image Processing_advanced Course

    219/240

    1 2 16 2 1

    0 1 2 1 00 0 1 0 0

    for LoG but given matrix is

    the most common in practice.

    The Canny detector is a special form of the LoG detectorassumed to be one of the best (but not the simplest one).

    Canny detector Three different filters are employed in the Canny detector

    realization. The Gaussian with impulse response:

    Filters with impulse response equal to partial derivativesof the Gaussian filter impulse response:

    22 2 2 (( , 2) exp( ( 2 ) / )) /h n m n m= + adopted constant

  • 7/31/2019 Digital Image Processing_advanced Course

    220/240

    of the Gaussian filter impulse response:2 2 2 2

    ( , ) ( , ) / exp( ( ) / 2 ) /( )xh n m h n m n n n m= = + 2 2 2 2

    ( , ) ( , ) / exp( ( ) / 2 ) /( )y

    h n m h n m m m n m= = +

    Calculate the response of the Gaussian filter:

    ( , ) ( , )* * ( , )n m

    g n m f n m h n m=

    This operation is used t o reduce the noise inf luence.

    Canny detector After this operation output of the Gaussian filter is filtered with filters

    having responses equal to derivatives of the Gaussian function:

    ( , ) ( , ) * * ( , )x n m xe n m g n m h n m=( , ) ( , ) * * ( , )

    y n m ye n m g n m h n m=

  • 7/31/2019 Digital Image Processing_advanced Course

    221/240

    Detector response is equal to:

    2 2( , ) ( , ) ( , )x ye n m e n m e n m= + This value is normalizedcommonly to 1 by dividing it w it hmaximum of e(n,m) .

    Commonly instead of e(n,m) we presentbinary image obtained by comparing it witha threshold.

    Canny detector - Thresholds There are several steps in obtaining edges in the Canny detector

    using e(n,m): Determine percentage of image that could belong to image. This

    percentage corresponds to the largest values of e(n,m). Eliminate all points that are not local maximum along the corresponding

    direction. In the Canny detector check it is performed also for diagonaldirections.Candidates for edges are pixels that are larger than the selected

  • 7/31/2019 Digital Image Processing_advanced Course

    222/240

    Candidates for edges are pixels that are larger than the selectedthreshold (threshold 1), that among the largest detector responses, and

    that are local maximum. Sometimes we perform determination of the edges by additional

    comparison with second threshold (larger than threshold 1) and finalresponse is obtained as some combination of edges obtained with thesetwo thresholds (larger number of pixels is recognized as edges withrespect to smaller threshold and larger than in the case of higher

    threshold). HUHUHUH!!!

    Detection of isolate points Isolated points can be detected by using mask function of

    the shape:

    When edge is not abrupt change in luminance but single

    1 1 1

    1 8 1

    1 1 1

  • 7/31/2019 Digital Image Processing_advanced Course

    223/240

    When edge is not abrupt change in luminance but single

    line passing over a background in other color we can usematrices of the form:

    1 1 1

    2 2 2

    1 1 1

    1 1 2

    1 2 1

    2 1 1

    2 1 1

    1 2 1

    1 1 2

    1 2 1

    1 2 1

    1 2 1

    Detection of edges in color

    images The simplest technique is to calculate edges for separate

    channels and to connect them using logical operations:

    A=imread('flowers.tif');er=edge(A(:,:,1));eg=edge(A(:,:,2));

    Detectors for variouschannels calculated w it hdefault paramet ers of t heMATLAB edge function.

  • 7/31/2019 Digital Image Processing_advanced Course

    224/240

    eb=edge(A(:,:,3));

    e=er|eg|eb;imshow(e)

    Logical operat ion OR applied onedges detected in channels.

    This is very simple and produces effective results but recently some moresophisticated techniques for color edge detection are proposed. Interestedstudents can take this techniques as a topic for self-excercise.

    Other edge detectors We reviewed almost all important edge detectors

    within our lecture.

    Recently with a lot success several novel techniqueswhere size of mask is determined in adaptive manneris used. Theoretically almost exact values of theimage derivatives are determined in such a manner

  • 7/31/2019 Digital Image Processing_advanced Course

    225/240

    image derivatives are determined in such a manner.

    This is significant advantage with respect to usage ofdifferences.

    We have seen that threshold determination iscomplicated and commonly heuristic (ad-hoc)

    technique are applied for this purpose.

    Hough transform Images are in some application transformed to binary

    form using edge detectors and after they are used forrecognition of geometrical objects primitives.

    The simplest primitive object is straight line. It can be represented using linear function y=ax+b (or

    m=an+b). The main goal is to determine if pixels belong

  • 7/31/2019 Digital Image Processing_advanced Course

    226/240

    ) g p gto line and to determine parameters of line (a,b) .

    The procedure is not quite simple. Consider (x1,y1) thatbelongs to edge but we do not know if this edge is straighline and if it is we do not know its parameters.

    Hough transform

    Algorithm We adopt domain of possible values a and b as Cartisian

    product AxB where aiA and bjB are possible values

    from these sets. Denote ai=amin+ia, bj=bmin+jb where amin and bmin are

    minimal values from corresponding sets.

    Let a are b maximal values from sets and let

  • 7/31/2019 Digital Image Processing_advanced Course

    227/240

    Let amax are bmax maximal values from sets and let

    number of elements in sets is NA and NB respectively. Then: a=(amax-amin)/(NA-1) and b=(bmax-bmin)/(NB-1). Number of elements in sets should not be too large and

    too small. Large number increases burden and sometimes

    makes detection more difficult while small numberproduces not precise results.

    Algorithm for Hough Transform Create matrix P(i,j)=P(ai,bj) where each element from

    the set has value P(i,j).

    Initialize all P(i,j) i=1,..., Na and j=1,...,Nb to zero. For each image pixel (xk,yk) with edge detector giving 1

    (detected edge) e(xk,yk)=1 determine all straight lines to

  • 7/31/2019 Digital Image Processing_advanced Course

    228/240

    ( g ) ( k,yk) gwhich this pixel can belong b

    r= y

    k-a

    qx

    kand increment

    values of P corresponding to these lines:P(q,r)=P(q,r)+1.

    Algorithm for Hough transform Procedure is repeated for each pixel from edges and after that

    we detect maximum ofP and this value corresponds to linewith given parameters.

    After that we remove this maximum and region around themaximum from matrix P and we repeat procedure for detectingnext maximum.Thi d i t d til d t t ll li h

  • 7/31/2019 Digital Image Processing_advanced Course

    229/240

    This procedure is repeated until we detect all lines or when

    there are no dominant maxima in the matrix P. Even very simple the Hough transform is quite effective line

    detector. The main problem in the Hough transform is related to lines

    parallel to x-axis such as x+b=0 where coefficient a approachestoward infinity.

    Problem in the Hough transform This problem can be overcome by the following

    parameterization:

    r=ycos+xsiny

    Rr0 /2>-/2

  • 7/31/2019 Digital Image Processing_advanced Course

    230/240

    x

    r

    Limit of domain can be determinedby using image dimensions.

    In this manner both parametersused for line parameterization have

    limited domain.

    Hough transform

    Test exampleclear

    %

    N= 256;

    B= zeros(N);% Lini je

    for k= 60:150,B(k,k)= 1;end

    for k= 20:110 B(k k+ 80)= 1;end

    Realization is illustrative and withoutelements that can produce more efficientalgorithm or more robust result to noise

    influence.Rectangle (four straight lines).

  • 7/31/2019 Digital Image Processing_advanced Course

    231/240

    for k= 20:110,B(k,k+ 80)= 1;end

    for k= 60:-1:20,B(k ,120-k)= 1;endfor k= 150:-1:110,B(k ,300-k)= 1;end

    M= 256;

    P= zeros(M);

    t acnost = 0.2;

    R= linspace(-M,M,M);th= l inspace(-pi / 2,pi / 2,M);

    Matrix P, initialized and space of parameters.

    Additional parameter used in thealgorithm.

    MATLAB Realization - Examplefor y= 1:Nfor x= 1:N

    i f (B(x,y)= = 1)

    for r= 1:Mfor p= 1:M

    if(abs(R(r )-x * cos(t h(p)) -

    y* sin(th(p)) )< tacnost) ,

    If pixel belongs to edge...

  • 7/31/2019 Digital Image Processing_advanced Course

    232/240

    y sin(th(p)) )< tacnost) ,P(r ,p)= P(r,p)+ 1;end

    end

    end

    end

    end

    endfigure(1),imshow(B)

    figur e(2) ,pcolor( t h,R,P) ,shading int erp

    ... Increase for 1 elements from Pthat represents lines that passthrough the pixel.

    Graphical representation.

    Results

  • 7/31/2019 Digital Image Processing_advanced Course

    233/240

    Rectangle

    Hough t ransform w ithdetected lines.

    Hough transform - Conclusion This is very interesting, semi-intuitive, technique that can

    be subject to numerous improvements (accuracyimprovement, robustness to noise influence, determinationof short lines) and even today it is one of the most popularalgorithms for detection of straight lines.

    Comparative analysis has shown that it is better than other

  • 7/31/2019 Digital Image Processing_advanced Course

    234/240

    p y

    algorithms almost on all criterion. It can be connected with the Radon transform.

    It can be used in modified form for other shapes that canbe parameterized using 2 parameters or when they can be

    reduced to case with 2 parameters in some acceptablemanner.

    Hough transform Circle The circle can be represented using coordinates of

    center and radius as:(x-a)2+(y-b)2=r2

    Then for parameterization in the Hough algorithm isrequired three parameters (a,b,r).

    All pixels belonging to the circuit can be given as:

  • 7/31/2019 Digital Image Processing_advanced Course

    235/240

    p b o g g o u a b g a

    x=a+rcos y=b+rsin Strategies for simplification are developed in order to

    reduce 3D search (for 3 parameters) to lessdemanding realization.

    Circle parameters In the case of the circle parameterization we can use

    edge direction (angle). Namely, we can employ someedge detection algorithm that produces edge e(x,y) andedge direction (angle) (x,y) .

    In the case of the circle the edge direction is normal toradius and search for the circle center can be reduced to

  • 7/31/2019 Digital Image Processing_advanced Course

    236/240

    1D search along the line normal with respect to the edgedirection.

    Unfortunately, edge direction can be determined up tolimited accuracy and we cannot employ this idea in

    straightforward manner. Instead we will use segment of the circle in the search

    procedure.

    Circle parameters - illustration

    detected edge direction

  • 7/31/2019 Digital Image Processing_advanced Course

    237/240

    Angular segment where we performsearch for circle center

    For self-exercise Realize all introduced edge detectors: Roberts, Sobel, Prewitt,

    Laplace, Gauss-Laplace, Canny detector. Realize described methods for mapping edge detector to binary

    image. Study methodology for determination of the threshold for

    various edge detectors (especially for Canny detector) in theMATLAB function edge.

    For mini-project: Consider edge detectors for color images using

  • 7/31/2019 Digital Image Processing_advanced Course

    238/240

    p j g g g

    the Canny and Kumani operators. In this case, detectors are notevaluated separately along channels but based on channelscombinations.

    For mini-project:Application of the edge detector in realizationof adaptive filters.

  • 7/31/2019 Digital Image Processing_advanced Course

    239/240

    For self-exercise Establish relationship between the Hough and Radon transform. For mini-project: SLIDE algorithm for edge detection. For mini-project: Improvements of the Hough transform. For mini-project: Compare the improved Hough transform andthe SLIDE algorithm. Hint: References related to the SLIDE

    algorithm can be found from the lecturer. Realizujte algoritam za prepoznavanje krugova i krunih lukova. Za miniprojekat: Algoritam za prepoznavanje elipsi

  • 7/31/2019 Digital Image Processing_advanced Course

    240/240

    Za miniprojekat:Algoritam za prepoznavanje elipsi. Kako se pomou Houghove transformacije moe prepoznati

    poetak i kraj linije? Za miniprojekat: Realizacija algoritama za praenje ivica.

    Pogledati skriptu.