The DCT domain and JPEG

Similar documents
INF5063: Programming heterogeneous multi-core processors. September 17, 2010

Introduction ti to JPEG

Steganography using Odd-even Based Embedding and Compensation Procedure to Restore Histogram

Breaking the OutGuess

Features. Sequential encoding. Progressive encoding. Hierarchical encoding. Lossless encoding using a different strategy

Steganography: Hiding Data In Plain Sight. Ryan Gibson

AN ANALYSIS OF VARIOUS STEGANOGRAPHIC ALGORITHMS

IMAGE COMPRESSION USING FOURIER TRANSFORMS

Multimedia Systems Image III (Image Compression, JPEG) Mahdi Amiri April 2011 Sharif University of Technology

Image Compression Techniques

Wireless Communication

Lecture 5: Compression I. This Week s Schedule

An introduction to JPEG compression using MATLAB

A Reversible Data Hiding Scheme For JPEG Images

2.2: Images and Graphics Digital image representation Image formats and color models JPEG, JPEG2000 Image synthesis and graphics systems

Digital Image Representation. Image Representation. Color Models

DigiPoints Volume 1. Student Workbook. Module 8 Digital Compression

Lecture 8 JPEG Compression (Part 3)

Jeff Hinson CS525, Spring 2010

Robert Matthew Buckley. Nova Southeastern University. Dr. Laszlo. MCIS625 On Line. Module 2 Graphics File Format Essay

Digital Image Representation Image Compression

In 2001, US officials stated that they have suspicions that terrorists communicate using steganography in the internet.

ECE 417 Guest Lecture Video Compression in MPEG-1/2/4. Min-Hsuan Tsai Apr 02, 2013

JPEG. Wikipedia: Felis_silvestris_silvestris.jpg, Michael Gäbler CC BY 3.0

Steganography. Brent McClain Rob Carey

Lecture 8 JPEG Compression (Part 3)

Chaos-based Modified EzStego Algorithm for Improving Security of Message Hiding in GIF Image

compression and coding ii

7: Image Compression

EMPIRICAL ANALYSIS ON STEGANOGRAPHY USING JSTEG, OUTGUESS 0.1 AND F5 ALGORITHMS

HYBRID TRANSFORMATION TECHNIQUE FOR IMAGE COMPRESSION

Multimedia Signals and Systems Still Image Compression - JPEG

Compression-Compatible Fragile and Semi-Fragile Tamper Detection

F5 A Steganographic Algorithm

LETTER Improvement of JPEG Compression Efficiency Using Information Hiding and Image Restoration

Compression II: Images (JPEG)

Ian Snyder. December 14, 2009

Video Compression An Introduction

Digital Image Processing

Forensic analysis of JPEG image compression

Image Steganography (cont.)

JPEG Modes of Operation. Nimrod Peleg Dec. 2005

JPEG decoding using end of block markers to concurrently partition channels on a GPU. Patrick Chieppe (u ) Supervisor: Dr.

Digital Image Steganography Techniques: Case Study. Karnataka, India.

COLOR IMAGE COMPRESSION USING DISCRETE COSINUS TRANSFORM (DCT)

Topics. Number Theory Review. Public Key Cryptography

VC 12/13 T16 Video Compression

Secure Information Hiding Portfolio. Ruoxi Li

Hiding of Random Permutated Encrypted Text using LSB Steganography with Random Pixels Generator

CMPT 365 Multimedia Systems. Media Compression - Image

Enhancing the Image Compression Rate Using Steganography

A Image Comparative Study using DCT, Fast Fourier, Wavelet Transforms and Huffman Algorithm

SD 575 Image Processing

SECURITY METHOD FOR COMBINATION STEGANOGRAPHY ALGORITHMS ON TRANSFORM DOMAIN FOR JPEG IMAGES

DIGITAL TELEVISION 1. DIGITAL VIDEO FUNDAMENTALS

AUDIOVISUAL COMMUNICATION

AN4996 Application note

7.5 Dictionary-based Coding

The term, steganography, comes from Greek roots, Image steganography and steganalysis Mayra Bachrach and Frank Y.

Watermarking Moble Phone Color Images With Error Correction Codes

A Steganography method for JPEG2000 Baseline System

Image, video and audio coding concepts. Roadmap. Rationale. Stefan Alfredsson. (based on material by Johan Garcia)

Bit Adjusting Image Steganography in Blue Channel using AES and Secured Hash Function

