Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 5 Image Compression

Similar presentations


Presentation on theme: "Lecture 5 Image Compression"— Presentation transcript:

1 Lecture 5 Image Compression
Dr. Mohsen NASRI College of Computer and Information Sciences, Majmaah University, Al Majmaah

2 Introduction Definition Benefits Applications
Reduce size of Image (number of bits needed to represent an image) Benefits Reduce storage needed Reduce transmission cost / latency / bandwidth Applications Wireless image transmission image storage in multimedia/image databases difficult to send real-time uncompressed image over current network

3 Need for image compression
Huge sizes of the data files, in uncompressed form The storage devices have relatively slow access =>impossible to render/index image info in real time limited bandwidth of the communication channels => Multimedia data (esp. image and video) have large data volume The main advantage/need of/for image compression is that it reduces the data storage requirement. It also offers an alternative approach to reduce the communication cost

4 Need for image compression (cont…)
Reduce the size of data. Reduces storage space and hence storage cost. Compression ratio = original data size/compressed data size Reduces time to retrieve and transmit data.

5 Basic concept of a compresssion

6 Compression categories
Compression = Image coding Image compression Lossless Lossy Lossless compression The information content is not modified Lossy compression The information content is reduced and it is not recoverable

7 Image compression model
Original Image Statistical Redundancy Psychovisual Redundancy Reduction of data redundancy Reduction of Entropy Entropy encoding Decompressed Image

8 Statistical Redundancy
Statistical redundancy occurs due to the fact that pixels within an image tend to have very similar intensities as those of its neighborhood, except at the object boundaries or illumination changes. For still images, statistical redundancies are essentially spatial in nature. For natural two-dimensional images, redundancies are present along both the x- and y-dimensions. Video signals exhibit yet another form of statistical redundancy and that is temporal. For video, intensities of same pixel positions across successive frames tend to be very similar, unless there is large amount of motion present. In this lesson however, we focus our attention to only one form of statistical redundancy and that is spatial redundancies of images. Presence of statistical redundancies in natural images allows efficient representation in the transformed output.

9 Psychovisual Redundancy
Psychovisual redundancy arises due to the problem of perception. Our eyes are more responsive to slow and gradual changes of illumination than perceiving finer details and rapid changes of intensities. Hence, to what extent we should preserve the details for our perception and to what extent we can compromise on the quality of reconstructed image that we perceive is essentially carried out by exploiting the psychovisual redundancy. As we shall see later, psychovisual redundancy has been well studied and its exploitation has been included within the multimedia standards.

10 Measuring the quality of reconstructed images
To evaluate the image quality, we should use the peak signal-to-noise ratio metric, which is defined (in decibels) by: where q is the number of bits per pixel (bpp) of the original image, and MSE is the mean-square-error which is defined by:

11 Elements of Image Compression System
A typical image compression system/image encoder consists of the following elements Compressed Image Compression system Decompression system The image file is converted into a series of binary data, which is called the bit-stream The decoder receives the encoded bit-stream and decodes it to reconstruct the image The total data quantity of the bit-stream is less than the total data quantity of the original image

12 Source coding algorithms
To achieve less average length of bits per pixel of the image. Assigns short descriptions to the more frequent outcomes and long descriptions to the less frequent outcomes Entropy Coding Methods Huffman Coding Arithmetic Coding Lossless Compression Source Encoder Sequence of source symbols ui Sequence of code symbols ai Source alphabet Code alphabet

13 Huffman code Approach Principle Variable length encoding of symbols
Exploit statistical frequency of symbols Efficient when symbol probabilities vary widely Principle Use fewer bits to represent frequent symbols Use more bits to represent infrequent symbols A A B A A A B A

14 Huffman Code Data Structures
Binary (Huffman) tree Represents Huffman code Edge  code (0 or 1) Leaf  symbol Path to leaf  encoding Example A = “000”, B = “001”, C = “01” d = “1” Priority queue To efficiently build binary tree 4 1 3 1 1 D 2 1 1 C 1 1 A B

15 Huffman Code Algorithm Overview
Encoding Calculate frequency of symbols in file Create binary tree representing “best” encoding Use binary tree to encode compressed file For each symbol, output path from root to leaf Size of encoding = length of path Save binary tree

