Digital Image Processing

Similar documents
IMAGE COMPRESSION. Image Compression. Why? Reducing transportation times Reducing file size. A two way event - compression and decompression

Image compression. Stefano Ferrari. Università degli Studi di Milano Methods for Image Processing. academic year

7: Image Compression

Image Compression Algorithm and JPEG Standard

CS 335 Graphics and Multimedia. Image Compression

Lecture 8 JPEG Compression (Part 3)

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

Digital Image Representation Image Compression

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

Lecture 5: Compression I. This Week s Schedule

Topic 5 Image Compression

Image coding and compression

CMPT 365 Multimedia Systems. Media Compression - Image

Lecture 8 JPEG Compression (Part 3)

Video Compression An Introduction

IMAGE COMPRESSION. Chapter - 5 : (Basic)

15 Data Compression 2014/9/21. Objectives After studying this chapter, the student should be able to: 15-1 LOSSLESS COMPRESSION

Image Compression. CS 6640 School of Computing University of Utah

IMAGE COMPRESSION- I. Week VIII Feb /25/2003 Image Compression-I 1

AN ANALYTICAL STUDY OF LOSSY COMPRESSION TECHINIQUES ON CONTINUOUS TONE GRAPHICAL IMAGES

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

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

VC 12/13 T16 Video Compression

CSEP 521 Applied Algorithms Spring Lossy Image Compression

VIDEO SIGNALS. Lossless coding

06/12/2017. Image compression. Image compression. Image compression. Image compression. Coding redundancy: image 1 has four gray levels

Wireless Communication

An introduction to JPEG compression using MATLAB

EE67I Multimedia Communication Systems Lecture 4

Compression II: Images (JPEG)

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

Introduction ti to JPEG

Digital Image Representation. Image Representation. Color Models

MRT based Fixed Block size Transform Coding

Image Coding. Image Coding

IMAGE COMPRESSION USING FOURIER TRANSFORMS

CoE4TN4 Image Processing. Chapter 8 Image Compression

The PackBits program on the Macintosh used a generalized RLE scheme for data compression.

IMAGE COMPRESSION TECHNIQUES

compression and coding ii

1.Define image compression. Explain about the redundancies in a digital image.

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

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

JPEG Compression. What is JPEG?

A COMPRESSION TECHNIQUES IN DIGITAL IMAGE PROCESSING - REVIEW

ROI Based Image Compression in Baseline JPEG

Lossless Compression Algorithms

Fundamentals of Multimedia. Lecture 5 Lossless Data Compression Variable Length Coding

Multimedia Communications. Transform Coding

Image Compression for Mobile Devices using Prediction and Direct Coding Approach

Department of electronics and telecommunication, J.D.I.E.T.Yavatmal, India 2

Lecture Coding Theory. Source Coding. Image and Video Compression. Images: Wikipedia

Image Compression - An Overview Jagroop Singh 1

Compression of Stereo Images using a Huffman-Zip Scheme

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

7.5 Dictionary-based Coding

IMAGE COMPRESSION USING HYBRID QUANTIZATION METHOD IN JPEG

13.6 FLEXIBILITY AND ADAPTABILITY OF NOAA S LOW RATE INFORMATION TRANSMISSION SYSTEM

Chapter 1. Digital Data Representation and Communication. Part 2

Fundamentals of Video Compression. Video Compression

Repetition 1st lecture

Final Review. Image Processing CSE 166 Lecture 18

Week 14. Video Compression. Ref: Fundamentals of Multimedia

Data Compression. Media Signal Processing, Presentation 2. Presented By: Jahanzeb Farooq Michael Osadebey

Multimedia Networking ECE 599

So, what is data compression, and why do we need it?

yintroduction to compression ytext compression yimage compression ysource encoders and destination decoders

Lecture 6: Compression II. This Week s Schedule

IMAGE PROCESSING (RRY025) LECTURE 13 IMAGE COMPRESSION - I

Image Coding and Data Compression

Image Coding and Compression

Data and information. Image Codning and Compression. Image compression and decompression. Definitions. Images can contain three types of redundancy

Welcome Back to Fundamentals of Multimedia (MR412) Fall, 2012 Lecture 10 (Chapter 7) ZHU Yongxin, Winson

( ) ; For N=1: g 1. g n

