Upload
bhavsinghpm007
View
240
Download
0
Embed Size (px)
Citation preview
8/8/2019 94001 DCT
1/38
DCT Image Compression
D. BHAVSINGHD. BHAVSINGH
EC94001EC94001
M.TECH ,E.IM.TECH ,E.I
8/8/2019 94001 DCT
2/38
What is Compression?
Compression is an agreement between sender and receiver to a
system for the compaction of source redundancy and/or removal of
irrelevancy.
lossless and
lossy image compression.
8/8/2019 94001 DCT
3/38
8/8/2019 94001 DCT
4/38
THEDISCRETECOSINETRANSFORM
the Discrete Cosine Transform (DCT) attempts to decorrelate the
image data
decorrelation each transform coefficient can be encoded
independently without losing compression efficiency
important properties.
One-Dimensional DCT
Two-Dimensional DCT
8/8/2019 94001 DCT
5/38
8/8/2019 94001 DCT
6/38
One-Dimensional DCT
The most common DCT definition of a 1-D sequence of length N is
Similarly, the inverse transformation is defined as
8/8/2019 94001 DCT
7/38
Two-Dimensional DCT
The 2-D Discrete Cosine Transform is just a one dimensional DCT
applied twice, once in the x direction, and again in the y direction.
The DCT equation (Eq.1) computes the i, jth entry of the DCT of an
image
8/8/2019 94001 DCT
8/38
Lossy Image Compression (JPEG)
Block-based Discrete Cosine Transform (DCT)
8/8/2019 94001 DCT
9/38
THEDCTMATRIX
the matrix form of Equation (1), we will use the following equation
8x8 block it results in this matrix
8/8/2019 94001 DCT
10/38
DCTON AN 8x8 BLOCK
the pixel values of a black-and-white image range from 0 to
255
Pure black is represented by 0,
Pure white by 255 This particular block was chosen from the very upper- left-hand
corner of an image
8/8/2019 94001 DCT
11/38
the DCT is designed to work on pixel values ranging from -128 to
127 the original block is leveled off by subtracting 128 from each
entry.
This results in the following matrix
8/8/2019 94001 DCT
12/38
The discrete Cosine Transform, is accomplished by matrix
multiplication
D = TMT-----(5)
This block matrix now consists of 64 DCT coefficients
c (i, j) i and j range from 0 to 7
8/8/2019 94001 DCT
13/38
QUANTIZATION
8x8 block of DCT coefficients is compression by quantization
Its decide on quality levels ranging from 1 to 100,
1 gives the poorest image quality and highest compression, 100 gives the best quality and lowest compression
8/8/2019 94001 DCT
14/38
Quantization is achieved by dividing each element in the
transformed image matrix D by corresponding element in the
quantization matrix
8/8/2019 94001 DCT
15/38
CODING
Before storage, all coefficients of C are converted by an encoder to a
stream of binary data (01101011...).
JPEG takes advantage of this by encoding quantized coefficients in
the zig-zag sequence
8/8/2019 94001 DCT
16/38
DECOMPRESSION:
Reconstruction of our image begins by decoding the bit stream
representing the Quantized matrix C.
R i, j =Q i, j C i, j
The IDCT is next applied to matrix R, which is rounded to the nearest
integer. Finally, 128 is added to each element of that result, giving us
the decompressed JPEG version N of our original 8x8 image block M
8/8/2019 94001 DCT
17/38
Lossy DCT Image Compression
The lossy DCT method compression
method is widely used in current
standards. For example, JPEG images
and MPEG-1 and MPEG-2 (DVD)
videos.
As we can see here, heavily DCT-
compressed images contain blocking
artefacts. Ringing artefacts can also be
seen around edges.
LosslessLossless
LossyLossy
8/8/2019 94001 DCT
18/38
Rate/Distortion
As we have seen, quality can fall rapidly
as shown by the steep slope of rate/
distortion graph.
DCT methods typically* work well up to
around 10:1 compression ratios and
then quality falls rapidly beyond this.
a) Original b) DCT : QF 3 : CR 8:1
c) DCT : QF 10 : CR 11.6:1 d) DCT : QF 20 : CR 13.6:1
e) DCT : QF 25 : CR 14.2:1 f) Difference a-e
8/8/2019 94001 DCT
19/38
DCTCompression
DCT QF 3 image (CR=8:1)
8/8/2019 94001 DCT
20/38
DCTCompression
DCT QF 15 image (CR=12:1)
8/8/2019 94001 DCT
21/38
DCTCompression
DCT QF 25 image CR=14:1
8/8/2019 94001 DCT
22/38
DCTCompression
8/8/2019 94001 DCT
23/38
DCT Image Compression
The philosophy behind DCT
image compression is that
the human eye is less
sensitive to higher-frequency
information and also more
sensitive to intensity than tocolour.
The examples shown here
are from Dr Flowers MPEG
slides showing the effects of
percentage reduction of colour.
Original (100%) 0.5 UV (25%) 0.25 UV (6.25%)
0.2 UV (4%) 0.1 UV (1%) 0.0 UV (0%)
8/8/2019 94001 DCT
24/38
DCT Image CompressionThe Discrete Cosine Method uses continuous cosine waves,like cos(x) below, of increasing frequencies to represent theimage pixels.
The bases are the set of 64 frequencies that can be combined
to represent each block of 64 pixels.
Firstly, the image must be transformed into the frequencydomain. This is done in blocks across the whole image.
8/8/2019 94001 DCT
25/38
The Discrete CosineTransform BasesLow frequency
High frequency
8/8/2019 94001 DCT
26/38
DCT Image Compression
The DCT method is an example of a transform method.Rather than simply trying to compress the pixel valuesdirectly, the image is first TRANSFORMED into the frequencydomain. Compression can now be achieved by more coarselyquantizing the large amount of high-frequency componentsusually present.
Firstly, the image must be transformed into the frequencydomain. This is done in blocks across the whole image.
The JPEG* standard algorithm for full-colour and grey-scaleimage compression is a DCT compression standard that uses8x8 blocks.
It was not designed for graphics or line drawings and is notsuited to these image types.
8/8/2019 94001 DCT
27/38
DCT Image Compression
The DCT itself does not achieve compression, butrather prepares the image for compression.
Once in the frequency domain the image's high-
frequency coefficients can be coarsely quantised sothat many of them (>50%) can be truncated to zero.
The coefficients can then be arranged so that thezeroes are clustered (zig-zag collection) and Run-LengthEncoded.
8/8/2019 94001 DCT
28/38
THEDCTMATRIX
8/8/2019 94001 DCT
29/38
Summary of DCT Stages
Blocking (8x8)
DCT (Discrete Cosine Transformation)
Quantization
Zigzag Scan
DPCM* on the dc value (the average value in the top left)
RLE on the ac values (all 63 values which arent the dc/ average)
Huffman Coding
* DPCM Differential Pulse Code Modulation Instead of
sending the value send the difference from the previous
value.
8/8/2019 94001 DCT
30/38
The DCT
Take each 8x8 pixel block andrepresent it as amounts(coefficients) of the basis functions(the frequency set).
represent the 8x8 pixels asamounts of lowest frequency(the average or DC value)through to the highestfrequency
64 pixels values areTRANSFORMED into 64coefficients which represent theamount of each frequency.
8/8/2019 94001 DCT
31/38
DCTMathematics
The Discrete Cosine Transform below takes the pixels(x,y) and
generates DCT(i,j) values.
The pixel values can be calculated as shown in the 2nd line, where
DCT(i,j) values are used to calculate pixel(x,y) values.
8/8/2019 94001 DCT
32/38
01,021)(
2
)12(
2
)12(cos),()()(
2
1),(
2
)12(
2
)12(cos),()()(
2
1),(
1
0
1
0
1
0
1
0
"!
-
-
!
-
-
!
!
!
!
!
xifelseisxifxC
N
y
N
xjiDCTjCiC
Nyxpixel
N
y
N
xyxpixeljCiC
N
jiDCT
N
i
N
j
N
x
N
y
TT
TT
8/8/2019 94001 DCT
33/38
The Baseline JPEGStandardQuantization Matrix -
determined by subjective testing -
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
8/8/2019 94001 DCT
34/38
Nelsons Simpler LinearQuantizer
The Nelson DCT implementation (this is the DCT compressorused in the laboratory) uses a very simple linear quantizationstrategy.
Q= quality or quantization factor
The higher Qthe LOWER the image quality.
Where each DCT coefficient (i,j) is quantised as
For (i=0;i
8/8/2019 94001 DCT
35/38
NelsonQuanitizer forQ=2
3 5 7 9 11 13 15 17
5 7 9 11 13 15 17 19
7 9 11 13 15 17 19 21
9 11 13 15 17 19 21 23
11 13 15 17 19 21 23 25
13 15 17 19 21 23 25 27
15 17 19 21 23 25 27 29
17 19 21 23 25 27 29 31
8/8/2019 94001 DCT
36/38
Before and AfterQuantization
8/8/2019 94001 DCT
37/38
PROPERTIES OF DCT
Decorrelation
Energy Compaction
Separability
Symmetry
8/8/2019 94001 DCT
38/38
Thank
You