+ All Categories
Home > Documents > Chapter 18 Discrete Cosine Transform

Chapter 18 Discrete Cosine Transform

Date post: 31-Dec-2015
Category:
Upload: rowan-holden
View: 206 times
Download: 26 times
Share this document with a friend
Description:
Chapter 18 Discrete Cosine Transform. Learning Objectives. Introduction to the DCT and IDCT. Decomposition of a 2-D DCT to two 1-D DCTs. Implementation of a 2-D DCT using a 1-D DCT. Introduction. - PowerPoint PPT Presentation
14
Chapter 18 Chapter 18 Discrete Cosine Transform Discrete Cosine Transform
Transcript
Page 1: Chapter 18 Discrete Cosine Transform

Chapter 18Chapter 18

Discrete Cosine TransformDiscrete Cosine Transform

Page 2: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 2

Learning ObjectivesLearning Objectives

Introduction to the DCT and IDCT.Introduction to the DCT and IDCT. Decomposition of a 2-D DCT to two 1-D Decomposition of a 2-D DCT to two 1-D

DCTs.DCTs. Implementation of a 2-D DCT using a 1-Implementation of a 2-D DCT using a 1-

D DCT.D DCT.

Page 3: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 3

IntroductionIntroduction

To perform the JPEG coding, an image (in colour or grey scales) is first To perform the JPEG coding, an image (in colour or grey scales) is first subdivided into blocks of 8x8 pixels.subdivided into blocks of 8x8 pixels.

The Discrete Cosine Transform (DCT) is the performed on each block.The Discrete Cosine Transform (DCT) is the performed on each block. This generates 64 coefficients which are then quantised to reduce their This generates 64 coefficients which are then quantised to reduce their

magnitude.magnitude.

DCT

IDCT

Quantiser

Dequantiser

EntropyEncoder

EntropyDecoder

Channelor

Storage

reversezigzag

zigzag

An8x8

block

Im age

8 pixels

8 p

ixels

Page 4: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 4

IntroductionIntroduction

The coefficients are then reordered into a one-dimensional array in The coefficients are then reordered into a one-dimensional array in a zigzag manner before further entropy encoding.a zigzag manner before further entropy encoding.

The compression is achieved in two stages; the first is during The compression is achieved in two stages; the first is during quantisation and the second during the entropy coding process.quantisation and the second during the entropy coding process.

JPEG decoding is the reverse process of coding.JPEG decoding is the reverse process of coding.

DCT

IDCT

Quantiser

Dequantiser

EntropyEncoder

EntropyDecoder

Channelor

Storage

reversezigzag

zigzag

An8x8

block

Im age

8 pixels

8 p

ixels

Page 5: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 5

Implementation of the DCTImplementation of the DCT

DCT-based codecs use a two-DCT-based codecs use a two-dimensional version of the transform.dimensional version of the transform.

The 2-D DCT and its inverse (IDCT) of The 2-D DCT and its inverse (IDCT) of an N x N block are shown below:an N x N block are shown below:

Note: The DCT is similar to the DFT Note: The DCT is similar to the DFT since it decomposes a signal into a series since it decomposes a signal into a series of harmonic cosine functions.of harmonic cosine functions.

2-D DCT:2-D DCT:

2-D IDCT:2-D IDCT:

1

0

1

