chapter 2 digital image transform …poseidon.csd.auth.gr/lab_publications/books/dip... · i. pitas...

65
I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI 1998 2.1 CHAPTER 2 DIGITAL IMAGE TRANSFORM ALGORITHMS DIGITAL IMAGE PROCESSING DIGITAL IMAGE PROCESSING DIGITAL IMAGE PROCESSING

Upload: ledang

Post on 21-Aug-2018

233 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.1

CHAPTER 2

DIGITALIMAGE TRANSFORM

ALGORITHMS

DIGITAL IMAGE PROCESSINGDIGITAL IMAGE PROCESSINGDIGITAL IMAGE PROCESSING

Page 2: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.2

ContentsContentsContents

uIntroductionu2-d discrete Fourier transform

uRow-column FFT (RCFFT) algorithmuMemory problems in 2-d DFT calculationsuVector-radix FFT (VRFFT) algorithmuPolynomial transform FFT (PTFFT)

u2-d power spectrum estimationuDiscrete cosine transform (DCT)u2-d DCT

Page 3: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.3

AxX =

A A− =1 *T

where x and X are the original and transformed image respectively.In most cases the transform matrices are unitary:

u The columns of A*T are the basis vectors of the transform and in 2-d transforms they correspond tobasis images.u The most popular image transforms are:/ Discrete Fourier Transform (DFT)./ Discrete Cosine Transform (DCT).

u Image transforms are represented by transform matrices A:

IntroductionIntroduction

