Color space selection for JPEG image compression - CiteSeerX

36 downloads 152 Views 4MB Size Report
Appendix G. Sample Probit Analysis SAS Code. 103. Appendix H. ..... Yellow-BI. Luminance. 0.1. 0.3. 1. 3. 10. Spatial fr
Rochester Institute of Technology

RIT Scholar Works Theses

Thesis/Dissertation Collections

1-1993

Color space selection for JPEG image compression Nathan Moroney

Follow this and additional works at: http://scholarworks.rit.edu/theses Recommended Citation Moroney, Nathan, "Color space selection for JPEG image compression" (1993). Thesis. Rochester Institute of Technology. Accessed from

This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact [email protected].

Color Space Selection for JPEG Image Compression

Nathan Moroney B .S. Philadelphia College of Textiles and Science ( 1991)

A thesis submitted for partial fulfillment of the requirements for the degree of Master of Science in Color Science in the Center for Imaging Science on the College of Imaging Arts and Sciences of the Rochester Institute of Technology

December 1993

Nathan M. Moroney Signature of Author

Mark D. Fairchild Accepted by

College of Imaging Arts and Science Rochester Institute of Technology Rochester, New York

CERTIFICATE OF APPROVAL

M.S. DEGREE THESIS

The M.S. Degree Thesis of Nathan Moroney has been examined and approved by two members of the color science faculty as satisfactory for the thesis requirement for the Master of Science degree.

Mark D. Fairchild Dr. Mark Fairchild, Thesis Advisor

Roy Berns Dr. Roy Berns

Thesis Release Permission Form

Rochester Institute of Technology Center for Imaging Science

Title of Thesis Color Space Selection for JPEG Image Compression

1, Nathan M. Moroney, hereby grant permission to the Wallace Memorial Library of R.I.T. to reproduce my thesis in whole or in part Any reproduction will not be for commercial use or profit.

Date

_

l

d._,_;/l~b_,/"-4L.:!.)'----'

I

Color Space Selection for JPEG Image Compression

Nathan

Moloney

Submitted for partial fulfillment for the degree of Master of Science in Color Science in the Center for Imaging Science the Rochester Institute of Technology

of the requirements

at

ABSTRACT

The Joint Photographic Experts Group's image compression algorithm has been be a very efficient and powerful method of compressing images. However, there is litde substantive information about which color space should be utilized when implementing the JPEG algorithm. Currendy, the JPEG algorithm is set up for use with any three component color space. The objective of this research was to determine whether or not the color space selected will significandy improve image compression capabilities. The RGB, XYZ, YIQ, CIELAB, CIELUV, and CIELAB LCh color spaces were examined and compared. Both numerical measures and psychophysical techniques were used to assess the results. The final results indicate that the device space, RGB, is the worst color space to compress images. In comparison, the nonlinear transforms of the device space, CIELAB and CIELUV, are the best color spaces to compress images. The XYZ, YIQ, and CIELAB LCh color spaces resulted in intermediate levels of shown to

compression.

Acknowledgments

I

would

received as

I

like

to thank the

following people for all of the help

and assistance that

I

the Munsell

Lab, for providing the support and environment that made all of this possible, Mark Fairchild, for suggesting such a terrific research topic and for overseeing the entire process, Mike Stokes, for getting carried out

my thesis

research:

everything started by patiendy helping me to debug and implement my JPEG code, Tim Kohler, for coundess programming tips, software details, and trivia, and Eli, for her hope and love.

"Learning

changes us;

'preserve'

-as

it does what all nourishment does which also does not merely down' know. But at the bottom of us, really 'deep there is, of

physiologists

course, something unteachable, some granite

of spiritual

fatum,

of predetermined

decision and answer to predetermined selected questions. Whenever a cardinal problem is at stake, there speaks an unchangeable 'this is T; about man and woman, for example, a thinker cannot relearn but only finish learning -only discover ultimately how this is At times we find certain solutions of problems that inspire strong faith in 'settled in him.'

'convictions.'

Later -we see them only as steps to us; some call them henceforth their problem we are, -rather, to the great stupidity we are, to self-knowledge, signposts to the down.' " our spiritual fatum, to what is unteachable very 'deep Friedrich Nietzsche Beyond Good and Evil

Table

Table List

of

of

List List 1

.

2

.

4

.

i iii

Figures

iv vi

Introduction

1

Background

3

Baseline

JPEG

2.1.1.

The

2.1.2.

Quantization

2.1.3.

Huffman

2.1.4.

Measures

2.2.

.

Contents

Tables

2.1.

3

Contents

Images of

of

of

Color

FDCT

3 IDCT

and

and

Dequantization

5 of the

Encoding and Decoding of

Image Compression

Spaces

DCT Coefficients

8 12 17

19

2.2.1.

Device Color Spaces

2.2.2.

Linear Transforms

2.2.3.

Nonlinear Transforms

2.2.4.

CRT Gamut Transforms

of

Device Space of

Device Space

Color Spaces

2.3.

JPEG Quantization

2.4.

Computational Example

of

20 21 22 25 26

29 33

Experimental

3.1.

Environment

33

3.2.

Experiment One

38

3.3.

Experiment

Results

4.1.

Two

40

Discussion

42

Experiment One

42

and

4.1.1.

Probit Analysis

of Data

43

Table

4.2.

.

Contents

(continued)

Two

49

4.2.1.

Analysis

4.2.2.

Image

4.2.3.

Colorimetric Measures

4.2.4.

Error Images

4.3.

5

Experiment

of

of

the

Logistically

Processing

Transformed Data

Measures

of

Error

of Error

51 54

58 61

Analysis

62

4.3.1.

Channel

4.3.2.

Perceptual

4.3.3

Quantization

4.3.4.

Improvement Over RGB Compression

66

Redundancy L*

67

Polar hab Information

69

Uniformity of of

Conclusions

70 74

References

77

Appendix A. Huffman Encoding Tables for AC Terms

80

Appendix B. JPEG

86

C

Code

Appendix C. Inverse Color Space Transformations

95

Appendix D. CRT Calibration

97

Appendix E.

Preliminary Psychophysics

Experiment

100

Appendix F. Observer Instructions

102

Appendix G. Sample Probit Analysis SAS Code

103

Appendix H. Bits/Min2 Calculations

1 05

ii

List

of

Images

Image 3.1 Birds

34

Image 3.2 Fruit

34

Image 3.3 Musicians

35

Image 3.4 Pasture

35

Image 4.1 CIELAB

Fruit Error

63

Image

Image 4.2 CIELAB LCh Fruit Error Image

63

Image 4.3 CIELUV Fruit Error Image

64

Image 4.4 RGB Fruit Error Image

64

Image 4.5 XYZ Fruit Error Image

65

Image 4.6

65

YIQ Fruit Error Image

in

List

Figures

of

Fig. 2.1

Flowchart for Baseline JPEG Algorithm

4

Fig. 2.2

The 64 DCT Basis Functions

7

Fig. 2.3

Human Luminance

7

Fig. 2.4

Example Luminance

Fig. 2.5

Quantization Scaled DCT Basis Functions

11

Fig. 2.6

The

14

Fig. 2.7

CRT Gamut in RGB Space

27

Fig. 2.8

CRT

Gamut

in

XYZ

27

Fig. 2.9

CRT

Gamut

in

YIQ Space

Fig. 2.10

CRT Gamut in CIELAB Space

28

Fig. 2.11

CRT Gamut in CIELUV Space

28

Fig. 2.12

Example

Fig. 2.13

Example

Fig. 3.1

Experimental Electronic

Fig. 3.2

Observer

Fig. 4. 1

Sample Probit Analysis

Fig. 4.2

Visually

Fig. 4.3

Visually Lossless

Thresholds

of

Compression for Fruit Image

46

Fig. 4.4

Visually Lossless

Thresholds

of

Compression for Musicians Image

46

Fig. 4.5

Visually Lossless

Thresholds

of

Compression for Pasture Image

47

Fig. 4.6

Visually Lossless Thresholds

of

Compression Averaged for All Images

47

Fig. 4.7

Image

Fig. 4.8

Overall Image

Fig. 4.9

L*

and

Chrominance CSFs

and

Chrominance Q-Tables

Zig-Zag Ordering of the Quantized DCT coefficients

of

of

Space

27

Color Space Transformations

JPEG Compression

and

Decompression

Imaging

System

32

37

43

Lossless Thresholds

of

Scales Derived

Quality

30

37

Viewing Conditions

Quality

9

Compression for Birds Image

Using

Scale Derived

Logistic Analysis

Using

Logistic Analysis

45

53 53

68

Transform Jones Diagram

iv

List

of

Figures

Fig. 4.10

Example hab Compression

Fig. H.l

Basic Experimental

Fig. H.2

Simplified Experimental

and

(continued)

Decompression

Viewing Geometry Viewing Geometry

71 105 105

List

of

Tables

Table 2.1

Categorization Table for AC

Table 2.2

Baseline entropy encoding table for DC terms

15

Table 2.3

Quantization Schemes Used for Different Color Spaces

29

Table 3.1

List

39

Table 3.2

List

Table 4. 1

Visually lossless Thresholds for Compression in Bits/Pixel

48

Table 4.2

Two Standard Errors in Bits/Pixel for the Thresholds in Table 4.1

48

Table 4.3

Frequency

Table 4.4

Proportionality Matrix for Birds Using 25

Table 4.5

Matrix

Table 4.6

Logit interval

Table 4.7

Image

Processing Error Metrics Averaged for Each of the Color Spaces

Table 4.8

Image

Processing

Table 4.9

Colorimetric Error Metrics Averaged for Each

of

Images

of

used

Images

of

and

DC Coefficients

for Experiment One

used

for Experiment Two

Matrix for Birds Image

Using

scales

derived for

Table 4.12 Percent Improvement

Table A.2

Huffman

50

Encoding

of the

of the

51

images

52

of

the Images

RGB Compression

Table for Luminance AC Terms

Encoding Table for Chrominance AC Term

vi

Images

Color Spaces

Channels for Fruit Image

over

observers

each of the color spaces and

Error Metrics Averaged for Each

of

50

Observers

Logistically Transformed Data for Birds using 25

Table 4. 1 1 Standard Deviations

Huffman

41

25 Observers

Table 4. 10 Colorimetric Error Metrics Averaged for Each

Table A.l

15

58 58

60 61 67 72

80 83

1.

Any

by

given scene viewed

million receptors.

This

be transmitted

the one million

human

by

visual system

seven to one

visual

a

human

observer

of years.

achieves a

routinely

visually lossless level

(Granrath 1981). It is encouraging to

One

has been possible

of the most

Baseline JPEG

widely

with

Group

CCITT

up to study

industry

formulating, revising

its

and

color

image

is

of compression

decade that the

of thousands

same

level

of

originally

used to

compression.

about to approve as an

has been developed is the

an acronym

The

standard compression algorithm which

and

levels

images.

JPEG is

name was

that it can

means that the

for hundreds

used and successful methods that

Photographic Experts

the

color

compression algorithm.

committee set

under our noses

This

seven

of compression of about

realize that such

within the past

digital

compressed so

to the brain.

or so optic neurons

However, it has only been

compression

is detected using roughly

information is then automatically

information have been occurring right

of visual

identify

Introduction

standing for the Joint

identify

name

is

the joint

ISO /

now also used to

the committee has been

international

standard

(Mitchell

and

Pennebaker 1991). Image

information ways and

compression refers to

needed to represent a

JPEG

utilizes

techniques involves as

spatial, temporal

any

class of

techniques used to reduce the amount of

digital image. This

two of the

can

most common

methods which attempt

be done in

approaches.

a number of

The first group

to reduce any redundancies

or spectral correlations.

The

second

different

in the image,

of

such

group involves systematically

throwing out less visually significant information from the image (Limb 1976). The JPEG

