the dct domain and jpeg - university of surrey

102
The DCT domain and JPEG CSM25 Secure Information Hiding Dr Hans Georg Schaathun University of Surrey Spring 2008 Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 1 / 62

Upload: others

Post on 26-Oct-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The DCT domain and JPEG - University of Surrey

The DCT domain and JPEGCSM25 Secure Information Hiding

Dr Hans Georg Schaathun

University of Surrey

Spring 2008

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 1 / 62

Page 2: The DCT domain and JPEG - University of Surrey

Learning Objectives

Be able to work with and JPEG images and other representationsin the transform domain.Understand what happens during JPEG compression, and itspotential consequence to watermarking and steganography.Be able to apply simple LSB embedding in the JPEG domain.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 2 / 62

Page 3: The DCT domain and JPEG - University of Surrey

Overview

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 3 / 62

Page 4: The DCT domain and JPEG - University of Surrey

Overview

The elements of JPEG

Operates on luminence and chrominance (YCbCr) (not on RGB)Grayscale images have luminence component only.

DownsamplingWorks in the DCT domain (not the spatial domain)QuantisationEntropy coding (lossless compression)

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 4 / 62

Page 5: The DCT domain and JPEG - University of Surrey

Overview

JPEG is not a file format

JPEG is a compression systemThe system employs three different compression techniques

JPEG is not a file format.Files with extension .jpeg are often JFIF or EXIF.

JFIF is traditionally the most common file format for JPEG.EXIF is made for digital cameras and contain extra metainformation.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 5 / 62

Page 6: The DCT domain and JPEG - University of Surrey

Overview

Reading

Core ReadingDigital Image Processing Using MATLAB.

Chapter 6: colour imagesRepresentationProcessingConversion

Chapter 8.5: JPEG compressionChapter 4: Frequency domain processing

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 6 / 62

Page 7: The DCT domain and JPEG - University of Surrey

Image Representation Alternatives to RGB

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 7 / 62

Page 8: The DCT domain and JPEG - University of Surrey

Image Representation Alternatives to RGB

The RGB colour representations

RGB : A colour is a vector (R, G, B)

R is amount of red light.G is amount of green light.B is amount of blue light.

Each pixel can be eitherA colour vector (R, G, B); ora reference to an array of colour vectors (the palette)

Each coefficient can be∈ [0, 1]; floating point (double in matlab)∈ {0, 1, . . . , 255}; 8-bit integer (uint8 in matlab)∈ {0, 1, . . . , 216 − 1}; 16-bit integer (uint16 in matlab)

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 8 / 62

Page 9: The DCT domain and JPEG - University of Surrey

Image Representation Alternatives to RGB

Alternatives to RGB

NTSC : (Y , I, Q)YIQ

=

0.299 0.587 0.1140.596 −0.274 −0.3220.211 −0.523 0.312

RGB

where R, G, B ∈ [0, 1].YCbCr : (Y , Cb, Cr) Y

CbCr

=

16128128

+

65.481 128.553 24.966−37.797 −74.203 112.000112.000 −93.786 −18.214

RGB

where R, G, B ∈ [0, 1] and Y , Cb, Cr ∈ [0, 255].

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 9 / 62

Page 10: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 10 / 62

Page 11: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

Block-wise

Each colour-channel (Y,Cb,Cr) considered separatelyM × N matrix divided into 8× 8 blocksEach block is handled separately

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 11 / 62

Page 12: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

The DCT transform

Several different DCT transform.We use the following.

Tf (u, v) =M−1∑x=0

N−1∑y=0

f (x , y)

√α(u)α(v)

MNcos

(2x + 1)uπ

2Mcos

(2y + 1)vπ

2N

where

α(a) =