Professor Laurence S. Dooley. School of Computing and Communications Milton Keynes, UK

3. (a) Prove any four properties of 2D Fourier Transform. (b) Determine the kernel coefficients of 2D Hadamard transforms for N=8.

Computer and Machine Vision

ISSN (ONLINE): , VOLUME-3, ISSUE-1,

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

Digital Image Processing

JPEG: An Image Compression System. Nimrod Peleg update: Nov. 2003

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

A HYBRID DPCM-DCT AND RLE CODING FOR SATELLITE IMAGE COMPRESSION

DIGITAL TELEVISION 1. DIGITAL VIDEO FUNDAMENTALS

Digital Image Processing

Video Compression MPEG-4. Market s requirements for Video compression standard

Forensic analysis of JPEG image compression

Digital Video Processing

Ch. 2: Compression Basics Multimedia Systems

COLOR IMAGE COMPRESSION USING DISCRETE COSINUS TRANSFORM (DCT)

Image Compression Techniques

Image Processing Computer Graphics I Lecture 15

Image Processing. Blending. Blending in OpenGL. Image Compositing. Blending Errors. Antialiasing Revisited Computer Graphics I Lecture 15

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

Ian Snyder. December 14, 2009

Lecture 3 Image and Video (MPEG) Coding

Lecture 6 Introduction to JPEG compression

Image Compression Compression Fundamentals

Multimedia Signals and Systems Still Image Compression - JPEG

Data Compression. An overview of Compression. Multimedia Systems and Applications. Binary Image Compression. Binary Image Compression

Transcription:

Lecture 9+10 Image Compression Lecturer: Ha Dai Duong Faculty of Information Technology 1. Introduction Image compression To Solve the problem of reduncing the amount of data required to represent a digital image Why do we need compression? Data storage Data transmission 2 1

1. Introduction Image compression techniques fall into two broad categories: Information preserving: These methods allow an image to be compressed and decompressed without lossing information. Information lossing: These methods provide higher levels of data reduction but the result in a less than perfect reproduction of original image. 3 1. Introduction How can we implement Compresion Coding redundancy: Most 2-D intensity arrays contain more bits than are needed to represent the intensities Spatial and temporal redundancy: Pixels of most 2- D intensity arrays are correlated spatially and video sequences are temporally correlated Irrelevant information: Most 2-D intensity arrays contain information that is ignored by the human visual system 4 2

2. Fundamentals Data Redundancy Let b and b denote the number of bits in two representations of the same information, the relative data redundancy R is R = 1-1/C C is called the compression ratio, defined as C=b/b For example, C = 10, the corresponding relative data redundancy of the larger representation is 0.9, indicating that 90% of its data is redundant 5 2. Fundamentals Assume that a discrete random variable r k in the interval [0,1] represents the grays of an image and that each r k occurs with probability p k (r k ) If number of bits used to represent each value of r k is l(r k ), then average number of bits required to represent each pixel is 6 3

2. Fundamentals Examples of redundancy 7 2. Fundamentals Coding Redundancy The average number of bits required to represent each pixel is L 1 L = l( r ) p ( r ) = 0.25(2) + 0.47(1) + 0.24(3) + 0.03(3) = 1.81bits avg k r k k = 0 8 C = 4.42 1.81 R = 1 1/ 4.42 = 0.774 8 4

2. Fundamentals Spatial and Temporal Redundancy 1. All 256 intensities are equally probable. 2. The pixels along each line are identical. 3. The intensity of each line was selected randomly. 9 2. Fundamentals Spatial and Temporal Redundancy Run-length pair specifies the start of a new intensity and the number of consecutive pixels that have that intensity. Each 256-pixel line of the original representation is replaced by a single 8-bit intensity value and length 256 in the run-length representation. The compression ratio is 256 256 8 = 128:1 (256 + 256) 8 10 5

2. Fundamentals Irrelevant information 256 256 8 / 8 = 65536 :1 11 2. Fundamentals The previous example shown that image data can be redunced! The question that naturally arises is How few data actually are needed to represent an image? 12 6

