Image Compression
Image Compression
IMAGE COMPRESSION 2
Transform coding
Color images have different color channels for each color component such as red, green and
blue.
JPEG
1
The JPEG (Joint Photographic Experts Group) standard is a joint international standard of the
ISO and ITU-T (formerly CCITT) standards organizations. JPEG compression includes a wide
variety of techniques, but of particular interest is the widely-implemented baseline DCT (discrete
cosine transform) algorithm. This permits a wide range of trade-offs of image quality versus
compressed file size.
2
This conversion separates luminance from chrominance components
Since our visual systems are much more sensitive to changes in brightness than color we can
simply down size chroma sample to save some space. This strategy is called chroma
subsampling.. used in may video processing pipelines.
3
Since luminance is more sensitive than chrominance to the human eyes we transfer the color
space from RGB to 𝑌 𝐶𝑏 𝐶𝑟 and use down sampling (4: 2: 2 𝑜𝑟 4: 2: 0 𝑑𝑜𝑤𝑚𝑠𝑎𝑚𝑝𝑙𝑖𝑛𝑔) to
reduce information recorded in the JPEG file.
Another characteristic of human visual system that we can take advantage of is the frequency
dependent contrast sensitivity.
This means is that it is easy for small objects or fine details in the picture as compared to large
ones which is scan abuse.
In this figure the spatial frequency of the bars increases from left to right and the contrast
decreases from bottom to the top this may vary from person to person
4
Below the bars under the curve are visible than the rest. This because our visual system is more
sensitive to brightness variation in this range of frequencies. Forget the bars of low contrast and
at high frequencies part of the figure they are barely visible. This phenomena give as some room
for compression in those less visible frequencies.
In the figure above, spatial frequency increases as you look from left to right (the bars become
thinner and thinner) and contrast decreases as you look from bottom to top (bars become more
difficult to see). From a fixed viewing distance, notice over the range of spatial frequencies the
contrast values where the bars are just barely visible - imagine placing a curve along those points
of threshold visibility. You'd trace out an inverted U-shaped curve. This is your contrast
sensitivity function.
5
JPEG compression - dividing the image into 8 X 8 blocks and quantizing that in frequency
domain representation.
And each of those pixel group is separately encoded with its own discrete cosine transform
This is done by comparing each one of this 8 X 8 blocks with 64 frequency patterns. The spatial
frequency increases from left to right and top to bottom.
Each of those 8 by 8 pixel groups can be exactly replicated by 64, so 8 by 8 cosine waves.
6
This actually shows the 64 base cosine waves that produce any image we might like to do in 8 by
8 pixels
As we increase the frequency in both directions, we get a kind of checkerboard pattern, this is
high frequency information that we’re encoding in these regions. So these are the 64 cosine
functions that can be combined to make any 8 by 8 image.
This is only in one channel, so let’s say just illuminance or 𝐶𝑟 .
For example, if we had half of this wave and half of this wave,
7
The what you get is a square image that is generally brighter on the left, with a little bit of bright
on the right hand side, because you have summed the two together.
To create any kind of 8 by 8 image, what we need to do is have a combination of all of these at
the same time. Each of these is weighted based on something called a coefficient which is a
number representing the contribution of each of these individual blocks to the whole.
If we just look at an example of image. So this is a small crop section of our flower image.
8
This is the component, so it’s just every value from 0 – 255, how intense is the pixel
9
So you can see it’s kind of grey with a little bit of brighter region down here.
What we want to try and do is calculate the contributions of each of our cosine waves to this
image.
Which bits of cosine do we need to add together to create an image that looks exactly like this.
So to start with, what we need to do is center all of these values, which are currently centered at
128 because they’re from 0 – 255.
We center with values around zero, because remember cosine wave goes from −1 𝑡𝑜 + 1.
10
So we take away 128 off every value, and we get our shifted block like this
So this is the exact same image, but this time now centered around zero.
And how can we use this in the discrete cosine transform to calculate our coefficients.
We apply the actual discrete cosine transform # 2 which is the one that’s always used in JPEG.
And what that does, it calculate the contribution of each of our cosine waves that when added
together, will create this image exactly.
Which of these blocks, when multiplied by that coefficient, tell us how much of each one we use
will add together to create this exact image.
This and that ………
11
JPEG Patterns
And so you’ll find that all of these will have some impact on the image
It is almost certain, unless the image is completely flat.
One of the things with JPEG is these low frequency ones will have a much bigger coefficient
than high frequency data and we also see them better.
12
So, we calculate our DCT2 coefficient, and that gives us some slightly arbitrary values between
−1024 𝑎𝑛𝑑 + 1024.
DCT coefficients.
And we have, each of these represents the weight, or amount, of each of our cosine waves.
If we take the cosine , and multiply it by -370, and add it to the next one multiplied by 29.7 and
so on and we do it for all of them, the added sum will be the original image back again.
Usually this top left coefficient is much bigger than the others. Because it’s flat and not cosine
wave. It represents the general intensity of that particular image block. So this is called direct
current coefficient or DC coefficient. All of the others are alternating current, AC coefficients.
In practice, usually the DC coefficient are stored separately.
The really important aspect of JPEG that you want to understand is that these coefficients are
very - very small and the and the others a very big.
And what that tells is that for the high frequency cosine waves, don’t really contribute much to
the image. If you could just take them away and save space all that space.
The next step, after calculating our discrete cosine transform coefficient is basically, try to
remove the ones you don’t want.
We call the processes of removing the high frequency data quantization
13
JPEG Quantization Table
So in JPEG standard, different compressors, like the one used in photoshop, will use different
quantization tables.
For Luminance
The DCT coefficients are then quantized by divided then for the quantization values defined in
the luminance and chrominance quantization tables.
14
The quantization values can be set individually for each DCT coefficient, using criteria based on
visibility of the basis functions. The quantization generates error by its nature. Therefore, the
fault tolerance systems need to distinguish between the quantization errors and the computer
failure errors.
15
Both Run-Length encoding and Huffman coding are lossless compression methods. No
information is thrown out in this steps. The compression is achieved by storing redundant data
more efficiently. This type of compression is used to compress, transmit and store many types of
data including images, audio and documents.
The DCT operation in a JPEG image compression system starts with 8×8 image data block,
f(x,y). This block can be transformed to a new 8×8 block, F(x,y), by the forward discrete cosine
transform (FDCT). The original block f(x,y) can be obtained by the inverse discrete cosine
transform (IDCT). The equations for the discrete cosine transforms are:
Because the 2-D DCT is separable, the summations can be done as eight 1-D DCTs on all rows,
and then eight 1-D DCTs on the eight columns formed by the coefficients for the rows.
16
A transform is a mathematical function that transforms (changes) the input data from
one domain (view) to another to,
17