{1, if a = 0,

2, otherwise.

M = N = 8,

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 12 / 62

Page 13: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

The DCT transform

The inverse is similar

f (x , y) =M−1∑u=0

N−1∑v=0

Tf (u, v)

√α(u)α(v)

MNcos

(2x + 1)uπ

2Mcos

(2y + 1)vπ

2N

where

α(a) =

{1, if a = 0,

2, otherwise.

M = N = 8,

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 13 / 62

Page 14: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

Matlab

Matlab functionsdct2 (2D DCT transform)idct2 (Inverse)blkproc ( X, [M N], FUN )

For instanceblkproc ( X, [8 8], @dct2 )

Use help system for detailsUnfortunately, we do not have the JPEG toolbox.

Loading JPEG images converts them to the spatial domain.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 14 / 62

Page 15: The DCT domain and JPEG - University of Surrey

Image Representation The blockwise DCT domain

Transform image

Linear combination of patterns (seeright)DC (upper left) gives average colourintensityLow frequency: coarse structureHigh frequency: fine details

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 15 / 62

Page 16: The DCT domain and JPEG - University of Surrey

Compression Downsampling

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 16 / 62

Page 17: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 18: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 19: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 20: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 21: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 22: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 23: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 24: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 25: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 26: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What is sampling?

FactThe human eye is more sensitive to changes in luminance than inchrominance.

To sample is to collect measurements.Each pixel is a sample (measuring the colour of the image).Lower resolution means fewer samples.Reducing resolution = downsampling

Basic M × N image: N ·M samples per component (Y , Cb, Cr ).Y is more useful than Cb and Cr .Therefore we can downsample Cb and Cr

M/2× N/2 is common for Cb and CrStill use M ×M for Y

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 17 / 62

Page 27: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What do we save?

Original: M × N pixels ×3 components .Compressed:

2× M2× N

2+ M × N = 1

12

M × N

RatioCompressed

Original=

112MN

3MN=

12.

We just saved 50%

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 18 / 62

Page 28: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What do we save?

Original: M × N pixels ×3 components .Compressed:

2× M2× N

2+ M × N = 1

12

M × N

RatioCompressed

Original=

112MN

3MN=

12.

We just saved 50%

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 18 / 62

Page 29: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What do we save?

Original: M × N pixels ×3 components .Compressed:

2× M2× N

2+ M × N = 1

12

M × N

RatioCompressed

Original=

112MN

3MN=

12.

We just saved 50%

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 18 / 62

Page 30: The DCT domain and JPEG - University of Surrey

Compression Downsampling

What do we save?

Original: M × N pixels ×3 components .Compressed:

2× M2× N

2+ M × N = 1

12

M × N

RatioCompressed

Original=

112MN

3MN=

12.

We just saved 50%

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 18 / 62

Page 31: The DCT domain and JPEG - University of Surrey

Compression Downsampling

Chrominance versus Luminence

FactThe human eye is more sensitive to changes in luminance than inchrominance.

Watermarking tend to embed in Y (luminence)Embedding in Cb and Cr would more easily be destroyed byJPEG

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 19 / 62

Page 32: The DCT domain and JPEG - University of Surrey

Compression Downsampling

Chrominance versus Luminence

FactThe human eye is more sensitive to changes in luminance than inchrominance.

Watermarking tend to embed in Y (luminence)Embedding in Cb and Cr would more easily be destroyed byJPEG

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 19 / 62

Page 33: The DCT domain and JPEG - University of Surrey

Compression Downsampling

Chrominance versus Luminence

FactThe human eye is more sensitive to changes in luminance than inchrominance.

Watermarking tend to embed in Y (luminence)Embedding in Cb and Cr would more easily be destroyed byJPEG

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 19 / 62

Page 34: The DCT domain and JPEG - University of Surrey

Compression Downsampling

Downsampling in JPEG

1 Translation to YCbCr.2 Downsampling3 DCT transform

Each downsampled component matrix Y , Cb, Cr isDivided into 8× 8 blocksDCT transformed blockwise

An 8× 8 block in Cb can be associated with 1,2 or 4 Y blocksdepending on downsampling.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 20 / 62

Page 35: The DCT domain and JPEG - University of Surrey

Compression Quantisation

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 21 / 62

Page 36: The DCT domain and JPEG - University of Surrey

Compression Quantisation

What is quantisation?Rounding in general

Rounding numbers is quantisation.Measuring gives continuous numbers

Whether you measure pixel luminence, or the length ofyour garage.No matter how close to points are,

there is a point in between.

However, our precision is limited.We give lengths to the nearest unit.Luminence is categorised into 256 intervals (8bitintegers).

Computer memory is finite,256 different possibilites for a byte

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 22 / 62

Page 37: The DCT domain and JPEG - University of Surrey

Compression Quantisation

Quantisation in JPEG

Quantisation in the DCT domainEach coefficient is divided by the quantisation constant.The result is rounded to nearest integer.Different quantisation constants for each coefficient in the block.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 23 / 62

Page 38: The DCT domain and JPEG - University of Surrey

Compression Quantisation

ExampleQuantisation in JPEG

2666666666664

DCT matrix−415 −30 −61 27 56 −20 −2 0

4 −22 −61 10 13 −7 −9 5−47 7 77 −25 −29 10 5 −6−49 12 34 −15 −10 6 2 212 −7 −13 −4 −2 2 −3 3−8 3 2 −6 −2 1 4 2−1 0 0 −2 −1 −3 4 −10 0 −1 −4 −1 0 1 2

3777777777775./

2666666666664

Quantisation matrix16 11 10 16 24 40 51 6112 12 14 19 26 58 60 5514 13 16 24 40 57 69 5614 17 22 29 51 87 80 6218 22 37 56 68 109 103 7724 35 55 64 81 104 113 9249 64 78 87 103 121 120 10172 92 95 98 112 100 103 99

3777777777775

2666666666664

Quantised DCT matrix−26 −3 −6 2 2 −1 0 0

0 −2 −4 1 1 0 0 0−3 1 5 −1 −1 0 0 0−4 1 2 −1 0 0 0 01 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 0

3777777777775Example from Wikipedia.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 24 / 62

Page 39: The DCT domain and JPEG - University of Surrey

Compression Source Coding

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 25 / 62

Page 40: The DCT domain and JPEG - University of Surrey

Compression Source Coding

Entropy Coding

Recall

−26 −3 −6 2 2 −1 0 00 −2 −4 1 1 0 0 0−3 1 5 −1 −1 0 0 0−4 1 2 −1 0 0 0 01 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 0

Observe

0 is extremely common±1 is commonTwo-digit numbers are very rare

This is typical

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 26 / 62

Page 41: The DCT domain and JPEG - University of Surrey

Compression Source Coding

Entropy Coding

In order to compress the dataUse few bits (short codewords) for frequent symbolsMany bits (long codewords) only for rare symbols

Usually, JPEG uses a simple Huffman code.it can use other codes (saving space, but computionally costly)

For instance, a single short codeword to say‘the rest of the block is zero’

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 27 / 62

Page 42: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 28 / 62

Page 43: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Before or after compression

pixmapLSB

embedding// JPEG

compression// stego-

image//

message��

pixmapJPEG

compression// LSB

embedding// stego-

image//

message��

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 29 / 62

Page 44: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Fragility of LSB

LSB embedding is criticised for being fragileJPEG removes insignificant information

... such as the LSB

JPEG compression after embedding (probably) ruins the messageWhen is this a problem?

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 30 / 62

Page 45: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

When fragility is a problem

It is a problem in robust watermarkingJPEG compression is common-placemost applications need robustness

If the purpose is steganography,and Alice and Bob are allowed to exchange pixmaps,then it is not a problem.

Obviously, if your steganogram is supposed to be JPEG... Do not do LSB in the pixmap.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 31 / 62

Page 46: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

When fragility is a problem

It is a problem in robust watermarkingJPEG compression is common-placemost applications need robustness

If the purpose is steganography,and Alice and Bob are allowed to exchange pixmaps,then it is not a problem.

Obviously, if your steganogram is supposed to be JPEG... Do not do LSB in the pixmap.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 31 / 62

Page 47: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

When fragility is a problem

It is a problem in robust watermarkingJPEG compression is common-placemost applications need robustness

If the purpose is steganography,and Alice and Bob are allowed to exchange pixmaps,then it is not a problem.

Obviously, if your steganogram is supposed to be JPEG... Do not do LSB in the pixmap.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 31 / 62

Page 48: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Double compression

Common bug in existing softwareRead a arbitrary image file

JPEG is decompressed on reading... → pixmap

Embedding works on JPEGimage is compressed to produce JPEG signalquality factor (QF) either default or supplied by user

A JPEG steganogram has now been compressed twicedifferent QF produces an artifact

Is there any reason for de- and recompressing?

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 32 / 62

Page 49: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Important lessons

1 Do not make unnecessary image conversions.2 Many techniques apply to any format

LSB applies to JPEG signals... but it is called Jsteg

3 Use a technique which fits the target (stego-) formati.e. the format you are allowed to use on the channel.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 33 / 62

Page 50: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 51: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 52: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 53: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 54: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 55: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Into the compressed domain

Main developmentThe past at a glance

Core Reading

Hide and Seek: An Introduction to Steganography by Niels Provos andPeter Honeyman, in IEEE Security & Privacy 2003.

1 JSteg was published2 JSteg was broken3 OutGuess was published4 OutGuess was broken5 F5 was published6 F5 was broken

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 34 / 62

Page 56: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 35 / 62

Page 57: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

The JSteg algorithm

JSteg denotes a software package.Approach: simple LSB in the DCT domain.No different from LSB in the spatial domainχ2 analysis applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 36 / 62

Page 58: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

PseudocodeThe JSteg algorithm

Input: Image I, Message ~mOutput: Image J

for each bit b of ~mc := next DCT coefficient from Iwhile c = 0 or c = 1,

c := next DCT coefficient from Iend whilec := c mod 2 + breplace coefficient in I by c

end for

May ignore high and/or low frequency coefficients

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 37 / 62

Page 59: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Bitflips in JSteg

0 +1 +2 +3 +4 +5−1−2−3−4−5Cover

0 +1 +2 +3 +4 +5−1−2−3−4−5Stego������ ��

������

���� ��������

�� �� ��������

�� �� ��������

��....

....

�� �� ....

....

�� �� ��....

....

�� ....

....

�� ��

Typical JPEG. Typical JSteg.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 38 / 62

Page 60: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 61: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 62: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 63: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 64: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 65: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 66: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Pros and Cons

Why is JSteg important?First publicly available solution.Simple solution

What are the disadvantages?Similar to LSB in Spatial domain.Histogramme analysis appliesχ2/pairs of values applies

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 39 / 62

Page 67: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Outguess 0.1

How can we improve JSteg?How did we improve LSB in the Spatial Domain?

SolutionChoose random coefficients from the entire image.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 40 / 62

Page 68: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Outguess 0.1

How can we improve JSteg?How did we improve LSB in the Spatial Domain?

SolutionChoose random coefficients from the entire image.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 40 / 62

Page 69: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

Outguess 0.1

How can we improve JSteg?How did we improve LSB in the Spatial Domain?

SolutionChoose random coefficients from the entire image.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 40 / 62

Page 70: The DCT domain and JPEG - University of Surrey

Steganography in JPEG JSteg and OutGuess 0.1

PseudocodeOutguess 0.1

Input: Image I, Message ~m, Key kOutput: Image J

Seed PRNG with kfor each bit b of ~m

c := pseudo-random DCT coefficient from Iwhile c = 0 or c = 1,

c := pseudo-random DCT coefficient from Iend whilec := c mod 2 + breplace coefficient in I by c

end for

May ignore high and/or low frequency coefficients

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 41 / 62

Page 71: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Steganalysis

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 42 / 62

Page 72: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Steganalysis

Histogramme analysis

1 Pairs of valuesGeneralised χ2 works

2 SymmetryEmbedding exchange +2 ↔ +3 and −2 ↔ −1.The DCT histogramme is expected to be symmetricOutguess/JSteg destroy the symmetry.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 43 / 62

Page 73: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Steganalysis

Symmetry analysis

J2i =

(1− q

2

)I2i +

q2

I2i+1,

J2i+i =q2

I2i +

(1− q

2

)I2i+1

Writing

a =1− q/21− q

and b =q/2

1− q,

we get

I2i = aJ2i − bJ2i+1,

I2i+1 = −bJ2i + aJ2i+1.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 44 / 62

Page 74: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Steganalysis

Symmetry analysis (II)

∑i>0

I2i =∑i<0

I2i , and∑i<0

I2i+1 =∑i>0

I2i+1.

In other words ∑i>0

I2i +∑i<0

I2i+1 =∑i<0

I2i +∑i>0

I2i+1.

Substitute for I2i and J2i+1

One equation in one unknown : q

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 45 / 62

Page 75: The DCT domain and JPEG - University of Surrey

Steganography in JPEG Steganalysis

ExerciseSymmetry analysis

∑i>0

I2i +∑i<0

I2i+1 =∑i<0

I2i +∑i>0

I2i+1.

Substitute for I2i and I2i+1get equation in J2i and J2i+1.

Solve for J1, write as equation inJ1 (left hand side)∆i = J2i − J2i+1 (i > 0), and ∆i = J2i+1 − J2i (i < 0).

Solve for qCan you implement the resulting expression for p in Matlab?

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 46 / 62

Page 76: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 47 / 62

Page 77: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Improvements at a glance

F3 – F4 changes the embeddingbetter histogramme – maintain symmetry

Statistics-aware embeddingOutguess 0.2 uses unused capacitydummy changes are used to even out the statistics

Matrix coding/wet paper codingF5 minimises distortion using coding theoryfewer bit-flips per message bittechniques from coding for restricted memory

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 48 / 62

Page 78: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Bitflips in F3

Avoid pairs of values.Always decrease absolute value when changingZeros are ignored.Zero created: reembed in new coefficient

0 +1 +2 +3 +4 +5−1−2−3−4−5Cover

0 +1 +2 +3 +4 +5−1−2−3−4−5Stego��..

....

..

�� ��������

��....

....

�� ....

....

�� ��������

�� ��������

���� �������� ��....

....

�� ....

....

�� ��������

�� ��������

���� ���� ��

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 49 / 62

Page 79: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

The problem of F3

ReembeddingZero created by message zeroesZeros are reembeddedExtra zeros embedded ⇒ overweight of even coefficients.

Typical JPEG. Typical F3.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 50 / 62

Page 80: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F4 : evening out even values

Swap interpretation for negative coefficients+1 causes reembedding of zero-1 causes reembedding of one

0 +1 +2 +3 +4 +5−1−2−3−4−5Cover

0 +1 +2 +3 +4 +5−1−2−3−4−5Stego

F3��..

....

..

�� ��������

��....

....

�� ....

....

�� ��������

�� ��������

���� �������� ��....

....

�� ....

....

�� ��������

�� ��������

���� ���� ��

0 +1 +2 +3 +4 +5−1−2−3−4−5Cover

0 +1 +2 +3 +4 +5−1−2−3−4−5Stego

F4��..

....

..

�� ��������

�� ��������

�� ��������

���� ���� ....

....

�� ....

....

���� �� �� ��������

�� ��������

���� ��....

....

�� ....

....

�� ����

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 51 / 62

Page 81: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F4 histogramme

What does the histogramme look like after F4 embedding?Coefficients have generally been decreased.Effect similar to reduced quality factor.F4 (and F5) can be broken

Suggested Reading

Jessica Fridrich, Miroslav Goljan, Dorin Hogea: ‘Steganalysis of JPEGImages: Breaking the F5 Algorithm’. http://www.ws.binghamton.edu/fridrich/Research/F5.pdf

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 52 / 62

Page 82: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F4 histogramme

What does the histogramme look like after F4 embedding?Coefficients have generally been decreased.Effect similar to reduced quality factor.F4 (and F5) can be broken

Suggested Reading

Jessica Fridrich, Miroslav Goljan, Dorin Hogea: ‘Steganalysis of JPEGImages: Breaking the F5 Algorithm’. http://www.ws.binghamton.edu/fridrich/Research/F5.pdf

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 52 / 62

Page 83: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F4 histogramme

What does the histogramme look like after F4 embedding?Coefficients have generally been decreased.Effect similar to reduced quality factor.F4 (and F5) can be broken

Suggested Reading

Jessica Fridrich, Miroslav Goljan, Dorin Hogea: ‘Steganalysis of JPEGImages: Breaking the F5 Algorithm’. http://www.ws.binghamton.edu/fridrich/Research/F5.pdf

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 52 / 62

Page 84: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F4 histogramme

What does the histogramme look like after F4 embedding?Coefficients have generally been decreased.Effect similar to reduced quality factor.F4 (and F5) can be broken

Suggested Reading

Jessica Fridrich, Miroslav Goljan, Dorin Hogea: ‘Steganalysis of JPEGImages: Breaking the F5 Algorithm’. http://www.ws.binghamton.edu/fridrich/Research/F5.pdf

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 52 / 62

Page 85: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

F5 : Matrix embedding

Embedding as F4. . . extra Matrix Coding layer

n coefficients represent k bits

Flip fewer k/2 bits on average.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 53 / 62

Page 86: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

ExampleMatrix embedding

n = 3 coefficients (LSB): x1, x2, x3

k = 2 message bits: m1, m2

Decoderm̂1 = x1 ⊕ x3m̂2 = x2 ⊕ x3

Encoderm1 = x1 ⊕ x3 and m2 = x2 ⊕ x3 : no changem1 6= x1 ⊕ x3 and m2 = x2 ⊕ x3 : change x1m1 = x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x2m1 6= x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x3

Averange number of changes: 3/4 per two bitsCompare to F4 (and others): 1 per two bits

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 54 / 62

Page 87: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

ExampleMatrix embedding

n = 3 coefficients (LSB): x1, x2, x3

k = 2 message bits: m1, m2

Decoderm̂1 = x1 ⊕ x3m̂2 = x2 ⊕ x3

Encoderm1 = x1 ⊕ x3 and m2 = x2 ⊕ x3 : no changem1 6= x1 ⊕ x3 and m2 = x2 ⊕ x3 : change x1m1 = x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x2m1 6= x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x3

Averange number of changes: 3/4 per two bitsCompare to F4 (and others): 1 per two bits

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 54 / 62

Page 88: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

ExampleMatrix embedding

n = 3 coefficients (LSB): x1, x2, x3

k = 2 message bits: m1, m2

Decoderm̂1 = x1 ⊕ x3m̂2 = x2 ⊕ x3

Encoderm1 = x1 ⊕ x3 and m2 = x2 ⊕ x3 : no changem1 6= x1 ⊕ x3 and m2 = x2 ⊕ x3 : change x1m1 = x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x2m1 6= x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x3

Averange number of changes: 3/4 per two bitsCompare to F4 (and others): 1 per two bits

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 54 / 62

Page 89: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

ExampleMatrix embedding

n = 3 coefficients (LSB): x1, x2, x3

k = 2 message bits: m1, m2

Decoderm̂1 = x1 ⊕ x3m̂2 = x2 ⊕ x3

Encoderm1 = x1 ⊕ x3 and m2 = x2 ⊕ x3 : no changem1 6= x1 ⊕ x3 and m2 = x2 ⊕ x3 : change x1m1 = x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x2m1 6= x1 ⊕ x3 and m2 6= x2 ⊕ x3 : change x3

Averange number of changes: 3/4 per two bitsCompare to F4 (and others): 1 per two bits

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 54 / 62

Page 90: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Matrix coding

Longer codewords (larger n) saves moree.g. k = 9; n = 511: change ≈ 1/9 pixels per message bitMatrix embedding based on coding theoryWe will return to coding theory and matrix coding later

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 55 / 62

Page 91: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 92: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 93: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 94: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 95: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 96: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Statistics-aware embeddingOutguess 0.2

Modify unused coefficientsMimick original statisticTune for every statistic used in known analysis techniques

OutGuess 0.2Embedding as OutGuess 0.1.Modify selected unused coefficients to correct histogram

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 56 / 62

Page 97: The DCT domain and JPEG - University of Surrey

Steganography in JPEG F3 – 4 – 5

Combinations

Statistics-aware Matrix CodingMore advanced code allows a choice of coefficient to modifyUse choice to mimick original statistical distribution

Known as Wet Paper CodesBased on Dirty Paper Codes by Costa 1983.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 57 / 62

Page 98: The DCT domain and JPEG - University of Surrey

The JPEG toolbox

Outline

1 Overview2 Image Representation

Alternatives to RGBThe blockwise DCT domain

3 CompressionDownsamplingQuantisationSource Coding

4 Steganography in JPEGInto the compressed domainJSteg and OutGuess 0.1SteganalysisF3 – 4 – 5

5 The JPEG toolbox

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 58 / 62

Page 99: The DCT domain and JPEG - University of Surrey

The JPEG toolbox

JPEG ToolboxReading a JPEG image

» im = jpeg_read ( ’Kerckhoffs.jpg’ )

im =image_width: 180image_height: 247

image_components: 3image_color_space: 2jpeg_components: 3jpeg_color_space: 3

comments: {}coef_arrays: {[248x184 double] [128x96 double] [128x96 double]}quant_tables: {[8x8 double] [8x8 double]}

ac_huff_tables: [1x2 struct]dc_huff_tables: [1x2 struct]optimize_coding: 0

comp_info: [1x3 struct]progressive_mode: 0

»

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 59 / 62

Page 100: The DCT domain and JPEG - University of Surrey

The JPEG toolbox

JPEG ToolboxJPEG data

» Xy = im.coef_arrays{im.comp_info(1).component_id} ;» whos XyName Size Bytes Class AttributesXy 248x184 365056 double

» Q = im.quant_tables{im.comp_info(1).quant_tbl_no}

Q =6 4 4 6 10 16 20 245 5 6 8 10 23 24 226 5 6 10 16 23 28 226 7 9 12 20 35 32 257 9 15 22 27 44 41 3110 14 22 26 32 42 45 3720 26 31 35 41 48 48 4029 37 38 39 45 40 41 40

»

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 60 / 62

Page 101: The DCT domain and JPEG - University of Surrey

The JPEG toolbox

w/o the toolboxLoad/Save workspace

jpeg_read and jpeg_write are compiled functions,Non-trivial to install

In the exercises, can load presaved workspaces

» load ’image.mat’» whosName Size Bytes Class Attributesim 1x1 575836 struct

There is one mat-file for each image on the web page

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 61 / 62

Page 102: The DCT domain and JPEG - University of Surrey

The JPEG toolbox

Other toolbox functions

I recommend that you use the other toolbox functionsbdct, ibdct, quantize, dequantize

These are m-files, which can be copied into current directory.

Alternatively, use matlab on tweek which has the toolbox.

Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2008 62 / 62