IMAGE COMPRESSION AND
SEGMENTATION
Unit III:
1
Image compression models
▪ a compression system consists of two distinct structural
blocks: an encoder and a decoder.
▪ An input image f(x, y) is fed into the encoder, which
creates a set of symbols from the input data.
▪ After transmission over the channel, the encoded
representation is fed to the decoder, where a reconstructed
output image f^(x, y) is generated.
▪ In general, f^(x, y) may or may not be an exact replica of
f(x, y).
2
Image compression models
▪ If the system is not error free or information preserving,
some level of distortion is present in the reconstructed
image.
▪ The encoder is made up of a source encoder, which
removes input redundancies, and a channel encoder,
which increases the noise immunity of the source encoder's
output.
3
Image compression models
▪ the decoder includes a channel decoder followed by a
source decoder.
▪ If the channel between the encoder and decoder is noise
free (not prone to error), the channel encoder and decoder
are omitted, and the general encoder and decoder become
the source encoder and decoder, respectively.
4
Source encoder /source decoder model
▪ Run-length coding is an example of a mapping that directly
results in data compression in the initial stage of the
overall source encoding process.
▪ The second stage, or quantizer block, reduces the
accuracy of the mapper’s output in accordance with some
preestablished fidelity criterion.
▪ In the third and final stage, the symbol coder creates a
fixed- or variable-length code to represent the quantizer
output and maps the output in accordance with the code.
5
Source encoder /source decoder model
▪ The source decoder shown contains only two components:
a symbol decoder and an inverse mapper, which perform,
in reverse order, the inverse operations of the source
encoder's symbol encoder and mapper blocks.
▪ quantization results in irreversible information loss,
▪ inverse quantizer block is not included in the general
source decoder model
6
Channel Encoder / Decoder
▪ The channel encoder and decoder play an important role in
the overall encoding-decoding process when the channel of
is noisy or prone to error.
▪ One of the most useful channel encoding techniques was
devised by R. W. Hamming (1950).
▪ It is based on appending enough bits to the data being
encoded to ensure that some minimum number of bits must
change between valid code words.
7
Channel Encoder / Decoder
▪ To decode a Hamming encoded result, the channel decoder
must check the encoded value for odd parity over the bit
fields in which even parity was previously established.
▪ A single-bit error is indicated by a nonzero parity word
where the decoder simply complements the code word bit
position indicated by the parity word.
▪ The decoded binary value is then extracted from the
corrected code word.
8
Image compression
▪ Image compression is a process applied to a graphics file to
minimize its size in bytes without degrading image quality
below an acceptable threshold.
▪ Advantages?
▪ two categories:
▪ lossy
▪ lossless.
9
Lossy compression
▪ Reduces an image file size by permanently removing less
critical information, particularly redundant data.
▪ can significantly reduce file size, but it can also reduce image
quality to the point of distortion, especially if the image is
overly compressed.
▪ Disadvantage / challenge?
▪ it's irreversible
▪ lossy compression has proved to be a valuable strategy for the
web, where a moderate amount of image degradation can often
be tolerated. E.g., JPEG
10
Lossless compression
▪ compression without removing critical data or reducing
image quality and results in a compressed image that can
be restored to its original state with no degradation or
distortion.
▪ It doesn’t reduce the file size nearly as much as lossy
compression, offering little advantage in terms of storage
space, network bandwidth or download speeds.
▪ generally used in situations where image quality is more
important than disk space or network performance, such as
for product images or to showcase artwork. E.g., PNG
11
12
Huffman Coding
▪ a lossless data compression algorithm.
▪ The idea is to assign variable-length codes to input
characters (Prefix Codes), lengths of the assigned codes are
based on the frequencies of corresponding characters.
▪ two major parts in Huffman Coding
▪ Build a Huffman Tree from input characters.
▪ Traverse the Huffman Tree and assign codes to characters.
13
Steps to build Huffman Tree
Input is an array of unique characters along with their
frequency of occurrences and output is Huffman Tree.
▪ Create a leaf node for each unique character and build a min
heap of all leaf nodes (Min Heap is used as a priority queue.
The value of frequency field is used to compare two nodes in
min heap. Initially, the least frequent character is at root)
▪ Extract two nodes with the minimum frequency from the
min heap.
14
Steps to build Huffman Tree (Contd..)
▪ Create a new internal node with a frequency equal to the
sum of the two nodes frequencies. Make the first extracted
node as its left child and the other extracted node as its
right child. Add this node to the min heap.
▪ Repeat #2 and #3 until the heap contains only one node.
The remaining node is the root node and the tree is
complete.
15
Huffman Coding
▪ example
16
Image segmentation
▪ The goal of image segmentation is to cluster pixels into
salient image regions, i.e., regions corresponding to
individual surfaces, objects, or natural parts of objects.
▪ A segmentation could be used for object recognition,
occlusion boundary estimation within motion or stereo
systems, image compression, image editing, or image
database look-up.
17
Image segmentation
▪ The goal of image segmentation is to cluster pixels into
salient image regions, i.e., regions corresponding to
individual surfaces, objects, or natural parts of objects.
▪ A segmentation could be used for object recognition,
occlusion boundary estimation within motion or stereo
systems, image compression, image editing, or image
database look-up.
18
Thank You
19