Page 4: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.4

}0,0:),{(22112121

NnNnnnR NN <≤<≤=

),(~),(~),(~22121121

NnnxnNnxnnx +=+=

where N1, N2 denote the horizontal and vertical periods.

The fundamental period of this sequence is the rectangleRN1N2 having size N1×N2:

Two-dimensional discrete Fourier transform

Let be a 2-d rectangularly periodic sequence. Its periodicity is defined as:

),(~21

nnx

Page 5: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.5

Figure 1: Rectangularly periodic sequence and its fundamental period.

Two-dimensional discrete Fourier transform

Page 6: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.6

+= ∑∑

=

= 2

22

1

111

1

2

2

21

21

21

22exp),(

~1),(~

1

0

1

0 N

kni

N

knikkX

NNnnx

N

k

N

k

ππ

∑ ∑−

=

=

−−=

1

0

1

0

1

1

2

2 2

22

1

11

2121

22exp),(~),(

~ N

n

N

n N

kni

N

kninnxkkX

ππ

u A periodic sequence can be represented by a Fourier series.u The 2-d DFS is used for the representation of a 2-d rectangularly periodic signal:

u The Fourier series coefficients are :

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 7: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.7

u A discrete 2-d space-limited signal can be represented by DFT as:

∑ ∑−

=

=

−−=

1

0

1

0

1

1

2

2 2

22

1

11

2121

22exp),(),(

N

n

N

n N

kni

N

kninnxkkX

ππ

+= ∑ ∑

=

= 2

22

1

111

1

2

2

21

21

21

22exp),(

1),(

1

0

1

0 N

kni

N

knikkX

NNnnx

N

k

N

k

ππ

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 8: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.8

2,12

exp =

−= j

NiW

jN j

πwhere:

u Another commonly used form of the DFT is:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

∑ ∑−

=

=

=1

0

1

0

1

1

2

2

22

2

11

12121),(),(

N

n

N

n

knN

knN WWnnxkkX

22

2

11

1

1

1

2

2

21

21

21

1

0

1

0

),(1

),( knN

knN

N

k

N

k

WWkkXNN

nnx −−−

=

=∑ ∑=

Page 9: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.9

u The DFT is related to the Fourier transform of a discrete 2-d signal which is defined as:

∑ ∑∞

−∞=

−∞=

−−=1 2

2112121)exp(),(),( 2

n n

nininnxX ωωωω

∫ ∫− −

+=π

π

π

π

ωωωωωωπ 2122112121

)exp(),(4

1),(

2ddniniXnnx

2

22

1

112121

2,

2),(),(N

k

N

kXkkX πω

πωωω ===

over the unit bicircle z1 = exp(iù1), z2 = exp(iù2).

The DFT coefficients are a sampled version of the 2-d FT of a discrete sequence:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 10: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.10

Nnn

mnmnxnny

N

NN

mod))((

)))((,))(((),(22211121

=

++=

∑ ∑−

=

=

−−=

=⊗⊗=1

0

1

0

1

1

2

2

22211121

212121

)))((,))(((),(

),(),(),(N

m

N

m

NN mnmnhmmx

nnhnnxnny

u The circular convolution of two signals can be computed by means of the circular shift of a signal.

Circular Shift

Circular Convolution

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 11: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.11

Figure 2: Circular shift of a 2-d sequence

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 12: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.12

u In most applications the linear convolution of two signals is needed. It is defined as:

∑ ∑−

=

=

−−=1

0

1

0

1

1

2

2

22112121),(),(),(

Q

m

Q

m

mnmnxmmhnny

where RP1P2 = [0, P1) x [0, P2) and RQ1Q2 = [0, Q1) x [0, Q2) are the regions of support of x, h.

u The region of support of the convolution is:

2,11),0[),0[ 2121=−+=×= iQPLLLR iiiLL

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 13: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.13

u The algorithm consists of the following steps:

1. Choose N1,N2 such that Ni ≥ Pi + Qi - 1, i = 1, 2.2. Pad the sequences x(n1, n2) and h(n1, n2) with zeros, so that:

−∈

∈=

2121

21

),(0

),(),(),(

21

2121

21PPNN

PP

RRnn

Rnnnnxnnx

p

−∈

∈=

2121

21

),(0

),(),(),(

21

2121

21QQNN

QQ

RRnn

Rnnnnhnnh

p

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 14: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.14

4. Calculate the DFT Yp(k1, k2), as the product of Xp(k1, k2) and Hp(k1, k2).5. Calculate yp(n1, n2) by using the inverse DFT. The result of the linear convolution is:

21212121),( ),(),(

LLpRnnnnynny ∈=

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

3. Calculate the DFTs of the new sequences xp(n1, n2) and hp(n1, n2).

IDFT y

DFT

DFT

××

x

h

Figure 3: Convolution calculation using the DFTs

Page 15: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.15

u The DFT also supports the 2-d correlation:

),(),(),(221 121 kkYkkXkkPxy

∗=

∑ ∑−

=

=

++=1

0

1

02211

1

1

2

2

2121),(),(),(

N

n

N

n

mnmnynnxmmRxy

∑ ∑−

=

=

++=1

0

1

0

1

1

2

2

22112121),(),(),(

N

n

N

n

mnmnxnnxmmRxx

u If both sequences are real then in the frequency domain:

u The autocorrelation of an image is defined as:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 16: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.16

)()(),()()(),(221121221121

kXkXkkXnxnxnnx =↔=

),(),(),(

),(),(),(

21221

212121

1 kkWbkkVakkX

nnwbnnvannx

⋅+⋅=↔⋅+⋅=

),(),(

)))((,))(((),(

21

22

2

11

121

22211121

kkXWWkkY

mnmnxnnykm

Nkm

N

NN

=

↔−−=

1.1. Separable sequence:Separable sequence:

Properties of the 2-d DFT

3. Circular shift:Circular shift:

2. Linearity:Linearity:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 17: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.17

5. Complex conjugate property:Complex conjugate property:

),()))((,))(((21222111

** kkXnNnNxNN

↔−−

)))((,))(((),(22211121

*NN

kNkNXkkX −−=

4. Modulation:Modulation:

6. Reflection:Reflection:

)))((,))(((),(

),(),(

22211121

21

22

2

11

121

NNlklkXkkY

nnxWWnnyln

Nln

N

−−=↔= −−

),(),(1212

kkXnnx ↔

If x(n1, n2) is a real-valued signal:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 18: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.18

9. Circular convolution and multiplication:Circular convolution and multiplication:),(),(),(),(

21212121kkHkkXnnhnnx ⋅↔⊗⊗

),(),(1

),(),(2121

21

2121kkHkkX

NNnnhnnx ⊗⊗↔

∑ ∑∑ ∑−

=

=

=

=

=1

0

1

0

21

0

1

0

2 1

1

2

2

21

21

1

1

2

2

21),(

1),(

N

k

N

k

N

n

N

n

kkXNN

nnx

7. Initial value and DC value:Initial value and DC value:

∑ ∑∑ ∑−

=

=

=

=

=1

0

1

0

*1

0

1

0

*1

1

2

2

2121

1

1

2

2 21

2121),(),(

1),(),(

N

k

N

k

N

n

N

n

kkYkkXNN

nnynnx

∑ ∑−

=

=

=1

0

1

0

1

1

2

2

21),()0,0(

N

n

N

n

nnxX∑ ∑−

=

=

=1

0

1

0

1

1

2

2

21

21

),(1

)0,0(N

k

N

k

kkXNN

x

8. Parseval’sParseval’s theorem:theorem:

TwoTwo--dimensional discrete Fourier transformdimensional discrete Fourier transform

Page 19: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.19

∑−

=

=′1

0

2

2

22

22121),(),(

N

n

knNWnnXknX

∑−

=

′=1

0

1

1

11

12121),(),(

N

n

knNWknXkkX

u The simplest algorithm for the calculation of the 2-d DFT is the Row - Column FFT (RCFFT) algorithm.

u The 2-d DFT can be decomposed in N1 DFTs along rows and N2 DFTs along columns:

RowRow--column FFT algorithmcolumn FFT algorithm

Page 20: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.20

22 ),(),(),(212121

kkXkkXkkXIRM

+=

= −

),(

),(tan),(

21

21

21

1

kkX

kkXkk

R

u The transform magnitude is:

u The transform phase is:

u The magnitude of the transform provides useful information about the frequency content of an image.

RowRow--column FFT algorithmcolumn FFT algorithm

Page 21: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.21

)(log2

log2

log2 212

2112

1222

21 NN

NNN

NNN

NNC =+=

)(log 21221 NNNNA =

)log( 22 NkNO

u The number of complex multiplications for RCFFT is:

u If radix-2 FFT is used then the number of complex additions for RCFFT is:

u The computational complexity is of the order :

RowRow--column FFT algorithmcolumn FFT algorithm

Page 22: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.22

u There are memory problems in the calculation of 2-d DFT even for moderately sized images.

u A solution to this problem is the storage of the image on a hard disk in a row-wise manner.

Figure 4: (a) Storage of an image in a row-wise manner. Each image row occupies one data record. b) Access of image in a column-wise manner.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

(a) (b)

Page 23: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.23

u If K signal rows (or columns) can be stored in RAM, the number of I/O operations required are:

NNNNNNNIO 32)1(232 2 +=−++=

NK

NN IO 3

2 2

+=

u The total number of I/O operations is:

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 24: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.24

u A further speed-up is obtained by combining the row transform computation with a part of the column transform computation.

u The number of I/O operations is:

knNN IO /2=

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 25: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.25

Figure 5: Radix-2 FFT algorithm for N=8.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 26: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.26

u Another approach for the reduction of the I/O operations is to use fast matrix transposition algorithms.

u If the matrix has size N×N, where N = 2n, it can be split into four submatrices of size (N/2)×(N/2) each.

u This procedure is repeated until submatrices of size 2×2 are reached.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 27: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.27

u This algorithm has n = log2N steps.

u The transposition can be performed in place.

u The first stage needs 2N I/O operations.

u The number of stages is log2N.

u The total number of I/O operations is:

NNN IO 2log2=

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 28: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.28

Figure 6: Three stages in the transposition of an 8×8 matrix.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 29: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.29

u If the image is real, the complex conjugate property can be used for reducing memory requirements.

u Suppose that the dimensions N1, N2 of the image are powers of 2 and that the image is stored on a matrix A of size N1×N2.

u The first stage of the RCFFT processes the conjugate symmetry.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 30: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.30

u The columns X´(n1, 0), X´(n1, N2/2) are real numbers.

u They are used to store the real and imaginary parts of X´(n1, k2) in place as:

[ ][ ] ),(),(Im

),(),(Re

22121

2121

kNnknX

knknX

−→′

→′

A

A10,2/1 1122 −≤≤<≤ NnNk

u This storage requires only 50% of the memory required for the storage of the complete complex signal and is performed in place.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 31: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.31

u The column transform also satisfies the conjugate property.

u The samples X(0, 0), X(N1 / 2, 0), X(0, N2 / 2), X(N1 / 2, N2 / 2) are real and can be stored in the corresponding positions of A. The samples X(k1, 0), X(k1, N2 / 2) can be stored as:

[ ][ ][ ][ ] )2/,()2/,(Im

)2/,()2/,(Re

)0,()0,(Im

)0,()0,(Re

21121

2121

111

11

NkNNkX

NkNkX

kNkX

kkX

−→

−→

A

A

A

A

2/1 11 Nk <≤

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 32: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.32

u The real and imaginary parts of the samples X(k1, k2), 1 ≤ k1 ≤ N1-1, 1 ≤ k2 < N2/2 are stored as:

[ ][ ] )))((,))(((),(Im

),(),(Re

21 221121

2121

NN kNkNkkX

kkkkX

−−→

A

A

2/1,11 2211 NkNk <≤−≤≤for

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

Page 33: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.33

Figure 7: In-place storage of the 2-d DFT of a real-valued signal. (a) Storage after row transform. (b) Storage after column transform. The cross-hatched areas denote the storage places for the imaginary part of the transform.

Memory problems in 2Memory problems in 2--d DFT calculationsd DFT calculations

(a) (b)

Page 34: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.34

211

2

1 2

2211

),(),(

),(),(

),(),(

2121

2121

1

0

1

02121

kkNoo

kNoe

kNeoee

N

n

N

n

knN

knN

WkkGWkkG

WkkGkkG

WWnnxkkX

+

=

=

+

++=

= ∑ ∑

u Let x(n1, n2) be a square image N×N.

u Its DFT can be split into four 2-d DFTs of size (N/2)×(N/2), by following a decimationdecimation--inin--timetime approach:

VectorVector--radix fast Fourier transform algorithmradix fast Fourier transform algorithm

Page 35: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.35

22

1 2

11 212/

0

12/

0

2212100 )2,2(),( kl

N

N

l

N

l

klN WWllxkkS ∑ ∑

=

=

=

22

1 2

11 212/

0

12/

0

2212101 )12,2(),( kl

N

N

l

N

l

klN WWllxkkS ∑ ∑

=

=

+=

22

1 2

11 212/

0

12/

0

2212110 )2,12(),( kl

N

N

l

N

l

klN WWllxkkS ∑ ∑

=

=

+=

22

1 2

11 212/

0

12/

0

2212111 )12,12(),( kl

N

N

l

N

l

klN WWllxkkS ∑ ∑

=

=

++=

Where:

VectorVector--radix fast Fourier transform algorithmradix fast Fourier transform algorithm

Page 36: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.36

Figure 8: Radix-2×2 butterfly.

VectorVector--radix fast Fourier transform algorithmradix fast Fourier transform algorithm

Page 37: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.37

Figure 9: Flow diagram of a 4×4 vector-radix FFT.

VectorVector--radix fast Fourier transform algorithmradix fast Fourier transform algorithm

Page 38: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.38

u VRFFT has log2N stages.u Each stage contains N2/4 butterflies.u Each butterfly requires 3 complex multiplications.u The total number of complex multiplications is:

NN

C 2

2

log4

3=

NNA 22 log2=

u The number of complex additions is:

u All computations of the VRFFT can be performed in place.

VectorVector--radix fast Fourier transform algorithmradix fast Fourier transform algorithm

Page 39: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.39

[ ] )(mod)()()(ˆ1

0

zPzGzXzXN

m

mkmk ∑

=

=

[ ] )( mod)()(ˆ1)(

1

0

zPzGzXN

zXN

k

mkkm ∑

=

−=

∑−

=

=1

0

),()(N

n

nm znmxzX

where P(z) is an irreducible polynomial and G(z) = 1 mod P(z)

is a polynomial N-th root of unity. The polynomial of degree N-1 is:

u A polynomial transform can be defined as:

Polynomial transform FFTPolynomial transform FFT

Page 40: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.40

u Only 2N2log2N real additions are needed for the calculation of the polynomial transform.

u A polynomial transform can be employed for the fast calculation of the 2-d DFT.

)1( mod ))(()(ˆ1

0

2 += ∑−

=

NmkN

mmk zzzXzX

u The following polynomial transform is used for a 2-d FFT:

Polynomial transform FFTPolynomial transform FFT

Page 41: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.41

uu Polynomial transform FFT (PTFFT).Polynomial transform FFT (PTFFT).

2

2

2

1

1

021 ),()( n

N

n

nn zWnnxzX ∑

=

−=

∑−

=+ +=

1

0

2)12(

1

11

112)1(mod)()(ˆ

N

n

Nknnkk zzzXzX

∑−

=

=+1

0

21212

2),(),)12((N

l

lklWWlkykkkX

∑−

=+ =

1

01)12( ),()(ˆ

12

N

l

lkk zlkyzX

where y(k1,l) are the coefficients of the polynomial:

Polynomial transform FFTPolynomial transform FFT

Page 42: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.42

Figure 10: Polynomial transform FFT

Polynomial transform FFTPolynomial transform FFT

Page 43: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.43

u If a radix-2 FFT is used for the 1-d DFTs then the total number of real multiplications is:

)log4(2 22 NNC +=

A N N= +224 5( log )

u The total number of real additions is:

u A comparison between RCFFT and PTFFT shows thatPTFFT is better than RCFFT for N>16.

Polynomial transform FFTPolynomial transform FFT

Page 44: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.44

u The power spectrum carries important information about the 2-d signal content.

u The squared magnitude is the periodogramof the discrete signal and can be used as an estimator of its 2-d power spectrum.

21

0

1

021

21

2

2121

21

1

1

2

2

22

2

11

1),(

1

),(1

),(ˆ

∑ ∑−

=

=

=

=

N

n

N

n

knN

knN

xx

WWnnxNN

kkXNN

kkP

$ ( , )P k kxx 1 2

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 45: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.45

u The periodogram is the Fourier transform of the estimator of the autocorrelation function:

∑ ∑−= −=

++++

=1

11

2

22

),(),()12)(12(

1),(ˆ

221121*

2121

N

Nk

N

Nkxx nknkxkkx

NNnnR

),(ˆ21

nnRxx

),(ˆ21

ωωxx

P

u The periodogram is a smoothed version of the actual 2-d power spectrum. It is very poor for small images and it is a noisy power spectrum estimator.

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 46: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.46

Figure 11: (a) Test image LENNA; (b) periodogram of LENNA.

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 47: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.47

u The Bartlett estimator can reduce the noise. The 2-d signal of size N1×N2 is split into K1×K2 non-overlapping sections each having size M1×M2:

),(),( 221121 jMniMnxnnxij

++=

1,...,0,1,...,0 21 −=−= KjKi

21

0

1

021

2121

)(1

1

2

2

22

2

11

1),(

1),(ˆ ∑ ∑

=

=

=M

n

M

n

knM

knMij

ijxx WWnnx

MMkkP

u The periodogram of each section is:

where

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 48: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.48

u Blackman-Tukey 2-d power spectrum estimator: An estimator of the 2-d autocorrelation function Rxx(m1,m2) is used:

∑ ∑−

=−−

=

=22

01212

22

0212121

1

1

22

2

11

1

2

2

),(),(),(N

m

kmN

kmN

N

mxx

BTxx WWmmwmmRkkP

∑∑−

=

=

=1

0

1

021

)(

2121

1 2

),(ˆ1),(ˆ

K

i

K

j

ijxx

Bxx kkP

KKKKP

u The new spectral estimator is the average of theperiodograms of all sections:

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 49: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.49

u A separable 2-d window can be used. The triangular 1-d window or the 1-d Hamming window can be used for each of the dimensions.

u The BT estimator can be obtained by using the 2-d DFT of the windowed autocorrelation function:

[ ]),(),(),( 212121 mmRmmwDFTkkP xxBT

xx =

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 50: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.50

u Technique based on 2-d AR modeling of images.

∑∑∈

+−−=),(

212121 ),(),(),(),(ji A

nnwjninxjiannx

A is the prediction windowá(i,j) are the predictor coefficientsw(n1,n2) is a white noise random process, having variance ów

2.

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Figure 12: Examples of prediction windows.

Page 51: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.51

2

),(21

2

21

21

22

2

11

1),(

),(

∑ ∑∈

=

mm A

kmN

kmN

wARxx

WWmma

kkPσ

u The power spectrum can be estimated by the followingformula:

Two dimensional power spectrum estimationTwo dimensional power spectrum estimation

Page 52: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.52

∑−

=

=1

0

)(1

)0(N

n

nxN

C

∑−

=

+=

1

0 2

)12(cos)(

2)(

N

n N

knnx

NkC

π

x nN

CN

C kn k

Nk

N

( ) ( ) ( ) cos( )

= ++

=

∑10

2 2 1

21

1 π

u DCT is used in the JPEG and MPEG standards.

/ Forward DCT transform:

/ Inverse DCT:

Discrete cosine transformDiscrete cosine transform

Page 53: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.53

u Let x(n) be a signal. An even sequence f(n) can be produced by this signal as:

Figure 13: Creation of an even sequence

f nx n

x N n( )

( )

( )=

− − 2 1

0 1

2 1

≤ ≤ −≤ ≤ −n N

N n N

Discrete cosine transformDiscrete cosine transform

Page 54: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.54

u Algorithm for the fast calculation of DCT using DFT:

1. Formation of the even sequence f(n).2. The DFT of length 2N is calculated by using a

1-d FFT of length 2N.3. Calculation of the DCT coefficients C(k) using the

relations:

10)(2

)(2/

2 −≤≤= NkforkFN

WkC

kN

where F(k) are the DFT coefficients.

Discrete cosine transformDiscrete cosine transform

Page 55: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.55

u Alternative method for the fast calculation of the 1-d DCT:

+

−= ∑−

= N

kninx

NkC

N

n 2

)12(expRe)(

2)(

1

0

π

−= ∑

=

12

0

exp)(2

expRe2

)(N

n N

nkiny

N

ki

NkC

ππ

y nx n

( )( )

= 0

0 1

2 1

≤ ≤ −≤ ≤ −n N

N n N

u If x(n) is a real sequence then:

where:

Discrete cosine transformDiscrete cosine transform

Page 56: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.56

u Alternative definition for the DCT pair:

C k x nn k

Nn

N

( ) ( )cos( )

=+

=

∑ 22 1

20

1 π

x nN

w k C kn k

Nk

N

( ) ( ) ( ) cos( )

=+

=

∑1 2 1

20

1 π

where: w k( )/

=

1 2

1

k

k N

=≤ ≤ −

0

1 1

u Thus, the DCT coefficients are related to the DFT coefficients by:

)()( 2/2 kFWkC k

N=

Discrete cosine transformDiscrete cosine transform

Page 57: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.57

u Fast DCT algorithm:1. Formation of a sequence í(n) as:

v nx n

x N n( )

( )

( )=

− −

2

2 2 1

01

2

1

21

≤ ≤−

+

≤ ≤ −

nN

Nn N

{ })(Re2)(Re2)( 4

1

04 kVWWnvWkC k

N

N

n

nkN

kN =

= ∑−

=

{ })(Im2)( 4 kVWkNC kN−=−

2. Computation of the DFT V(k), 0 ≤ k ≤ N-1 by using an FFT algorithm of length N.3. Computation of C(k), 0 ≤ k ≤ [N/2], and C(N-k) as:

Discrete cosine transformDiscrete cosine transform

Page 58: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.58

u Fast calculation of the inverse DCT: 1. Computation of V(k) as:

v nx n

x N n( )

( )

( )=

− −

2

2 2 1

01

2

1

21

≤ ≤−

+

≤ ≤ −

nN

Nn N

10 )()(2

1)( 4 −≤≤−−=

− NkkNiCkCWkV k

N

2. Computation of í(n) from V(k) by means of an inverse FFT algorithm of length N.

3. Retrieval of x(n) from í(n) by using the formula:

Discrete cosine transformDiscrete cosine transform

Page 59: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.59

u A 2-d N1×N2 DCT is defined as:

2

221

0

1

0 1

112121 2

)12(cos

2)12(

cos),(4),(1

1

2

2N

kn

N

knnnxkkC

N

n

N

n

ππ ++= ∑ ∑

=

=

2

221

0

1

0 1

11212211

2121 2

)12(cos

2

)12(cos),()()(

1),(

1

1

2

2N

kn

N

knkkCkwkw

NNnnx

N

k

N

k

ππ ++= ∑∑

=

=

where:

=1

2/1)(

11kw

=1

2/1)(

22kw

11

0

11

1

−≤≤=

Nk

k11

0

22

2

−≤≤=

Nk

k

for 0 ≤ k1 ≤ N1-1, 0 ≤ k2 ≤ N2-1.

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 60: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.60

u The expansion of the signal forms a new one as:

−−−−−−

−−=

)12,12(

)12,(

),12(

),(

),(

2211

221

211

21

21

nNnNx

nNnx

nnNx

nnx

nnf

12 12

12 10

10 12

10 10

222111

22211

22111

2211

−≤≤−≤≤−≤≤−≤≤

−≤≤−≤≤−≤≤−≤≤

NnNNnN

NnNNn

NnNnN

NnNn

),(),( 212/

22/

2212

2

1

1kkFWWkkC k

NkN=

u The DCT coefficients C(k1, k2) are related to the DFT ones F(k1, k2) as:

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 61: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.61

Figure 14: (a) Original sequence x(n1,n2). (b) Expanded sequence f(n1,n2).

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 62: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.62

−−−−−−

−−=

)122,122(

)122,2(

)2,122(

)2,2(

),(

2211

221

211

21

21

nNnNx

nNnx

nnNx

nnx

nnv

12

1 1

21

12

1

21

0

21

0 12

1

21

0 2

10

222

111

2221

1

2211

1

22

11

−≤≤

+

−≤≤

+

−≤≤

+

≤≤

≤≤−≤≤

+

≤≤

≤≤

NnN

NnN

NnNN

n

NnNn

N

Nn

Nn

u Fast calculation of the 2-d DCT follows:1. Formation of a sequence í(n1,n2) as:

for:

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 63: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.63

2. The DFT V(k1,k2) is calculated by using a N1×N2 FFT algorithm.

3. The DCT coefficients are calculated as:

[ ]{ }[ ]{ }),(),(Re2

),(),(Re2),(

21142144

2214214421

1

1

1

1

2

2

2

2

2

2

1

1

kkNVWkkVWW

kNkVWkkVWWkkCk

NkN

kN

kN

kN

kN

−+=

−+=−

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 64: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.64

[ ]{

[ ]}),(),(

),(),(4

1),(

221211

22112144212

2

1

1

kNkCkkNCi

kNkNCkkCWWkkV kN

kN

−+−−

−−−= −−

u There is also an algorithm for the fast calculation of the inverse 2-d DCT.

1. Computation of V(k1,k2) as:

2. Calculation of í(n1,n2) by using an inverse N1×N22-d FFT algorithm.

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform

Page 65: CHAPTER 2 DIGITAL IMAGE TRANSFORM …poseidon.csd.auth.gr/LAB_PUBLICATIONS/Books/dip... · I. Pitas Digital Image Processing Fundamentals Digital Image Transform Algorithms THESSALONIKI

I. Pitas Digital Image Processing FundamentalsDigital Image Transform Algorithms THESSALONIKI 1998

2.65

−−−−−−

−−=

)122,122(

)122,2(

)2,122(

)2,2(

),(

2211

221

211

21

21

nNnNx

nNnx

nnNx

nnx

nnv

12

1 1

2

1

12

1

21

0

2

10 1

2

1

2

10

2

10

222

111

2221

1

2211

1

22

11

−≤≤

+

−≤≤

+

−≤≤

+

≤≤

≤≤−≤≤

+

≤≤

≤≤

NnN

NnN

NnNN

n

NnNn

N

Nn

Nn

3. Retrieval of x(n1,n2) from í(n1,n2) by using the following formula:

for:

TwoTwo--dimensional discrete cosine transformdimensional discrete cosine transform