Nios II Embedded Electronic Photo Album

JPEG Compression Using MATLAB

Compression of Stereo Images using a Huffman-Zip Scheme

Sign-up Sheet posted outside of my office HFH 1121

Invisible Image Watermarking Using Hybrid DWT Compression-Decompression Technique

Digital Video Processing

ROI Based Image Compression in Baseline JPEG

Lecture 6 Introduction to JPEG compression

2014 Summer School on MPEG/VCEG Video. Video Coding Concept

Color Imaging Seminar. Yair Moshe

Robbery Detection Camera

Steganography and Steganalysis

Content-independent steganography and steganalysis of JPEG images

Introduction to Video Compression

A Secure Image Communication Scheme based on combination of Compression, Cryptography and Steganography

Steganography: Dct Coefficient Replacement Method and Compare With JSteg Algorithm

Interframe coding A video scene captured as a sequence of frames can be efficiently coded by estimating and compensating for motion between frames pri

Steganalysis Techniques: A Comparative Study

Lecture 3 Image and Video (MPEG) Coding

DIGITAL IMAGE WATERMARKING BASED ON A RELATION BETWEEN SPATIAL AND FREQUENCY DOMAINS

Abstract. Keywords: Semi-fragile watermarking, DCT embedding, Localisation, Restoration

Image Compression Standard: Jpeg/Jpeg 2000

VIDEO SIGNALS. Lossless coding

Motivation. Gray Levels

Image Compression Algorithm and JPEG Standard

JPEG Compression. What is JPEG?

The Core Technology of Digital TV

From Wikipedia, the free encyclopedia

Index. 1. Motivation 2. Background 3. JPEG Compression The Discrete Cosine Transformation Quantization Coding 4. MPEG 5.

CS1114 Assignment 5 Part 1

A Blind Steganalysis on JPEG Gray Level Image Based on Statistical Features and its Performance Analysis

STEGANALYSIS OF STEGOSTORAGE LIBRARY

Lab # 2 - ACS I Part I - DATA COMPRESSION in IMAGE PROCESSING using SVD

Steganography and Steganalysis of JPEG Images

Quo Vadis JPEG : Future of ISO /T.81

Redundant Data Elimination for Image Compression and Internet Transmission using MATLAB

The Analysis and Detection of Double JPEG2000 Compression Based on Statistical Characterization of DWT Coefficients

Transcription:

The DCT domain and JPEG CSM25 Secure Information Hiding Dr Hans Georg Schaathun University of Surrey Spring 2009 Week 3 Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 1 / 47

Learning Objectives Be able to work with and JPEG images and other representations in the transform domain. Understand what happens during JPEG compression, and its potential 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 2009 Week 3 2 / 47

Outline Overview 1 Overview 2 Image Representation 3 Compression 4 Steganography in JPEG 5 Matlab Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 3 / 47

Overview The elements of JPEG Operates on luminence and chrominance (YCbCr) (not on RGB) Grayscale images have luminence component only. Downsampling Works in the DCT domain (not the spatial domain) Quantisation Entropy coding (lossless compression) Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 4 / 47

Overview JPEG is not a file format JPEG is a compression system The 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 meta information. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 5 / 47

Overview Reading Core Reading Digital Image Processing Using MATLAB. Chapter 6: colour images Representation Processing Conversion Chapter 8.5: JPEG compression Chapter 4: Frequency domain processing Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 6 / 47

Outline Image Representation 1 Overview 2 Image Representation Alternatives to RGB The blockwise DCT domain 3 Compression 4 Steganography in JPEG 5 Matlab Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 7 / 47

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 either A colour vector (R, G, B); or a 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,..., 2 16 1}; 16-bit integer (uint16 in matlab) Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 8 / 47

Alternatives to RGB Image Representation Alternatives to RGB NTSC : (Y, I, Q) where R, G, B [0, 1]. YCbCr : (Y, Cb, Cr) Y 0.299 0.587 0.114 R I = 0.596 0.274 0.322 G Q 0.211 0.523 0.312 B Y 16 65.481 128.553 24.966 R Cb = 128 + 37.797 74.203 112.000 G Cr 128 112.000 93.786 18.214 B where R, G, B [0, 1] and Y, Cb, Cr [0, 255]. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 9 / 47

Image Representation The blockwise DCT domain Block-wise Each colour-channel (Y,Cb,Cr) considered separately M N matrix divided into 8 8 blocks Each block is handled separately Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 10 / 47

