MMTE-003 Sample Solution

MMTE-003 Solved Assignment 2025

Question:-1(a)

The arithmetic decoding process is the reverse of the encoding procedure. Decode the message 0.23355 given the coding model.

Symbol Probability
a 0.2
e 0.3
i 0.1
o 0.2
u 0.1
! 0.1

Answer:

To decode the message 0.23355 using arithmetic decoding with the given coding model, we reverse the arithmetic encoding process. The coding model provides symbols with their probabilities, which we use to define intervals in [0, 1). The goal is to determine the sequence of symbols that corresponds to the given number by iteratively narrowing down the interval.

Step 1: Define the Cumulative Probability Intervals

The coding model is:
Symbol Probability Cumulative Probability Interval
a 0.2 0.0 [0.0, 0.2)
e 0.3 0.2 [0.2, 0.5)
i 0.1 0.5 [0.5, 0.6)
o 0.2 0.6 [0.6, 0.8)
u 0.1 0.8 [0.8, 0.9)
! 0.1 0.9 [0.9, 1.0)
The cumulative probability for a symbol s s sss is the sum of probabilities of all symbols before it. The interval for symbol s s sss with probability p s p s p_(s)p_sps and cumulative probability F s F s F_(s)F_sFs is [ F s , F s + p s ) [ F s , F s + p s ) [F_(s),F_(s)+p_(s))[F_s, F_s + p_s)[Fs,Fs+ps).

Step 2: Initialize the Decoding Process

The encoded message is D = 0.23355 D = 0.23355 D=0.23355D = 0.23355D=0.23355. We start with the initial interval [ l o w , h i g h ) = [ 0 , 1 ) [ l o w , h i g h ) = [ 0 , 1 ) [low,high)=[0,1)[low, high) = [0, 1)[low,high)=[0,1), where l o w = 0 l o w = 0 low=0low = 0low=0, h i g h = 1 h i g h = 1 high=1high = 1high=1, and the range is r a n g e = h i g h l o w = 1 r a n g e = h i g h l o w = 1 range=high-low=1range = high – low = 1range=highlow=1. We iteratively select the symbol whose interval contains D D DDD, update the interval, and continue until we encounter the termination symbol ! ! !!! or reach sufficient precision.

Step 3: Decode Iteratively

We compute which symbol’s interval contains D = 0.23355 D = 0.23355 D=0.23355D = 0.23355D=0.23355 and update the interval accordingly.

Iteration 1: Initial Interval [0, 1)

  • Range: r a n g e = 1 0 = 1 r a n g e = 1 0 = 1 range=1-0=1range = 1 – 0 = 1range=10=1.
  • Compute the scaled position of D = 0.23355 D = 0.23355 D=0.23355D = 0.23355D=0.23355 within [0, 1): Scaled value = D l o w r a n g e = 0.23355 0 1 = 0.23355 . Scaled value = D l o w r a n g e = 0.23355 0 1 = 0.23355 . “Scaled value”=(D-low)/(range)=(0.23355-0)/(1)=0.23355.\text{Scaled value} = \frac{D – low}{range} = \frac{0.23355 – 0}{1} = 0.23355.Scaled value=Dlowrange=0.2335501=0.23355.
  • Find the symbol whose interval contains 0.23355:
    • a a aaa: [0.0, 0.2) → 0.23355 is not in this interval.
    • e e eee: [0.2, 0.5) → 0.2 0.23355 < 0.5 0.2 0.23355 < 0.5 0.2 <= 0.23355 < 0.50.2 \leq 0.23355 < 0.50.20.23355<0.5, so the symbol is e e eee.
  • Update the interval using e e eee’s interval [0.2, 0.5): l o w new = l o w + r a n g e F e = 0 + 1 0.2 = 0.2 , l o w new = l o w + r a n g e F e = 0 + 1 0.2 = 0.2 , low_(“new”)=low+range*F_(e)=0+1*0.2=0.2,low_{\text{new}} = low + range \cdot F_e = 0 + 1 \cdot 0.2 = 0.2,lownew=low+rangeFe=0+10.2=0.2, h i g h new = l o w + r a n g e ( F e + p e ) = 0 + 1 ( 0.2 + 0.3 ) = 0.5 . h i g h new = l o w + r a n g e ( F e + p e ) = 0 + 1 ( 0.2 + 0.3 ) = 0.5 . high_(“new”)=low+range*(F_(e)+p_(e))=0+1*(0.2+0.3)=0.5.high_{\text{new}} = low + range \cdot (F_e + p_e) = 0 + 1 \cdot (0.2 + 0.3) = 0.5.highnew=low+range(Fe+pe)=0+1(0.2+0.3)=0.5.
  • New interval: [0.2, 0.5).
  • New range: r a n g e = 0.5 0.2 = 0.3 r a n g e = 0.5 0.2 = 0.3 range=0.5-0.2=0.3range = 0.5 – 0.2 = 0.3range=0.50.2=0.3.
  • Output symbol: e e eee.