algorithm

technologies. These advances

an

in

imaging science are opening entire new regions for future

development. Currently, JPEG is

images in

important

is

being

an electronic environment.

used

This

part of

the rapidly

growing

compression

to improve the storage capacity for digital

means

that storing and

communicating digital

images is will

be

now

for

vital

and

less

At the be

future, JPEG

high definition television,

there is little substantive

time,

implementing

Some

authors

have

and related

color

faxes,

(Leger, Omachi

information

technologies

video

and

telephones

Wallace 1991).

about which color space

the JPEG algorithm (Wallace 1988).

the RGB device space is

shown that

compression space.

near

storage and retrieval systems

utilized when

has

research

present

In the

expensive.

such products as

high-end image

and other

should

faster

a poor choice

suggested that the

for

Previous

a color

image

NTSC YIQ, NTSC YCbCr,

or

the CIE XYZ tristimulus space should be used when compressing color images (Pratt 1971 and

Ylakoski

and

Ronngren 1992). These

from providing any would

be

concrete

optimal

details

for JPEG

psychophysics which

results provide a

point

but they

are

far

about which of the multitude of color spaces available

compression.

have been

starting

In addition, there is

published on this

issue. This thesis

minimal

research

reported

investigates

this topic and will provide numerical and psychophysical assessment of which color space should

be

used with

The selected

significant

for

algorithm are

compression.

image

differences in the

use with the

differences in the

color

the JPEG algorithm.

just

JPEG

perceptual

a

few

This thesis

compression.

of

various color spaces suggest that the color space

algorithm will affect the

resulting

compression.

The

uniformity, channel redundancy, and compatibility with the

the

variables

that could affect the efficiency of the resulting

research also attempts to

determine how these factors influence

2.

The

following

sections

Background

discuss the details

of

the Baseline JPEG

the specifics of each of the color spaces used in this research

is

computational example

from

original

RGB

This

presented.

form,

example

follows

Finally,

are reviewed.

a sample

Then

algorithm.

8x8 block

a

of pixels

through the color space transformations, through the

compression steps and then

back

illustrates the discussions

the JPEG algorithm and the color space transformations.

of

out

through the decompression steps.

Moreover, the example provides a useful reference for the Results

2.1.

Discussion

of

the major objectives of the JPEG committee

compression technique

with all of

To

use throughout

Additional

individual

users

implemented be

industry. A and software

changes could then

be

made

was

noted that

in

This

algorithm was

compression

compatible

to the Baseline algorithm according to

accept

the term pixel

would

8 bits

is

be universally

per pixel

images.

loosely

to mean

used

The

either a single monochrome pixel or a single channel of a color pixel.

terminology is specified, the green or

used

in this thesis

word pixel will

blue

be

and

the reader

should

be

aware

that,

same

unless otherwise

synonymous with a single pixel channel or an

individual

pixel component.

The Baseline JPEG

algorithm

is

composed of three major compression steps and

three major decompression steps. This is

following page.

image

developed the Baseline JPEG

designed to

literature,

be

that would be performing

preferences, but only the Baseline algorithm

and utilized.

basic

to establish a

method that would

accomplish this goal the committee

algorithm.

should

for

the various types of hardware

compression.

red,

section.

Baseline JPEG

One

It

and

This further

The first step in the

shown

process

in flowchart form in Fig. 2.1

is to break the

original

on

the

image down into

eight

Original Digital Image 3 Channels 8 Bits / Channel 8x8 Image Block III

jr

Color Space Conversion

Image Compression

V Forward Discrete

Huffman

Quantization

Encoding

Storage

or

Transmission

of

-^r

Cosine Transform

Image

Y Huffman -^

De-Quantization

Decoding

Invserse Discrete

Cosine Transform

Image Decompression

Reconstructed 8x8 Image Block

HI




50 t/>

c 0) CO

to ?0 a i

c

o

O

10

03

0.1

Spatial

3

1

0.3

10

frequency (cycles/degree)

Fig. 2.3. Human Luminance (From Mitchell

and

and

Chrominance CSF's

Pennebaker 1993).

100

f(x,y)

=

^ 4

i2.

v

X u

=

0v

=

rv

\rv \t_. C(u)C(v)F(u,v)cos

(2x + l)uTC

(2y + l)vTC i

.

(2.2)

cos

16

0

16

where:

The

variables u, v,

output of

the IDCT

adding 2(n~l)

-

1 to

and the

concentrates a

Woods 1990). As compact

2.1.2.

it

-jLforu,v =

V2

1

otherwise.

back from in

IDCT

0,

in the IDCT

a signed

order to get

integer to

as

an unsigned

essentially lossless. A lossless transform is

are

portion of

result, the DCT does

integer

the signal in the not

by

the original values.

information is lost. This transform is

large

in the FDCT. The

actually

a crucial

step in JPEG

lower frequencies (Gonzalez

compress the

one

and

information but it does

significantly.

Quantization

The

step

a

=

shifted

which none of the original

because it

C(u),C(v)

all of the values

Both the FDCT

in

be

=

perform the same roles

x, and y must

C(u),C(v)

Dequantization

step in the flow

next

compresses

and

the image

quantizing the DCT the DCT terms are

by

chart

is the

selectively

coefficients attempts

quantized

of

the DCT Coefficients

quantization of

discarding

to

model

the FDCT coefficients.

information. The JPEG

the human visual system.

according to their visual

This

scheme

for

Specifically,

significance.

Early on the JPEG committee recognized that color information could be quantized differently than monochrome information. color

information

could

(Hunt 1988). This

be

quantized more

scheme was

based

To illustrate, the human luminance

on

The largest difference

was that chrominance or

coarsely than the luminance

the

or

physiological properties of

and chrominance contrast

tone information

the visual system.

sensitivity functions

are

shown

in Fig. 2.3. This figure

roughly bell sensitivity The

shaped and peaks around

7

chrominance

sensitive to

sensitivity is

frequencies.

luminance

1991). The JPEG

luminance

cycles per

function, in comparison, is plateau

maximum

of the

shows that the

contrast

sensitivity function is

degree. The

chrominance contrast

shaped and peaks at a

lower

frequency level.

higher for the luminance information than for the

also

This demonstrates that the human

visual system

is

more

frequency changes than chrominance frequency changes (Schreiber

quantization scheme attempts to model this relationship, as well as some

details. The JPEG

committee

has

not provided

any

quantization

tables,

Q-Tables, for use

or

in Fig. 2.4, for

as standards.

They have provided two example tables,

algorithm and

this research utilized these two tables. One table is for quantizing luminance

information

and the other

is for

shown

chrominance quantization.

It has been

there are some irregularities in these two tables (Klein 1992). concepts of

and of

quantizing

varying the

valid and

chrominance

information

rate of quantization

have been

based

more

on the

by experimental results

supported

use with

commented

Nevertheless,

the

that

the basic

coarsely than luminance information

frequency

of the

basis functions

are

(Lohscheller 1984).

JPEG Chrominance O-Table

JPEG Luminance O-Table 16

11

10

16

24

40

51

61

17

18

24

47

99

99

99

99

12

12

14

19

26

58

60

55

18

21

26

66

99

99

99

99

14

13

16

24

40

57

69

56

24

26

56

99

99

99

99

99

18

22

37

56

68

109

103

77

47

99

99

99

99

99

99

99

24

35

55

64

81

104

113

92

99

99

99

99

99

99

99

99

49

64

78

87

103

121

120

101

99

99

99

99

99

99

99

99

72

92

95

98

112

100

103

99

99

99

99

99

99

99

99

99

Fig. 2.4 Example Luminance

and

Chrominance Q-Tables

Another way committee

is

shown

are shown with

particular

of

illustrating

the quantization scheme

The

sizes.

varying

will

be

size of

coarsely it

will

quantization

how

much

for

the basis functions is indicative

quantized

2.4. The larger the basis function, the will

more

using the luminance Q-Table

quantized and the more

each

block has been

smaller

information

scaled relative

larger the basis functions in the

of

how that

shown

in Fig.

finely the signal will be quantized and the less

be discarded. In comparison, the be

the JPEG

by

in Fig. 2.5. In this figure, the 64 DCT basis functions from Fig. 2.2

DCT basis function

information

proposed

upper

left

the basis function the more

will

to each blocks portion of

The

be lost.

the

amount of

relative size.

figure

Notice

are compared

to

the other basis functions.

The

actual equation

corresponding nearest

integer

quantization

the

follows:

indices

used

are the

=

Integer Round

to locate the

FDCT

this the

case

quantization

the Q-Table

coefficient

is then

rounded

fF(u,v) l

specific elements

coefficients and

Q(u,v)

operation of

are

the

by

the

to the

(2.3)

l.Q(u,v)

The dequantization is the inverse the same two

FDCT

the entire operation can be expressed as

Q-Table, F(u,v)

uses

each

number

in the Quantization Table.

Fq(u,v)

where u and v are

is to divide This

element

and

for

in the 8x8 FDCT block

and

the Q-Table values.

quantization process.

This step

tables as are used for quantizing the FDCT coefficients.

values are multiplied

by the IDCT coefficients.

This

can

be

written

In in

following form:

Fc? (u, v)

where

IDCT

u, v,

and

Q(u,v)

=

(2.4)

Fq(u, v) Q(u, v)

are the same variables as specified

coefficients.

10

previously

and

Fq(u,v)

are the

il______i

i"

'1.

.._'___

SiSllllSl|l|liSll MM

r

'I JBh

1 1

I

10*1

4

'

will 4

ii rr

IH

m fcW

__OCI

il IBEHSSBS

Mi .

SSf

lliili

a__-_______-aa^|"*^1t^^

Fig. 2.5 Quantization Scaled DCT Basis Functions.

11

The Q-Tables of compression

much an

image

all of

scaling

instance,

are a vital part of

achieved, but because will

be

the elements in the Q-Tables

a constant greater

more

decrease

be

compression.

be

no

compression

in

possible

Q-Table

values should

finely,

be larger

all of the Q-

Multiplying all of the elements by

deals

with

and

with

data

its

lossy as

Basically,

this

step

is

image is

compression

visually lossless

no round-off

referred to as

error

free, it is

minimal.

lossless

not used

Therefore,

most

lossy compression. lossy

which there

is

algorithm.

no perceptible

compression and results

compression occurs with no

in

a

distortion in the image

experiment performed

for visually lossless JPEG

for this

compression.

Decoding

algorithm

according to image works

is

step, is a

in

Walowit 1990). The first

and

assuming

often referred to as

quantization

The final step in the Baseline JPEG coefficients and to encode them

is completely

what

determining levels

Encoding

of compression

compression of the

to perform

which a maximum

Huffman

space.

by

discard less information.

discards information in

