Docsity

Image Compression Techniques: Subsampling, Quantization, and Error Diffusion, Exams of Computer Science

Toggle sidebar
bg1
1
Subsampling
•Selecting one single value to represent
several values in a part of the image.
–For example, use top left corner of 2X2 block to
represent the block
–Compression ratio 75%
11 15 19 55
13 14 21 32
39 17 24 76
43 34 27 80
11 11 19 19
11 11 19 19
39 39 24 24
39 39 24 24
Subsampling
•A better way-averaging
•Compression ratio 75%
11 15 19 55
13 14 21 32
39 17 24 76
43 34 27 80
13 13 32 32
13 13 32 32
33 33 51 51
33 33 51 51
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Image Compression Techniques: Subsampling, Quantization, and Error Diffusion and more Exams Computer Science in PDF only on Docsity!

Subsampling

  • Selecting one single value to represent several values in a part of the image. - For example, use top left corner of 2X2 block to represent the block - Compression ratio 75%

11 15 19 55 13 14 21 32 39 17 24 76 43 34 27 80

11 11 19 19 11 11 19 19 39 39 24 24 39 39 24 24

Subsampling

  • A better way- averaging
  • Compression ratio 75%

11 15 19 55 13 14 21 32 39 17 24 76 43 34 27 80

13 13 32 32 13 13 32 32 33 33 51 51 33 33 51 51

Subsampling

  • Subsample in non-square blocks
  • Different components may be subsampled at different frequencies
  • Works best for images with low frequency components
  • Suitable when target output resolution is lower than source resolution
  • Works poorly on images with fine details, including text

Quantization

  • Mapping of a large range of possible sample values into a smaller range of values or codes.
  • Fewer bits are required to encode the quantized sample.
  • Examples
    • -Letter grades (A, B, C, D, F)
    • Rounding of person’s age, height, or weight

Rounding

  • Add 5 and then truncate the result.
    • One more LSB participate than in truncation
    • average error 1/4 LSB

13 19 9 5 14 17 8 15 52 49 53 47 50 58 51 42

10 20 10 10 10 20 10 20 50 50 50 50 50 60 50 40

Random Rounding

  • Add a random number in the range [0,LSB], then truncate to LSB.
  • Decimal number “43” has 70% chance of being “40” and 30% chance of being “50”.
  • Information in all bits participates.
  • Average error 1/3 LSB (higher than rounding, but results look better.)
  • Identical pixels may be rounded to different values.
  • Colors not available in target color space may result.

Error Diffusion

  • Quantize the number, subtract quantization error from adjacent pixels that have not been quantized. - Preserves color levels over very localized areas - Every bit contributes to the final image

Error Diffusion

17 14 12 19

20 11 12 19

10 13 19

10 22 20

Result 20 10 10 20

Delta Coding

  • Code the difference between adjacent pixels.
  • Since adjacent pixels are similar, the difference is normally small, and requires fewer bits to code.
  • A typical pixel value requires 8 bits.
  • The difference between any 8 bit pixels is in the range [-255,255], which needs 9 bits!

Delta Coding

  • But most deltas will be small.
    • Smaller deltas can be assigned shorter codes
    • Smaller deltas can be ignored completely
    • smaller deltas can be quantized more finally for better quality
  • Complementary delta values can share a code; e.g., +1 and -255 yield same result in 8 bit positive value.
  • 9 bits are not required!

Encoding with quantization loss

  • Encoder must calculate incorrect pixel value that the decoder will decode, and use that value in computing the next delta, to minimize the quantization loss.

Prediction

  • Prediction further reduces delta values.
  • In delta coding prediction is the last pixel
  • Better prediction algorithm means better compression ratio.
  • It can improve picture quality

RLE: Example

Huffman Coding

  • Given “n” possible symbols we need log 2 (n) bits to code them using binary system.
  • If probability of occurrence of these symbols is not uniform, then we can code them using variable number of bits.
  • This is lossless and efficient coding.
  • Assign shorter codes to more frequent symbols, and longer codes to less frequent.

Huffman Coding

A 1

A 2

A 3

A 4

P=.
P=.
P=.
P=.

1 A 1 0

A 2 10 A 3 110 A 4 111

Huffman Coding

()log ( )

255 0 2

H pi pi ∑ i = = −

. 125 log. 125 1. 75

. 5 log. 5. 25 log. 25. 125 log. 125

H =− − − −

× =

R = × + × + × +

Entropy

Codeword length

Variable Length Coding (Vector

Deltas)

Variable Length Coding (DCT

AC Coefficients)

EOB 10

Color Images

Color Science

  • “Colors” as we perceive them are weighted sum of multiple wavelengths.
  • Three types of photoreceptors in eye roughly correspond to Red, Green and Blue.
  • We simulate colors by hitting those photoreceptors with calculated amounts of Red, Green and Blue.

Color Spaces

• R, G, B
  • Y, Cb, Cr
  • Y, I, Q
  • C, M, Y
  • I, H, S
  • Y, U, V

Luma & Chroma

. 5 2 . 5

  1. 6 . 3. 6. 1

−

−

= + +

B Y C

R Y C

Y R G B

r

b

Y, I, Q

Q R G B

I R G B

Y R G B

I=Red-Cyan

Q=magenta-green

Y=white-black

C, M, Y

Y B

M G

C R

Cyan, Magenta and Yellow: Primary

colors of pigments.

The Color Circle

The Color Cylinder

Y, U, V

− −

= − − 

B

G

R

V

U

Y

. 5. 419. 081 . 169. 331. 5 . 299. 587. 114

 = − − 

Y

V

U

B

G

R

1 1. 772 0

    1. 714

1 0 1. 4002

Y represents the brightness of a pixel.

U, V represent how far blue and red are

from white.

Average Delta Values for Adjacent Pixels

Y=

U=

V=

YUV=

R=

G=13.

B=12.

RGB=

We can sub-sample U & V over a number

of pixels without loss of picture quality.