16 Huffman Code – Algorithm
Huffman Coding Algorithm (1) Order the symbols according to the probabilities Alphabet set: S1, S2,…, SN Probabilities: P1, P2,…, PN The symbols are arranged so that P1≧ P2 ≧ … ≧ PN (2) Apply a contraction process to the two symbols with the smallest probabilities. Replace the last two symbols SN and SN-1 to form a new symbol HN-1 that has the probabilities P1 +P2. The new set of symbols has N-1 members: S1, S2,…, SN-2 , HN-1 (3) Repeat the step 2 until the final set has only one member. (4) The codeword for each symbol Si is obtained by traversing the binary tree from its root to the leaf node corresponding to Si

17 Huffman Tree Construction
The message to be encoded is "ABBBBAAC" C B A Symbols 1 4 3 Frequency of occurrence 00 Huffman code 8 High frequency of occurrence : shorter bit strings Low frequency of occurrence :Longer bit strings 1 4 B char encoding A B C 4 1 B  The principle is to use a lower number of bits to encode the data that occurs more frequently 1 3 C A

18 Huffman Code Properties
Prefix code No code is a prefix of another code Example Huffman(“I”)  00 Huffman(“X”)  // not legal prefix code Can stop as soon as complete code found No need for end-of-code marker Nondeterministic Multiple Huffman coding possible for same input If more than two trees with same minimal weight

19 Huffman Code Properties
Greedy algorithm Chooses best local solution at each step Combines 2 trees with lowest frequency Still yields overall best solution Optimal prefix code Based on statistical frequency Better compression possible (depends on data) Using other approaches (e.g., pattern dictionary)

20 Arithmetic Coding Algorithm
Arithmetic Coding: a direct extension of Shannon-Fano-Elias coding calculate the probability mass function p(xn) and the cumulative distribution function F(xn) for the source sequence xn Lossless compression technique Treate multiple symbols as a single data unit Arithmetic Coding Algorithm Input symbol is l Previouslow is the lower bound for the old interval Previoushigh is the upper bound for the old interval Range is Previoushigh - Previouslow Let Previouslow= 0, Previoushigh = 1, Range = Previoushigh – Previouslow =1 WHILE (input symbol != EOF) EOF = End Of File get input symbol l Range = Previoushigh - Previouslow New Previouslow = Previouslow + Range* intervallow of l New Previoushigh = Previouslow + Range* intervalhigh of l END

21 Arithmetic Coding Input String : k l u w r e ? k l u w r e ?
Symbol Probability Sub-interval k 0.05 [0.00,0.05) l 0.2 [0.05,0.25) u 0.1 [0.20,0.35) w [0.35,0.40) e 0.3 [0.40,0.70) r [0.70,0.90) ? [0.90,1.00) k l u w r e ? ? r e w u l k 1.00 0.25 0.35 0.40 0.70 0.90 0.05 1 ? r e w u l k 0.25 0.05 ? r e w u l k 0.10 0.06 ? r e w u l k 0.074 0.070 ? r e w u l k 0.0714 0.0710 ? r e w u l k ? r e w u l k ? r e w u l k