Iteration 2: Interval [0.2, 0.5)

  • Range: r a n g e = 0.3 r a n g e = 0.3 range=0.3range = 0.3range=0.3.
  • Compute the scaled value: Scaled value = D l o w r a n g e = 0.23355 0.2 0.3 = 0.03355 0.3 0.1118333 . Scaled value = D l o w r a n g e = 0.23355 0.2 0.3 = 0.03355 0.3 0.1118333 . “Scaled value”=(D-low)/(range)=(0.23355-0.2)/(0.3)=(0.03355)/(0.3)~~0.1118333.\text{Scaled value} = \frac{D – low}{range} = \frac{0.23355 – 0.2}{0.3} = \frac{0.03355}{0.3} \approx 0.1118333.Scaled value=Dlowrange=0.233550.20.3=0.033550.30.1118333.
  • Find the symbol whose interval contains 0.1118333:
    • a a aaa: [0.0, 0.2) → 0 0.1118333 < 0.2 0 0.1118333 < 0.2 0 <= 0.1118333 < 0.20 \leq 0.1118333 < 0.200.1118333<0.2, so the symbol is a a aaa.
  • Update the interval using a a aaa’s interval [0.0, 0.2): l o w new = l o w + r a n g e F a = 0.2 + 0.3 0.0 = 0.2 , l o w new = l o w + r a n g e F a = 0.2 + 0.3 0.0 = 0.2 , low_(“new”)=low+range*F_(a)=0.2+0.3*0.0=0.2,low_{\text{new}} = low + range \cdot F_a = 0.2 + 0.3 \cdot 0.0 = 0.2,lownew=low+rangeFa=0.2+0.30.0=0.2, h i g h new = l o w + r a n g e ( F a + p a ) = 0.2 + 0.3 ( 0.0 + 0.2 ) = 0.2 + 0.06 = 0.26 . h i g h new = l o w + r a n g e ( F a + p a ) = 0.2 + 0.3 ( 0.0 + 0.2 ) = 0.2 + 0.06 = 0.26 . high_(“new”)=low+range*(F_(a)+p_(a))=0.2+0.3*(0.0+0.2)=0.2+0.06=0.26.high_{\text{new}} = low + range \cdot (F_a + p_a) = 0.2 + 0.3 \cdot (0.0 + 0.2) = 0.2 + 0.06 = 0.26.highnew=low+range(Fa+pa)=0.2+0.3(0.0+0.2)=0.2+0.06=0.26.
  • New interval: [0.2, 0.26).
  • New range: r a n g e = 0.26 0.2 = 0.06 r a n g e = 0.26 0.2 = 0.06 range=0.26-0.2=0.06range = 0.26 – 0.2 = 0.06range=0.260.2=0.06.
  • Output symbol: a a aaa.