quality (Gentile, Allebach, research

values.

compression

degradation in the image. This is known compression

the

to quantize the signal more

information lost. This type

Although lossless

Nevertheless, it is

of

be determined

factor (Wallace 1990). For

coefficients are not quantized at all,

The JPEG Baseline algorithm,

less

some constant

default

and will

extensively because the resulting

2.1.3.

of compression can

how

determining

Multiplying all of the elements by a constant less than one will

the Q-Table values

will

for

of the amount

than one will increase all of the Q-Table values and will, consequently,

information.

all of

error, there

thesis

by

hand,

smaller than their

However, if the DCT

image

provide a mechanism

to quantize the signal more coarsely, all

values should

discard

they

The level

compressed.

than their default values. On the other

Table

the JPEG algorithm, not only because

by

giving the

12

is take the

statistics so

most

that

quantized

they

will

FDCT

take up even

commonly occurring

sequences

of quantized

occurring

FDCT

sequences of quantized

Huffman encoding

English language letter like A be

assigns

This step is

coefficients.

might

coefficients the shortest code words.

or

E

might

a unique

similar

occur more

be

of

study known

Before the reorganized

in

actual

order

to

coefficients are given the

binary

taking

advantage of the

given a code word of

as

the least commonly

longest

code words.

codeword to each sequence of

frequently than others.

given a code word of

larger field

FDCT

Likewise,

010

fact that

For example, or

11

and a

a

letters in the

some

commonly occurring

less frequent letter like

1001 1 10 (Raisbeck 1965). These techniques

Q

are a part of a

information theory.

encoding

sequence

to take advantage of the

begins,

the quantized DCT coefficients are

compaction of

15

information that

*16

28

occurs

*"29

P// / / / / \/ / / / / / A 3

5

S

14

17

27

30

43

A

9

13

15

26

31

42

44

/////// \/ // / // A 10

12

19

25

32

41

45

54

11

20

24

33

40

46

53

55

/////// \/ / // //A / // ///P

21

23

34

39

47

52

56

61

22

35

36

46

51

57

60

62

36

^37

49

*"5Q

58

59

63

**64

Fig. 2.6 The

FDCT

Zig-Zag Ordering of the Quantized DCT coefficients.

13

following the DCT.

This

new

ordering is

shown

the upper left corner to the lower right comer.

lower

frequency

zeros after

values to

value

be

64

first. The higher

zig-zagging from the

sequence allows all of

frequencies,

which are

usually

all

encoded all at once.

coefficients

between neighboring DC

as an arrow

This encoding

to be encoded is the DC term and this

average value of the

correlation

encoded

can then

quantization,

The first

be

in Fig. 2.5

in that block. As

coefficients.

a

coefficient

a measure of the

there is a

Generally, result, the

is

amplitude of

fairly

high

the DC term

to be encoded is the current DC coefficient minus the previous coefficient.

The two category

values

and the amplitude of the term.

within

and can

or

is

converted to a category.

be both

MSB,

of

positive and negative.

The

range

category is the

DC

codelength and

shows

intervals

The total

categories.

Table 2.2 lists these in

images

is just

the JPEG committee.

luminance

and the chrominance

Next, LSB is

the least

calculated

amplitude of the

5.

56

by taking

DC term

and the previous

Using Table 2.1,

FDCT

significant

the combined for the final was

by

bits

either

analyzed

DC

or

LSB

written

most significant

how the MSB bits to

bits,

of the

encode a given

This table is based

a previous study.

on

the

Once again, this table

are separate tables

of the codeword must

difference

minus

To illustrate, if the

be

51,

1. The MSB

current

for the

computed.

The

and the

luminance DC

LSB

can

coefficient

the difference value or amplitude would

5 is in category 3. The MSB

the difference between 100000 and 101 is Oil. The final then be

on the powers of two

the positive difference between the MSB and the

coefficient was

a value of

based

number of

There

which

range that an amplitude

shows

values.

the

coefficients.

or the negative

codeword.

are

Table 2.2

statistical properties of a set of

a sample provided

how the

The category determines the

the codeword to be assigned.

codewords are assigned to the

are

The category is determined according to

falls in. Table 2. 1

the amplitude

range of values

falls

that are then used to assign the DC coefficient's code word

100011.

14

of

be

category 3 terms is 100

and

for this DC term

can

codeword

Table 2.1 Categorization Table for AC Range 0 1 -1,

I

-3,-2, -7,

...,

-4,

-15,

...,

-8,

-31,

...,

-16,

-63,

...,

-32,

-127,

...,

-64,

-255,

...,

-128,

-511,

...,

-256,

-1023,

...,

-512,

-2047,

...,

-1024,

-4095,

...,

-2048,

-8191,

...,

-4096,

-16383,

...,

-8192,

-32767,

Category 0 1

...,

-16384,

and

DC

DC Coefficients

Category AC Category 0

N/A

1

1

2,3

2

2

7 4, 15 8, 31 16, 63 32, 127 64, 255 128, 511 256, 1023 512, 2047 1024, 4095 2048, 8191 4096, 16383 8192, 32767 16384,

3 4

4

5

5

...,

...,

...,

3

6

6

7 8

7

9

9 10

...,

10 11 12

...,

13

13

...,

14

14

15

N/A

...,

...,

...,

...,

...,

...,

...,

8

11

!

12

Table 2.2 Baseline entropy encoding table for DC terms. Luminance Luminance Chrominance Chrominance Codelength MSB of Codelength MSB of Codeword Codeword 2 00 2 00 4

010

3

011

4

10

100

4

5 6 7

5

8

110

110 1110 11110

6

10

1110

6 8 10 12

111110

7

12

11110

14

1111110

8

14

111110

16 18

11111110

2

3

101

9

16

1111110

10

18

11111110

11

20

111111110

The 63 AC terms

are encoded

the amplitude and category encoded.

information,

This is done because,

quantized a

majority

of

using

as was

number of zeros

previously stated,

1111111110 11111111110

scheme, but in addition to

proceeding that term is

once

j

111111110

20 22

a somewhat similar

the

01

also

the DCT terms have been

the AC coefficients are now zero. This variable length encoding

uses the number of zeros

proceeding the term,

or runlength, and the

15

category

of the

AC

determine the

coefficient to

AC

coefficient

is just the

The

coefficients.

preceding the category the

runlength can

runlength and

There

amplitude

depending JPEG

0

or

differential encoding is

by

of the

coefficient

EOB

category

two other

remaining

simply counting the

AC term is determined

falls in. The

on whether

has

values would

15

process

be

used

special code words.

The

in the block

is based

One

15. Once again, there

are

15

by of

AC term

on the same

possible sizes of

This is known

is for

for

encoded

details to

other operations

but this level

of

the negative difference

bits from the Huffman

At this

attend

of

point the

suffices

use with

minus

The

the JPEG algorithm. Due

The LSB

can

of the

and the

1.

encoded

DC

and

image is maximally

for this

of

AC terms

compacted.

are joined

There

format, byte-stuffing,

are

and

research.

Image Compression

When the final bit string has been

has

AC term

two different tables to be used

to such as establishing a storage

detail

the

as

they are listed in Appendix A for reference. These tables

or as

numerous other

Measures

an

by taking either the positive difference between the MSB

together into one bit string.

compression that

which

the special code words

are zero.

other special code word

provided two example tables

determined

From here the

2.1.4.

number of zeros

by finding

then be used to determine the MSB of the AC coefficients code word.

amplitude of the

for the AC

the block contains luminance or chrominance information.

to the size of these two tables,

codeword are

used

of the

to look up the MSB of the

possible runlengths

coefficients

codeword.

and a runlength of

committee

computed

consists of

are also

signifies that all of the

block

no

the code word. The amplitude

of

determining the DC categories and is also shown in Table 2.1.

This table

code word.

be

AC

bits

that term;

The category

amplitude of the

Then the

end of

value of

coefficient.

table used for the

codewords.

most significant

assembled

occurred as a result of the

16

it is

JPEG

possible

to determine the amount

algorithm.

For this research, four

different are

measures were used to assess

the final bit size of the

image,

compressed

The final memory

and

computed

image

These

compression.

measures

image, the compression ratio, the number of bits per pixel for the

the number of bits per minute squared for the

compressed

the compressed image is nothing more than the

size of

in bits that the

measured

the resulting

compressed

image took

The

up.

size

in

image. computer

compression ratio was

by dividing the number of bits in the original image by the number of bits in the image. The is

compressed

can

be formulated

Compression Ratio

as

follows:

=

-

(2.5)

-

Bits in Compressed Image

The resulting of

value can range

4 to 10. No

Likewise

an

one to some

in the image

compression

image

from

compressed to

half the

large

positive

would correspond

size of

number, usually in the range

to a compression ratio of one.

the original would result in

a compression

ratio of two.

The bits

1990). To

per pixel measure of compression

compute

image is divided

the

number of

,.

.

channels.

as was

The

,

original

compression

monitor.

the

=

image has

bits

from

a

eight

(Rabbani

the number of bits in the compressed

This

can

be

written:

little

number of

refers

per pixel and

after

under one

that avoids the ambiguities of

(2.6)

actually

pixels

bits

per minute squared

In this case, the

another simple quotient

Bits in Compressed Image ^ Number of Pixels

previously mentioned,

values can range anywhere

Lastly,

per pixel

by the number of pixels in the image.

Bits / Pixel

Remember,

bits

is

to

about

has been

17

by

JPEG

two and a

compression the

half.

suggested as a measure of

pixel size and

bits is divided

to the individual pixel

the

distance

of observer

image

from the

number of pixels as was

done

for the bits

per pixel computations.

This

minutes squared.

can

be

Then,

this value is multiplied

by the size of one pixel in

expressed as:

Bits/Mlule==!^E^p.e|s.e.MBfcl

Number

This

image

measure of

compression

This is important because the conditions

but only

image

an

original size and still

is independent

perceived

quality

of

of pixel size and

viewing distance.

the image is dependent on the viewing

be

can

compressed anywhere

be visualy indistinguishable from the

from a quarter to original.

an eighth of the

Further

compression

is

by sacrificing image quality. Therefore, a compression of 2 bits/pixel can

usually be

achieved with

image

is

size

Pixels

(Klein 1992).

Typically,

possible

of

one of

little

or no

loss

of

image fidelity. This dramatic

reduction

the major reasons that JPEG is used so extensively in many

in

imaging

applications.

2.2. Color Spaces

The JPEG committee, space

for

use with

JPEG

previously stated, did

Initially,

the algorithm.

as a standard color

was used as the

as was

the YCbCr color space was considered

space, but this idea was abandoned.

default

color space

not select a standard color

for much

However,

for

use

the YCbCr color space

of the experimental research carried out

by the

committee.

There has been affects the

a

limited

compressibility

amount of research on

of color

images. Although,

how the

given the

use of other color spaces

drastic differences among

the various ways of representing color, it seems unlikely that there would be no

among the

color spaces.

better than the RGB

In fact, the XYZ

color space

for image

and

YCbCr

color spaces

compression

18

(Ylakoski

have been

and

differences

shown to

Ronngren 1992

be

and

Peterson, Peng, Morgan, been

shown to

Allenbach,

be

and

and

Pennebaker 1991). Moreover, the CIELUV

a good color space

Walowit 1990).

for the

quantization of color

Therefore,

selection of a given color space would

the initial

have

color space

has

