21
JPEG стандарт Лекц-15 МУИС ХШУИС МКУТийн багш П.Гантуяа

JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

JPEG стандарт

Лекц-15

МУИС ХШУИС МКУТийн багш П.Гантуяа

Page 2: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

What is JPEG?

JPEG: Joint Photographic Expert Group —

an international standard in 1992.

Works for both color and grayscale images.

Targets at natural images.

Applications include satellite, medical

imaging, general photography ...

Page 3: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Color Space Conversion

JPEG first converts RGB to YUV or YCrCb.

Y is the luminance component (brightness).

Y = 0.299 R + 0.587 G + 0.144 B

U and V are color components

U = B – Y

V = R - Y

Y U V

Page 4: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Color Subsampling

JPEG down-samples-дээж the “color channels” by

half-хагас and partitions-хуваах,тусгаарлах

images into-руу 8x8 small blocks.

Y1 Y2

Y3 Y4

U V

Intensity-эрч Component-бүрэлдэхүүн Color components

Page 5: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

DCT (Discrete Cosine Transform)

DCT converts each image 8x8 block into another

8x8 block.

The energy in DCT domain is concentrated into

very few coefficients.

DCT

Image

block

DCT

coefficients

Page 6: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

0

2

4

6

8

0

2

4

6

8

-10

0

10

20

col

row

DC

T C

oeff

icie

nts

0

24

6

8

0

2

4

6

80

2

4

6

8

10

colrow

Gra

yscale

Level

Image block DCT Coefficients

Page 7: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Definition of DCT

A linear transfrom F(u,v) = x=07

y=0 7 h(u,v,x,y) f(x,y)

where h(u,v,x,y) is the linear weighting-нэмэгдэл function.

DCT:

The inverse transform IDCT recovers the original data from DCT

coefficients.

Page 8: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

For DCT, h(u,v,x,y) can be decomposed-задрах

into g(u,x) * g(v,y)

F(u,v) = x=07

y=0 7 h(u,v,x,y) f(x,y)

= y=07

g(v,y) [x=0 7 g(u,x) f(x,y)]

Horizontal 1D DCT Vertical 1D DCT

followed

by

Page 9: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Given u and v, h can be viewed as an image of x and y.

u

v

DCT coefficients are projection of image block into these patterns.

Page 10: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Quantization

Recall that quantization can be used to collapse-

нурах the input into smaller number of values.-

эрхэм

For DCT coefficients,- we quantize different

coefficients in different details:

DC coefficient should have the most quantization

levels.

Quantization for AC coefficients can be coarser and

coarser as the frequency increases.

Page 11: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

Y quantization table

17 18 24 99 99 99 99 99

18 21 26 66 99 99 99 99

24 26 56 99 99 99 99 99

47 66 99 99 99 99 99 99

99 99 99 99 99 99 99 99

99 99 99 99 99 99 99 99

99 99 99 99 99 99 99 99

U, V quantization table

Fq(u,v) = round(F(u,v)/Q(u,v)) Quantization:

Fr(u,v) = Fq(u,v) * Q(u,v) De-quantization:

Page 12: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

quantization

dequantization

Page 13: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

The Quality Factor

For most-ихэнх current-урсгал JPEG encoders,

we can choose a quality-чанар factor-хүчин зүйл

from 1 to 100.

The method-арга of controlling the compression-

шахах quality is by scaling- the quantization table.

For example,-жишээ

Fq(u,v) = round(F(u,v)* (quality) / Q(u,v))

Page 14: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

DC Coefficients Encoding

D(m,n) D(m,n+1) D(m,n+2) D(m,n+3)

We compute the difference of each two successive quantized

coefficients

D(m,n) – 0 => d(m,n)

D(m,n+1) – D(m,n) => d(m,n+1)

D(m,n+2) – D(m,n+1) => d(m,n+2)

D(m,n+3) – D(m,n+2) => d(m,n+3)

Page 15: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

DC Coefficients Encoding

Then, we encode each DC difference value by

(size, coefficient)

1 -1, 1

2 -3, -2, 2, 3

3 -7 …-4, 4, …,7

4

11 -2047,…,-1024,1024,…,2047

The Size Table

7 will be coded as (3, 7)

• The first number 3 is Huffman -

coded.

• The second 7 is encoded as

1’s complement 111.

(-7 will be 000)

Can we encode the dc difference value directly?

Page 16: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

AC Coefficients Encoding

AC coefficients are not differentially encoded.

Instead, we first do run-length coding.

Zig-zag scanning

(0,11), (0,-12), (1, -12),

(0, 10), (0,16), (0, 0)

The run length code:

Indicates all are 0

from here

Page 17: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

AC Coefficients Encoding (cont)

For AC coefficients, we now have a bunch-баглаа

of symbols-тэмдэг like

The “value”-үнэ цэнэ has large number of

possible-боломжтой values in [-1023, 1023].

Direct Huffman coding is infeasible.-

Instead, we generate-гаргах symbols like

(zero-run length, value)

( zero-run length, size, value)

Huffman coded 1’s complement

Page 18: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

JPEG File Format

Start of image Frame End of image

Tables Header Scan Scan Scan …

Tables Header Segment Restart Segment ….

Block Block Block

Page 19: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

JPEG Extensions

The basic mode of JPEG supports-дэмжлэг

sequential –дараалсан coding (the order-дэс

дараа is from top-оройгоос to bottom –төгсгөл

and left to right-зүүнээс баруун).

JPEG extensions support progressive-аажим,

дэвшилтэт modes-төрөлүүд*(JPEG өрөгтгөлийг

дэмждэг дэвшилтэт төрөлүүд)

Spectrum selection.-спектер сонголт

Successive approximation.-дараалсан утга

Hierarchical mode.-шаталсан төлөв

Page 20: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

JPEG 2000

JPEG 2000 is a new standard-стандарт based on

wavelet- transform.-өөрчлөн хувиргах

JPEG2000 does not partition-хуваах, хуваагдал,

тусгаарлах an image into-руу small blocks.

Wavelet decomposes-зардал the whole-бүхэл

image into different-ялгаатай “bands” and then-

тэгээд дараа нь encodes-кодолсон the

coefficients in different-ялгаатай bands smartly.

Page 21: JPEG стандарт Лекц-15 · JPEG down-samples-дээж the “color channels” by half-хагас and partitions-хуваах,тусгаарлах images into-руу 8x8

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

500

The wavelet decomposition of Lena image using Haar Wavelet.

HL

LH

HH

LL