I seems to be stuck in one of my derivation regarding histogram equalization. The other StackExchange answers didn't help me go through it. I would like someone to check if my derivation/set up is correct as well as help me finish.

So the problem is that we have an image with intensities values in $[0,1]$. We set the probability density function of the image as $p:[0,1] \rightarrow \mathbb{R}$. We set the distribution function as $P:\sigma([0,1]) \rightarrow [0,1]$. We also set a transition function from old intensity to new ones as $g:[0,1] \rightarrow [0,1]$. Now from probability theory we have : \begin{align} P(x < a) = \int_0^a p(t)dt = F(a) \end{align} With $F$ being the cumulative distribution function. Now let's assume $y = g(x)$ where y is the transformed intensity and assume g is monotone increasing. We have : \begin{align} F_2(a) = P(y < a) = P(g(x) < a) = P(x < g^{-1}(a)) = F(g^{-1}(a)) \end{align} Where $F_2$ is the cumulative distribution function of the transformed intensities. Now let's take derivatives : \begin{align} F_2'(a) &= F(g^{-1}(a))' \\ &= F'(g^{-1}(a)).(g^{-1})'(a)\\ &= p(g^{-1}(a)).(g^{-1})'(a) \end{align}

We want the density of the transformed pixel to be constant so $F_2'(a) = (\int_0^a dt)' = 1$ So that : \begin{align} 1 = p(g^{-1}(a)).(g^{-1})'(a) \end{align}

Now in all solutions I've found they say to take $g^{-1}(a) = \int_0^a p(t)dt$. But when plugging in to see if everything checks out I'm left with: \begin{align} 1 = p\big( \int_0^a p(t)dt\big).p(a) \end{align}

What am I missing here ?


Ok the problem seems to come from my sloppy notation. The probability function $P$ can't be used to model both histogram. To be able to do that I need to be more precise and use random variable. Here is the solution I came out with :

  • Let $\Omega = [0,N-1]$ be the probability space equipped with the usual sigma algebra. $N$ is the number of pixels in the image.
  • Let X and Y be Random variable such that $X:\Omega \rightarrow [0,1]$ and $Y:\Omega \rightarrow [0,1]$. X and Y represent the assignment of a pixels intensity (continuous case ). X is going to model the current image, and Y is going to represent the image with the flat histogram.
  • Let $g:[0,1] \rightarrow [0,1]$ represent the mapping function from old intensities to new ones. With these definitions we have $Y(\omega) = g(X(\omega))$. Now let's calculate the cumulative distribution function of Y :

\begin{align} P_Y(y<b) &= PY^{-1}(y<b) \\ &= P(\{\omega \in \Omega | Y(\omega) < b\})\\ &= P(\{\omega \in \Omega | g(X(\omega)) < b\})\\ &=P(\{\omega \in \Omega | X(\omega) < g^{-1}(b)\}) \text{ g is monotone increasing}\\ &= PX^{-1}(y<g^{-1}(b)) \\ &=\int_0^{g^{-1}(b)} f(t)dt \end{align}

On the other hand since Y has a flat density we have $P_Y(y<b) = b$ so that : \begin{align} b &= \int_0^{g^{-1}(b)} f(t)dt\\ g(b) &= \int_0^{b} f(t)dt\\ \end{align}

Does that sounds right ?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.