2. Fundamentals Measuring (Image) Information A random event E that occurs with probability P(E) is said to containt: (1) units of information The quantity I(E) often is called the self-information of E If P(E)=1, the event E always occurs, I(E) =0 -> No information is attributed to it. The base of logarithm determines the unit used to measure information. If the base 2 is selected the resulting unit of information is called a bit. For example, if P(E)=1/2, I(E)= - log 2 (1/2) =1. That means, 1 bit is the amount of Information to describe event E. 13 2. Fundamentals Measuring (Image) Information Give a source of statistically independent random events from a discrete set possible events {a 1, a 2,.., a J } with associated probabilities {P(a 1), P(a 2),.., P(a J )}, the average information per source output, called the entropy of the source (2) a j is called source symbols. Because they are statistically independent, the source called zeromemory source 14 7

2. Fundamentals Measuring (Image) Information If an image is considered to be the output of an imaginary zero-memory Intensity source, we can use the histogram of the observed image to estimate the symbol probabilities of the source. The intensity source s entropy becames P r (r k ) the normalized histogram (3) 15 2. Fundamentals For example 16 8

3. Image Compression models 17 3. Image Compression models Some standards 18 9

3. Image Compression models Some standards 19 3. Image Compression models Some standards 20 10

3. Image Compression models Some standards 21 4. Huffman Coding 22 11

4. Huffman Coding The average length of this code is L = 0.4*1+ 0.3* 2 + 0.1*3+ 0.1* 4 + 0.06*5 + 0.04*5 avg = 2.2 bits/pixel 23 5. Arithmetic Coding => 0.068 can be a code word for a 1 a 2 a 3 a 3 a 4 24 12

5. Arithmetic Coding 1.0 0.8 0.72 0.592 a 4 Decode 0.572. The length of the 0.5728 message is 5? a 3 0.8 0.72 0.688 0.5856 0.57152 Since 0.8>code word > 0.4, the first symbol should be a 3. 0.4 0.56 0.624 0.5728 056896 a 2 a 1 0.2 0.0 0.48 0.4 0.592 0.5664 0.56768 0.56 0.56 0.5664 Therefore, the message is a 3 a 3 a 1 a 2 a 4 25 6. LZW Coding LZW (Lempel-Ziv-Welch) coding, assigns fixedlength code words to variable length sequences of source symbols Requires no a priori knowledge of the probability of the source symbols. LZW was formulated in 1984 26 13

6. LZW Coding The ideas A codebook or dictionary containing the source symbols is constructed For 8-bit monochrome images, the first 256 words of the dictionary are assigned to the gray levels 0-255 27 6. LZW Coding Important features The dictionary is created while the data are being encoded. So encoding can be done on the fly The dictionary is not required to be transmitted. The dictionary will be built up in the decoding If the dictionary overflows then we have to reinitialize the dictionary and add a bit to each one of the code words. Choosing a large dictionary size avoids overflow, but spoils compressions 28 14

6. LZW Coding Example Initial Dictionary Image 39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126 29 6. LZW Coding 39 39 126 126 39 39 126 126 39 39 126 126 39 39 126 126 30 15

6. LZW Coding Decoding LZW Let the bit stream received be: 39-39 - 126 126-256 - 258-260 - 259-257 - 126 In LZW, the dictionary which was used for encoding need not be sent with the image. A separate dictionary is built by the decoder, on the fly, as it reads the received code words. 31 6. LZW Coding Recognized Encoded value pixels Dic. address Dic. entry 39 39 39 39 39 256 39-39 39 126 126 257 39-126 126 126 126 258 126-126 126 256 39-39 259 126-39 256 258 126-126 260 39-39-126 258 260 39-39-126 261 126-126-39 260 259 126-39 262 39-39-126-126 259 257 39-126 263 126-39-39 257 126 126 264 39-126-126 32 16

7. Run-Length Coding 1. Run-length Encoding, or RLE is a technique used to reduce the size of a repeating string of characters 2. This repeating string is called a run, typically RLE encodes a run of symbols into two bytes, a count and a symbol. 3. RLE can compress any type of data 4. RLE cannot achieve high compression ratios compared to other compression methods 5. It is easy to implement and is quick to execute 33 7. Run-Length Coding Example WWWWWWWWWWWWBWWWWWWWWWWWWBB BWWWWWWWWWWWWWWWWWWWWWWWWB WWWWWWWWWWWWWW RLE coding: 12W1B12W3B24W1B14W 34 17