0

]2

)12(cos[]

2

)12(cos[),()()(

2),(

N

y

N

x N

vy

N

uxyxfvCuC

NvuF

1

0

1

0

]2

)12(cos[]

2

)12(cos[),()()(

2),(

N

v

N

u N

vy

N

uxvuFvCuC

Nyxf

Page 6: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 6

2-D DCT using a 1-D DCT Pair2-D DCT using a 1-D DCT Pair

One of the properties of the 2-D DCT is that it is separable meaning One of the properties of the 2-D DCT is that it is separable meaning that it can be separated into a pair of 1-D DCTs.that it can be separated into a pair of 1-D DCTs.

To obtain the 2-D DCT of a block a 1-D DCT is first performed on the To obtain the 2-D DCT of a block a 1-D DCT is first performed on the rows of the block then a 1-D DCT is performed on the columns of the rows of the block then a 1-D DCT is performed on the columns of the resulting block.resulting block.

The same applies to the IDCT.The same applies to the IDCT. This process is illustrated on the following slide.This process is illustrated on the following slide.

Page 7: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 7

2-D DCT using a 1-D DCT Pair2-D DCT using a 1-D DCT PairRaw B lock of P ixels

F inal result after DCT by colum ns Result after DCT by rows

128

128

125

127

127

130 128 134 130 128 128

128128130134128130

126 130 127 130 131 128 127

127127

131

131

131

129

129

128

130129

132

133131

129

126127

130

134131129

131

124 128

132

129 134134 136 136 137 134 132

132135140137138136135133

365

365

362

359

368

370

378

383

-1

-1

-3

-3

1

0

-3

-1

-4

-4

-4

-3

1

-3

-6

-6

1

1

0

0

-1

-3

0

2

-3

-3

-3

-3

1

1

-1

-1

-2

00-3

1

1

-3

-3

1

-1

-3

2

0

-2

-1

-1

3

3

1

1

-1

-2

2

-3

pixel[n]

An 8x8block

Part of a picture

Colum ns (256 pixels)

Row

s (

256 p

ixels

)

p ixel[256+n]

pixel[n+1]

1024

-18

11

0

-2

-4

0

2

-4

-1

-11

-1

1

-5

2 2

1 1

-3 -3

0 -1

0 1 0

-2

-1

1 0 -1 -1 -2

0 -1 -1 -1

011-1

-3 -1 0 -2

3-2-23-3

0 1

-1

-12

0

0 -4 -6 0 1

0

2 4-22

Page 8: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 8

2-D DCT using a 1-D DCT Pair2-D DCT using a 1-D DCT Pair

1-D DCT:1-D DCT:

1-D IDCT:1-D IDCT:

]2

)12(cos[)()(

2)(

1

0

N

i N

kiixkC

NkX

]2

)12(cos[)()(

2)(

1

0

N

kN

kikXkC

Nix

k = 0, 1, 2, …, N-1.and i = 0, 1, 2, …, N-1.

Page 9: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 9

Implementation IssuesImplementation Issues Precalculate the DCT coefficients and Precalculate the DCT coefficients and

scale them (see scale them (see \Links\DCT \Links\DCT Coeffs.pdfCoeffs.pdf).).

0.707

0.981

0.924

0.707

0.831

0.707 0.707 0.707 0.707 0.707 0.707

-.981-0.8310.556-0.1950.1950.556

0.383 -0.383 -.0924 -0.924 -0.383+0.38

30.924

-0.8310.195

0.556

0.707

0.981

-0.707

-0.195

-0.707

0.9810.556

0.707

-0.8310.831

0.707

-0.556-0.981

-.707

0.981-0.9810.556

0.707

0.831 -0.195

-0.707

0.383 0.924-0.924 0.383 -0.383 0.924 -0.924 0.383

-0.1950.556-0.8310.981-0.9810.8310.5560.195

1448

2008

1892

1448

1702

1448 1448 1448 1448 1448 1448

-2008-1702-1137-3993991137

783 -783 -1892 -1892 -783 783 1892

-1702399

-1137

1448

2008

-1448

-399

-1448

20081137

1448

-17021702

1448

-1137-2008

-1448

399-20081137

1448

1702 -399

-1448

783 1892-1892 -783 -783 1892 -1892 783

-3991137-17022008-20081702-1137399

Multiplied by 211

]16

)12(cos[),(*2

kikicoef

coef(i, k) in Q12 form at

Page 10: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 10

Block-based DCT and IDCT in CBlock-based DCT and IDCT in C

The most straightforward way of implementing a DCT and The most straightforward way of implementing a DCT and an IDCT is to use the 1-D DCT and IDCT.an IDCT is to use the 1-D DCT and IDCT.

The following C code shows how to translate the 1-D The following C code shows how to translate the 1-D equations for the DCT and IDCT into C code.equations for the DCT and IDCT into C code.

The program also takes into account the numerical issues The program also takes into account the numerical issues associated with fixed-point processors.associated with fixed-point processors.

Page 11: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 11

Implementation IssuesImplementation Issues(1)(1) The program runs on the DSK with the C6711 and does not use any communication with the host.The program runs on the DSK with the C6711 and does not use any communication with the host.

(2)(2) The The scenary.hscenary.h file is quite large (256x256 8-bit pixels or 65536 bytes) and therefore needs to be file is quite large (256x256 8-bit pixels or 65536 bytes) and therefore needs to be located in a specific memory location in the DSK. By using the located in a specific memory location in the DSK. By using the #pragma DATA_SECTION (…)#pragma DATA_SECTION (…) directive the picture can be located in the DRAM (origin address 0x0800 0000).directive the picture can be located in the DRAM (origin address 0x0800 0000).

(3)(3) For example, For example, #pragma DATA_SECTION (image_in, “ext_sdram”)#pragma DATA_SECTION (image_in, “ext_sdram”) allows the image_in data array to allows the image_in data array to be loaded into the section called “ext_sdram” which is defined in the command file. The same be loaded into the section called “ext_sdram” which is defined in the command file. The same applies to image_out.applies to image_out.

(4)(4) The directory DSPCODE\DCT contains the entire source and executable files required. The The directory DSPCODE\DCT contains the entire source and executable files required. The program can be loaded into the DSK C6711 and by using the display feature of the CCS as shown program can be loaded into the DSK C6711 and by using the display feature of the CCS as shown below the contents of image_in and image_out can be displayed and compared.below the contents of image_in and image_out can be displayed and compared.

Page 12: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 12

Implementation IssuesImplementation Issues

Graph properties for image_inGraph properties for image_in

Graph properties for image_outGraph properties for image_out

image_inimage_in

image_outimage_out

Page 13: Chapter 18 Discrete Cosine Transform

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002

Chapter 18, Slide 13

DCT Code and LinksDCT Code and Links

Code location:Code location: Code\Chapter 18 - Discrete Cosine Transform\Code\Chapter 18 - Discrete Cosine Transform\

Projects:Projects: Fixed Point in C:Fixed Point in C: \DCT_C_Fixed\\DCT_C_Fixed\

Links:Links: \Links\Imaging \Links\Imaging Kit.pdfKit.pdf

Page 14: Chapter 18 Discrete Cosine Transform

Chapter 18Chapter 18

Discrete Cosine TransformDiscrete Cosine Transform

- End -- End -


Recommended