Given an intensity histogram,we apply an histogram equalization.Calculate the new intensity of the pixels in the original histogram had a150 intensity

1.7k Views Asked by At

It's a question from an exam that I can't understand its result.

Given the following intensity histogram of an image:

enter image description here

After an histogram equalization applied for this histogram, we've got the following intensity histogram:

enter image description here

The question:

What is the new intensity value of the pixels that had a 150 intensity value, in the original histogram?

According to the answers I get 200. There's no explanation so I can't get the reason.

Please help me. thanks in advance.

1

There are 1 best solutions below

0
On

I will try to explain math and afterwards argument the answers you get.

Math part:

Let $L$ be the total possible values pixel can get (usually $L=256$ for grayscale images). Then pixel values are in the range $[0, L - 1]$. So, by doing histogram equalization you basically want to transform old pixels values to new pixel values so that resulting values of pixels are uniformly distributed.

Let $p_1(w)$ be the probability of pixel value $w$ before histogram equalization: $$p_1(w) = \frac{\text{number of pixels with value $w$ in old distribution}}{\text{total number of pixel}}.$$

Let $p_2(w)$ be the probability of pixel value $w$ after histogram equalization: $$p_2(w) = \frac{\text{number of pixels with value $w$ in new distribution}}{\text{total number of pixel}}.$$

The relation that must hold between $p_1(x)$ and $p_2(y)$ is $$p_1(x) \cdot \frac{dx}{dy} = p_2(y),$$ that we can write as $$p_1(x) \cdot \frac{dx}{dT(x)} = p_2(T(x)).$$

The following image shows what we want to do:

enter image description here

Let $T(x)$ be the function that transforms an old pixel value $x$ to the new pixel value $y = T(x)$. It must be a non-decreasing function, otherwise we would get a distorted image. Histogram equalization defines it as: $$T(x) = (L - 1)\cdot\int_{0}^{x}p_1(w) \ dw,$$ where the $(L - 1)$ factor makes the values range in $[0, L - 1]$ instead of $[0, 1]$.

Now, taking the derivative of $T(x)$ with respect to $x$, we get: $$ \begin{align} \frac{dT(x)}{dx} &= \frac{d \left((L - 1)\cdot \displaystyle \int_{0}^{x}p_1(w) \ dw\right)}{dx} = \\ &= (L - 1)\cdot\frac{d \left(\displaystyle \int_{0}^{x}p_1(w)\ dw\right)}{dx} = \\ &= (L - 1)\cdot p_1(x) \end{align}$$

Now let's see what this definitions of $T(x)$ leads to: $$ \begin{align} p_2(y) &= p_1(x)\cdot \frac{dx}{dy}\\ &= p_1(x)\cdot \frac{dx}{dT(x)}\\ &= p_1(x)\cdot \frac{1}{(L - 1) \cdot p_1(x)}\\ &= \frac{1}{L - 1}, \end{align} $$ that is exactly what we wanted to obtain (remember the picture).

Argument the answer part:

From the histogram you have provided we can say that pixel count is $10000 + 30000 + 50000 + 20000 + 5000 = 115 \cdot 10^3$ and $$ p_1(x) = \begin{cases} \displaystyle\frac{10^4}{115 \cdot 10^3} &\text{ if } x = 50,\\ \displaystyle\frac{3 \cdot 10^4}{115 \cdot 10^3} &\text{ if } x = 100,\\ \displaystyle\frac{5 \cdot 10^4}{115 \cdot 10^3} &\text{ if } x = 150,\\ \displaystyle\frac{2 \cdot 10^4}{115 \cdot 10^3} &\text{ if } x = 200,\\ \displaystyle\frac{5 \cdot 10^3}{115 \cdot 10^3} &\text{ if } x = 250.\\ \end{cases} $$ According to the formula we derived we must calculate: $$ \begin{align} y &= T(150)\\ &= (L - 1) \cdot \int_{0}^{150}p_1(w) \ dw\\ &= (256 - 1) \cdot \left(\frac{10^4}{115 \cdot 10^3} +\frac{3 \cdot 10^4}{115 \cdot 10^3}+ \frac{5 \cdot 10^4}{115 \cdot 10^3}\right)\\ &= 255 \cdot \frac{(1 + 3 + 5) \cdot 10^4}{115 \cdot 10^3}\\ &\approx 199,565217391, \end{align} $$ that is rounded to the value $200$.