8. Symbol - Based Coding In symbol- or token-based coding, an image is represented as a collection of frequently occurring sub-images, called symbols Each symbol is stored in a symbol dictionary Image is coded as a set of triplets {(x1,y1,t1), (x2, y2, t2), } 35 8. Symbol - Based Coding 36 18

9. Bit-Plane Coding An m-bit gray scale image can be converted into m binary images by bit-plane slicing; Encode each bit-plane by using one of mentioned methods, RLC, for example. However, a small difference in the gray level of adjacent pixels can cause a disruption of the run of zeroes or ones For example: Assume that, one pixel has a gray level of 127 and the next pixel has a gray level of 128. In binary: 127 = 01111111 & 128 = 10000000 Therefore a small change in gray level has decreased the run-lengths in all the bit-planes 37 9. Bit-Plane Coding Gray code Images are free of this problem which affects images which are in binary format In gray code the representation of adjacent gray levels will differ only in one bit (unlike binary format where all the bits can change Let g m-1.g 1 g 0 binary number. Then: represent the gray code representation of a g = a g i m 1 = a a m 1 In gray code: 127 = 01000000 128 = 11000000 i i+ 1 0 i m 2 38 19

9. Bit-Plane Coding To convert a binary number b 1 b 2 b 3..b n-1 b n to its corresponding binary reflected Gray code, do some step as follows: Start at the right with the digit bn. If the b n-1 is 1, replace bn by 1-b n ; otherwise, leave it unchanged. Then proceed to b n-1 Continue up to the first digit b 1, which is kept the same since it is assumed to be a b 0 =0 The resulting number is the reflected binary Gray code 39 9. Bit-Plane Coding For instance: Decode: a a i Dec Gray Binary 0 000 000 1 001 001 2 011 010 3 010 011 4 110 100 5 111 101 6 101 110 7 100 111 = m 1 g = i a g m 1 m i+ 1 0 2 i 40 20

(Transform) JPEG stands for Joint Photographic Experts Group Source Image DCT Quantizer Entropy Encoder Compressed Image Data Compressed Image Data Entropy Encoder Dequantizer Inverse DCT Uncompressed Image JPEG coder and decoder 41 JPEG compression consists basic steps: 1. Input the source dark - gray image I. 2. Partition image into 8 x 8 pixel blocks and perform the DCT on each block. 3. Quantize resulting DCT coefficients. 4. Entropy code the reduced coefficients. 42 21

The second step consists of separating image components are: Broken into arrays or "tiles" of 8 x 8 pixels. The elements within the tiles are converted to signed integers (for pixels in the range of 0 to 255, subtract 128). These tiles are then transformed into the spatial frequency domain via the forward DCT. Element (0,0) of the 8 x 8 block is referred to as DC, DC is the average value of the 8 x 8 original pixel values. The 63 other elements are referred to as AC YX, where x and y are the position of the element in the array. 43 For example -128 F - A 8x8 block extracted F - Signed block 44 22

DCT of image block F as matrix G: G( u, v) = α( u) α( v) 7 7 x= 0 y= 0 F( x, y)cos (( x + 1/ 2) π u / 8) cos( ( y + 1/ 2) π v / 8) where u = 0, 1,..,7; v = 0, 1,..,7 and α( 0) = 1/ 8, α( u) = 2 / 8, u = 1, 2,...,7 45 For example DTC F - Signed block G = DTC of F 46 23

Quantization The human eye is good at seeing small differences in brightness over a relatively large area, but not so good at distinguishing the exact strength of a high frequency brightness variation. This allows one to greatly reduce the amount of information in the high frequency components. This is done by simply dividing each component in the frequency domain by a constant for that component, and then rounding to the nearest integer. This is the main lossy operation in the whole process. As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers, which take many fewer bits to store. 47 Quantization A typical quantization matrix, as specified in the original JPEG Standard Q is Q = B( x, y) G( x, y) = round, Q( x, y) for x, y = 0,1,...,7 48 24

For example Quantization G = DTC of F B - Quantization of G 49 For example Zigzag B - Quantization of G The coefficients in B are reordered in accordance with the zigzag ordering: B(0,0), B(0,1), B(1,0), B(2,0), B(1,1), B(1,2),... {-28, -2, -1, -1,-1,-3, 0, -3, 0, -2, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, -1, EOB} Where the EOB symbol denotes the end-of-block condition. 50 25

The Zero Run Length Coding (ZRLC) Let's consider the 63 vector (it's the 64 vector without the first coefficient). Say that we have -2, -1, -1,-1,-3, 0, -3, 0, -2, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0,0, only 0,..,0. Here it is how the RLC JPEG compression is done for this example : (0,-2), (0,-1), (0,-1), (0,-1), (0,-3), (1,-3), (1,-2), (2, 2), (1,1), (3,1), (1,-1), EOB ACTUALLY, EOB has as an equivalent (0,0) and it will be (later) Huffman coded like (0,0). So we'll encode : (0,-2), (0,-1), (0,-1), (0,-1), (0,-3), (1,-3), (1,-2), (2, 2), (1,1), (3,1), (1,-1), (0,0) 51 Huffman coding JPEG standard stores the minimum size in bits in which keep that value (it's called the category of that value) and then a bit-coded representation of that value like this: 52 26