The DCT transform Image Representation The blockwise DCT domain Several different DCT transform. We use the following. T f (u, v) = M 1 N 1 x=0 y=0 α(u)α(v) f (x, y) cos MN (2x + 1)uπ 2M cos (2y + 1)vπ 2N where α(a) = M = N = 8, { 1, if a = 0, 2, otherwise. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 11 / 47

The DCT transform Image Representation The blockwise DCT domain The inverse is similar f (x, y) = M 1 N 1 u=0 v=0 α(u)α(v) T f (u, v) cos MN (2x + 1)uπ 2M cos (2y + 1)vπ 2N where α(a) = M = N = 8, { 1, if a = 0, 2, otherwise. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 12 / 47

Image Representation The blockwise DCT domain Matlab Matlab functions dct2 (2D DCT transform) idct2 (Inverse) blkproc ( X, [M N], FUN ) For instance blkproc ( X, [8 8], @dct2 ) Use help system for details Do not use imread for JPEG images converts images to the spatial domain. you don t even know the compression parameters... Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 13 / 47

Image Representation The blockwise DCT domain Transform image Linear combination of patterns (see right) DC (upper left) gives average colour intensity Low frequency: coarse structure High frequency: fine details Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 14 / 47

Outline Compression 1 Overview 2 Image Representation 3 Compression Downsampling Quantisation Source Coding 4 Steganography in JPEG 5 Matlab Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 15 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What is sampling? Fact The human eye is more sensitive to changes in luminance than in chrominance. 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 Cr Still use M M for Y Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 16 / 47

Compression Downsampling What do we save? Original: M N pixels 3 components. Compressed: 2 M 2 N 2 + M N = 11 2 M N Ratio We just saved 50% Compressed Original = 1 1 2 MN 3MN = 1 2. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 17 / 47

Compression Downsampling What do we save? Original: M N pixels 3 components. Compressed: 2 M 2 N 2 + M N = 11 2 M N Ratio We just saved 50% Compressed Original = 1 1 2 MN 3MN = 1 2. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 17 / 47

Compression Downsampling What do we save? Original: M N pixels 3 components. Compressed: 2 M 2 N 2 + M N = 11 2 M N Ratio We just saved 50% Compressed Original = 1 1 2 MN 3MN = 1 2. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 17 / 47

Compression Downsampling What do we save? Original: M N pixels 3 components. Compressed: 2 M 2 N 2 + M N = 11 2 M N Ratio We just saved 50% Compressed Original = 1 1 2 MN 3MN = 1 2. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 17 / 47

Compression Downsampling Chrominance versus Luminence Fact The human eye is more sensitive to changes in luminance than in chrominance. Watermarking tend to embed in Y (luminence) Embedding in Cb and Cr would more easily be destroyed by JPEG Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 18 / 47

Compression Downsampling Chrominance versus Luminence Fact The human eye is more sensitive to changes in luminance than in chrominance. Watermarking tend to embed in Y (luminence) Embedding in Cb and Cr would more easily be destroyed by JPEG Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 18 / 47

Compression Downsampling Chrominance versus Luminence Fact The human eye is more sensitive to changes in luminance than in chrominance. Watermarking tend to embed in Y (luminence) Embedding in Cb and Cr would more easily be destroyed by JPEG Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 18 / 47

Compression Downsampling Downsampling in JPEG 1 Translation to YCbCr. 2 Downsampling 3 DCT transform Each downsampled component matrix Y, Cb, Cr is Divided into 8 8 blocks DCT transformed blockwise An 8 8 block in Cb can be associated with 1,2 or 4 Y blocks depending on downsampling. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 19 / 47

What is quantisation? Rounding in general Compression Quantisation Rounding numbers is quantisation. Measuring gives continuous numbers Whether you measure pixel luminence, or the length of your 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 (8bit integers). Computer memory is finite, 256 different possibilites for a byte Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 20 / 47

Compression Quantisation Quantisation in JPEG Quantisation in the DCT domain Each 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 2009 Week 3 21 / 47

Compression Quantisation Example Quantisation in JPEG 2 3 2 3 DCT matrix Quantisation matrix 415 30 61 27 56 20 2 0 16 11 10 16 24 40 51 61 4 22 61 10 13 7 9 5 12 12 14 19 26 58 60 55 47 7 77 25 29 10 5 6 14 13 16 24 40 57 69 56 49 12 34 15 10 6 2 2./ 14 17 22 29 51 87 80 62 12 7 13 4 2 2 3 3 18 22 37 56 68 109 103 77 6 8 3 2 6 2 1 4 2 7 624 35 55 64 81 104 113 92 7 4 1 0 0 2 1 3 4 15 449 64 78 87 103 121 120 1015 0 0 1 4 1 0 1 2 72 92 95 98 112 100 103 99 2 3 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 0 1 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 7 4 0 0 0 0 0 0 0 05 0 0 0 0 0 0 0 0 Example from Wikipedia. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 22 / 47

Entropy Coding Compression Source Coding Recall 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 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Observe 0 is extremely common ±1 is common Two-digit numbers are very rare This is typical Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 23 / 47

Entropy Coding Compression Source Coding In order to compress the data Use few bits (short codewords) for frequent symbols Many 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 2009 Week 3 24 / 47

Outline Steganography in JPEG 1 Overview 2 Image Representation 3 Compression 4 Steganography in JPEG Into the compressed domain JSteg and OutGuess 0.1 5 Matlab Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 25 / 47

Steganography in JPEG Before or after compression Into the compressed domain pixmap message LSB embedding JPEG compression stegoimage pixmap JPEG compression message LSB embedding stegoimage Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 26 / 47

Steganography in JPEG Into the compressed domain Fragility of LSB LSB embedding is criticised for being fragile JPEG removes insignificant information... such as the LSB JPEG compression after embedding (probably) ruins the message When is this a problem? Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 27 / 47

Steganography in JPEG When fragility is a problem Into the compressed domain It is a problem in robust watermarking JPEG compression is common-place most 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 2009 Week 3 28 / 47

Steganography in JPEG When fragility is a problem Into the compressed domain It is a problem in robust watermarking JPEG compression is common-place most 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 2009 Week 3 28 / 47

Steganography in JPEG When fragility is a problem Into the compressed domain It is a problem in robust watermarking JPEG compression is common-place most 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 2009 Week 3 28 / 47

Steganography in JPEG Into the compressed domain Double compression Common bug in existing software Read an arbitrary image file JPEG is decompressed on reading... pixmap Embedding works on JPEG image is compressed to produce JPEG signal quality factor (QF) either default or supplied by user A JPEG steganogram has now been compressed twice different QF produces an artifact Is there any reason for de- and recompressing? Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 29 / 47

Important lessons Steganography in JPEG Into the compressed domain 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-) format i.e. the format you are allowed to use on the channel. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 30 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

Steganography in JPEG Into the compressed domain Main development The past at a glance Core Reading Hide and Seek: An Introduction to Steganography by Niels Provos and Peter Honeyman, in IEEE Security & Privacy 2003. 1 JSteg was published 2 JSteg was broken 3 OutGuess was published 4 OutGuess was broken 5 F5 was published 6 F5 was broken Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 31 / 47

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 2009 Week 3 32 / 47

Steganography in JPEG JSteg and OutGuess 0.1 Pseudocode The JSteg algorithm Input: Image I, Message m Output: Image J for each bit b of m c := next DCT coefficient from I while c = 0 or c = 1, c := next DCT coefficient from I end while c := c c mod 2 + b replace 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 2009 Week 3 33 / 47

Bitflips in JSteg Steganography in JPEG JSteg and OutGuess 0.1 Cover Stego 5 5 4 3 4 3 2 1 2 1 0 +1 +2 +3 +4 +5 0 +1 +2 +3 +4 +5 Typical JPEG. Typical JSteg. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 34 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

Pros and Cons Steganography in JPEG JSteg and OutGuess 0.1 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 2009 Week 3 35 / 47

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? Solution Choose random coefficients from the entire image. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 36 / 47

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? Solution Choose random coefficients from the entire image. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 36 / 47

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? Solution Choose random coefficients from the entire image. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 36 / 47

Steganography in JPEG JSteg and OutGuess 0.1 Pseudocode Outguess 0.1 Input: Image I, Message m, Key k Output: Image J Seed PRNG with k for each bit b of m c := pseudo-random DCT coefficient from I while c = 0 or c = 1, c := pseudo-random DCT coefficient from I end while c := c c mod 2 + b replace 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 2009 Week 3 37 / 47

Histogramme analysis Steganalysis Steganography in JPEG JSteg and OutGuess 0.1 1 Pairs of values Generalised χ 2 works 2 Symmetry Embedding exchange +2 +3 and 2 1. The DCT histogramme is expected to be symmetric Outguess/JSteg destroy the symmetry. Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 38 / 47

Outline Matlab 1 Overview 2 Image Representation 3 Compression 4 Steganography in JPEG 5 Matlab The JPEG toolbox Randomness Masking Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 39 / 47

JPEG Toolbox Reading a JPEG image Matlab The JPEG toolbox» im = jpeg_read ( Kerckhoffs.jpg ) im = image_width: 180 image_height: 247 image_components: 3 image_color_space: 2 jpeg_components: 3 jpeg_color_space: 3 comments: {} coef_arrays: {[248x184 double] [128x96 double] [128x96 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 2009 Week 3 40 / 47

JPEG Toolbox JPEG data Matlab The JPEG toolbox» Xy = im.coef_arrays{im.comp_info(1).component_id} ;» whos Xy Name Size Bytes Class Attributes Xy 248x184 365056 double» Q = im.quant_tables{im.comp_info(1).quant_tbl_no} Q =» 6 4 4 6 10 16 20 24 5 5 6 8 10 23 24 22 6 5 6 10 16 23 28 22 6 7 9 12 20 35 32 25 7 9 15 22 27 44 41 31 10 14 22 26 32 42 45 37 20 26 31 35 41 48 48 40 29 37 38 39 45 40 41 40 Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 41 / 47

Matlab The JPEG toolbox w/o the toolbox Load/Save workspace jpeg_read and jpeg_write are compiled functions, Available on web page for Intel/Linux and Intel/Windows Compilation required for other systems. If you have trouble with the toolbox, it is possible to load/save files as Matlab workspaces.» load image.mat» whos Name Size Bytes Class Attributes im 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 2009 Week 3 42 / 47

Other toolbox functions Matlab The JPEG toolbox If you want to write your own (de)compressor, the following functions are useful. bdct, ibdct, quantize, dequantize Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 43 / 47

Matlab Randomness Pseudo-random number generators A pseudo-random number generator (PRNG) finite state machine starting state given by user input the seed each transition outputs a number observing a sequence of number, it is computationally infeasible to predict the next number looks random It is deterministic if sender and receiver share the seed (a key) they can generate the same sequence Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 44 / 47

Random locations Matlab Randomness Many ways to do it but some makes it hard to avoid using the same pixel twice A simple approach 1 randomly permute the pixels 2 embed in the first pixels in the permuted sequence 3 reverse the permutation If the sender and receiver use the same PRNG seed, they get the same pseudo-random permutation Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 45 / 47

Matlab functions Matlab Randomness Many functions using a PRNG rand, randperm, randn And one dedicated for performing random permutations new = randintrlv ( old, seed ) the seed is given directly when the permutation is used reverse: old = randdeintrlv ( new, seed ) new/old should be a 1D vector serialise the image into a vector (im(:)) before randintrlv reshape ( vector, [ N, M ] ) to recover the 2D image after randdeintrlv Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 46 / 47

Matlab Masking Masking Boolean matrix as index Matlab allows Boolean (logical) matrices as indices Say A is an n m matrix B = logical(ones(n,m)) B(1,1) = 0 A(B) will be all elements of A except (1, 1) repmat(b,m,n) replicates B to form a larger matrix m times the heigh n times the width How do you extract the AC coefficients in a JPEG image? Make an 8 8 mask of ones Set the DC entry to 0, e.g. (1, 1) Replicate the mask using repmat Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 47 / 47

Matlab Masking Masking Boolean matrix as index Matlab allows Boolean (logical) matrices as indices Say A is an n m matrix B = logical(ones(n,m)) B(1,1) = 0 A(B) will be all elements of A except (1, 1) repmat(b,m,n) replicates B to form a larger matrix m times the heigh n times the width How do you extract the AC coefficients in a JPEG image? Make an 8 8 mask of ones Set the DC entry to 0, e.g. (1, 1) Replicate the mask using repmat Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 47 / 47

Matlab Masking Masking Boolean matrix as index Matlab allows Boolean (logical) matrices as indices Say A is an n m matrix B = logical(ones(n,m)) B(1,1) = 0 A(B) will be all elements of A except (1, 1) repmat(b,m,n) replicates B to form a larger matrix m times the heigh n times the width How do you extract the AC coefficients in a JPEG image? Make an 8 8 mask of ones Set the DC entry to 0, e.g. (1, 1) Replicate the mask using repmat Dr Hans Georg Schaathun The DCT domain and JPEG Spring 2009 Week 3 47 / 47