Date post: | 04-Jun-2018 |
Category: |
Documents |
Upload: | eng-rabah-elmasri |
View: | 231 times |
Download: | 0 times |
of 24
8/13/2019 Khalil ImageCompression
1/24
1
8/13/2019 Khalil ImageCompression
2/24
8/13/2019 Khalil ImageCompression
3/24
8/13/2019 Khalil ImageCompression
4/24
o LosslessInformation preserving
Low compression ratios
o LossyNot information preserving
High compression ratios
Trade-off: image quality vs compression ratio
8/13/2019 Khalil ImageCompression
5/24
oLossless algorithms do not change the content of a file. If you compress afile and then decompress it, it has not changed.The following algorithms are lossless:
Flate/deflate compressionHuffman compressionLZW compression
RLE compression
oLossy algorithms achieve better compression ratios by selectively gettingrid of some of the information in the file. Such algorithms can be used forimages or sound files but not for text or program data.The following algorithms are lossy :
JPEG compressionMPEG compression
8/13/2019 Khalil ImageCompression
6/24
Run Length encoding (RLE).
Lample Zie welch (LZW). Flate / Deflate .
Huffman .
JPEG .
8/13/2019 Khalil ImageCompression
7/24
RLE is probably the easiest compression algorithm there
is. It replaces sequences of the same data values within a
file by a count number and a single value. Suppose the
following string of data (17 bytes) has to be compressed:
ABBBBBBBBBCDEEEEF
Using RLE compression, the compressed file takes up 10bytes and could look like this:A*8BCD*4EF
8/13/2019 Khalil ImageCompression
8/24
Input: string of characters
Internal: dictionary of (codewords, words)
Output: string of codewords and characters.Codewords are distinct from characters.
In algorithm, w is a string, cis character and
w+cmeans concatenation.
When adding a new word to the dictionary, anew code word needs to be assigned.
8/13/2019 Khalil ImageCompression
9/24
Huffman compression belongs into a family of algorithms with a variable
codeword length. That means that individual symbols (characters in a text
file for instance) are replaced by bit sequences that have a distinct length.
So symbols that occur a lot in a file are given a short sequence while other
that are used seldom get a longer bit sequence.
A practical example will show you the principle: Suppose you want to
compress the following piece of data: ACDABA
Since these are 6 characters, this text is 6 bytes or 48 bits long. With
Huffman encoding, the file is searched for the most frequently appearing
symbols (in this case the character Aoccurs 3 times) and then a tree isbuild that replaces the symbols by shorter bit sequences. In this particular
case, the algorithm would use the following substitution table: A=0, B=10,
C=110, D=111. If these code words are used to compress the file, the
compressed data look like this:01101110100
8/13/2019 Khalil ImageCompression
10/24
The JPEG algorithms performs its compression in four phases :
1) First, the JPEG algorithms first cuts up an image in separate blocks of 88
pixels. The compression algorithm is calculated for each separate block,
which explains why these blocks or groups of blocks become visible when
too much compression is applied.
2) The next step in the compression process is to apply a Discrete Cosine
Transform (DCT) for the entire block. DCT is a complex process that is let
loose on each individual pixel. It replaces actual color data for each pixelfor values that are relative to the average of the entire matrix that is being
analyzed. This operation does not compress the file, it simply replaces 88
pixel values by an 88 matrix of DCT coefficients.
8/13/2019 Khalil ImageCompression
11/24
3) Once this is done, the actual compression can start. First the compression
software looks at the JPEG image quality the user requested (e.g. Photoshop
settings like lowquality, mediumquality,) and calculates two tables of
quantization constants, one for luminance and one for chrominance. Once thesetables have been constructed, the constants from the two tables are used to
quantize the DCT coefficients. Each DCT coefficient is divided by its
corresponding constant in the quantization table and rounded off to the nearest
integer. The result of quantizing the DCT coefficients is that smaller,
unimportant coefficients will be replaced by zeros and larger coefficients will
lose precision. It is this rounding-off that causes a loss in image quality.
8/13/2019 Khalil ImageCompression
12/24
4) The resulting data are a list of streamlined DCT coefficients. The last step in
the process is to compress these coefficients using either a Huffman or
arithmetic encoding scheme. Usually Huffman encoding is used.
8/13/2019 Khalil ImageCompression
13/24
By putting 2 compression algorithms on top of each other, JPEG achieves
remarkable compression ratios. The downside of JPEG compression is that the
algorithm is only designed for continuous tone images (remember that the P
in JPEG stands for Photographic). JPEG not does not lend itself for images with
sharp changes in tone.
JPEG Making image files smaller is a plus for transmitting files across networksand for archiving libraries of images. Being able to compress a 2 Mbyte full-
color file down to, say, 100 Kbytes makes a big difference in disk space and
transmission time! And JPEG can easily provide 20:1 compression of full-color
data. JPEG is that it stores full color information: 24 bits/pixel (16 million
colors).
After the above, we conclude that the best choice for image
compression is JPEG algorithm .
But!!!!! (thatscorrect before 2000)
8/13/2019 Khalil ImageCompression
14/24
The JPEG2000 compression algorithm was released by an ISOstandardization committee in January 2000. It is based on the
existing JPEG specifications and adds important things to the
existing standard.
The JPEG 2000 is a new image coding system that uses state-of-
the-art compression techniques based on wavelet technology.
8/13/2019 Khalil ImageCompression
15/24
o DWT= intra-component decorrelation
concentrate image energy in a small area
o No blocking artefacts at high compression ratios
o
Enables multi-resolution image representation
8/13/2019 Khalil ImageCompression
16/24
Improved compression efficiency.
Lossy to lossless compression.
Single compression / Multiple decompression.
Scalability :
- Resolution.
- Quality (SNR scalability).
Region of Interest Coding (ROI). Error Resilience.
8/13/2019 Khalil ImageCompression
17/24
JPEG JPEG2000
8/13/2019 Khalil ImageCompression
18/24
Compression
Decompression
storage
8/13/2019 Khalil ImageCompression
19/24
+
+
2.6 kBytes (1:100)
8/13/2019 Khalil ImageCompression
20/24
1.6 %download
8.0 % download
2.2 % download
26.4 % download
100 % download
8/13/2019 Khalil ImageCompression
21/24
8/13/2019 Khalil ImageCompression
22/24
Embedded error : 16 bytes set to 0 in the middleof the compressed file.
JPEG JPEG2000
8/13/2019 Khalil ImageCompression
23/24
JPEG 2000 offers numerous advantages over the old JPEGstandard. One main advantage is that JPEG 2000 offers bothlossy and lossless compression in the same file stream, whileJPEG usually only utilizes lossy compression.
A second advantage of JPEG 2000 over JPEG is that JPEG 2000
is able to offer higher compression ratios for lossy compression. Another advantage of JPEG 2000 is its ability to display images
at different resolutions and sizes from the same image file. WithJPEG, an image file was only able to be displayed a single way,with a certain resolution.
SO , the best choice for image compression isJPEG2000 algorithm
8/13/2019 Khalil ImageCompression
24/24