SlideShare a Scribd company logo
1 of 20
Download to read offline
426
Back
Close
Compression: Images (JPEG)
What is JPEG?
• JPEG: Joint Photographic Expert Group — an international
standard since 1992.
• Works with colour and greyscale images
• Up to 24 bit colour images (Unlike GIF)
• Target photographic quality images (Unlike GIF)
• Suitable for many applications e.g., satellite, medical, general
photography...
427
Back
Close
Basic JPEG Compression Pipeline
JPEG compression involves the following:
• Encoding
• Decoding – Reverse the order for encoding
428
Back
Close
Major Coding Algorithms in JPEG
The Major Steps in JPEG Coding involve:
• Colour Space Transform and subsampling (YIQ)
• DCT (Discrete Cosine Transformation)
• Quantisation
• Zigzag Scan
• DPCM on DC component
• RLE on AC Components
• Entropy Coding — Huffman or Arithmetic
We have met most of the algorithms already:
• JPEG exploits them in the compression pipeline to achieve
maximal overall compression.
429
Back
Close
Quantisation
Why do we need to quantise:
• To throw out bits from DCT.
• Example: (101101)2 = 45 (6 bits).
Truncate to 4 bits: (1011)2 = 11.
Truncate to 3 bits: (101)2 = 5.
• Quantisation error is the main source of Lossy Compression.
• DCT itself is not Lossy
• How we throw away bits in Quantisation Step is Lossy
430
Back
Close
Quantisation Methods
Uniform quantisation
• Divide by constant N and round result
(N = 4 or 8 in examples on previous page).
• Non powers-of-two gives fine control
(e.g., N = 6 loses 2.5 bits)
431
Back
Close
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.
• Eye is most sensitive to low frequencies (upper left corner),
less sensitive to high frequencies (lower right corner)
• JPEG Standard defines 2 default quantisation tables, one for
luminance (below), one for chrominance. E.g Table below
----------------------------------
16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99
----------------------------------
432
Back
Close
Quantization Tables (Cont)
• Q: How would changing the numbers affect the picture
E.g., if we doubled them all?
Quality factor in most implementations is the scaling factor for
default quantization tables.
• Custom quantization tables can be put in image/scan header.
JPEG Quantisation Example
• JPEG Quantisation Example (Java Applet)
433
Back
Close
Zig-zag Scan
What is the purpose of the Zig-zag Scan:
• To group low frequency coefficients in top of vector.
• Maps 8 x 8 to a 1 x 64 vector
434
Back
Close
Differential Pulse Code Modulation
(DPCM) on DC Component
• Another encoding method is employed
• DPCM on the DC component.
• Why is this strategy adopted:
– DC component is large and varies, but often close to
previous value (like lossless JPEG).
– Encode the difference from previous 8x8 blocks – DPCM
435
Back
Close
Run Length Encode (RLE) on AC
Components
Yet another simple compression technique is applied to the
AC component:
• 1x63 vector (AC) has lots of zeros in it
• Encode as (skip, value) pairs, where skip is the number of
zeros and value is the next non-zero component.
• Send (0,0) as end-of-block sentinel value.
436
Back
Close
Huffman (Entropy) Coding
DC and AC components finally need to be represented by a
smaller number of bits
(Arithmetic coding also supported in place of Huffman coding):
• (Variant of) Huffman coding: Each DPCM-coded DC
coefficient is represented by a pair of symbols :
(Size, Amplitude)
where Size indicates number of bits needed to represent
coefficient and
Amplitude contains actual bits.
• Size only Huffman coded in JPEG:
– Size does not change too much, generally smaller Sizes
occur frequently (= low entropy so is suitable for coding,
– Amplitude can change widely so coding no real benefit
437
Back
Close
Huffman (Entropy) Coding (Cont)
• Example Size category for possible Amplitudes:
-------------------------------------------------
Size Typical Huffman Code for Size Amplitude
0 00 0
1 010 -1,1
2 011 -3,-2,2,3
3 100 -7..-4,4..7
4 101 -15..-8,8..15
. . .
. . .
--------------------------------------------------
• Use ones complement scheme for negative values: i.e 10 is
binary for 2 and 01 for -2 (bitwise inverse). Similarly, 00 for
-3 and 11 for 3.
438
Back
Close
Huffman Coding DC Example
• Example: if DC values are 150, -6, 5, 3, -8
• Then 8, 3, 3, 2 and 4 bits are needed respectively.
Send off Sizes as Huffman symbol, followed by actual values
in bits.
(8huff , 10010110), (3huff , 001), (3huff , 101), (2huff , 11), (4huff , 0111)
where 8huff . . . are the Huffman codes for respective numbers.
• Huffman Tables can be custom (sent in header) or default.
439
Back
Close
Huffman Coding on AC Component
AC coefficient are run-length encoded (RLE)
• RLE pairs (Runlength, Value) are Huffman coded as with
DC only on Value.
• So we get a triple: (Runlength, Size, Amplitude)
• However, Runlength, Size allocated 4-bits each and put
into a single byte with is then Huffman coded.
Again , Amplitude is not coded.
• So only two symbols transmitted per RLE coefficient:
(RLESIZEbytehuff, Amplitude)
440
Back
Close
Example JPEG Compression
441
Back
Close
Another Enumerated Example
442
Back
Close
JPEG Example MATLAB Code
The JPEG algorithm may be summarised as follows,
im2jpeg.m (Encoder) jpeg2im.m (Decoder)
mat2huff.m (Huffman coder)
m = [16 11 10 16 24 40 51 61 % JPEG normalizing array
12 12 14 19 26 58 60 55 % and zig-zag reordering
14 13 16 24 40 57 69 56 % pattern.
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99] * quality;
order = [1 9 2 3 10 17 25 18 11 4 5 12 19 26 33 ...
41 34 27 20 13 6 7 14 21 28 35 42 49 57 50 ...
43 36 29 22 15 8 16 23 30 37 44 51 58 59 52 ...
45 38 31 24 32 39 46 53 60 61 54 47 40 48 55 ...
62 63 56 64];
[xm, xn] = size(x); % Get input size.
x = double(x) - 128; % Level shift input
t = dctmtx(8); % Compute 8 x 8 DCT matrix
% Compute DCTs of 8x8 blocks and quantize the coefficients.
y = blkproc(x, [8 8], ’P1 * x * P2’, t, t’);
y = blkproc(y, [8 8], ’round(x ./ P1)’, m);
443
Back
Close
y = im2col(y, [8 8], ’distinct’); % Break 8x8 blocks into columns
xb = size(y, 2); % Get number of blocks
y = y(order, :); % Reorder column elements
eob = max(y(:)) + 1; % Create end-of-block symbol
r = zeros(numel(y) + size(y, 2), 1);
count = 0;
for j = 1:xb % Process 1 block (col) at a time
i = max(find(y(:, j))); % Find last non-zero element
if isempty(i) % No nonzero block values
i = 0;
end
p = count + 1;
q = p + i;
r(p:q) = [y(1:i, j); eob]; % Truncate trailing 0’s, add EOB,
count = count + i + 1; % and add to output vector
end
r((count + 1):end) = []; % Delete unusued portion of r
y = struct;
y.size = uint16([xm xn]);
y.numblocks = uint16(xb);
y.quality = uint16(quality * 100);
y.huffman = mat2huff(r);
444
Back
Close
Further Information
Further standards:
• Lossless JPEG: Predictive approach for lossless compression
(why?), not widely used
• JPEG 2000: ISO/IEC 15444
– Based on wavelet transform, instead of DCT, no 8 × 8 blocks,
less artefacts
– Often better compression ratio, compared with JPEG
445
Back
Close
Further Information
References:
• http://www.jpeg.org
• Online JPEG Tutorial
• The JPEG Still Picture Compression Standard
• The JPEG 2000 Still Image Compression Standard

More Related Content

What's hot (20)

Image compression standards
Image compression standardsImage compression standards
Image compression standards
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representation
 
Transform coding
Transform codingTransform coding
Transform coding
 
Jpeg dct
Jpeg dctJpeg dct
Jpeg dct
 
Introduction to Image Compression
Introduction to Image CompressionIntroduction to Image Compression
Introduction to Image Compression
 
Image compression
Image compressionImage compression
Image compression
 
Compression: Video Compression (MPEG and others)
Compression: Video Compression (MPEG and others)Compression: Video Compression (MPEG and others)
Compression: Video Compression (MPEG and others)
 
Chapter 8 image compression
Chapter 8 image compressionChapter 8 image compression
Chapter 8 image compression
 
Bit plane coding
Bit plane codingBit plane coding
Bit plane coding
 
Image compression .
Image compression .Image compression .
Image compression .
 
Image Compression
Image CompressionImage Compression
Image Compression
 
Audio compression
Audio compressionAudio compression
Audio compression
 
Multimedia image compression standards
Multimedia image compression standardsMultimedia image compression standards
Multimedia image compression standards
 
Dilation and erosion
Dilation and erosionDilation and erosion
Dilation and erosion
 
Video Compression Basics
Video Compression BasicsVideo Compression Basics
Video Compression Basics
 
Interpixel redundancy
Interpixel redundancyInterpixel redundancy
Interpixel redundancy
 
Video compression
Video compressionVideo compression
Video compression
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
JPEG
JPEGJPEG
JPEG
 

Viewers also liked

Image processing and compression techniques
Image processing and compression techniquesImage processing and compression techniques
Image processing and compression techniquesAshwin Venkataraman
 
Image compression
Image compressionImage compression
Image compressionAle Johnsan
 
Seminar Report on image compression
Seminar Report on image compressionSeminar Report on image compression
Seminar Report on image compressionPradip Kumar
 
image compression using matlab project report
image compression  using matlab project reportimage compression  using matlab project report
image compression using matlab project reportkgaurav113
 
Jpeg 2000 For Digital Archives
Jpeg 2000 For Digital ArchivesJpeg 2000 For Digital Archives
Jpeg 2000 For Digital ArchivesRichard Bernier
 
intoPIX - Everything about Jpeg2000
intoPIX - Everything about Jpeg2000intoPIX - Everything about Jpeg2000
intoPIX - Everything about Jpeg2000guestd38f1
 
Signal Compression and JPEG
Signal Compression and JPEGSignal Compression and JPEG
Signal Compression and JPEGguest9006ab
 
Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compressionM.k. Praveen
 
MPEG video compression standard
MPEG video compression standardMPEG video compression standard
MPEG video compression standardanuragjagetiya
 
Spandana image processing and compression techniques (7840228)
Spandana   image processing and compression techniques (7840228)Spandana   image processing and compression techniques (7840228)
Spandana image processing and compression techniques (7840228)indianspandana
 
Data compression introduction
Data compression introductionData compression introduction
Data compression introductionRahul Khanwani
 
Image processing
Image processingImage processing
Image processingVarun Raj
 

Viewers also liked (20)

image compression ppt
image compression pptimage compression ppt
image compression ppt
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 
Image compression
Image compressionImage compression
Image compression
 
Image compression
Image compressionImage compression
Image compression
 
Image processing and compression techniques
Image processing and compression techniquesImage processing and compression techniques
Image processing and compression techniques
 
Image compression
Image compressionImage compression
Image compression
 
Seminar Report on image compression
Seminar Report on image compressionSeminar Report on image compression
Seminar Report on image compression
 
Compression
CompressionCompression
Compression
 
image compression using matlab project report
image compression  using matlab project reportimage compression  using matlab project report
image compression using matlab project report
 
Jpeg 2000 For Digital Archives
Jpeg 2000 For Digital ArchivesJpeg 2000 For Digital Archives
Jpeg 2000 For Digital Archives
 
Jpeg
JpegJpeg
Jpeg
 
intoPIX - Everything about Jpeg2000
intoPIX - Everything about Jpeg2000intoPIX - Everything about Jpeg2000
intoPIX - Everything about Jpeg2000
 
Signal Compression and JPEG
Signal Compression and JPEGSignal Compression and JPEG
Signal Compression and JPEG
 
Image processing ppt
Image processing pptImage processing ppt
Image processing ppt
 
Fundamentals of Data compression
Fundamentals of Data compressionFundamentals of Data compression
Fundamentals of Data compression
 
MPEG video compression standard
MPEG video compression standardMPEG video compression standard
MPEG video compression standard
 
Spandana image processing and compression techniques (7840228)
Spandana   image processing and compression techniques (7840228)Spandana   image processing and compression techniques (7840228)
Spandana image processing and compression techniques (7840228)
 
Data compression introduction
Data compression introductionData compression introduction
Data compression introduction
 
Data compression
Data compressionData compression
Data compression
 
Image processing
Image processingImage processing
Image processing
 

Similar to Compression: Images (JPEG)

CyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfCyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfMohammadAzreeYahaya
 
lossy compression JPEG
lossy compression JPEGlossy compression JPEG
lossy compression JPEGMahmoud Hikmet
 
SOC Application Studies: Image Compression
SOC Application Studies: Image CompressionSOC Application Studies: Image Compression
SOC Application Studies: Image CompressionA B Shinde
 
Image compression- JPEG Compression & its Modes
Image compression- JPEG Compression & its ModesImage compression- JPEG Compression & its Modes
Image compression- JPEG Compression & its Modeskanimozhirajasekaren
 
M4L1.ppt
M4L1.pptM4L1.ppt
M4L1.pptdudoo1
 
Multimedia communication jpeg
Multimedia communication jpegMultimedia communication jpeg
Multimedia communication jpegDr. Kapil Gupta
 
MPEG-1 Part 2 Video Encoding
MPEG-1 Part 2 Video EncodingMPEG-1 Part 2 Video Encoding
MPEG-1 Part 2 Video EncodingChristian Kehl
 
image compression in data compression
image compression in data compressionimage compression in data compression
image compression in data compressionZaabir Ali
 
Why Image compression is Necessary?
Why Image compression is Necessary?Why Image compression is Necessary?
Why Image compression is Necessary?Prabhat Kumar
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.pptnaghamallella
 
Archi Modelling
Archi ModellingArchi Modelling
Archi Modellingdilane007
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Kshitij Singh
 
jpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptjpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptnaghamallella
 
Cycle’s topological optimizations and the iterative decoding problem on gener...
Cycle’s topological optimizations and the iterative decoding problem on gener...Cycle’s topological optimizations and the iterative decoding problem on gener...
Cycle’s topological optimizations and the iterative decoding problem on gener...Usatyuk Vasiliy
 
introduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptintroduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptnaghamallella
 

Similar to Compression: Images (JPEG) (20)

CyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdfCyberSec_JPEGcompressionForensics.pdf
CyberSec_JPEGcompressionForensics.pdf
 
lossy compression JPEG
lossy compression JPEGlossy compression JPEG
lossy compression JPEG
 
Data compression
Data compressionData compression
Data compression
 
SOC Application Studies: Image Compression
SOC Application Studies: Image CompressionSOC Application Studies: Image Compression
SOC Application Studies: Image Compression
 
Image compression- JPEG Compression & its Modes
Image compression- JPEG Compression & its ModesImage compression- JPEG Compression & its Modes
Image compression- JPEG Compression & its Modes
 
M4L1.ppt
M4L1.pptM4L1.ppt
M4L1.ppt
 
Multimedia communication jpeg
Multimedia communication jpegMultimedia communication jpeg
Multimedia communication jpeg
 
MPEG-1 Part 2 Video Encoding
MPEG-1 Part 2 Video EncodingMPEG-1 Part 2 Video Encoding
MPEG-1 Part 2 Video Encoding
 
image compression in data compression
image compression in data compressionimage compression in data compression
image compression in data compression
 
Why Image compression is Necessary?
Why Image compression is Necessary?Why Image compression is Necessary?
Why Image compression is Necessary?
 
Jpeg standards
Jpeg   standardsJpeg   standards
Jpeg standards
 
Ch7 031102
Ch7 031102Ch7 031102
Ch7 031102
 
image processing for jpeg presentati.ppt
image processing for jpeg presentati.pptimage processing for jpeg presentati.ppt
image processing for jpeg presentati.ppt
 
Image compression and jpeg
Image compression and jpegImage compression and jpeg
Image compression and jpeg
 
Archi Modelling
Archi ModellingArchi Modelling
Archi Modelling
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1
 
jpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.pptjpg image processing nagham salim_as.ppt
jpg image processing nagham salim_as.ppt
 
Cycle’s topological optimizations and the iterative decoding problem on gener...
Cycle’s topological optimizations and the iterative decoding problem on gener...Cycle’s topological optimizations and the iterative decoding problem on gener...
Cycle’s topological optimizations and the iterative decoding problem on gener...
 
*αí*ß
*αí*ß*αí*ß
*αí*ß
 
introduction to jpeg for image proce.ppt
introduction to jpeg for image proce.pptintroduction to jpeg for image proce.ppt
introduction to jpeg for image proce.ppt
 

More from danishrafiq

More from danishrafiq (8)

Usability issues in mobile web
Usability issues in mobile webUsability issues in mobile web
Usability issues in mobile web
 
Lecture5---Gantt Chart
Lecture5---Gantt ChartLecture5---Gantt Chart
Lecture5---Gantt Chart
 
Ccna day5
Ccna day5Ccna day5
Ccna day5
 
Ccna day4
Ccna day4Ccna day4
Ccna day4
 
Ccna day3
Ccna day3Ccna day3
Ccna day3
 
Ccna day2
Ccna day2Ccna day2
Ccna day2
 
Ccna day1
Ccna day1Ccna day1
Ccna day1
 
Presentation wpf
Presentation wpfPresentation wpf
Presentation wpf
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Compression: Images (JPEG)

  • 1. 426 Back Close Compression: Images (JPEG) What is JPEG? • JPEG: Joint Photographic Expert Group — an international standard since 1992. • Works with colour and greyscale images • Up to 24 bit colour images (Unlike GIF) • Target photographic quality images (Unlike GIF) • Suitable for many applications e.g., satellite, medical, general photography...
  • 2. 427 Back Close Basic JPEG Compression Pipeline JPEG compression involves the following: • Encoding • Decoding – Reverse the order for encoding
  • 3. 428 Back Close Major Coding Algorithms in JPEG The Major Steps in JPEG Coding involve: • Colour Space Transform and subsampling (YIQ) • DCT (Discrete Cosine Transformation) • Quantisation • Zigzag Scan • DPCM on DC component • RLE on AC Components • Entropy Coding — Huffman or Arithmetic We have met most of the algorithms already: • JPEG exploits them in the compression pipeline to achieve maximal overall compression.
  • 4. 429 Back Close Quantisation Why do we need to quantise: • To throw out bits from DCT. • Example: (101101)2 = 45 (6 bits). Truncate to 4 bits: (1011)2 = 11. Truncate to 3 bits: (101)2 = 5. • Quantisation error is the main source of Lossy Compression. • DCT itself is not Lossy • How we throw away bits in Quantisation Step is Lossy
  • 5. 430 Back Close Quantisation Methods Uniform quantisation • Divide by constant N and round result (N = 4 or 8 in examples on previous page). • Non powers-of-two gives fine control (e.g., N = 6 loses 2.5 bits)
  • 6. 431 Back Close 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. • Eye is most sensitive to low frequencies (upper left corner), less sensitive to high frequencies (lower right corner) • JPEG Standard defines 2 default quantisation tables, one for luminance (below), one for chrominance. E.g Table below ---------------------------------- 16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 ----------------------------------
  • 7. 432 Back Close Quantization Tables (Cont) • Q: How would changing the numbers affect the picture E.g., if we doubled them all? Quality factor in most implementations is the scaling factor for default quantization tables. • Custom quantization tables can be put in image/scan header. JPEG Quantisation Example • JPEG Quantisation Example (Java Applet)
  • 8. 433 Back Close Zig-zag Scan What is the purpose of the Zig-zag Scan: • To group low frequency coefficients in top of vector. • Maps 8 x 8 to a 1 x 64 vector
  • 9. 434 Back Close Differential Pulse Code Modulation (DPCM) on DC Component • Another encoding method is employed • DPCM on the DC component. • Why is this strategy adopted: – DC component is large and varies, but often close to previous value (like lossless JPEG). – Encode the difference from previous 8x8 blocks – DPCM
  • 10. 435 Back Close Run Length Encode (RLE) on AC Components Yet another simple compression technique is applied to the AC component: • 1x63 vector (AC) has lots of zeros in it • Encode as (skip, value) pairs, where skip is the number of zeros and value is the next non-zero component. • Send (0,0) as end-of-block sentinel value.
  • 11. 436 Back Close Huffman (Entropy) Coding DC and AC components finally need to be represented by a smaller number of bits (Arithmetic coding also supported in place of Huffman coding): • (Variant of) Huffman coding: Each DPCM-coded DC coefficient is represented by a pair of symbols : (Size, Amplitude) where Size indicates number of bits needed to represent coefficient and Amplitude contains actual bits. • Size only Huffman coded in JPEG: – Size does not change too much, generally smaller Sizes occur frequently (= low entropy so is suitable for coding, – Amplitude can change widely so coding no real benefit
  • 12. 437 Back Close Huffman (Entropy) Coding (Cont) • Example Size category for possible Amplitudes: ------------------------------------------------- Size Typical Huffman Code for Size Amplitude 0 00 0 1 010 -1,1 2 011 -3,-2,2,3 3 100 -7..-4,4..7 4 101 -15..-8,8..15 . . . . . . -------------------------------------------------- • Use ones complement scheme for negative values: i.e 10 is binary for 2 and 01 for -2 (bitwise inverse). Similarly, 00 for -3 and 11 for 3.
  • 13. 438 Back Close Huffman Coding DC Example • Example: if DC values are 150, -6, 5, 3, -8 • Then 8, 3, 3, 2 and 4 bits are needed respectively. Send off Sizes as Huffman symbol, followed by actual values in bits. (8huff , 10010110), (3huff , 001), (3huff , 101), (2huff , 11), (4huff , 0111) where 8huff . . . are the Huffman codes for respective numbers. • Huffman Tables can be custom (sent in header) or default.
  • 14. 439 Back Close Huffman Coding on AC Component AC coefficient are run-length encoded (RLE) • RLE pairs (Runlength, Value) are Huffman coded as with DC only on Value. • So we get a triple: (Runlength, Size, Amplitude) • However, Runlength, Size allocated 4-bits each and put into a single byte with is then Huffman coded. Again , Amplitude is not coded. • So only two symbols transmitted per RLE coefficient: (RLESIZEbytehuff, Amplitude)
  • 17. 442 Back Close JPEG Example MATLAB Code The JPEG algorithm may be summarised as follows, im2jpeg.m (Encoder) jpeg2im.m (Decoder) mat2huff.m (Huffman coder) m = [16 11 10 16 24 40 51 61 % JPEG normalizing array 12 12 14 19 26 58 60 55 % and zig-zag reordering 14 13 16 24 40 57 69 56 % pattern. 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99] * quality; order = [1 9 2 3 10 17 25 18 11 4 5 12 19 26 33 ... 41 34 27 20 13 6 7 14 21 28 35 42 49 57 50 ... 43 36 29 22 15 8 16 23 30 37 44 51 58 59 52 ... 45 38 31 24 32 39 46 53 60 61 54 47 40 48 55 ... 62 63 56 64]; [xm, xn] = size(x); % Get input size. x = double(x) - 128; % Level shift input t = dctmtx(8); % Compute 8 x 8 DCT matrix % Compute DCTs of 8x8 blocks and quantize the coefficients. y = blkproc(x, [8 8], ’P1 * x * P2’, t, t’); y = blkproc(y, [8 8], ’round(x ./ P1)’, m);
  • 18. 443 Back Close y = im2col(y, [8 8], ’distinct’); % Break 8x8 blocks into columns xb = size(y, 2); % Get number of blocks y = y(order, :); % Reorder column elements eob = max(y(:)) + 1; % Create end-of-block symbol r = zeros(numel(y) + size(y, 2), 1); count = 0; for j = 1:xb % Process 1 block (col) at a time i = max(find(y(:, j))); % Find last non-zero element if isempty(i) % No nonzero block values i = 0; end p = count + 1; q = p + i; r(p:q) = [y(1:i, j); eob]; % Truncate trailing 0’s, add EOB, count = count + i + 1; % and add to output vector end r((count + 1):end) = []; % Delete unusued portion of r y = struct; y.size = uint16([xm xn]); y.numblocks = uint16(xb); y.quality = uint16(quality * 100); y.huffman = mat2huff(r);
  • 19. 444 Back Close Further Information Further standards: • Lossless JPEG: Predictive approach for lossless compression (why?), not widely used • JPEG 2000: ISO/IEC 15444 – Based on wavelet transform, instead of DCT, no 8 × 8 blocks, less artefacts – Often better compression ratio, compared with JPEG
  • 20. 445 Back Close Further Information References: • http://www.jpeg.org • Online JPEG Tutorial • The JPEG Still Picture Compression Standard • The JPEG 2000 Still Image Compression Standard