information (Gentile,

hypothesis

was made

a significant effect on the

that the

resulting

compression.

The

various color spaces

These divisions

categories.

and non-linear

spaces,

disadvantages for computational

also

are

currently device

transforms

of

color

device

spaces, linear transforms

and visual

The

uniformity (Kasson

main

and

the additional considerations of channel redundancy and

The

six color spaces selected

CIELAB LCh, color spaces

these

and

is the

for this

international

sections provide some

background

transformations to each of these color

brevity,

the inverse

An

trade-offs are between

Plouffe 1990). There

reasons

are

for selecting these

these color spaces.

on each of these color spaces.

spaces are also

be

In addition,

The forward

For the

presented.

sake of

in Appendix C.

the device color space for the CRT is the RGB or

In this

defining the color image. interface

space

are advantages and

the currently available color spaces. The

color space transformations are given

example of

color space.

space.

color

Device Color Spaces

2.2.1.

Blue

use of all of

device

RGB, XYZ, YIQ, CIELAB,

the CIELUV color spaces. One of the main widespread

of

ease of sub-band coding.

research are the

six spaces provide a good cross-section of

following

There

color spaces.

each of these three categories.

complexity

be divided into three different

available can

color

This

space, the RGB

color space

is

values are

used as an

simply the digital

input to the CRT

and therefore no additional computations are needed to

In comparison, any

before it

can

other color space will

be displayed. Regardless

signal

and

counts

processing

display an image in RGB

have to be transformed back into RGB

of this advantage, the

19

Red, Green,

RGB

color space

is

not

very visually do

space

uniform.

means that equivalent steps

in different

not correspond to equivalent perceived changes

is very

color space

three channels

correlated and there

(Limb, Rubenstein

device dependent color

This

and cannot

be

and

is

a considerable

in

RGB

areas of the

Likewise,

color.

redundancy

of

the RGB

information in the

Thompson 1977). Lastly, the RGB

directly displayed on any other device

color

color space

without

is

altering the

fidelity of the original image. The RGB

monitor corrected

counts used to

CRT, like the space

is

correct

now

RGB

drive the

a

and

gamma,

RGB

on color

spaces, the raw RGB

2.2.2.

color space will

remainder of

be the

one that

raw

spaces,

RGB

account certain

space can

CRT

are

digital

features

of the

be derived. This RGB

values.

derived

The terms when

and

color

needed

to

the monitor

is

this section on color spaces, the monitor

is

color space will

Although

being utilized. be the

is

one that

after

this section

meant when the

RGB

mentioned.

Linear Transforms

An

RGB

a new

other

color space consists of the actual

and gamma of the

corrected

is

RGB

linear transform away from tristimulus

(Motta 1991). For the

color space

raw

However, by taking into

monitor.

gain, offset,

only

The

space.

for the gain, offset,

calibrated

be further divided into two

color space can

example of a

of

Device Space

linear transform

of

the device color space is the CIE XYZ or

tristimulus color space. Extensive research has shown that the human visual system uses

three different types of cones to perceive color. sensitivities

has

proven

to be an

Direct

measurement of

matching functions. These themselves,

are a

color

matching functions,

linear transform

for determining if two

Therefore, in

elusive and problematic goal.

several elaborate psychophysical experiments were conducted

while not

of the cone sensitivities

colors match or not.

Essentially,

20

these three cone

in

order

the 1930s

to derive the color

the actual cone sensitivities

This

color space

is very

useful

the products of a given spectral

power

distribution for

matching functions Previous

can

illuminant,

an

be integrated to

for

a reflectance curve

yield three

values, the

has demonstrated that the CIE XYZ

research

the CRT's monitor corrected RGB space (Motta 1991).

necessary to

convert

from RGB to XYZ

calibrating the CRT. This and the method and

transform derived

The R, G,

and

B

between 0

and

1

in lux. The 3x3 RGB

space.

the RGB

A

be

3x3

17.50

Y

9.68

35.36

4.82

Z

0.71

5.36

62.90

linear transform

a

exact

used

linear transform

by

colorimetrically

for this thesis

research

in Appendix D. The form

of

of

actual

the transform is:

(2.8)

green, and blue digital counts for a given

pixel normalized

the units for the XYZ values listed inside of the matrix are measured

matrix shown above can then

The XYZ

space

is

second example of a

This

expressed as a

be inverted to transform from XYZ back to

somewhat more

color space

is

3x3

matrix

linear transform used

visually

computing the

computed

beginning

going from

uniform and

matrix transform used

is

as

of

less

color space

is very closely

this section.

space

The

NTSC RGB

YIQ

redundant

than

is the NTSC

YIQ

to

follows:

21

since

related

to the YCbCr

color space can

space

(Buchsbaum 1987).

However,

method was used

device

and

a standardized

same values.

the second

of a

for television

3x3 transform going from XYZ to YIQ

been

is

is determined

matrix and the equation

18.78

color space mentioned at the

means of

The

are outlined

X

are the red,

space

for the CRT

process was carried out

written as

again

X, Y and Z values.

space.

color space.

a

back

the results of the calibration

can

and

and

sample, and the color

a

to

YIQ

Both

be

space or as

are equivalent

the CIE XYZ values had already

compute

the

YIQ

values.

The

exact

3x3

Y I

0.000 1.000 1.389 0.827 0.453 0.938 1.195 0.233

Q

The inverse

of the above matrix will go

space, the

color

YIQ

redundant.

The

band

for transmission

coded

2.2.3.

YIQ

color space

The CIELAB

space

However, it is

CIELAB

color space are

a given color

given color

in

and a negative

a*

is

L*,

bluish

first be in XYZ

space

visually

additional

back to XYZ. Like the XYZ considerably less

meaningful and

feature that it

can

be efficiently

sub-

Device Space

an example of a nonlinear

is among the

a*

a*

and

visually

Likewise,

The

uniform color spaces

The three

axis or

L*

currently

coordinates of the

represents

how light

coordinates are rectangular coordinates that

lightness. A

In

transform of the device color

complex.

b*. The lightness

b*

colors.

space.

most

computationally

and

greenish colors.

b*

of

somewhat

is. The

more

has the

a plane of constant

and a negative

should

little

YIQ

purposes.

color space

available.

dark

a

Nonlinear Transforms

The CIELAB space.

is

space

from the

(2.9)

positive

a positive

a*

b*

locate

a

corresponds to reddish colors

corresponds to yellowish colors

order to convert to the

following

or

CIELAB space, the

transformations will then yield

colors

CIELAB

coordinates:

1 L*

L*

=

=

I

i

-

VYnJ

0.008856

=

500

=

200 ,Yn>

22

(2.10)

0.008856

(2.11)

UnJ

(2.12)

Yn

KXnJ b*

>




7.787^1 + -^ for Xn VXny 116

=

.Xn,

(2.14)

Xn


0.008856

(2.16)

Yn

YA

for

+

KYnJ

116




wSm

WPP 3mP'

Aillillll liiii^iiiiiiiii^^^iii .'A. ftjftftft..-

W2y-y;y>.:^ffi2;ySiy ""ftftft!ft-:ft!;ftft.;ftftft.ftvftft

W/p&ipmp, AAAstA&"-ft /jlllL ?.

,"sP,W

-

,

s

Ppp' as

:'ft>'

Image 4.2 CIELAB LCh Fruit Error Image.

63

^^^^^^^ffff^^fff.

Ijii

i s^^^_____MiiiSiiiiiiii ff-

ft-

fgipi

iiilHIi

_^_^____^ss____^

PPpSBp'PPA

iiii

yf-Ai

AmAy}Mai$pi

mm

WMpplgpMSMMM Image 4.3 CIELUV Fruit Error Image.

.^Aw-*-*

*

**

**"*

Image 4.4 RGB Fruit Error Image.

64

MMmsyyy'mmmm .

___s

A.''W2y2iUyAm^fJ^ AA'

WiKMtPPPPi ..

o.

,,.

;

ft

:

?--

mm

y.

.

/

ftftiftft .:.:.

....:....

.

ft

-

...

.

fj|

:

ft

:.::,

-,ApA ss$%8is0f%3&fs&& "

I^fct ^Alftftllllftl .....#3:;^

'

A

.'-:...

ftftftftftftft'ftftilfeft:;

5&2X

:-ft; ftftftft;

ftftftftftft

?5ftAA:A'

WiWrnT -

plf::.;

Alifll

APAPy.PkS

ym2p&pppPP^mPAA:-AAy.m^yFm

mmmm'srm;mm,:s

my

bbssss^ SjftftftftftV-'-ftftftftftftftv-ft

:'.:.ft- ft

^

,2,ftftSft|ii:iP ":'

'"'"

:...,.

.

i

S-____^4MssSf^__^_U9i

Image 4.5 XYZ Fruit Error Image

WSW-

ftftft'ftftftftftftftft-.:::::::

..

ft

ft

....................... ................... ....ft.. .. ...... ^ :::::::::

.:,..

:::

.

.

::::':: ..:.:..: :.

:

.:

*aJliillllilfL.

P- pppppmp: ApAppmPM-

Image 4.5

-

p.

YIQ Fruit Error Image 65

A

22 ,

'ftftftft

discussion be

should

be focused

in this

examined

RGB

improvement in

Channel

The issue color spaces.

RGB

and

redundancy

of

deviations for

hue information. Lastly, there

for

be

if a color

and the

of the

space of other than the

compression.

of channel

redundancy

was noted

this aspect of color spaces

color spaces performed so poorly.

information in the three

briefly

in the Background

one of the significant reasons that the

In

order to provide some measure of the

channels of each of the color spaces, the standard

each of the channels were computed

between 0

and

255. The

section on

is

separately for the fruit image. Before

this calculation was performed, the pixel values for all of the color normalized

L*

be brief discussion

will

attained

of

will

Redundancy

However,

XYZ

redundancy, the perceptual uniformity

compression that could

color space was used

4.3.1.

the specifics of the results. Three specific topics that

section are channel

problem of quantizing polar percent

on

standard

deviation

images

were

using the

usual

space

was then calculated

equation:

Standard Deviation

where

value

X is the

for that

mean pixel value

channel.

fruit image. The

This

value of

summed and each of the

converted the standard

percentages can

for