Iteration 3: Interval [0.2, 0.26)

  • Range: r a n g e = 0.06 r a n g e = 0.06 range=0.06range = 0.06range=0.06.
  • Compute the scaled value: Scaled value = D l o w r a n g e = 0.23355 0.2 0.06 = 0.03355 0.06 0.5591667 . Scaled value = D l o w r a n g e = 0.23355 0.2 0.06 = 0.03355 0.06 0.5591667 . “Scaled value”=(D-low)/(range)=(0.23355-0.2)/(0.06)=(0.03355)/(0.06)~~0.5591667.\text{Scaled value} = \frac{D – low}{range} = \frac{0.23355 – 0.2}{0.06} = \frac{0.03355}{0.06} \approx 0.5591667.Scaled value=Dlowrange=0.233550.20.06=0.033550.060.5591667.
  • Find the symbol whose interval contains 0.5591667:
    • a a aaa: [0.0, 0.2) → not in this interval.
    • e e eee: [0.2, 0.5) → not in this interval.
    • i i iii: [0.5, 0.6) → 0.5 0.5591667 < 0.6 0.5 0.5591667 < 0.6 0.5 <= 0.5591667 < 0.60.5 \leq 0.5591667 < 0.60.50.5591667<0.6, so the symbol is i i iii.
  • Update the interval using i i iii’s interval [0.5, 0.6): l o w new = l o w + r a n g e F i = 0.2 + 0.06 0.5 = 0.2 + 0.03 = 0.23 , l o w new = l o w + r a n g e F i = 0.2 + 0.06 0.5 = 0.2 + 0.03 = 0.23 , low_(“new”)=low+range*F_(i)=0.2+0.06*0.5=0.2+0.03=0.23,low_{\text{new}} = low + range \cdot F_i = 0.2 + 0.06 \cdot 0.5 = 0.2 + 0.03 = 0.23,lownew=low+rangeFi=0.2+0.060.5=0.2+0.03=0.23, h i g h new = l o w + r a n g e ( F i + p i ) = 0.2 + 0.06 ( 0.5 + 0.1 ) = 0.2 + 0.06 0.6 = 0.236 . h i g h new = l o w + r a n g e ( F i + p i ) = 0.2 + 0.06 ( 0.5 + 0.1 ) = 0.2 + 0.06 0.6 = 0.236 . high_(“new”)=low+range*(F_(i)+p_(i))=0.2+0.06*(0.5+0.1)=0.2+0.06*0.6=0.236.high_{\text{new}} = low + range \cdot (F_i + p_i) = 0.2 + 0.06 \cdot (0.5 + 0.1) = 0.2 + 0.06 \cdot 0.6 = 0.236.highnew=low+range(Fi+pi)=0.2+0.06(0.5+0.1)=0.2+0.060.6=0.236.
  • New interval: [0.23, 0.236).
  • New range: r a n g e = 0.236 0.23 = 0.006 r a n g e = 0.236 0.23 = 0.006 range=0.236-0.23=0.006range = 0.236 – 0.23 = 0.006range=0.2360.23=0.006.
  • Output symbol: i i iii.

Iteration 4: Interval [0.23, 0.236)

  • Range: r a n g e = 0.006 r a n g e = 0.006 range=0.006range = 0.006range=0.006.
  • Compute the scaled value: Scaled value = D l o w r a n g e = 0.23355 0.23 0.006 = 0.00355 0.006 0.5916667 . Scaled value = D l o w r a n g e = 0.23355 0.23 0.006 = 0.00355 0.006 0.5916667 . “Scaled value”=(D-low)/(range)=(0.23355-0.23)/(0.006)=(0.00355)/(0.006)~~0.5916667.\text{Scaled value} = \frac{D – low}{range} = \frac{0.23355 – 0.23}{0.006} = \frac{0.00355}{0.006} \approx 0.5916667.Scaled value=Dlowrange=0.233550.230.006=0.003550.0060.5916667.
  • Find the symbol whose interval contains 0.5916667:
    • a a aaa: [0.0, 0.2) → not in this interval.
    • e e eee: [0.2, 0.5) → not in this interval.
    • i i iii: [0.5, 0.6) → 0.5 0.5916667 < 0.6 0.5 0.5916667 < 0.6 0.5 <= 0.5916667 < 0.60.5 \leq 0.5916667 < 0.60.50.5916667<0.6, so the symbol is i i iii.
  • Update the interval using i i iii’s interval [0.5, 0.6): l o w new = l o w + r a n g e F i = 0.23 + 0.006 0.5 = 0.23 + 0.003 = 0.233 , l o w new = l o w + r a n g e F i = 0.23 + 0.006 0.5 = 0.23 + 0.003 = 0.233 , low_(“new”)=low+range*F_(i)=0.23+0.006*0.5=0.23+0.003=0.233,low_{\text{new}} = low + range \cdot F_i = 0.23 + 0.006 \cdot 0.5 = 0.23 + 0.003 = 0.233,lownew=low+rangeFi=0.23+0.0060.5=0.23+0.003=0.233, h i g h new = l o w + r a n g e ( F i + p i ) = 0.23 + 0.006 0.6 = 0.23 + 0.0036 = 0.2336 . h i g h new = l o w + r a n g e ( F i + p i ) = 0.23 + 0.006 0.6 = 0.23 + 0.0036 = 0.2336 . high_(“new”)=low+range*(F_(i)+p_(i))=0.23+0.006*0.6=0.23+0.0036=0.2336.high_{\text{new}} = low + range \cdot (F_i + p_i) = 0.23 + 0.006 \cdot 0.6 = 0.23 + 0.0036 = 0.2336.highnew=low+range(Fi+pi)=0.23+0.0060.6=0.23+0.0036=0.2336.
  • New interval: [0.233, 0.2336).
  • New range: r a n g e = 0.2336 0.233 = 0.0006 r a n g e = 0.2336 0.233 = 0.0006 range=0.2336-0.233=0.0006range = 0.2336 – 0.233 = 0.0006range=0.23360.233=0.0006.
  • Output symbol: i i iii.

