FIT 2011 Blok Sort

23
by Basar KOC & Ziya ARNAVUT 

Transcript of FIT 2011 Blok Sort

Page 1: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 1/23

by Basar KOC & Ziya ARNAVUT 

Page 2: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 2/23

What are digital colors? Human beings perceive colors by the nature of the light

reflected from an object!

 Achromatic Color: means literally ³without color´

Only intensities (amount of light)

Gray levels as seen on black/white TV-monitor 

Ranges from black to white

Chromatic Color: All colors other than neutral colors (white, black,

and the pure grays), are chromatic.

The word ³color´ in ordinary language is often used to refer 

exclusively to chromatic colors, e.g., color vs. black-and-white

television.

Page 3: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 3/23

RGB Color Theory RGB stands for Red, Green, Blue RGB color is in use in many devices,

Televisions, computer screens, digital cameras.

When the visible color spectrum wavelength (400-700 nm) is

broken into thirds,

RGB colors are the predominant colors.

Three types of cone cells exist in human eye.

Each cell is more sensitive to either  short ( S ), medium( M ), or long( L ) wavelength light.

These curves are often also referred as the ³tri-stimulus functions´.

Page 4: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 4/23

RGB Color Space  A single pixel consists of three components each in range of 

[0,255].

Each pixel is a triplet

128 251 60 =

Pixel vectorin memory Final pixel inthe image

Page 5: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 5/23

Size consideration in an RGB image

The lowest resolution for a monitor 

Displaying a Windows desktop is 640 x 480 pixels.

In a bitmap of this resolution, then, there would be 3 bytes per 

pixel, For a total of 640 x 480 x 3, or about 900 kilobytes.

Page 6: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 6/23

Bit-Depth = Color-Depth Number of Colors = 2^(Bit-depth) Bit-depth is the number of bits.

It is also called ³Color resolution´.

Bit depthBit depth Color resolutionColor resolution CalculationCalculation1-bit 2 colors 2^1 = 2

2-bits 4 colors 2^2 = 4

3-bits 8 colors 2^3 = 8

4-bits 16 colors 2^4 = 16

8-bits 256 colors 2^8 = 256

16-bits 65,536 colors 2^16 = 65536

24-bits 16,777,215 colors 2^24 = 16.7 million

Page 7: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 7/23

Color Palettes Images look best

If they¶re stored with as RGB images with 16,777,216 colors.

However, file seizes may be very large.

For practical purposes,

we would like to reduce the number of colors from 16,777,216 to

256 colors.

Such files are referred to as using palette-color.

The colors in a palette-color file are derived from a potential paletteof 16,777,216 colors, but no more than 256 of them can be used in

any one image.

Page 8: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 8/23

Graphics Interchange Format (GIF)

The GIF is one of the most commonly used graphic file formats,

especially on the Internet.

an indexed color image format.

The color of the image is indexed in a palette. (a color-table)

The GIF is only capable of supporting a maximum of 256 colors.

Uses lossless compression algorithm.

Page 9: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 9/23

Structure of a BMP

Color-Palette Image

Information ± 56 bytes

Size

Dimensions Width, height

Bit per pixel 8, 4, 2, 1

Color Table 3 x 256 bytes at most

The color-mapped table of an image

Index R G B

0 28 0 1

1 19 2 5

2 34 1 1

3 39 2 3

4 44 0 2

.. .. .. ..

254 193 211 223

255 206 212 222

Page 10: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 10/23

Euclidean Distance Metric

Let E[a,b] be the Euclidean distance between two color indices

a and b.

(0 a, b 255)

where,

E[a,b]: Distance between index a and index b. eR: Difference between R values of a and b indices.

eG: Difference between G values of a and b indices.

eB: Difference between B values of a and b indices.

Page 11: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 11/23

Euclidean and Pseudo Distance

matrices

Pseudo-distance matrix

Distance matrix

created from the color palette

converted 

Index R G B

0 28 0 1

1 19 2 5

2 34 1 1

3 39 2 3

4 44 0 2

.. .. .. ..

254 193 211 223255 206 212 222

Color-map table

Page 12: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 12/23

Encoding

Reference pixel x and its neighbors Ranking with pseudo-distance matrix

X is the index value to be predicted. a, b, c are neighboring indices.

Using (a, x) we determine ranking value, or error e.

Pseudo-distance matrix

Page 13: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 13/23

Decoding

In error matrix E,

the index number of the first pixel at the top-left corner, call it a, is

copied to I. Later we apply the following:

Receive the error signal e of the next pixel from the encoded image.

In row a of the pseudo-distance matrix search the error signal value e.

Emit the corresponding column value  x as the original index value of 

the image.

Let  x  be a and repeat the process until we reach to the end of file.

Clearly, in decoding process, we obtain original index valueswithout any loss.

Page 14: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 14/23

a1  x1 x2e11

e12

