Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

تذكر الوقوف بي يدي الله والحساب وحقوق العباد the histogram of an image …

Question

تذكر الوقوف بي يدي الله والحساب وحقوق العباد
the histogram of an image is given next. perform histogram equalization and give the new histogram.

original histogram
gray level i | 0 | 1 | 2 | 3 | 4 | 5
count n_i | 43 | 0 | 48 | 29 | 15 | 17

new histogram
gray level i | 0 | 1 | 2 | 3 | 4 | 5
count n_i | 0 | 43 | 0 | 48 | 44 | 17

Explanation:

Step1: Calculate Total Pixels

First, find the total number of pixels \( N \) by summing all \( n_i \).
\( N = 43 + 0 + 48 + 29 + 15 + 17 = 152 \)

Step2: Compute Cumulative Distribution Function (CDF)

For each gray level \( i \), compute \( CDF(i) = \sum_{k=0}^{i} n_k \).

  • \( CDF(0) = 43 \)
  • \( CDF(1) = 43 + 0 = 43 \)
  • \( CDF(2) = 43 + 0 + 48 = 91 \)
  • \( CDF(3) = 43 + 0 + 48 + 29 = 120 \)
  • \( CDF(4) = 43 + 0 + 48 + 29 + 15 = 135 \)
  • \( CDF(5) = 43 + 0 + 48 + 29 + 15 + 17 = 152 \)

Step3: Histogram Equalization Transformation

The transformation for histogram equalization is \( s_i = \lfloor \frac{(L - 1)}{N} \cdot CDF(i)
floor \), where \( L = 6 \) (number of gray levels, 0–5).

  • For \( i = 0 \): \( s_0 = \lfloor \frac{5}{152} \cdot 43

floor \approx \lfloor 1.414
floor = 1 \)

  • For \( i = 1 \): \( s_1 = \lfloor \frac{5}{152} \cdot 43

floor = 1 \) (same as \( i=0 \), since \( CDF(1)=CDF(0) \))

  • For \( i = 2 \): \( s_2 = \lfloor \frac{5}{152} \cdot 91

floor \approx \lfloor 2.987
floor = 2 \)

  • For \( i = 3 \): \( s_3 = \lfloor \frac{5}{152} \cdot 120

floor \approx \lfloor 3.947
floor = 3 \)

  • For \( i = 4 \): \( s_4 = \lfloor \frac{5}{152} \cdot 135

floor \approx \lfloor 4.447
floor = 4 \)

  • For \( i = 5 \): \( s_5 = \lfloor \frac{5}{152} \cdot 152

floor = 5 \)

Step4: Count New Histogram

Count how many original gray levels map to each new gray level:

  • New gray level 0: No mappings (since all \( s_i \geq 1 \)) → \( n_0 = 0 \)
  • New gray level 1: \( i=0,1 \) → \( n_1 = 43 + 0 = 43 \)
  • New gray level 2: \( i=2 \) → \( n_2 = 48 \) (Wait, correction: Wait, \( i=2 \) maps to 2, so \( n_2 = 48 \)? Wait, no—wait, original \( n_2 = 48 \), and \( s_2 = 2 \), so \( n_2 \) in new is 48? But the given new histogram has 0 for gray level 2. Wait, maybe the initial new histogram in the image is incorrect. Let's recalculate properly.

Wait, re-express: The transformation is \( s_i = \text{round} \) or \( \lfloor \) of \( \frac{(L-1)}{N} CDF(i) \). Let's recheck \( L \): gray levels 0–5, so \( L = 6 \), \( L-1 = 5 \).

CDF(0) = 43, CDF(1)=43, CDF(2)=91, CDF(3)=120, CDF(4)=135, CDF(5)=152.

For \( i=0 \): \( (5/152)*43 ≈ 1.414 \) → floor to 1.
For \( i=1 \): same as i=0, so 1.
For \( i=2 \): (5/152)*91 ≈ 2.987 → floor to 2.
For \( i=3 \): (5/152)*120 ≈ 3.947 → floor to 3.
For \( i=4 \): (5/152)*135 ≈ 4.447 → floor to 4.
For \( i=5 \): (5/152)*152 = 5 → floor to 5.

Now, count the number of pixels mapping to each new gray level:

  • New level 0: 0 (no \( s_i = 0 \))
  • New level 1: \( i=0 \) (n=43) and \( i=1 \) (n=0) → total 43 + 0 = 43
  • New level 2: \( i=2 \) (n=48) → 48
  • New level 3: \( i=3 \) (n=29) → 29? Wait, no! Wait, original \( n_i \) is the count for gray level \( i \). So when \( i=3 \), \( n_i = 29 \), and \( s_3 = 3 \), so new \( n_3 = 29 \). But the given new histogram has 48 for gray level 3. This suggests a mistake in the initial new histogram.

Wait, the problem’s given new histogram has:
Gray Level 0: 0
Gray Level 1: 43
Gray Level 2: 0
Gray Level 3: 48
Gray Level 4: 44
Gray Level 5: 17

But according to correct calculation, let's sum the new counts: 0 + 43 + 0 + 48 + 44 + 17 = 152, which matches \( N \). So let's see how the mappings lead to this:

Alternative approach: Maybe the transformation is \( s_i = \frac{(L-1)}{N} CDF(i) \) rounded or adjusted. Let's check the sum of new counts: 0 + 43 + 0 + 48 + 44 + 17 = 152, which is correct.

Let's see which original \( n_i \) map to new gray levels:

  • New gray level 1: original gray levels with \( s_i = 1 \). \( s_0 = 1 \), \( s_1 = 1 \) → \( n_0 + n_1 = 43 + 0 = 43 \) (…

Answer:

The new histogram after equalization is:

Gray Level \( i \)012345