You are on page 1of 72

UNITII

ImageCompressionand
Standards
Vishal Bharti
Assistant Professor(CSE) AssistantProfessor(CSE)
Digital Media DigitalMedia
For images, these files can have an extension Forimages,thesefilescanhaveanextension
like
BMP,JPG,GIF,TIF,PNG,PPM, , , , , , ,
Foraudios,thefileextensionsinclude ,
WAV,MP3,
Thevideosfilesusuallyhaveextensions:
AVI,MOV, , ,
Digital Media Capturing DigitalMediaCapturing
Togetadigitalimage,anaudiooravideoclip,weneedsomemedia
capturingdevicesuchas
adigitalcameraorascanner,
adigitalaudiorecorder,
oradigitalcamcorder.
Allthesedeviceshavetocompletetasks:
Sampling:Toconvertacontinuousmediaintodiscreteformats.
Digitization:Toconvertcontinuoussamplesintofinitenumberofdigital
numbers.
Thereareprobablysomefurthercompressionprocess.
Image
A Raster Image can be described by breaking the image
into a two dimensional array of points, and allocating a
colour to each of the points If the points are close colour to each of the points. If the points are close
enough, then we believe the image to be continuous.
Pixel - a picture element, containing the colour or the Pixel a picture element, containing the colour or the
hue and relative brightness of that point in the image.
Image Resolution - The number of pixels in the image. g p g
An image is a continuous thing. We aim to sample points
across the 2 dimensions of the image at a high enough
f h i h f f h frequency so that we are at twice the frequency of the
wanted textures in the picture (Nyquist Limit).
Images: Contd: Images:Contd:
Animageisaspatialrepresentationofanobject,atwo
dimensionalorthreedimensionalsceneoranotherimage.
Oftentheimagesreflecttheintensityoflights.
Mostphotographsarecalledcontinuoustoneimages
becausethemethodusedtodevelopthephotograph
createstheillusionofperfectcontinuoustonethroughout
theimage.
Images stored and processed by computers, displayed on Imagesstoredandprocessedbycomputers,displayedon
computerscreens,arecalleddigitalimagesalthoughthey
oftenlooklikecontinuoustone.Thisisbecausetheyare
representedbyamatrixofnumericvalueseachrepresents p y p
aquantizedintensityvalues.
AcquiringImages
VectorGraphicsRevisited
VectorVsBitmaps
Pixels/Pals Pixels/Pals
Basic Concepts: The smallest element on a BasicConcepts:Thesmallestelementona
digitalimageisknownasapixel apicture
element A digital image consists of a (usually element.Adigitalimageconsistsofa(usually
rectangular)matrixofpixels.
Depth:Thedepthofanimageisthe
numberofbitsusedtorepresenteach
i l pixel.
1bitblackandwhiteimage,also
calledbitmapimage. p g
4bitcanrepresent16colors,usedin
lowresolutionscreens(EGA/VGA)
8 bit can have 256 colors The 256 8bitcanhave256colors.The256
colorimagesareoftenknownas
indexedcolorimages.Thevaluesare
actually indexes to a table of many actuallyindexestoatableofmany
moredifferentcolors.Forexample,
Color3ismappedto(200,10,10).
8bitgrey256greylevels.Theimage
containsonlybrightness/intensity
datawithoutcolorinformation.
Resolution
1. Reduced Color Images
Monochrome Image - Each pixel contains a single Monochrome Image Each pixel contains a single
bit of information, indicating whether the pixel is
light or dark.
Grey scale Images Each pixel is stored as a byte Grey-scale Images - Each pixel is stored as a byte,
indicating the degree of brightness of the point.
Normally interpreted as the brightness from black
to white to white.
2. 24-Bit Colour Image - Each pixel is represented
by three bytes,
RGB - Sometimes stored as a 32 bit quantity,
where top byte is byte, indicating degree of
transparency or other special effects. High degree p y p g g
of correlation between RGB values for typical
images.
YUV,YCbCr - Transformed RGB values such that YUV,YCbCr Transformed RGB values such that
there is low corrlelation between the three bytes.
Digital Images DigitalImages
Animagecontains2Dsamplesofasurface,whichcanberepresented
as matrices Each sample in an image is called a pixel asmatrices.Eachsampleinanimageiscalledapixel.
ColorScheme
RGBColorModel
CMYColorModel
HSBColorModel YUVColorModel
Gamut
Color Models Revisited ColorModelsRevisited
Color Models Contd: 1 ColorModelsContd:1
Color Models Contd: 2 ColorModelsContd:2
Color Models Contd: 3 ColorModelsContd:3
Color Models Contd: 4 ColorModelsContd:4
Color Models Contd: 5 ColorModelsContd:5
Color Model:
a. additive color mixing; b. subtractive mixing
Three main properties:
Brightness: the amount of energy that
stimulates the eye and varies on a gray scale
from black to highest white. It is independent g p
of the color of the source.
Hue: actual color of the source, each color
h diff t f / l th d has a different frequency/wavelength and
the eye determines the color from this.
Saturation: the strength or vividness of the Saturation: the strength or vividness of the
color (lowest has a pastel color. Also, a
saturated color as red has no white light in it.
Luminance: refers to the brightness.
Chrominance: refers to the hue and
t ti ( l l t d) saturation (color related).
Types of Digital Images TypesofDigitalImages
Grayscale image Grayscaleimage
Usuallyweuse256levelsforeachpixel.Thuswe
need 8bits to represent each pixel (2^8 == 256) need8bitstorepresenteachpixel(2 8 256)
Someimagesusemorebitsperpixel,forexample
MRI images could use 16bits per pixel. MRIimagescoulduse16bitsperpixel.
A8bitgrayscale
Image.
BinaryImage
Abinaryimagehasonlytwovalues(0or1).
Binaryimageisquiteimportantinimageanalysisandobject
detectionapplications.
Image Techniques: Dithering ImageTechniques:Dithering
A technique to represent a grayscale image Atechniquetorepresentagrayscaleimage
withabinaryone.
Dithering Contd: Dithering Contd:
Image Techniques: Anti Aliasing ImageTechniques:AntiAliasing
ColorImage
r
gg
b
24bitimage
Color Palettes ColorPalettes
Color Palette: Contd: ColorPalette:Contd:
Coding Methods CodingMethods
Compression: Lossless Compression:Lossless
Encoder
(compression)
Storageor
networks
Decoder
(decompression)
Information
source
(compression) networks (decompression)
DataInput
(asequenceofsymbols
f l h b t)
Recovereddata
Code(asequenceofcodewords)
source
fromanalphabet)
sequence
Losslesscompression:Therecovereddataisexactlythe
same as the input sameastheinput.
Lossycompression:Therecovereddataapproximatesthe
inputdata. p
Compressionratio=(bitsusedtorepresenttheinputdata)/
(bit f th d ) (bitsofthecode)
Lossless Compression LosslessCompression
1 Entropy 1.Entropy
2.Huffman'sCoding
3 i i d 3.DictionaryBased
4.LZ78
5.LZW
Coding Techniques CodingTechniques
The most common coding are Huffman and ThemostcommoncodingareHuffman and
Arithmetic
To compact the rest of the information into even Tocompacttherestoftheinformationintoeven
morecompactsizeHuffmanisfastertoencode
and decode than Arithmetic anddecodethanArithmetic
Arithmeticcodinggivesanadvantageofabout
5% in result size compared to Huffman 5%inresultsizecomparedtoHuffman
Arithmeticcodingisn'timplementedinallcoders
and decoders as it's patented and licensed anddecodersasit spatentedandlicensed
Properties of Huffman Coding PropertiesofHuffmanCoding
Huffmancodinguseslongercodewordforsymbols g g y
withsmallerprobabilitiesandshortercodewordfor
symbolsthatoftenoccur.
Thetwolongestcodeworddifferonlyinthelastbit.
Thecodewordareprefixcodesanduniquely
decodable.
H AverageCodewordLength<H+1
Extended Huffman Coding ExtendedHuffmanCoding
Huffmancodingisnoteffectiveforcaseswhenthere
aresmallnumberofsymbolsandtheprobabilitiesare
highlyskewed.
Example:
Asourcehas2symbolsaandb.P(a)=0.9andP(b)=
0 1 0.1.
H = 0 4690 H 0.4690
ForHuffmanCoding,averagecodewordlengthis1.(far
fromoptimal !)
Lossy Compression Lossy Compression
Apartfromlosslesscompression,wecanfurther p p ,
reducethebitstorepresentmediadataby
discardingunnecessaryinformation.
Mediasuchasimage,audioandvideocanbe
modified without seriously affecting the modified withoutseriouslyaffectingthe
perceivedquality.
Lossy multimediadatacompressionstandards
includeJPEG,MPEG,etc.
MethodsofDiscarding
I f ti /R d i Fil Si Information/ReducingFileSize
Reducingresolution
Originalimage 1/2resolutionandzoomin
Reducepixelcolorlevels
Originalimage
colorlevels
Foraudiosandvideoswecansimilarlyreduce
thesamplingrate,thesamplelevels,etc.
Thesemethodsusuallyintroducelarge ese et ods usua y t oduce a ge
distortion.Smarterschemesarenecessary!
2.3bits/pixel(JPEG)
Key Terms KeyTerms
Distortion: Distortion:theamountofdifferencebetweenthe
d d di d t d th i i l encodedmediadataandtheoriginalone.
Quantization:
d f l ll f Mapsacontinuousordiscretesetofvaluesintoasmallersetof
values.
Th b i th d t th i f ti Thebasicmethodtothrowawayinformation.
Quantizationcanbeusedforbothscalars(singlenumbers)or
vectors (several numbers together) vectors(severalnumberstogether).
Afterquantization,wecangenerateafixedlengthcodedirectly.
Image Compression: JPEG ImageCompression:JPEG
JPEGJointPhotographicExpertGroup
KeyPoints:
1. JPEGusesapowerfulbutlossy compressionmethodthat
produces files as much as ten times more compressed producesfilesasmuchastentimesmorecompressed
thanGIF.
2. TheJPEGcompressionschemecompressesabout20:1
before visible image degradation occurs. beforevisibleimagedegradationoccurs.
3. TocompressanimagewithJPEG,theimageisdividedinto
8x8pixelblocks,andtheresulting64pixels.
4 JPEG compresses slowly about one to three seconds for 4.JPEGcompressesslowlyaboutonetothreesecondsfor
a1MBimagedependinguponcomputerspeedbutJPEG
cancompressimagesasmuchas75:1,withloss.
JPEG (ISO 10918) JPEG(ISO10918)
Lossy compressionstandardforcontinuoustone y p
images
designedtoexploitknownlimitationsofthe
human eye humaneye
smallcolorchangesareperceivedlessaccurately
than small changes in brightness might not be thansmallchangesinbrightnessmightnotbe
suitableformachineanalyzedimages,line
drawingsortextualgraphicsalsoalosslessJPEG
exists but it is not widely used existsbutitisnotwidelyused
Basedondiscretecosinetransform(DCT)
Only a compression standard not a file format Onlyacompressionstandardnotafileformat
JPEG Compression Technique JPEGCompressionTechnique
Related standards Relatedstandards
JPEG (ISO 10918) JPEG(ISO10918)
Lossy compressionbasedondiscretecosine
transform transform
JPEG2000
Lossy compressionbasedonwavelet
transform
JBIG
Lossless bilevel (black & white) compression Losslessbi level(black&white)compression
JPEG File Interchange Format(JFIF) JPEGFileInterchangeFormat(JFIF)
JPEG only specifies the encoding of the image JPEGonlyspecifiestheencodingoftheimage
JFIFspecifiesthefileformatforcomputer
storage
IssuedbyIndependentJPEGGroup
ThemostcommonfileextensionforJFIFis
.jpg,but.jpeg,.jfif,.JPG,and.JPEarealsoused jpg, jp g, j , ,
AlsootherJPEGbasedfileformatsexistsuch
as JNG asJNG
Encoding Process EncodingProcess
1 Color Space Transformation 1.ColorSpaceTransformation
2.Downsampling
3 i C i f 3.DiscreteCosineTransform
4.Quantization
5.EntropyCoding
DCTDiscrete Cosine Transformation DCT DiscreteCosineTransformation
Transformation to Transformationto
frequencydomainisdone
i 8 8 bl k ( i ) in88blocks(matrices)
Allvaluesinthe
matrixarefirstshifteddown
(subtracted) by 128. (subtracted)by128.
Discrete Cosine Transform Contd: DiscreteCosineTransformContd:
DCT/IDCT Formula DCT/IDCTFormula
( ) ( ) ( ) ( )
( ) ( )v j u i
j i f v C u C v u F
i j
16
1 2
cos
16
1 2
cos ,
4
1
,
7
0
7
0
+ +
=

= =
( ) ( ) ( ) ( )
( ) ( )
( ) ( ) u C otherwise 0 u if u C
v j u i
v u F v C u C j i f
i j
i j
1
2
16
1 2
cos
16
1 2
cos ,
4
1
,
7
0
7
0
0 0
= = =
+ +
=

= =
DCTformulaisapplied
( ) ( ) u C otherwise 0, u if u C 1
2
= = =
Thevaluesareroundedto
integers
JPEGDCT JPEG DCT
Pros & Cons Pros&Cons
Pros
Lowcomplexity
Memoryefficient
Reasonablecodingefficiency
Excellentcolorrange g
Generallyexcellentimagequality/filesizes
forphotographs p g p
Compatibility(hardware&software)
Adjustable image quality Adjustableimagequality
Pros and Cons Contd: ProsandConsContd:
Cons
Singleresolution
Singlequality
No target bit rate Notargetbitrate
Blockingartifactsatlowbitrate
Poorerrorresilience
Notiling
Noregionsofinterest
Compression algorithm occasionally results in suboptimal Compressionalgorithmoccasionallyresultsinsuboptimal
visualresultswhenusedongraphicsartandtext
Nosupportfortransparency.
No support for animation Nosupportforanimation.
Application Areas ApplicationAreas
Internet Cultural Heritage Internet
DigitalPhotography
Medical Imaging
CulturalHeritage
ScientificandIndustrial
Digital Cinema MedicalImaging
WirelessImaging
Document Imaging
DigitalCinema
Imagearchivesand
databases
DocumentImaging
PrePress
Remote sensing and GIS
databases
Surveillance
Printing and scanning
RemotesensingandGIS
Printingandscanning
Facsimile
JPEG Processes: In a Nutshell
Initial Image Preparation
Image must be represented in YUV, and is manipulated
as 8 x 8 blocks of pixels. p
Discrete Cosine Transform
(DCT) is a fast transformation into frequency domain
that is close to optimal that is close to optimal.
Quantization
quantizes the frequency co-efficients. High frequency
coefficients has coarse quantization leading to loss of coefficients has coarse quantization, leading to loss of
high frequency information.
Entropy Encoder
U diff ti l di f DC t d Uses differential encoding for DC component, and run-
length encoding for AC components. Encodes each
run-length tuple using Huffman code.
T d d th i th i DCT To decode, reverse the process, using the inverse DCT.
Sequential mode where components are sent
in left-to-right, top-to-bottom scan in left to right, top to bottom scan
Lossless Mode using differential encoding
based on predictive techniques based on up
to three other surrounding pixels to three other surrounding pixels.
Progressive mode, in which DC components
and first few AC components of each block
stored first for all blocks Allows image to stored first for all blocks. Allows image to
appear faster.
Hierarchical Mode where subsampled image
i d d th th l d d is encoded, then other samples encoded as
differences.
JPEG 2000 appeared, based upon wavelets pp , p
instead of DCT, with features for interworking
with MPEG, content cataloguing, and
computer-generated images. p g g
Image and Graphics Software ImageandGraphicsSoftware
Image and Graphics File Formats ImageandGraphicsFileFormats
PNG (Portable Network Graphics) PNG(PortableNetworkGraphics)
PNG is a lossless image compressing method PNGisalosslessimagecompressingmethod
basedonLZ77.
PNG supports three main image types: true PNGsupportsthreemainimagetypes:true
color,grayscaleandpalettebased("8bit").
PNG l h h l PNGsupportsalphachannel
GIF (Graphics Interchange Format) GIF(GraphicsInterchangeFormat)
GIFwasdevisedbyUNISYSandCompuserve.
GIFisbasedonLZWlosslesscompression.
GIFsupports8bit(256)colorimagesonly.Each
imagecanhaveitsowncolortable. g
Itsupportstransparencylayerandsimple
animation functions animationfunctions.
Italsosupportsinterlacedcodinganddecoding. pp g g
GIF Contd: 1 GIFContd:1
GIF Contd: 2 GIFContd:2
References References
Wikipedia:JPEG
http://en.wikipedia.org/wiki/JPEG
Wikipedia:DiscreteCosineTransform
http://en.wikipedia.org/wiki/Discrete_cosine_transform
TheDiscreteCosineTransform(DCT):TheoryandApplication
http://www.egr.msu.edu/waves/people/Ali_files/DCT_TR802.pdf
Gernot Hoffman:JPEGCompression
http://www.fhoemden.de/~hoffmann/jpeg131200.pdf
G.K.Wallace,"TheJPEGStillPictureCompressionStandard,
CommunicationsoftheACM,April,1991,pp.35.
JointPhotographicExpertsGroup
http://www.jpeg.org

You might also like