e13

e14

e15

..

e21

e22

e23

e24

..

..

ei1

..

.. x12 .. x13 ..

.. .. .. .. .. ..

a1 .. e12 .. .. ..

.. .. .. .. ..

a2 .. .. .. e13 ..

«. .. .. .. .. ..

Copy e11 to I(1,1)

Let a1 e11

Determine x12 by searching e12 in row a1.

I(1,2)

x12Let a2 x12

Determine x13 by searching e13 in row a2.

I(1,3) x13

We repeat the process similarly.

1

2

3

Decoding (cont.)

E: Encoded image P: Pseudo-distance matrix I: Image

Page 15: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 15/23

Why do we use the pseudo-distance

transformation?

0%

10%

20%

30%

40%

50%

60%70%

80%

90%

100%

01

2

3Sunset Serrano Sea_dusk Yahoo

0%

10%

20%

30%

40%

50%

60%70%

80%

90%

100%

01

2

3Sunset Serrano Sea_dusk Yahoo

Before transformation After transformation

Page 16: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 16/23

Distribution of Music.bmp (n = 8) before and after transformation

Distribution of Serrano.bmp (n = 256) before and after transformation

Why do we use the pseudo-distance

transformation?

Page 17: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 17/23

Block-sorting Transformations

 After the pseudo-distance technique, we apply block

sorting transformations on the data.

Linear Ordering Transformation (LOT)

Context-level one

Burrows-Wheeler Transformation (BWT)

Context-level n

Page 18: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 18/23

Linear Ordering Transformation For example, let w = [1, 3, 1, 3, 2] 

Original l l -1

1 2 3 4 5  1 4 2 5 3  1 3 5 2 4

1 3 1 3 2  1 3 1 3 2  1 1 2 3 3 

Note that, the inverse permutation of LOT l  isl -1 = [1 ,3, 5, 2, 4].  l -1  is called the Canonical SortingPermutation of w.

Also, elements of w is sorted in non-decreasing order  by l -1 and consists of m-blocks of different sizes. 

Sorted data can be encoded cheaply.

Page 19: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 19/23

Burrows-Wheeler Transformation

Let w = [3,1,3,1,2] be a data string. Construct

3 1 3 1 2

M= 1 3 1 2 33 1 2 3 1

1 2 3 1 3

2 3 1 3 1by forming the successive rows of M , which are

consecutive cyclic left-shifts of w.

Page 20: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 20/23

Note that the original data string w  is the 5throw of  M  ¶ .

Given the I  = 5 (row index) of w  in M  ¶ and

L¶ = [3, 3, 1, 1, 2] we can recover w .

1 3

1 3

M  ¶

= 2 13 1

3 _ _ _ 2

Burrows-Wheeler Transformation

Page 21: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 21/23

Binary Arithmetic Coder 

We observed that after the pseudo-distance metric is applied to

indices of various color-mapped images, on some images

percentage of 0s varies from 72-90.

Hence, we applied context-adaptive binary arithmetic coder which includes run length coding and context modeling.

This yields better compression gain than Huffman coder, which

was originally proposed by Kuroki et al.

Page 22: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 22/23

Images #Colors Size GIF PDT+SAC

PDT+LIN+BAC

PDT+BWT+BAC

Benjerry 48 28,326 1.239 1.218 1.255 1.182

Books 7 29,338 3.046 3.447 3.121 2.757

Clegg 256 719,158 3.623 2.808 2.474 1.972

Cwheel 256 481,078 1.492 0.984 0.957 0.919

Descent 122 64,542 2.928 2.765 2.731 2.716

Fractal 256 389,190 6.923 5.335 5.355 5.354

Frymire 256 1,238,678 1.485 1.373 1.426 1.276

Gate 84 61,302 2.939 2.471 2.418 2.376

Ghouse 256 481,078 3.713 3.219 3.169 3.128

Music 8 6,302 2.482 2.305 2.356 2.037

Netscape 32 61,382 2.113 1.922 1.880 1.825

Party8 12 75,606 0.854 0.778 0.772 0.699

Pc 6 1,721,858 1.694 1.723 1.594 0.977

Sea_dusk 46 157,538 0.323 0.052 0.052 0.048

Serrano 256 502,886 1.629 1.389 1.341 1.211

Sunset 204 308,070 2.601 1.590 1.557 1.550

Winaw 10 148,894 0.997 0.980 0.933 0.856

 Yahoo 229 28,110 1.983 1.818 1.855 1.777

Average 361,296 2.337 2.010 1.958 1.814

W. Avg. 2.328 1.974 1.899 1.629

Normalized 1.429 1.212 1.166 1.000

Experimental Results

Page 23: FIT 2011 Blok Sort

8/3/2019 FIT 2011 Blok Sort

http://slidepdf.com/reader/full/fit-2011-blok-sort 23/23

Thank  You!

Questions?