((lr\

a given channel and

calculation was repeated

the

standard

individual

deviation

HA2

X2J-(xf I

=

deviations for

standard

values

to

for

X

(7.11)

is the

each of

the three channels of the

each of the three channels was

deviations

was

divided

normalized percentages.

be found in Table 4.11.

66

mean squared pixel

by

this total.

then

This

The resulting list

of

Table 4.11 Normalized Standard Deviations for Each of the Individual Channels for the Different Color Space Representations of the Fruit Image. Channel Three Color Space Channel Two Channel One LAB

61.86%

17.69%

20.45%

LCh

40.31%

18.55%

41.14%

LUV

67.94%

17.69%

14.37%

RGB

28.50%

39.47%

32.03%

XYZ

35.38% 61.28%

35.33%

29.29%

28.08%

10.64%

YIQ

As

be

can

color space representations of the

XYZ

suggests

majority

of their

most of the

hab

is

that there

Future conversion.

large

as the

in

one channel.

and

The

L*

variation.

XYZ

and

YIQ

equal.

Y

have

a

channels contain

in that the

values are unusual

In this case, this large hab-

This

color space

color spaces

and

and

This

value

will

for the

be further

following section on quantizing hab. these

conversion

color spaces

is

(Pratt 1971).

This

space

to the Karhunen-Louve color

an orthogonal transformation

uncorrelated channels and an optimal

independence for

for the RGB

approximately

L*

as a result of the polar nature of

The Karhunen-Louve

channels

would

distribution provide

a

of

energy in

base level

that

results

each of

the

of channel

comparison purposes.

Uniformity

Perceptual

of the major

is the way in

true in the

concentrated

as

channels

redundancy in the RGB

research could also compare

in statistically

One

is

is occurring

demonstrated in the

spaces

are all about

information for these images. The CIELAB LCh

channel

4.3.2.

a considerable

deviation

channel variation

three

fruit image

In comparison, the CIELAB, CIELUV

representations.

hab

in Table 4.1 1, the deviations in the three

seen

expansion of

Eqns. 2.10

uniform than

Y. The

L*

differences between the

which

defining L*,

of

nonlinear color spaces and

transformed. the lightness information was

the darker

and

2.11,

extent of

regions or shadows of

were

derived

this transformation

67

so that

it

in terms

the

of

This is especially

images.

would

be

the other color

The

more

equations

perceptually

CRT luminances may to be

from those two

obvious

This figure counts to

from Y to L*.

shows the conversion

Y in the lower right L*

digital

counts

a normalized

expands

arrow

until

left

of equivalent

The

linear red, green,

right

upper

was generated

from

L*

digital

that the bottom 20% of the digital

128. This

over

means

at

will

in

100

51

on

more

a more

L*

scale.

the RGB axis and circling the

back to 51

be

normalized

on the

RGB

accurately

perceptually

This

axis.

quantized

count trio of

This is

origin

in

and the

shown

blue

51 transforms to count

triplets

in Fig. 4.9

lightness information

Transform Jones Diagram.

68

normalized

additional precision means

uniform manner.

L*

to

as an

a counter-clockwise manner

r

Fig. 4.9

blue digital

matched red, green, and

L*

a

in Fig. 4.9.

quadrant shows the conversion

the conversion from

quadrant shows the conversion

and

Notice that

comes

compressed

Jones diagram

quadrant shows

to occupy over 50% of the

shadows

a

directly to normalized L*.

starting

it

from trios

quadrant.

and the the upper

The lower left

Therefore,

equations.

that the will

be

4.3.3 Quantization

The

Polar

of

hab Information

CIELAB LCh

main reason that

CIELUV

color spaces was

generated

high frequencies in the data

image. One polar

b*

coordinates

represent

between the

quadrant of

0

between

alternate

into

of

hab-

did

not

do

as well as

This is because the

even when

there was

the CIELAB and

hab

polar nature of

none present

in the

original

that is easy to imagine is for reddish pixels that happened to fall along the

case

discontinuity

positive

because

space

a

the high

CIELAB

and

high

positive

frequency

would

shifts

frequency hab

-negative

Small

space.

360. This

a*

b*

quadrant and the positive

variations could would cause the

transform a low

frequency

in hab- Consequently, it

data than it

shifts

hab

to

in CIELAB

would take more

would to represent the

a*-

lower

bits to

frequency

CIELAB data.

However, it is likely 360

discontinuity

at

generation of

high

achromatics.

An

and

are

that blocks containing pixels on both sides of the

fairly

uncommon.

frequency hab

example of

pixels at the

of the

top

be

RGB

4. 10 is just the hue

RGB 8x8 blocks

compressions to

as a result of minor variations

This flowchart is

original source

of Fig.

at

more probable case would

this is illustrated using a flowchart

decompression in Fig. 4.10.

2.13 and, in fact, the

data

Another,

the

compared.

top It is

of

pixel

similar

block is the

angle plane of

evident the

hab

the

This is

also

representations of

This

shift

the

true

when

original

the

hab

plane

hab

compression

same.

The

hab

block

of

8x8

allows the results of the

two

the original

data

representation of

green, or blue pixel

compared

to the XYZ and CIELAB

RGB data in Fig. 2.12.

to higher frequencies is because the CIELAB coordinates of original near

achromatic triangles were scattered around

widely in

is

a region of near

to the one presented in Fig.

definitely exhibits higher frequencies than was present in original red, planes.

be the

the CIELAB LCh representation

This

Fig. 2.12.

of

in

hab

polar

the CIELAB origin.

order to represent these near achromatics.

69

This

Consequently,

the

made

the

hab

vary

final bit string for

85.6

85.6

85.6

85.6

85.6

85.6

85.6

-33.1

250.8 215.2 189.1 177.5 208.7 240.7 212.

85.6

85.6

85.6

85.6

85.6

85.6

-33.1

-33.1

191.0 231.3 208.5 213.7 222.6 212.5

92,

106.9

85.6

85.6

85.6

85.6

85.6

-33.1

-33.1

-33.1

210.3 165.3 231.6 255.6 232.8

69.0

73,

104.1

85.6

85.6

85.6

85.6

-33.1

-33.1

-33.1

-33.1

224.1 219.7 177.9 233.5

88.6

64.9

87

99.2

B5.6

85.6

85. 6

-115.1

-115.1

-33.1

-33.1

-33.1

240.5 229.9 221.1

28.3 104.2

91

108.7

85.6

B5.6

-115.1

-115.1

-115.1

-115.1

-33.1

-33.1

220.4 230.1

5.6

16.5

0.0

29.9 121

94.5

85.6

-115.1

-115.1

-115.1

-115.1

-115.1

-115.1

-33.1

191.8

0.0

38.8

6.2

9.3

26.1

23

78.4

-115.1

-115.1

-115.1

-115.1

-115.1

-115.1

-115.1

-115.1

0.0

49.4

0.0

5.6

29.9

27.0

17.5

Normalized

hab

128 Subtracted.

with

0.0

Reconstructed Block Normalized

hab

of

82.6

8x8

pixels.

?

FDCT

IDCT

\r

+

128

-54.5

270.0

91.4

28.4

0.1

8.6

6.6

2.2

-51

270

96

47

0

0

0

0

494.4

59.3

-192.8

0.0

-40.7

0.0

-10.6

0.0

486

63

-182

0

0

0

0

0

-91.3

-123.9

-100.3

70.2

37.7

13.8

-0.2

3.2

-96

-130

-112

99

0

0

0

0

34.9

0.1

151.3

59.3

-56.2

-0.1

-18.8

-0.1

47

0

198

99

-99

0

0

0

-0.1

-22.4

-37.9

-45.6

-100.3

30.6

15.9

4.5

0

0

0

0

-99

0

0

0

22.8

-0.2

9.1

0.0

83.2

59.6

-12.6

0.2

0

0

0

0

99

99

0

0

-6.4

-6.8

-8.7

-15.8

-19.5

-100.5

10.7

0

0

0

0

0

0

-99

..0

0

-3.6

0.2

17.0

-0.0

-8.1

-0.2

52.6

59.2

99

99

Decoded

Forward Discrete Cosine Transform Coefficients

Quantize

and

Dequantized Values

Dequantize 0

-3

15

4

1

0

0

0

27

3

-7

0

0

0

0

0

10011100000011100100101

-5

-2

1

0

0

0

0

10100111000110101000111

-4

1

0

2

1

-1

0

0

0

01000010100100111111011

0

0

0

0

-1

0

0

0

10111101011001011101111

0

0

0

0

1

1

0

0

11100101111010011110011 111010111110100110101011

0

0

0

0

0

0

-1

0

0

0

0

0

0

0

1

1

Huffman Encoded Bit Stream

FDCT Coefficients Quantized

Using

Chrominance Q-Table

for the compression and decompression of a the same RGB blocks shown at the top of normalized 8x8 block of hab pixels based on the page and decompression Fig. 2.12. The compression steps are shown going down

Fig 4 10

Computational

steps are shown

0.0

example

going up the

page.

70

the

hab

compression shown

compression was

using the

4.3.4.

in Fig. 4.10 is

over

only 12 bits long. This is

120 bits long.

a clear

In comparison, the

demonstration

of the

inefficiency

b*

of

hab representation for JPEG compression.

Improvement Over RGB Compression

The

first

results of the

dependent algorithm, but is

experiment showed that not

also a color space

dependent

only is JPEG

algorithm.

image

an

The possibility

of

improving the JPEG compression based on color space selection was investigated using the visually lossless thresholds derived RGB

had the highest threshold.

compression

improvement in

during the first experiments.

compression will

be

Therefore,

made relative to the

The first step in comparing the different compressed the

Specifically,

the compressed threshold

image data

P

can

image. The

be

image

exact

can

This the

P is the

'Bits in

Compressed Image

the

for the RGB

of the other color spaces.

image

relative

original size

for

of the

expressed as a

is to determine how original

fraction

image.

or percentage

compute this percent reduction

in the

This

that the threshold

all of the

yielded a

images

(7.12)

,

images

difference in

71

for

all of

from

the

all of

compressed

color spaces.

the percentages

percent reduction over

space compression.

and also averaged

image has been

for

and

compression was subtracted

to the RGB color

differences for each

in

color compression.

100

=

percent of

cases, the

written:

calculation was performed

percentage

be

of

majority

all of the comparisons

color spaces

formula to

Bits in Original Image

where

a

threshold image for that color space was relative to the

of the size of the original

original

RGB

In

Table 4.12 lists

all of the color spaces.

to.

Next, for

all

the original

all of

these

Table 4.12 Percent Improvement over RGB Compression. Percent Percent Percent Percent Difference Difference Difference Difference for Birds for Fruit for for Pasture Musicians

Color Space

LAB

8.1%

14.2%

8.8%

13.2%

11.1%

LCh

7.5%

14.5%

3.8%

-2.9%

5.7%

LUV XYZ

9.8% 7.2% 7.7% 8.1%

13.1%

9.4% 3.4% 6.8% 6.4%

YIQ Average for Each Column

Based color spaces

CIELAB

the

on

did

at

RGB. The XYZ

11.0% 12.7% 13.1%

values

for the

the

color

YIQ

compression was

compression was

5% improvement. The last each of

and the

dependent

row

in forth

RGB

provided

It is

case, the images

Baseline JPEG

basis

10.2% 7.2%

9.6%

9.2%

7.1%

8.7%

color space

over

were

for JPEG

a close third with a

and the

CIELAB LCh

interesting

to note

musicians

all of

compression.

over

in fifth

with

space was

that,

on

over

RGB

averaged

the average, using a

compression

image. Of course these

according to the level

algorithm.

72

of

The

9% improvement

for the fruit

conclusions are

compression. of the comparisons and the conditions of the

were compared

the

10% better than the RGB

the most improvement in

least improvement for the

on the

in

8.4%

in Table 4.12 lists the improvement

the columns in the table.

color space other than

image

compressions

7.1%

differences in Table 4.12,

overall percentage

least 5% better than the RGB

CIELUV

and

compressions and

for

Overall Percent Difference

visually lossless

In this

compression

for

Conclusions

5.

The

results of both of the pyschophysical experiments and the numeric measures of

indicate that

error

compression.

Color

color spaces

tested.

CIELUV

YIQ

and

There

The device

color spaces were

for visually losseless

information

research

issues

some color spaces are

in

which

compression

Tables

in

to

customize

The

results of

could

plane.

be

by

used

this

Another

all

be

worst

the six and

for JPEG image The

and

CIELUV

of compression,

the XYZ

CIELAB

Finally, CIELAB LCh space.

as a result, the

interesting

addressed.

compression

First

was

very

The

hab

CIELAB LCh

than others.

Altering

results, but there are still a

of all, the

However,

possibly be

JPEG

as this research

Regardless,

enhanced

algorithm

is

has shown,

there are other

to be more conducive for

the Q-Tables or modifying the Huffman

be

made to the

JPEG

algorithm

specific color space.

research suggest

altering the

for

higher levels

efficiently and,

produced some

use as a color compression space.

compression

at

possible changes which could

it for a

of

bit.

algorithm could

two

the

a poor color compression

compress

a given color space.

are examples of

order

better for

was

and worse than

component color space.

the JPEG

in

However,

and problems to

designed for any three

ways

has

best

the RGB space produced intermediate results.

a good and

compression ranged varied quite a

multitude of

RGB,

space,

better than RGB

very difficult to

This thesis

color

performed the

difference between the CIELAB

than the RGB compression.

both

and was

was

of

compression.

color space was worse

inconsistent

CIELUV

and

was no significant

Linear transforms

XYZ

CIELAB

spaces such as

color spaces.

compression.

for JPEG image

nonlinear color spaces are the preferred color spaces

that tristimulus space

It may be

quantization scheme.

three planes or the

option would

be to

possible

very

efficient

for

For instance, the Luminance Q-Table

the tristimulus

73

not

to improve the tristimulus

chrominance plane could

convert

is

be

applied

data from XYZ to

to

just the Z

Yxy

and the

quantize the

Although, would

Luminance-Chrominance-Chrominance

a

the results do not indicate how much

have

yielded.

the XYZ scheme the

data according to

Yxy

It

used

seems

improvement these

of an

alternate schemes

likely though that these schemes could not be any worse than

for this thesis

and

any better than the

compression achieved

using

YIQ color space. The

compression

efficiency

of the

CIELAB LCh

changing the

hue

representation of

angle or

the other nonlinear color spaces.

hab

of the

first

hue information

as

pixel

AH*

Similarly, based

in

One

or the

altering the way in

possible method of

block

a given

and then

on observer

feedback

in the image is

supported

by the magnitude of chroma errors

could

gained

by

performing

chroma colors.

other color spaces although

transformation would

further

possible

b*

wider range of color spaces.

would produce results similar

research.

More

of

it is

for

be to

encode all the

level

of

encode

remaining

value.

would appear

that the loss

of chroma

is

also

listing the colorimetric errors

be

compression

the color channels

run

through a quadratic or

would assign a

could also

before

be

higher priority to

used with

any

of the

be necessary to determine if this

compression.

expanding the

testing.

It

to those of the

research

This

quantized.

this would

scope of the

investigation to include

For example, the OSA, HSL, YCbCr, YES

color spaces are also available

for this

This

This strategy

by

improvement in the

planes could

experiments would

truly improve the

Of course there is the topic

used

and

possibly be done

This dramatic loss

in the Table 4.9

look up table before compressing them.

maintaining the higher

it

some sort of transformation on

a*

by

compression to the

doing

and comments,

images. A

compressing them. For instance, the cubic

which

differentially

definitely a noticeable error.

second set of experimental

be

could

hue difference from the preceding hue

of chroma

for the

This

improve the CIELAB LCh

additional computational effort could

be improved

space could also

determining a method of quantizing the hue angle plane.

the

scheme.

seems

likely

74

support

many

other

that these other color spaces

device, linear,

is necessary to

and

a

and non-linear color spaces

this hypothesis.

Lastly, compression.

the study could be expanded to cover a wider visual range of image

The

differences in the This for

results of

compression

the XYZ compressions suggest that there may be

depending on the extent to which the image is compressed.

would then raise the question of which color space

all

levels

of

image

visual

compression.

75

is

optimal

for image

compression

References N.

Ahmed, T. Natarajan, K. R. Rao, "Discrete Cosine Transform", Computers, 23 1316-1322 (1974).

IEEE Transcations

B. A. Barry, Errors in Practical Measurement in Science, Engineering John Wiley and Sons, New York, 30-33 (1978).

and

on

Technology,

C. J. Bartleson, F. Grum, Optical Radiation Measurements, Vol. 5. Academic Press New York, 368-439 (1984). G. Buchsbaum, "Color Signal Coding: App., 12, 266-269 (1987).

Color Vision

and

Color Television", Col. Res

CIE, "Colorimetry", Publication 15.2, Comission International d'Eclairage, Austria, Vienna, (1984). M. Fairchild, Psychophysics for Imaging, Short Course Notes, Rochester Institute Technology, (1992).

of

R. S.

Gentile, J. P. Allebach, E. Walowit, "Visually Lossless Compression of Color Images", SPIE 1258 Image Communications and Workstations, 190-201 (1990).

R. S. Gentile, J. F. Allenbach, E. Walowit, "Quantization Uniform Color Spaces", Journ. Img. Tech. 16 11-21 (1990).

R. C. Gonzalez, R. E. Woods, Digital Image Processing, York, 1990, pp. 307-405.

of

Color Images based

Addison-

Wesley

on

Pub. Co., New

D. Goodenow, "JPEG Compression", PRINT RIT The Journal of the RIT School of Printing Management and Science, 1 6-9 (1993). D. J. Granrath, "The Role of Human Visual Models in Image Processing", Proc. of the IEEE., 69 552-561 (1981). N. C. Griswold, "Perceptual Coding in Engineering, 19 306-3 1 1 (1980).

the Cosine Transform

B. G. Haskell, A. N. Netravali, Digital Pictures: Representation Press, New York, 1988, pp 147-441.

and

Domain", Optical

Compression, Plenum

R. W. G. Hunt, The Reproduction of Color, Fountain Press, Tolworth, England, 399, (1988).

373-

J. M. Kasson, W. Plouffe, "Requirements for Computer Interchange Color Spaces", SPIE 1258 Image Communications and Workstations, 172-183 (1990). "'Perfect'

'perfect'

image compression in space and displays and S. A. Klein, T. Carney, and Digital Display II, 190-204 Visual Human Processing, SPIE Vision, 1453, time", (1991).

S. A. Klein, A. D. Silverstein, T. Carney, "Relavence of Human Vision to JPEG-DCT Compression", SPIE 1666, Human Vision, Visual Processing, and Digital Display III, 200-215 (1992). 76

A. Leger, T. Omachi, G. K. Wallace, "JPEG Still Picture Compression Algorithm", Optical Engineering, 30 947 -954 (1991). J. O. Limb, "Visual Perception Applied to the Encoding in Image Transmission Techniques 80-87 (1976).

of

J. O.

Pictures", SPIE 87, Advances

Limb, C. B. Rubinstein, J. E. Thompson, "Digital Coding Review", IEEE Trans, on Com., COM-25 1349-1384 (1977). H.

of

Lohscheller, "A Subjecticely Adapted Image Communication

Color Video Signals-A

System"

IEEE Trans,

on

Com., COM-32 1316-1322 (1984). J. L. Mannos

Encoding

of

and D. J. Sakrison, "The Effects of a Visual Fidelity Criterion Images", IEEE Trans, on Info. Theory, IT-20 525-536 (1974).

J.

Mauro, "Digital Image Compression Theory Theory", Electronic Imaging Feb, 1985 60-66. J. Mauro, "Digital Image Compression Electronic Imaging March, 1985 61-63. P. W.

Theory

and

and

on

the

Techniques, Part I: Information

Techniques, Part II: Image Theory",

Melnychuck, M. J. Barry, M. S. Mathieu, "Effect of Noise and MTF on the of High Resolution Color Images", SPIE 1244 Image Processing

Compressibility Algorithms

and

Techniques 255-262 (1990).

J. L. Mitchell, W. B. Pennebaker, "Evolving JPEG Color Data Compression Standards", Standardsfor Electronic Imaging Systems, SPIE Optical Engineering Press, Bellingham, Washington, 1991, pp 68-97. J. L.

Mitchell, W. B. Pennebaker, JPEG Still Image Compression Standard, Van Nostrand Reinhold, New York, (1993). R. J. Motta, "An Analytical Model for the Colorimetric Characterization of Color CRTs", MS Thesis, Rochester Institute of Technology, Center for Imaging Science, (1991).

H. A. Peterson, H. Peng, J. H. Morgan, W. B. Pennebaker, "Quantization of Color Images in the DCT Domain", SPIE 1453 Human Vision, Visual Processing, and Digital Display II, 210-222 (1991).

W. K. Pratt, 992 (1971).

"

Spatial Transform Coding", IEEE Trans,

on

Com. Tech. COM-19,

980-

M. Rabbani, Digital Image Compression, Short Course Notes, Rochester Institute Technology, (1990).

of

M. Rabbani, P. W. Jones, Digital Image Compression Techniques, SPIE Optical Press, Bellingham, Washington, 1991.

Engineering

G. Raisbeck, Information Theory: An Introduction for Scientists

Press,

and

Engineers, MIT

Cambridge, Massachusetts, 1965.

J. C. Russ, The Image Processing Handbook, CRC Press, Boca Raton, 232-233 (1992).

77

SAS/STAT Users's Guide, Version 6, Forth Ed., 1071-1126 (1990). W. F.

Schreiber, Fundamentals of Electronic Imaging Systems, Springer-Verlag, New York, 1991, pp 104-133, 198-207. C. S. Stein, A. B. Watson, L. E. Hitchner, "Psychophysical Rating of Image Compression Techniques", SPIE 1077, Human Vision, Visual Processing, and Digital Display, 198-207 (1989). M. D. Stokes, "Colorimetric Tolerances of Digital Images", MS Thesis, Rochester Institute of Technology, Center for Imaging Science (1991).

G. K. Wallace, "The JPEG Picture Compression Standard", IEEE Transactions Consumer Electronics, 38 xviii-xxxiv (1992). G. K. Wallace "Overview of the JPEG (ISO/CCITT) Still Image Compression SPIE 1244, Image Processing Algoritms and Techniques, 220-233 (1990).

on

Standard"

G. Wallace, R. Vivian, H. Poulsen, "Subjective Testing Results for Still Picture Compression Algorithms for International Standardization ",GLOBECOM 88 1022-1027 (1988). G. Wyszecki, W.S. Stiles, Color Science: Concepts Formulae, John Wiley and Sons, 1982.

and

I. Ylakoski, H. Ronngren, "CIE XYZ Colour Space Targa Proceedings, 139-151.

used

78

Methods, Qualitative Data

and

for Image Compression", 1992

Appendix A.

Tables H.l

H.2 list the

lengths

various zero run

using the

and

tables was copied

lengths

and coefficient sizes

or chrominance

directly out of the

is only the length, in bits, code word

is

for both the length

not

derived

until the

most significant and

and

adding the

for AC terms. These

least

length for

altogether.

These two tables

that simply converted

Code

0/0 0/1 0/2 0/3

(EOB)

significant

significant

length 1,

from run length

5 7 8 10

code

length

are computed.

bits

be

can

size

7 term

The total

computed

value.

code

length

by taking the MSB

For instance, using Table

would

look-up

be 16 tables

word

1010 00 01 100 1011 11010 1111000 11111000 1111110110 1111111110000010

16 16

1111111110000011

4

1100

5 7 9

1111001

1/5 1/6

11 16 16 16

1/8

for the

bits

1/1 1/2 1/3 1/4

1/7

text

or code word and that the complete

Code

2 2 3 4

two tables

plus

7

or

23 bits

in the JPEG C

and size straight to the total number of bits.

4

0/5 0/6 0/7 0/8 0/9 0/A

actual

Encoding Table for Luminance AC Terms

length

0/4

The

are

derived

bits

the coefficient to that

a run

assigned to

tables were

images. There

coefficients respectively.

were then used to create

Table A_ 1. Huffman

be

1990 ISO/CCITT DRAFT. Notice that the

least

size of

code word

Run/Size

AC

for AC Terms

and code words that would

of the most significant

H.l the total

program

code

Encoding Tables

average statistics of large collection of experimental

for either luminance

code

Huffman

11011 111110110 11111110110 1111111110000100

1111111110000101 1111111110000110

79

1/9

16

11111111 100001 1 1

VA

16

2/1

5 8 10 12 16

11111111 10001000 11100 11111001 1111110111

2/2 2/3 2/4

2/5 2/6

111111110100 1111111110001001 11111111 10001010

16

2/7

16

11111111 1000101 1

2/8

16

1111111110001100

2/9 2/A

16 16 6

1111111110001110

3/1

3/2 3/3 3/4

3/5 3/6 3/7

3/8 3/9 3/A 4/1

4/2

4/3 4/4

4/5 4/6 4/7

4/8

4/9 4/A

5/1

5/2 5/3 5/4 5/5 5/6 5/7 5/8 5/9 5/A 6/1 6/2 6/3 6/4

6/5 6/6 6/7 6/8

6/9 6/A 7/1 7/2 7/3 7/4 7/5 7/6 7/7-

7/8 7/9 7/A 8/1

8/2 8/3 8/4

8/5 8/6 8/7

1111111110001101 111010

9 12 16 16 16 16

111 1 101 1 1

111111110101 11111111 10001 1 1 1

1111111110010000 1111111110010001

1111111110010010 1111111110010011 1111111110010100 1111111110010101

16 16 16 6

111011

1111111000 1111111110010110 1 1111111 10010 111 1111111110011000 1111111110011001

10 16 16

16 16 16 16 16 16 7 11 16 16 16 16 16 16 16 16 7 12 16 16 16 16 16 16

1111111110101011

16

1111111110101100

16 8

1111111110101101

12 16 16

111111110111

1111111110011010 1111111110011011

1111111110011100 1111111110011101

1111010 11111110111

1111111110011110 1111111110011111

1111111110100000 1111111110100001

1111111110100010 1111111110100011

1111111110100100 1111111110100101

1111011 111111110110

1111111110100110 1111111110100111 1111111110101000 1111111110101001

1111111110101010

11111010 1111111110101110 1111111110101111

1111111110110000

16 16 16 16 16

1111111110110001

1111111110110010 1111111110110011

1111111110110100 1111111110110101

16 9 15 16 16 16 16 16

111111000 111111111000000 1111111110110110 1111111110110111

1111111110111000 1111111110111001

1111111110111010

80

B/a

16

1111111110111011

8/9 8/A 9/1

16

1 1 1 1 111 110111 100

16

1111111110111101

9

9/2 9/3 9/4

9/5 9/6

11111 1001

16

1111111110111110

16 16

1111111110111111 111111111 1000000 111111111 1000001 111111111 1000010

16 16

9/7

16

9/8

16

9/9 9/A

16

111111111 100001 1 111111111 1000100

16

111111111 1000101 111111111 10001 10 11111 1010

A/1

9

A/2

16

A/3

16

111111111 10001 1 1 111111111 1001000

A/4

16

111111111 1001001

A/ 5

16

A/6

16 16

111111111 1001010 111111111 1001011 111111111 1001 100 111111111 1001 101

A/7

A/8

16

A/9

16

A/A

16 10

B/l

16 16 16

B/2

B/3 B/4

B/7

B/8

C/1

16 10

C/2 C/3

16

C/4

1111111111011100 1111111111011101

16 16

C/8 C/9 C/A D/1

D/2 D/3 D/4

D/5 D/6 D/7

D/8 D/9 D/A E/1 E/2 E/3 E/4

E/5. E/6 E/7 E/8

F/5

11111 11111011011

16 16

C/7

F/

1111111111011000 1111111010 1111111111011001 1111111111011010

16

C/5 C/6

F/2 F/3

111111 1111010110 11 1 111111101011 1

16

B/9 B/A

F/1

11111111 11010001 111111111 1010010 1111111111010011 111111111 1010100 111 1111111010101

16 16 16 16

B/5 B/6

E/9 E/A F/0

11 1 1 1 11 1 1 10011 10 111111111 1001111 1 1 111 1 1001 111111111 1010000

(ZRL)

1111111111011110 1111111111011111

16 16 16 11 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 11 16 16 16 16 16

1111111111100000 1111 111111100001 11111111000 1111111111100010 1111111111100011

1111111111100100 1T11111111100101 1.111111111100110 1111111111100111

1111111111101000 1111111111101001 1111111111101010 1111111111101011 1111111111101100 1111111111101101

1111111111101110 1111111111101111 1111111111110000 1111111111110001

1111111111110010 1111111111110011

1111111111110100 11111111001 1111111111110101

1111111111110110 1111111111110111

1111111111111000 1111111111111001

81

F/6

16

F/7

16

1111111111111010 1111111111111011

F/8

16

1111111111111100

F/9

16

1111111111111101

F/A

16

1111111111111110

Table A.2. Huffman Encoding Table for Chrominance AC Terms Run/Size 0/0 0/1

Code

(EOB)

0/2 0/3 0/4

0/5 0/6 0/7

length

Code

2 2 3

00 01

4

1010

5 5

11001

100

11000

6 7

1 11000 1111000 111110100 1111110110 111111110100

9

0/8 0/9 0/A

10

12

1/1

4

1/2 1/3

6 8 9

1/4

word

1011 111001

11110110 111110101 11111110110

11

1/5 1/6 1/7

12 16

111111110101

1/8

16

1111111110001001

1/9 1/A

16

1111111110001010

16

1111111110001011

2/1

5 8

2/2 2/3 2/4

2/5 2/6 2/7 2/8 2/9 2/A 3/1

4/4

4/5 4/6-

4/7 4/8

4/9 4/A 5/1 5/2 5/3 5/4

5/5 5/6 5/7

10

1111110111

12 15 16 16 16 16 16

111111110110 111111111000010 1111111110001100 1111111110001101

1111111110001110 1111111110001111

1111111110010000 11011

11111000 1111111000

10

"

4/1 4/2 4/3

11O10 11110111

5 8

3/2 3/3 3/4 3/5 3/6 3/7 3/8

3/9 3/A

1111111110001000

111111110111

12 16 16 16 16 16 16

1111111110010001

1111111110010010 1111111110010011 1111111110010100 1111111110010101 1111111110010110

6 9

111010 111110110 1111111110010111

16 16 16 16 16 16 16 16 6 10 16 16 16 16 16

1111111110011000 1111111110011001

1111111110011010 1111111110011011 1111111110011100 1111111110011101

1111111110011110

111011 1111111001 1111111110011111

1111111110100000 1111111110100001

1111111110100011

82

S/8 5/9 5/A 6/1

16

6/2 6/3

11

1111001 11111110111

16

1 111 1 1 1 1 101001 1 1

6/4

16

11111111 10101000

6/5 6/6 6/7 6/8 6/9 6/A

16 16

1111111110101001 1111111110101010 1111111110101011 1111111110101100 1111111110101101 1111111110101110 1111010 11111111000

7/2 7/3 7/4

7/5 7/6 7/7 7/8 7/9 7/A 8/1

8/2 8/3 8/4

8/5 8/6 8/7

8/8 8/9 8/A 9/1

9/2 9/3 9/4

9/5 9/6 9/7 9/8 9/9

9/A A/1

A/2 A/3 A/4

A/5 A/6 A/7

A/8 A/9 A/A B/1

B/2 B/3 B/4 B/5.

B/6 B/7 B/8 B/9 B/A C/1

C/2 C/3 C/4

C/5 C/6

11111111 10100100 111 1 11 1 1 10100101

16 16

7

1111111110100110 .

16

16 16

16 7

..

11

16 16 16 16 16 16 16 16 8 16 16 16 16 16 16 16 16 16 9 16 16 16 16 16 16 16 16 16 9 16 16 16 16 16 16 16 16 16

1111111110101111

1111111110110000 mm moi 10001

1111111110110010 1111111110110011 1111111110110100 1111111110110101 1111111110110110 11111001 1111111110110111

1111111110111000 1111111110111001

1111111110111010 1111111110111011

1111111110111100 1111111110111101 1111111110111110 1111111110111111 111110111 1111111111000000 1111111111000001 1111111111000010 1111111111000011

1111111111000100 1111111111000101 1111111111000110 1111111111000111

1111111111001000 111111000 1111111111001001

1111111111001010 1111111111001011 11.11111111001100 1111111111001101 1111111111001110 1111111111001111 1111111111010000 1111111111010001

9

111111001 1111111111010010 1111111111010011

16 16 16

1111111111010100 1111111111010101

16 16 16 16 16 16 9 16 16 16 16 16

1111111111010110 1111111111010111 1111111111011000 1111111111011001

1111111111011010

111111010 1111111111011011 1111111111011100 1111111111011101 1111111111011110 1111111111011111

83

C/7

16

11 1 111 111 1 100000

C/8

16

C/9

16

1111111111 100001 1111111111 100010

C/A

16

1 1 1 nm ii ioooii

D/1

1 1

1 1 1 1 m 1001

D/2

16

111 1 1 1 1 1 1 1 100100

D/3

16

mi mi n iooioi mini imoono

D/4

16

0/5

16

1111111111100111

D/6

16

111111111 1101000

0/7

D/8

16 16

1111111 111101010

D/9

16

11 11111111101011

D/A E/1

16

1 1 11 1 11 1 11101 100

14

11111111100000

E/2

16

1111111111 101 10,1

E/3

16 16 16

11111 111 1 11011 10 1111111111101111

16

11111111111 10001

E/4

E/S E/6

111111 1111101001

11111111111 10000

E/7

16

1111111111110010

E/8

16

11111111 1111001 1

E/9

16

nn immioioo

E/A F/0 F/1

16

1111111 111110101

10

111.1 1 1 1010

15 16

1111 1 in i mono

(ZRL)

F/2

111111 111000011

1111111111110111

F/5

16 16 16

111111111 1111001

F/6

16

111111111 1111010

F/7

16

1111111111111011

F/8

16

F/9

16 16

1111111111111100 1111111111111101

F/3 F/4

F/A

.

111111111 imooo

1111111111111110

84

Appendix B.

JPEG C Code

/A************************************* /* /* /*

*/ file:

cexec_jpeg.c

Nathan

author:

/*

*/

Moroney

Mike

and

Stokes

*/

1/27/93

Date:

*/

/*

Mike

/*

Munsell

/*

Center

/*

Rochester

/*

Stokes

([email protected])

Color

Science

*/

Laboratory (MCSL)

*/

for Imaging Science Institute

Rochester,

*/ */

Technology

of

14623

NY

*/

/*

*/

/*

description:

/*

Baseline

/*

Forward Discrete

/*

*/

JPEG Program

/* /*

F(u,v)

1/4

=

/*

C(u)C(v)

*/

cos[(2y+l)vPI]/16

/*

Inverse

/*

Calculations

/*

f(x,y)

are

1/4 [

=

based

*

F(u,v)

on

the

*/

following

cos[

(2x+l)uPI]/16

This three will

program

channels

(L*,

Y)

/*

both

addition,

of

color

*/

*

*/ 16

the

and

is RGB.

X&Z,

will

into

i&q)

Otherwise

*/

the program

*/

the

first

table

for

the

channel

*/

two

*/

other

*/

.

work

only

vertically

*/ for

all

table

for

table

quatization

x&y,

program

image

space

]

Quantization

Luminance

quantization

u*&v*,

this

horizontally

sampling

the

chrominance

(a*&b*,

components

In

if the

the

and

use

luminance

the

use

will

*/

equation:

C(u)C(v)*

cos[(2y+l)vPI]/

/*

/*

*/

SUM(u=0-7)SUM(v=0-7)

/*

/*

*/

]

Discrete Cosine Transform

/*

/*

*/

cos[(2x+l)uPI]/16*

/*

/*

f(x,y)*

[SUM(x=0-7)SUM(y=0-7)

/*

/*

*/

image is first broken down into 8 by 8 blocks. */ These blocks are shifted from unsigned to signed integers first.*/ Calculations are based on the following formula: */ Input

/*

/*

*/

Cosine Transform

multiples

images

for of

8

(due

that to

*/

are

*/

the

8x8 blocks.

*/

/*

*/

(.include

# define PIE 3.14159265 /* Eight levels of Quatization */ # define P 8 # define HALFSCL 128.0 /* 128 for 0 to 255 images * images /

and

0.5

for

.

int cexec_jpeg(crs, crsimg_ptr win_ptr

win,

xfcn_jpeg)

crs;

win;

xfcn_ptr

xfcn_jpeg;

{ register

int xb,

int xtmp, ytmp; int tmp2 , width, int index ; int plane,

xp,

yb,

yp,

xt,

yt;

height;

11;

int qtabl_fact[8] [8]

,

qtab2_fact

[8] [8]

85

,

qtab3_fact

[8] [8]

;

0

to

1

float dctbasis[64] [64] /*

source

float

is

source

the

integer array

[8] [8] [3]

/*

/*

/*

qtcof

is the array

[8] [8] [3] ; quantcof [64] [3]

for

of

the

temp,

,

source

basis,

8x8

sum[3]

,

CC;

image block */

;

dctcof is the array float dctcof [8] [8] [3] ;

int int

idctbasis [64] [64]

,

dct

of

of

coefficients.

quantized

dct

'/

coefficients.

*/

qtcof

zzag[64][3]

;

is the

rearranged

(flattened)

array of quantized dct coefficients. the bit rate can be computed. */

int zzag[64] [3] ; int zagorder[64]

=

{ 18, 13, 28, 36, 30, 59, 54,

1, 25, 20, 21, 43, 23, 60, 61,

2, 33, 27, 14, 50, 16, 53, 62,

9, 26, 34, 7, 57, 24, 46, 55,

This

step

must

be done before

17, 10, 3, 4, 11, 19, 12, 5, 6, 41, 49, 42, 35, 8, 15, 22, 29, 58, 51, 44, 37, 31, 38, 45, 52, 39, 32, 40, 47, }; 48, 56, 63, 64

int DCLbitlut

[12] = {2,3,3, 3,3,3,4,5,6,7,8,9}; [12] = {2,2,2, 3,4,5,6,7,8,9,10,11}; int DCbitlut [12] [3 ]; 10, 16, 16, int ACLbitlut [16] [ io] = { ; 7, 3, 4, 5, 2, 11 16 16 16 16, 16, 9, 5, 7, 4, 16 16 16 16, 16, 10, 12, 16 5, 8, 16 16 16 16, 16, 12, 16, 16 6, 9, 16 16 16 16, 16, 6, 10, 16, 16, 16 16 16 16 16, 16, 11, 16, 16, 16 7, 16 16 16 16, 16, 12, 16, 16, 16 7, 16 16 16 16, 16, 12, 16, 16, 16 8, 16 16 16 16, 16, 15, 16, 16, 16 9, 16 16 16 16, 16, 16, 16, 16, 16 9, 16 16 16 16, 16, 16, 16, 16, 16 9, 16 16 16 16 16, 16, 16, 10, 16, 16, 16 16 16 16, 16, 10, 16, 16, 16, 16 16 16 16 16, 16, 11, 16, 16, 16, 16 16 16 16 16, 16, 16, 16, 16, 16, 16 16 16 16 16, 16 }; 16, 16, 16, 16, 16 9 10, 12, 6, 7, 5, 5, 4, 3, int ACCbitlut [16] [10] = { 16 16 12 11 16, 16, 8, 9, 6, 4, 16 16 16 16, 16, 10, 12, 15 8, 5, 16 16 16 16 16, 16, 12, 10, 8, 5, 16 16 16 16, 16, 16, 16, 16 9, 6, 16 16 16, 16, 16 10, 16, 16, 16 6, 16 16 16, 16, 16 11, 16, 16, 16 7, 16 16 16 16, 16, 16 11, 16, 16, 7, 16 16 16 16, 16, 16 16, 16, 16, 8, 16 16 16 16, 16, 16, 16, 16, 16 9, 16 16 16, 16, 16 16, 16, 16, 16 9, 16 16 16 16, 16, 16 16, 16, 16, 9, 16 16 16 16, 16, 16 16, 16, 16, 9, 16 16 16, 16, 16 11, 16, 16, 16, 16 int DCCbitlut

.

,

.

86

16, 16,

14, 15, int int int int

16, 16,

16, 16,

16, 16,

16, 16,

16, 16,

16, 16,

16, 16,

16, 16

};

ACbitlut

[16] [10] [3] ; {0, 0, 0}; numbits[3] {0, 0, 0}; numzero[3] {0, 0, 0}; DCprev[3]

=

=

=

intDCcur[3],

category [3 ] abszzag[3] int xc, yc, zc, count, twopow, DCflag, ACflag; int order, rangemax, zcount, bits, cat; int totalbits 0; absDCcur[3],

,

stop[3],

,

eob[3] ;

=

/*

dqtcof

is the array

float dqtcof [8] [8] [3] /*

lqtab_fact is

de-quantized dct

of

2D array that

a

coefficients.

*/

;

will

the

contain

pre-calculated

values

of

luminance

the

qtable

times

the

factor

quantization

(QFACT)

.

Similarly, cqtab_fact of

is

2D array that

a

chrominance

qtable

float lqtable[8] [8]

16.0, 12.0, 14.0, 14.0, 18.0, 24.0, 49.0, 72.0, }; /*

will

the

contain

pre-calculated

values

the

A

11.0, 12.0, 13.0, 17.0, 22.0, 35.0, 64.0, 92.0,

sample

the

or

float

10.0, 14.0, 16.0, 22.0, 37.0, 55.0, 78.0, 95.0,

times

the

{ 16.0, 19.0, 24.0, 29.0, 56.0, 64.0, 87.0, 98.0,

24.0, 26.0, 40.0, 51.0, 68.0, 81.0, 103.0, 112.0,

factor.

for

table

channel

for

a

40.0, 51.0, 61.0, 58.0, 60.0, 55.0, 57.0, 69.0, 56.0, 87.0, 80.0, 62.0, 109.0, 103.0, 77.0, 104.0, 113.0, 92.0, 121.0, 120.0, 101.0, 100.0, 103.0, 99.0 a

monochrome

device-

signal

independent

17.0,

18.0,

[8] 24.0,

= { 47.0,

99.0,

99.0,

99.0,

99.0,

18

.0,

21.

26.

66

.0,

99

.0,

99,

99,

99,

24

.0,

26,

56.

99

.0,

99

.0,

99,

99,

.0,

99,

47,

66,

99,

99.

99,

99,

99,

.0,

99,

99,

99.

99,

99.

99,

99,

99.

.0,

99,

.0,

cqtable[8]

.0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

,0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

.0,

,0,

.0,

99.

,0,

99.

,0,

99,

99,

99,

.0,

99,

99,

.0,

.0,

99,

.0,

99.

.0,

99,

99,

99.

.0,

99.

.0,

99,

.0,

99. 0,

99. 0,

99.

99,

,0,

99,

.0,

.0,

.0,

99,

,0,

,0,

99.

.0,

space.*/

.0,

99,

.0,

color

.0,

99,

99. 0,

*/

=

Quantization

Luminace

quantization

,0

}; switch

case

(crs->hdr.comp_type) CP_SHORT

"cexec_jpeg (NOT_OK) ;

crs_warn( return

{

: :

char

computations

not

yet

implemented");

:

long

computations

not

yet

implemented");

break ; case

CP_LONG

crs_warn( return

:

"cexec_jpeg

(NOT_OK)

;

break; case

CP_FLOAT

case

CP_DOUBLE

: :

87

width

11

.

(crs->hdr

=

crs->hdr

=

/*

(crs->hdr

=

height

A brief

image_width .

* .image_width

set

of

3)

image_height

3

hdr

pre-calculations

3;

.color_planes;

of

the

q-table

values

multiplied

times

the

quantization

factor

(QFACT)

.

This

is done to

make

the algorithm

for

little bit

a

faster.

0; xp < 8; xp++) { (xp 0; yp < 8; yp++) (yp

*/

=

for

=

if

(xfcn_jpeg->val [1]

qtabl_fact[xp] [yp]

=

[yp] [yp]

=

qtab2_fact[xp] qtab3_fact[xp] /*

Set up

=

{

{ lqtable[xp] [yp] lqtable[xp] [yp] lqtable[xp] [yp] ==1.0)

quantization

for RGB.*/

tables

} if

else

(xfcn_jpeg->val [1]

[yp] qtab2_fact [xp] [yp] qtab3_fact[xp] [yp] qtabl_fact[xp]

/*

Set up

=

=

=

{ [yp] lqtable [xp] [yp] cqtable[xp] [yp] ==2.0)

cqtable[xp]

quantization

for XYZ.*/

tables

} {

else

qtabl_fact qtab2_fact qtab3_fact /*

[xp] [yp] [xp] [yp] [xp] [yp] Q-

Set up

tables

=

lqtable [xp] [yp]

=

cqtable[xp]

=

cqtable[xp]

for

other

[yp] [yp]

color

spaces

.

}

[xp] [yp] *= xf cn_jpeg->val [0] ; [xp] [yp] *= xf cn_jpeg->val [0] ; *= xf cn_jpeg->val [0] ; qtab3_fact [xp] [yp] < for (xt xt 0; 8; xt++) { for (yt 0; yt < 8; yt++) { cos ( ( ( (2*xt)+l) *xp*PIE) /16. 0) dctbasis[xp*8+xt] [yp*8+yt] * cos( ( ( (2*yt)+l)*yp*PIE) /16.0) ; cos ( ( ( (2*xp) +1) *xt*PIE) /16 idctbasis[xp*8+xt] [yp*8+yt] * cos(( ( (2*yp)+l)*yt*PIE)/16.0) ; } qtabl_fact

qtab2_fact

=

=

=

=

}

if

if

(xfcn_jpeg->val[l] eob[0]

=

eob[l]

=

eob[2]

=

=

eob[l]

=

eob[2]

=

10; 11; 10;

==1.0)

{

==2.0)

{

==0.0)

{

}

(xfcn_jpeg->val[l] eob[0]

if

11; 11; 11;

}

(xfcn_jpeg->val[l]

11; 10;

eob[0]

=

eob[l]

=

eob[2]

=10;

}

88

.0)

for

(xc

if

0;

=

xc


val [1]

1.0)

==

[xc] [0] [xc] [1] [xc] [2]

{

=

DCLbitlut

=

DCLbitlut DCLbitlut

=

Set up Huffman

DC

codes

[xc] [xc] [xc]

for RGB space.*/

} if

(xfcn_jpeg->val [1] 2.0) { [xc] [0] DCCbitlut [xc] DCbitlut [xc] [1] DCLbitlut [xc] DCbitlut [xc] [2] DCCbitlut [xc]

else

==

DCbitlut

=

=

=

/*

Set up Huffman DC codes

; ; ;

for XYZ.

*/

}

{

else

DCbitlut DCbitlut DCbitlut /*

[xc] [0] [xc] [1] [xc] [2]

=

DCLbitlut

= =

DCCbitlut DCCbitlut

= =

Set up Huffman

DC

codes

[xc] [xc] [xc]

for L C C

spaces.*/

} for

(xc

=

for if

0;

16;++xc ) { 0; yc < 1 0;++yc) { (xfcn_jpeg->val [ 1] 1.0) xc

(yc


val[l]

==2.0)

[xc] [yc] [0] [xc] [yc] [1] [xc] [yc] [2]

Set up Huf fman AC

{

=

ACCbitlut

=

ACLbitlut

=

ACCbitlut

codes

[xc] [yc] [xc] [yc] [xc] [yc]

for XYZ

space

.

} else

{ ACbitlut ACbitlut ACbitlut /*

/*

the

actual

=

ACLbitlut

=

ACCbitlut

=

ACCbitlut

codes

(xb

[xc] [yc] [xc] [yc] [xc] [yc]

for L C C

*/

spaces.

compression/decompression.

0; xb < width; xb += 8) { ff lush(stdout) ; printf ("rows %4d\r", xb) ; for (yb 0; yb < height; yb += 8) { for (xp 0; xp < 8; xp++) { for (yp 0; yp < 8; yp++) { for

/*

Set up Huf fman AC

begins

And here

[xc] [yc] [0] [xc] [yc] [1] [xc] [yc] [2]

.

=

*/

=

=

=

xtmp

index

=

xb =

source source

source

+

xp;

ytmp

(yb+yp)*ll

[xp] [yp] [0] [xp] [yp] [1] [xp] [yp] [2]

+

=

yb

+

yp;

(xb+xp) *crs->hdr

.color_planes;

crs->cdata[index+0]

HALFSCL

crs->cdata[index+l]

HALFSCL

crs->cdata

}

89

[index+2

]

HALFSCL

*/

} /*

This

for

section

of

code

computes

0; xp < 8; xp++) { (xp for (yp 0; yp < 8; yp++) sum [ 0 ] 0.0; sum[l] 0.0; sum [ 2 ] 0.0;

the

FDCT coefficients.

=

{

=

=

=

=

if

( (yp

0) && (xp 0.5; if ( (yp 0) && 0.707107; if ( (yp != 0) && 0.707107;

CC

==

0) )

==

=

else

==

CC

(xp

!=

0))

(xp

==

0))

=

else

CC

=

else

CC

for

1.0;

=

(xt

0;

xt++) { 8; yt++) { basis = dctbasis [xp*8+xt] [yp*8+yt] ; * sum[0] += (source [xt] [yt] [0] basis) += sum[l] (source[xt] [yt] [1] * basis) * sum[2] += (source[xt] [yt] [2] basis) } } dctcof [xp] [yp] [0] (0.25*CC*sum[0] ) dctcof [xp] [yp] [1] (0.25*CC*sum[l] ) dctcof [xp] [yp] [2] (0.25*CC*sum[2] )

for

=

(yt

=

xt

0;

Suggest Documents