Iteration 5: Interval [0.233, 0.2336)

  • Range: r a n g e = 0.0006 r a n g e = 0.0006 range=0.0006range = 0.0006range=0.0006.
  • Compute the scaled value: Scaled value = D l o w r a n g e = 0.23355 0.233 0.0006 = 0.00055 0.0006 0.9166667 . Scaled value = D l o w r a n g e = 0.23355 0.233 0.0006 = 0.00055 0.0006 0.9166667 . “Scaled value”=(D-low)/(range)=(0.23355-0.233)/(0.0006)=(0.00055)/(0.0006)~~0.9166667.\text{Scaled value} = \frac{D – low}{range} = \frac{0.23355 – 0.233}{0.0006} = \frac{0.00055}{0.0006} \approx 0.9166667.Scaled value=Dlowrange=0.233550.2330.0006=0.000550.00060.9166667.
  • Find the symbol whose interval contains 0.9166667:
    • a a aaa: [0.0, 0.2) → not in this interval.
    • e e eee: [0.2, 0.5) → not in this interval.
    • i i iii: [0.5, 0.6) → not in this interval.
    • o o ooo: [0.6, 0.8) → not in this interval.
    • u u uuu: [0.8, 0.9) → not in this interval.
    • ! ! !!!: [0.9, 1.0) → 0.9 0.9166667 < 1.0 0.9 0.9166667 < 1.0 0.9 <= 0.9166667 < 1.00.9 \leq 0.9166667 < 1.00.90.9166667<1.0, so the symbol is ! ! !!!.
  • Since ! ! !!! is the termination symbol, we stop decoding.

Step 4: Output the Decoded Message

The sequence of symbols decoded is e , a , i , i , ! e , a , i , i , ! e,a,i,i,!e, a, i, i, !e,a,i,i,!. In arithmetic coding, the termination symbol ! ! !!! typically indicates the end of the message. Thus, the decoded message, excluding the termination symbol, is:
eaii eaii “eaii”\text{eaii}eaii

Verification

To ensure correctness, we can encode the sequence e , a , i , i , ! e , a , i , i , ! e,a,i,i,!e, a, i, i, !e,a,i,i,! using the arithmetic encoding process to see if it produces a value consistent with 0.23355:
  • Start with [0, 1).
  • Symbol e: Interval [0.2, 0.5), l o w = 0.2 l o w = 0.2 low=0.2low = 0.2low=0.2, h i g h = 0.5 h i g h = 0.5 high=0.5high = 0.5high=0.5, range = 0.3.
  • Symbol a: Interval [0.0, 0.2), l o w = 0.2 l o w = 0.2 low=0.2low = 0.2low=0.2, h i g h = 0.2 + 0.3 0.2 = 0.26 h i g h = 0.2 + 0.3 0.2 = 0.26 high=0.2+0.3*0.2=0.26high = 0.2 + 0.3 \cdot 0.2 = 0.26high=0.2+0.30.2=0.26, range = 0.06.
  • Symbol i: Interval [0.5, 0.6), l o w = 0.2 + 0.06 0.5 = 0.23 l o w = 0.2 + 0.06 0.5 = 0.23 low=0.2+0.06*0.5=0.23low = 0.2 + 0.06 \cdot 0.5 = 0.23low=0.2+0.060.5=0.23, h i g h = 0.2 + 0.06 0.6 = 0.236 h i g h = 0.2 + 0.06 0.6 = 0.236 high=0.2+0.06*0.6=0.236high = 0.2 + 0.06 \cdot 0.6 = 0.236high=0.2+0.060.6=0.236, range = 0.006.
  • Symbol i: Interval [0.5, 0.6), l o w = 0.23 + 0.006 0.5 = 0.233 l o w = 0.23 + 0.006 0.5 = 0.233 low=0.23+0.006*0.5=0.233low = 0.23 + 0.006 \cdot 0.5 = 0.233low=0.23+0.0060.5=0.233, h i g h = 0.23 + 0.006 0.6 = 0.2336 h i g h = 0.23 + 0.006 0.6 = 0.2336 high=0.23+0.006*0.6=0.2336high = 0.23 + 0.006 \cdot 0.6 = 0.2336high=0.23+0.0060.6=0.2336, range = 0.0006.
  • Symbol !: Interval [0.9, 1.0), l o w = 0.233 + 0.0006 0.9 = 0.233 + 0.00054 = 0.23354 l o w = 0.233 + 0.0006 0.9 = 0.233 + 0.00054 = 0.23354 low=0.233+0.0006*0.9=0.233+0.00054=0.23354low = 0.233 + 0.0006 \cdot 0.9 = 0.233 + 0.00054 = 0.23354low=0.233+0.00060.9=0.233+0.00054=0.23354, h i g h = 0.233 + 0.0006 1.0 = 0.2336 h i g h = 0.233 + 0.0006 1.0 = 0.2336 high=0.233+0.0006*1.0=0.2336high = 0.233 + 0.0006 \cdot 1.0 = 0.2336high=0.233+0.00061.0=0.2336.