Huffman coding In consequence for the previous example: (0,-2), (0,-1), (0,-1), (0,-1), (0,-3), (1,-3), (1,-2), (2, 2), (1,1), (3,1), (1,-1), (0,0) let's encode ONLY the right value of these pairs, except the pairs that are special markers like (0,0) (0,2)01, (0,1)0, (0,1)0, (0,1)0, (0,2)00, (1,2)00, (1,2)01, (2,2)10, (1,1)1, (3,1)1, (1,1)0, (0,0) 53 Huffman coding (0,2) 01, (0,1)0, (0,1)0, (0,1)0, (0,2)00, (1,2)00, (1,2)01, (2,2)10, (1,1)1, (3,1)1, (1,1)0, (0,0) The pairs of 2 values enclosed in bracket parenthesis, can be represented on a byte. In this byte, the high nibble represents the number of previous 0s, and the lower nibble is the category of the new value different by 0 The FINAL step of the encoding consists in Huffman encoding this byte, and then writing in the JPG file, as a stream of bits, the Huffman code of this byte, followed by the remaining bitrepresentation of that number. The final stream of bits written in the JPG file on disk for the previous example (01)01 (00)0 (00)0 (00)0 (01)00 (111001)00 (111001)01 (11111000)10 (1100)1 (111010)1 (1100)0 (1010) 54 27

Huffman coding The encoding of the DC coefficient DC is the coefficient in the quantized vector corresponding to the lowest frequency in the image (it's the 0 frequency), and (before quantization) is mathematically = (the sum of 8x8 image samples) / 8. The authors of the JPEG standard noticed that there's a very close connection between the DC coefficient of consecutive blocks, so they've decided to encode in the JPG file the difference between the DCs of consecutive 8x8 blocks: Diff = DC(i) - DC(i-1) And in JPG decoding you will start from 0 -- you consider that the first DC(0)=0 55 Huffman coding The encoding of the DC coefficient Diff = (category, bit-coded representation). For example, if Diff is equal to -511, then Diff corresponds to (9, 000000000). Say that 9 has a Huffman code = 1111110. (In the JPG file, there are 2 Huffman tables for an image component: one for DC (and one for AC). In the JPG file, the bits corresponding to the DC coefficient will be: 1111110 000000000 And, applied to this example of DC and to the previous example of ACs, for this vector with 64 coefficients, THE FINAL STREAM OF BITS written in the JPG file will be: 1111110 000000000 (01)01 (00)0 (00)0 (00)0 (01)00 (111001)00 (111001)01 (11111000)10 (1100)1 (111010)1 (1100)0 (1010) Note: (In the JPG file, first it's encoded DC then ACs) 56 28

JPEG Decoder process Decoding of Huffman, Decoding of ZRLC of bit stream from JPEG file (for a block 8x8) -> {-28, -2, -1, -1,-1,-3, 0, -3, 0, -2, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, -1, EOB} Dequantize the 64 vector : "for (i=0;i<=63;i++) vector[i]*=quant[i] Re-order from zig-zag the 64 vector into an 8x8 block Apply the Inverse DCT transform to the 8x8 block => F 57 Example Dequantize and Re-order from zig-zag 58 29

Example Inverse DTC 59 Example Unsigned 60 30

11. Homework and Discussion Is there anything else? 61 31