22 Arithmetic Coding cont…
Input String : ESIPE Symbol lower bound upper bound 0.0 1.0 E 0.4 S 0.16 0.24 I 0.208 0.224 P 0.2208 Symbol Probability Sub-interval E 0.4 [0.00,0.4[ S 0.2 [0.4,0.6[ I [0.6,0.8[ P [0.8,1.0[ The lower bound code the Input string

23 Overview of Image Compression Algorithms
Embedded zero-trees Wavelet (EZW) The EZW encoder is based on two important observations: 1. Natural images in general have a low pass spectrum. When an image is wavelet transformed the energy in the sub-bands decreases as the scale decreases (low scale means high resolution), so the wavelet coefficients will, on average, be smaller in the higher sub-bands than in the lower sub-bands. This shows that progressive encoding is a very natural choice for compressing wavelet transformed images, since the higher sub-bands only add detail; 2. Large wavelet coefficients are more important than smaller wavelet coefficients.

24 Overview of Image Compression Algorithms cont…
Embedded zero-trees Wavelet (EZW) The EZW encoder is based on DWT Energy is compacted into a small number of coeff. Significant coeff. tend to cluster at the same spatial location in each frequency subband Two set of info. to code: Where are the significant coefficients? What values are the significant coefficients? LH1 HL1 HH1 HL2 LH2 HH2 LL3 HL3 HH3 LH3 Three resolution level Two decomposition levels

25 Statistics Filters EZW based on three basic elements DWT EZW Encoder
Arithmetic Encoder Original Image Encoded Image Reconstructed Image Arithmetic decoder EZW decoder 2-D IDWT

26 Overview of Image Compression Algorithms cont…
Embedded zero-trees Wavelet (EZW) coefficients that are in the same spatial location consist of a quad-tree. Parent-children relation among coeff. Each parent coeff at level k spatially correlates with 4 coeff at level (k-1) of same orientation A coeff at lowest band correlates with 3 coeff.

27 Overview of Image Compression Algorithms cont…
Structure of EZW Root: a Descendants: a1, a2, a3

28 Overview of Image Compression Algorithms cont…
Structure of EZW EZW scanning order of sub-bands scan order of the transmission band

29 Overview of Image Compression Algorithms cont…
EZW algorithm With Ti=Ti/2 and T0 = ׀Cmax׀/2

30 Overview of Image Compression Algorithms cont…
EZW algorithm

31 Overview of Image Compression Algorithms cont…
EZW algorithm P N IZ ZT

32 EZW - example

33 EZW – Example cont...

34 EZW – Example Cont...

35 EZW – Example Cont...

36 Contd..

37 Color components (Y, Cb, or Cr)
JPEG JPEG encoder The encoding process consists of several steps: • Color space transformation. • Block splitting. • Discrete Cosine Transform. • Quantization. • Entropy coding. Huffman Table AC Zig-zag reordering Huffman coding Color components (Y, Cb, or Cr) 88 FDCT Quantizer JPEG bit-stream Difference Encoding Huffman coding DC Quantization Table Huffman Table JPEG : Joint Photographic Experts Group

38 JPEG JPEG decoder

39 Color Space Conversion
(a) translate from RGB to YCbCr (b) translate from YCbCr to RGB

40 DC and AC coefficients First coefficient in every 8 x 8 block
DC Coefficient : First coefficient in every 8 x 8 block Represents the average value of pixels in block AC Coefficients : Remaining 63 coefficients in every 8 x 8 block DC Coefficients: treated separately from the AC Coefficients Differential values of DC coeffs. of all blocks are derived and encoded

41 Zig-zag ordering in an 8x8 matrix
Zig-Zag ordering: converting a 2D matrix into a 1D array, so that the frequency (horizontal+vertical) increases in this order, and the coefficient variance decreases in this order.

42 Quantization in JPEG Quantization step is the main source of Lossy Compression • DCT itself is not Lossy Quantisation Tables • In JPEG, each F[u,v] is divided by a constant q(u,v). • Table of q(u,v) is called quantisation table. Quantization Dequantization

43 JPEG 2000 JPEG 2000 Encoder JPEG 2000 Decoder

44 Quantization in JPEG 2000 Quantization coefficients
ab(u,v) : the wavelet coefficients of subband b Quantization step size Rb: the nominal dynamic range of subband b εb: number of bits alloted to the exponent of the subband’s coefficients μb: number of bits allotted to the mantissa of the subband’s coefficients

45 Bitplane Scanning Significant Insignificant
The decimal DWT coefficients can be converted into signed binary format, so the DWT coefficients are decomposed into many 1-bit planes. In one 1-bit-plane Significant A bit is called significant after the first bit ‘1’ is met from MSB to LSB Insignificant The bits ‘0’ before the first bit ‘1’ are insignificant

46 Scanning Sequence The scanning order of the bit-plane Sample
Each element of the bit-plane is called a sample Column stripe Four vertical samples can form one column stripe Full stripe The 16 column stripes in the horizontal direction can form a full stripe

47 Comparison between JPEG and JPEG 2000
Image 1 Image 2

48 Thank You Have a Nice Day


Download ppt "Lecture 5 Image Compression"

Similar presentations


Ads by Google