The final interval [0.23354, 0.2336) contains 0.23355, confirming that the sequence e , a , i , i , ! e , a , i , i , ! e,a,i,i,!e, a, i, i, !e,a,i,i,! encodes to a value consistent with the given input.

Final Answer

The decoded message for the value 0.23355, given the provided coding model, is:
eaii eaii “eaii”\boxed{\text{eaii}}eaii

Question:-1(b)

A binary image contains straight lines oriented horizontally, vertically, at 45°, and at -45°. Give a set of 3×3 masks that can be used to detect 1-pixel breaks in these lines. Assume that the intensities of the lines and background are 1 and 0, respectively.

Answer:

To detect 1-pixel breaks in straight lines oriented horizontally, vertically, at 45°, and at -45° in a binary image, we can use a set of 3×3 masks that are designed to respond to gaps in these specific directions. The idea is to create masks that match the expected neighborhood of a pixel on a line in each direction, and then look for deviations that indicate a break.
Here is a set of 3×3 masks for detecting 1-pixel breaks in each of the four directions:

1. Horizontal Line Break Mask:

A break in a horizontal line would mean that the middle pixel in the row is 0, while the surrounding pixels in the horizontal direction are 1. The mask should detect this pattern.
Mask:
[ 1  1  1 ]
[ 1  0  1 ]
[ 1  1  1 ]
This mask will respond strongly if the center pixel is 0 (break) and the pixels to the left and right (in the horizontal direction) are 1 (line). However, this is a general mask. To specifically detect breaks in horizontal lines, we can use the following approach:
For a horizontal line, the expected neighborhood is:
[ 0  0  0 ]
[ 1  1  1 ]
[ 0  0  0 ]
A break in the horizontal line would be:
[ 0  0  0 ]
[ 1  0  1 ]
[ 0  0  0 ]
So the mask to detect this break is:
[ 0  0  0 ]
[ 1 -2  1 ]
[ 0  0  0 ]
This mask will give a high response (specifically, a negative response) when the center pixel is 0 and the left and right pixels are 1.

2. Vertical Line Break Mask:

Similarly, for a vertical line, the expected neighborhood is:
[ 0  1  0 ]
[ 0  1  0 ]
[ 0  1  0 ]
A break in the vertical line would be:
[ 0  1  0 ]
[ 0  0  0 ]
[ 0  1  0 ]
The mask to detect this break is:
[ 0  1  0 ]
[ 0 -2  0 ]
[ 0  1  0 ]

3. 45° Diagonal Line Break Mask:

For a 45° diagonal line (top-right to bottom-left), the expected neighborhood is:
[ 0  0  1 ]
[ 0  1  0 ]
[ 1  0  0 ]
A break in the 45° line would be:
[ 0  0  1 ]
[ 0  0  0 ]
[ 1  0  0 ]
The mask to detect this break is:
[ 0  0  1 ]
[ 0 -2  0 ]
[ 1  0  0 ]

4. -45° Diagonal Line Break Mask:

For a -45° diagonal line (top-left to bottom-right), the expected neighborhood is:
[ 1  0  0 ]
[ 0  1  0 ]
[ 0  0  1 ]
A break in the -45° line would be:
[ 1  0  0 ]
[ 0  0  0 ]
[ 0  0  1 ]
The mask to detect this break is:
[ 1  0  0 ]
[ 0 -2  0 ]
[ 0  0  1 ]

Summary of Masks:

  1. Horizontal Line Break:
    [ 0  0  0 ]
    [ 1 -2  1 ]
    [ 0  0  0 ]
    
  2. Vertical Line Break:
    [ 0  1  0 ]
    [ 0 -2  0 ]
    [ 0  1  0 ]
    
  3. 45° Diagonal Line Break:
    [ 0  0  1 ]
    [ 0 -2  0 ]
    [ 1  0  0 ]
    
  4. -45° Diagonal Line Break:
    [ 1  0  0 ]
    [ 0 -2  0 ]
    [ 0  0  1 ]
    

Scroll to Top
Scroll to Top