Image Compression
by
Mohamed Hagras
Contents
What is Image Compression?
Why Image Compression?
Lossless and Lossy Techniques
Bitmap Format
Graphics Interchange Format
Portable Network Graphics Format
Tag Image File format
JPEG
JPEG 2000
22/05/2010 Image Compression 2
Contents
Video Compression Principals
Frames
Types of frames
• I-frames
• P-frames
• B-frames
• PB-frames
• D-frames
Conclusion
22/05/2010 Image Compression 3
What is Image Compression?
A technique used to reduce the volume of information
to be transmitted about an image.
Width
1 Unit
M=Number
Height 1 of Samples
Unit M D=Spacing
D
Between
Samples
1/2
M
22/05/2010 Image Compression 4
Why Image Compression?
Requirements may outstrip the anticipated increase of
storage space and bandwidth.
For data storage and data transmission:
DVD
Real time applications
Printer
Take advantage of :
Spatial redundancy
Temporal redundancy (videos)
22/05/2010 Image Compression 5
Lossless And Lossy Compression
Lossless Compression Lossy Compression
Definition There is no information loss. Information loss is
The image can be tolerable.
reconstructed exactly the same
as the original.
e.g RLE JPEG 2000
Applications Medical imagery Commercial distribution
Archiving (DVD).
Rate constrained
environment where
lossless methods can not
provide enough
compression ratio.
22/05/2010 Image Compression 6
Bitmap Format
Files with .bmp extension
Each pixel is represented by a fixed number of bits
(integral power of 2)
Advantages Disadvantages
Simple Minimum or zero
Widely used compression
Relatively well
documented
Free of patents
22/05/2010 Image Compression 7
Graphics Interchange Format
GIF supports transparency and interlacing
Transparency is supported by specifying which pixels of the image is
unused and as such, to reuse the background color.
Interlacing creates the illusion of faster loading graphics as the
image is presented to the viewer in a series of interlaced frames.
256 colors out of a palette of 224 colors are indexed.
Amongst the oldest formats available.
Supports animations.
22/05/2010 Image Compression 8
Portable Network Graphics Format
PNG Developed to improve upon and replace GIF.
Supports:
2D Interlacing
Transparency
Variable Color Depth
Uses Lossless Data compression method called DEFLATE.
The same
A PNG image
image is
with an 8-bit
overlaid
transparency
onto a
channel
checkered
background
The only Disadvantage of png is that it doesn’t support Animations.
22/05/2010 Image Compression 9
Tag Image File Format
Developed by Aldus and Microsoft.
Tags used to indicate how data is arrange and
compressed.
e.g LZW/RLE compression
Advantages Disadvantages
Highly flexible and TIFF image can’t have
platform independent more than 4GB of data
Widely used by Difficult to write TIFF
scanning,faxing, word readers which take
processing advantage of all its features
capable of describing
bilevel, grayscale, palette-
color, and full-color image
data
22/05/2010 Image Compression 10
JPEG
Joint Photographic Expert’s Group.
International standard for photographs.
Lossless/lossy.
Based on the facts that :
Humans are more sensitive to lower spatial frequency
components.
A large majority of useful image contents change
relatively slowly across images.
22/05/2010 Image Compression 11
JPEG Encoding
Cr
Cb f(i, j) F(u, v) Fq(u, v)
Y DCT Quantization
8x8 8x8
Quant…
Tables
Coding Zig Zag
Tables Scan
Header
Tables
DPCM
Data Entropy
Coding
RLC
22/05/2010 Image Compression 12
JPEG (Cont)
Advantages Disadvantages
Compression ratios of 20:1 Doesn’t support
are easily attained. transparency.
24-bits per pixel can be Doesn’t work well with
used leading to better sharp edges.
accuracy.
Progressive Almost always lossy and
JPEG(interlacing) No target bit rate
22/05/2010 Image Compression 13
Comparative Analysis
a. 256 color bmp b. gif c. jpeg
253 KB 4.08 KB 10.1 KB
d. Png e. tiff
6.27 K 16.2 KB
22/05/2010 Image Compression 14
JPEG 2000
Wavelet based image compression standard
Source
Image Data
Forward Entropy
Quantization Compressed Image Data
Transform Encoding
Reconstructed
Image
Data
Inverse Inverse Entropy
Compressed Image Data
Transform Quantization Decoding
22/05/2010 Image Compression 15
Wavelet Transform Of An Image
Advantages:
Lossless and lossy
compression.
Progressive transmission by
pixel accuracy and
resolution.
Region-of-Interest Coding.
Random codestream access
and processing.
Robustness to bit-errors.
Content-based description.
Side channel spatial
information (transparency).
22/05/2010 Image Compression 16
JPEG vs. JPEG 2000
512x512 image reconstructed after compression of 0.2 bpp
using JPEG and JPEG 2000 respectively
22/05/2010 Image Compression 17
Moving Images (Videos)
Any video can be thought up of as a sequence of
digitized pictures or frames.
Types Of Frame Coding
Intra-Frame Coding Inter-Frame Coding
(Spatial Redundancy) (Temporal Redundancy)
I-Frame P-Frame
B-Frame
JPEG algo applied to each frame Only a small portion of each
independently moving JPEG or frame is involved with any
MJPEG motion, so only info related to
Typical compression ratios bw those segments is send
10:1 and 20:1
Not large enough to produce
the needed compression ratios
22/05/2010 Image Compression 18
I-Frame P-Frame B-Frame PB-Frame
Each frame is Encoded using a Their contents Two neighboring
coded combination of are predicted P- and B-frames
independently. either a preceding using both past are encoded as if
Y (luminance) I-frame or P- and future frames they were a single
and Cb, Cr frame. Allows for frame.
(chrominance) No. of P-frames occasional fast It increases the
matrices encoded limited as errors moving objects frame rate
separately using propagate from Provides better without
JPEG algo. one p-frame to motion increasing the
I-frames another. estimation. resulting bit rate
frequently used M = prediction required.
Provides highest
in order to tackle span = no. of level of
corruption. frames bw a P- compression.
N = GOP = no. of frame and the
immediately As they are not
frames bw involved in
successive I- preceeding I-
frame or P-frame. coding of other
frames, frames they do
range(3,12). not propagate
errors.
22/05/2010 Image Compression 19
Encoding Operation
22/05/2010 Image Compression 20
D-Frame
Used in movie / video-on-demand applications.
User may wish to rewind or fast-forward the video.
This requires the compressed video to be
decompressed at much higher speeds.
D-frames inserted at regular intervals throughout the
stream.
By using only the encoded DC coefficients of each
block of pixels in the periodically inserted D-frames, a
low resolution sequence of frames is provided at much
higher speeds.
22/05/2010 Image Compression 21
Performance
Compression ratios for I-frames is similar to that
obtained with JPEG and is typically between 10:1 and
20:1 depending on the complexity of the frame
contents.
Compression ratios for P-frames and B-frames are
higher and depend on the search algorithm used.
Typical figures are 30:1 for P-frames and 30:1 through
50:1 for B-frames.
22/05/2010 Image Compression 22
Conclusion
Every format has its own advantages and disadvantages.
Depending upon the application the appropriate format
should be used.
Bmp is simple but heavy.
Only redeeming feature of gif : supports animations.
Png better than the rest in overall terms.
Tiff is appropriate where flexibility is needed.
JPEG is good for photography.
JPEG 2000 is an all encompassing standard.
22/05/2010 Image Compression 23
Thanks For ListeninG