multimedia – image compression dr. lina a. nimri lebanese university faculty of economic sciences...
TRANSCRIPT
Multimedia – Image Compression
Dr. Lina A. NimriLebanese UniversityFaculty of Economic Sciences and Business Administration 1st branch
Image Compression
•To store, treat or print an image, it is necessary to reduce the size of the file of the image while keeping the information applicable▫It is necessary to compress the image
JPEG quality 100% JPEG quality 50 %
JPEG quality 25 % JPEG quality 0 %
Image Compression
•Image compression is applying data compression methods on digital images
•This compression is to reduce the size of an image to be able to store it using little storage space or to transmit it quickly
Image Compression
•Image compression can be lossless or lossy•Lossless compression is sometimes
preferred for images:▫Art drawings, technical designs, icons or
comics▫Requiring a high precision, such as medical
scans•Lossy methods are appropriate for images:
▫Natural photos, such as photos in an applications or when a minor loss of exactness is acceptable while acheiving a substantial reduction in the binary code.
Lossy Compression
•Lossless compression algorithms do not deliver compression ratios that are high enough. Hence, most multimedia compression algorithms are lossy.
•The compressed data is not the same as the original data, but a close approximation of it.
•Yields a much higher compression ratio than that of lossless compression
Lossy Compression
•The most important methods of lossy compression are:1. The reduction of the color depth to the
most frequent colors in the image2. Sub-sampling of chrominance
This method takes advantage of the fact that the eye perceives brightness more vigorously than color, dropping at least half of chrominance information in the image
3. Fractal compression
Lossy Compression - continued•The most important methods of lossy
compression are4. Compression –Transform Coding
This is the most commonly used method Discrete Cosine Transform (DCT) and
wavelet transforms are the most popular Transform Coding includes the application of
the transformation in the image, followed by quantization and entropy coding
Distortion Measure•Distortion is a mathematical measure of error
▫Where xn, yn and N are the input data sequence, reconstructed data sequence, and length of the data sequence respectively.
•The visual distortion (perceptual distortion) measures the perceived error
• It is possible to have a very clear visual distortion with a poor measure of distortion▫An image shifted to the right of a vertical line
The Rate-Distortion Theory• Rate: the average number of bits needed to
represent a data source • Typical Rate Distortion Function: R(D)
▫ If D is a tolerable distortion, then R (D) is the minimum rate with which the data source can be coded while having an upper limit of distortion equals to D
Fractal Compression
•Fractal Compression is an image compression little used today
•It is based on the detection of recurrence of the grounds, and tends to eliminate redundancy of information in the image.
•Fractal compression is a destructive compression method as all baselines are not reflected in the final image.
Fractal Compression
Compression –Transform Coding
La transformée en cosinus discrète et la transformation par ondelettes sont les transformations les plus populaires
Decoding
CodingQuanti-zation
Transfor-mation
Inverse Quatization
InverseTransfor-mation
Compressed image
Compressed image
Compression –Transform Coding: JPEG example
•JPEG is a free code, thus, allowing it to be widely distributed on the Internet
•It allows you to handle color images in grayscale
•It has many uses such as medical scanning because it offers a powerful method that is the reason of its widespread distribution
JPEG
Segmentation Blocks 8x8
Transformation DCT
Quantization Quantization Matrix
Coding RLE + Huffman
Discrete Cosine Transform DCT• The experts are based on the fact that
relevant information of an image, characterized by a two-dimensional signal Img (x, y), are only the components of the low frequency of the signal▫The eye is less sensitive to high frequencies.
• The DCT transforms a signal amplitude (each value of the image represents the "magnitude" of the image, and so, its intensity) into a frequency information ▫When working with the matrix Img (x, y), the X
and Y axes represent the vertical and horizontal dimensions of the image
▫On the matrix DCT(i, j), the axes represent the frequency of the signal in two dimensions
Discrete Cosine Transform DCT•Given
▫An image segmented into blocks 8 × 8 pixels
•Aim ▫Obtain a new representation of each
block: containing the same information Information is concentrated on a few elements
•Principle ▫Using a matrix of transformation
DCT Formula
Inverse DCT Transformation
Discrete Cosine Transform DCT•Here is the matrix representing the image
and the basic functionsf00
f01
f02
f03
f04
f05
f06
f07
f10
f11
f12
f13
f14
f15
f16
f17
f20
f21
f22
f23
f24
f25
f26
f27
f30
f31
f32
f33
f34
f35
f36
f37
f40
f41
f42
f43
f44
f45
f46
f47
f50
f51
f52
f53
f54
f55
f56
f57
f60
f61
f62
f63
f64
f65
f66
f67
f70
f71
f72
f73
f74
f75
f76
f77Matrix representing the
imageMatrix of the basic
functions
F0,0
Basic DCT functions•How the basic matrix is defined?
▫Transformation formula!▫y=u.π/16 and x=v. π/16
cosy.cosx cos3y.cosx cos5y.cosx cos7y.cosx cos9y.cosx cos11y.cosx cos13y.cosx cos15y.cosx
cosy.cos3x cos3y.cos3x cos5y.cos3x cos7y.cos3x cos9y.cos3x cos11y.cos3x
cos13y.cos3x
cos15y.cos3x
cosy.cos5x cos3y.cos5x cos5y.cos5x cos7y.cos5x cos9y.cos5x cos11y.cos5x
cos13y.cos5x
cos15y.cos5x
cosy.cos7x cos3y.cos7x cos5y.cos7x cos7y.cos7x cos9y.cos7x cos11y.cos7x
cos13y.cos7x
cos15y.cos7x
cosy.cos9x cos3y.cos9x cos5y.cos9x cos7y.cos9x cos9y.cos9x cos11y.cos9x
cos13y.cos9x
cos15y.cos9x
cosy.cos11x cos3y.cos11x
cos5y.cos11x
cos7y.cos11x
cos9y.cos11x
cos11y.cos11x
cos13y.cos11x
cos15y.cos11x
cosy.cos13x cos3y.cos13x
cos5y.cos13x
cos7y.cos13x
cos9y.cos13x
cos11y.cos13x
cos13y.cos13x
cos15y.cos13x
cosy.cos15x cos3y.cos15x
cos5y.cos15x
cos7y.cos15x
cos9y.cos15x
cos11y.cos15x
cos13y.cos15x
cos15y.cos15x
A block of the basic matrix for F0,0
Basic DCT functions
▫y=u.π/16 and x=v. π/16▫F0,0 is the sum of the multiplication of
elements Do not forget the constant
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
f00
f01
f02
f03
f04
f05
f06
f07
f10
f11
f12
f13
f14
f15
f16
f17
f20
f21
f22
f23
f24
f25
f26
f27
f30
f31
f32
f33
f34
f35
f36
f37
f40
f41
f42
f43
f44
f45
f46
f47
f50
f51
f52
f53
f54
f55
f56
f57
f60
f61
f62
f63
f64
f65
f66
f67
f70
f71
f72
f73
f74
f75
f76
f77
Mask
Basic DCT functions
▫F0,1 is the sum of the multiplication of elements
cos(π/16) cos(π/16) cos(π/16) cos(π/16) cos(π/16) cos(π/16) cos(π/16) cos(π/16)
cos(3π/16) cos(3π/16) cos(3π/16) cos(3π/16) cos(3π/16) cos(3π/16) cos(3π/16) cos(3π/16)
cos(5π/16) cos(5π/16) cos(5π/16) cos(5π/16) cos(5π/16) cos(5π/16) cos(5π/16) cos(5π/16)
cos(7π/16) cos(7π/16) cos(7π/16) cos(7π/16) cos(7π/16) cos(7π/16) cos(7π/16) cos(7π/16)
cos(9π/16) cos(9π/16) cos(9π/16) cos(9π/16) cos(9π/16) cos(9π/16) cos(9π/16) cos(9π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(11π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(13π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
cos(15π/16)
Basic DCT functions
▫F1,0 is the sum of the multiplication of elements
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
cos(π/16) cos(3π/16) cos(5π/16) cos(7π/16) cos(9π/16) cos(11π/16)
cos(13π/16)
cos(15π/16)
Basic DCT functions
▫F2,0 is the sum of the multiplication of elements y=2π/16=π/8 and x=0
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/86)
cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8) cos(15π/8)
cos(π/8) cos(3π/8) cos(5π/8) cos(7π/8) cos(9π/8) cos(11π/8) cos(13π/8 cos(15π/8)
Discrete Cosine Transform DCT
Choose a homogeneous block
Discrete Cosine Transform DCT
Choose a blockrich in texture
Discrete Cosine Transform DCT•It is observed that the coefficients of high absolute value are located on top and left
•The importance of the coefficients for the reconstruction of the image decreases as you move diagonally from top left to bottom right that corresponds to high frequencies▫To which the eye is the least sensitive
Inverse Discrete Cosine Transform IDCT• It is possible to restore the image by the
inverse process IDCT Note that in theory the DCT does not introduce any loss of information on the image
•The original block can be reconstructed without loss by using the Inverse DCT
• In fact, the DCT coefficients, i.e. those seen in the matrix of arrival are rounded to the nearest▫By making the transformation using Inverse DCT,
we can observe slight differences between the treated matrix and the initial matrix
Quantization
•In signal processing, quantization can approximate a continuous signal (or values in a discrete set of large size) by the values of a discrete set of relatively small size
•Quantization: reducing the number of distinct values in the source data must undergo a compression▫Quantization algorithms allow the partitioning
of data values▫The quantization is a primary source for loss
of data in lossy compression methods
Quantization
•Quantization of a signal
Quantization Types
•Uniform Scalar Quantizer is the simplest type of quantizer, where the intervals are constant length. ▫Quantization step is fixed
Quantization Types
•Uniform Quantization▫All intervals are the same size, except
sometimes the two extremes (longer)
Non Quantized Uniform Quantization
Quantization Types•Non-uniform Adaptive Quantization
▫Non-uniform: intervals may have different sizes (ex: Laplacien, Gaussian)
▫Adaptive: the sets of intervals are calculated for each block of coefficients
Non Quantized Adaptive Laplacien Quantization
Quantization of DCT coefficients• Quantification is a simple Euclidean division of
DCT coefficients by a divider (step), which replaces the original coefficients by the quotient of division▫ this is the stage at which we will lose some of the
information• DCT ranges the coefficients in order of
importance▫Those coding for the low frequencies towards the
upper left corner, while less important towards the lower right corner of the matrix
▫ It takes relatively small steps for the important values and increasingly large steps as we descend to the bottom right of the matrix
Quantization of DCT coefficients•The set of steps that is used for quantization
is called a quantization matrix▫Some of these matrices were built according to
psycho-visual criteria, but most follow this little formula: Q (i, j) = 1 + (1 + i + j) x Fq
•We will consider Fq = 5▫It is a quality factor, it can be little changed in
some software such as Photoshop•The quantization matrix can be given as a
result of psychophysical studies, with the goal of maximizing the compression ratio while minimizing perceptual losses in JPEG images.
Quantization of DCT coefficients•Quantization of the first block of Lena
with some quantization matrix
Quantization matrix Transformed matrix
Quantized matrix
Quantization of DCT coefficients•Quantization of the second block of Lena
with some quantization matrix•
Coding
•The third step is to compress, this time without loss, the quantized matrix that we have
•JPEG uses a VLC (Variable Length Code) coding type: Huffman coding
•The Experts Group JPEG has chosen to treat zeros in a special way because of their big number
•It uses a special scanning for larger possible sequences of zeros▫This method is called the zig-zag sequence
Coding
•It uses the zig-zag method, by which you count the longest possible sequence of zeros.
Decompression
•Decompression is performed by doing the opposite: all operations are reversible, but the quantization that causes the loss ▫We finally found a matrix very close to the first
Decompression – Example
Decompression – Example