HW5 Image Processing AUT
HW5 Image Processing AUT
Assignment #5
Image Compression and Morphological Operations
1. A source emits letters from an alphabet A a1, a2 , a3 , a4 , a5 with probabilities P a1 0.15 , P a2 0.04
, P a3 0.26 , P a4 0.05 , and P a5 0.50 .
a) Calculate the entropy of this source.
b) Find a Huffman code for this source.
c) Find the average length of the code in (b) and its redundancy.
3 (a). Given an initial dictionary consisting of the letters a b r y _ , encode the following message using
the LZW algorithm:
Entry
a
_
3
4
5
6
h
i
s
t
The output of the LZW encoder is the following sequence. Decode this sequence.
6
11
16
12
14
20
10
23
13
Encode the decoded sequence using the same initial dictionary. Does your answer match the sequence
given above?
4. Load the images eye.png and fingerprint.png, and apply the following morphological operators
namely erosion, dilation, opening and closing on them. Analyze the resultant images and include them
in your report.
5. Consider a binary image which contains several squares and circles. It is possible to have overlap
between the shapes. The sides of the squares are of equal length and the same condition is true with the
radii of circles. A sample of such an image is Fig. 2. Propose a solution for the following problems and
implement them in MATLAB. Verify your implementation on the image binary.png or any image of your
own choice which satisfies the aforesaid conditions.
a) Counting the number of squares.
b) Counting the number of shapes which have overlap with at least one other shape.
c) Computing the shared area between two or more overlapping shapes.