From "Digital Image Processing 4th ed. - Gonzalez, Woods"

Let $p_r(r)$ and $p_s(s)$ denote the PDFs of intensity values $r$ and $s$ in two different images. A fundamental result from probability theory is that if $p_r(r)$ and $T(r)$ are known, and $T(r)$ is continuous and differentiable over the range of values of interest, then the PDF of the transformed (mapped) variable $s$ can be obtained as: $$(1)\ \ p_s(s)\triangleq p_r(r)\left|\frac{dr}{ds}\right|$$

I should specify that $T(r)$ indicates a single-pixel intensity transformation. Now, I understand what the two PDFs indicate, but I fail to understand:

  1. The derivation of (1)
  2. The utility of (1)

EDIT: I found that $(1)$ is basically the change of variable formula for probability density functions, which holds when $T(r)$ is monotonic.

  • $\begingroup$ the derivation is in Papulous’s book. It’s one of the strengths of his book. putting the derivation aside, what is it about the utility you question? In image processing or just in general? Also, in image processing, the pixels values are actually discrete , so long as the mapping is one to one, you don’t need the Jacobian, $\endgroup$ – user28715 Oct 6 '19 at 18:43
  • $\begingroup$ is that really the notation they chose? Usually, authors make sure to make a difference between random variables (typically uppercase) and their possible values (typically lowercase), and the lack of that here really makes it awkward to quickly write down an answer. Would you mind if I adjusted the notation in your question a bit? $\endgroup$ – Marcus Müller Oct 6 '19 at 18:56
  • $\begingroup$ @StanleyPawlukiewicz I understand the question about utility is pointless now that I've understood that's simply the change of variable formula. I'm new to image processing so there's still a lot I have to learn. $\endgroup$ – NTAuthority Oct 6 '19 at 19:50
  • $\begingroup$ @MarcusMüller Yes, that's exactly the notation being used. Feel free to adjust it! $\endgroup$ – NTAuthority Oct 6 '19 at 19:51
  • $\begingroup$ @StanleyPawlukiewicz I can't find the author you're talking about $\endgroup$ – NTAuthority Oct 6 '19 at 19:52

Let $R$ be the random variable "intensity" with probability density function $f_R(r)$ ($=p_r$). That implies that $R$ also has a cumulative density function $F_R(r) = P(R \le r) = \int_{-\infty}^r f_R(u)\,\mathrm du$.

Let $S = T(R)$ be another random variable, the transformed version of $R$, with the transformation mapping $s=T(R)$ smooth and monotonous¹. We're looking for the pdf of $S$, $f_S(s)$ ($=p_s$).

We take the convenient detour through $f_S(s) = \frac{\mathrm d}{\mathrm ds}F_S(s)$:

\begin{align} \frac{\mathrm d}{\mathrm ds} F_S(s) &= \frac{\mathrm d}{\mathrm ds}P(S\le s)\\ &= \frac{\mathrm d}{\mathrm ds}P(S\le T(r))\\ &= \frac{\mathrm d}{\mathrm ds}P(T^{-1}(S)\le r)\\ &= \frac{\mathrm d}{\mathrm ds}F_R(T^{-1}(S)) & \text{chain rule of deriv.}\\ &= \frac{\mathrm d}{\mathrm d \left(T^{-1}(s)\right) }F_R(T^{-1}(S))\cdot \underbrace{\frac{\mathrm d}{\mathrm dS}T^{-1}(S)}_\text{deriv. of inv. function}\\ &=f_R(T^{-1}(S))\cdot \overbrace{\frac1{\frac{\mathrm d}{\mathrm dr}T(r)}}\\ &=f_R(R)\cdot \frac1{\frac{\mathrm d}{\mathrm dr}s}\\ &=f_R(R)\frac{\mathrm dr}{\mathrm ds} & \text{in original notation:}\\ &=p_r(r)\frac{\mathrm dr}{\mathrm ds} \end{align}

I feel like I've forgotten the formal step that introduces the absolute value, but in case of $T(r)$, I required local invertability, so that kind of goes with that. If someone has a good notation for that, please do not hesitate to edit my answer. It's kinda late!

¹ that's an addition to the original problem, but for this way of derivation I need $T$ to be invertible. We can go a lot more measure-theoretic at this, but I don't really think that helps, so I'm going with this restriction, which I don't think is too harsh, as other mappings would lead to questionable results, just from a picture perspective.

  • 1
    $\begingroup$ Hi Marcus, I added my answer which derives the reason for the absolute value. $\endgroup$ – Royi Oct 7 '19 at 21:16
  • 1
    $\begingroup$ @Royi ah nice! yeah, that fits. $\endgroup$ – Marcus Müller Oct 7 '19 at 21:18
  • $\begingroup$ Thanks again, I'd actually be interested in the measure-theoretic proof too, any place where I can find that? $\endgroup$ – NTAuthority Oct 9 '19 at 4:10

Let $ R $ be a random variable and $ S = T \left( R \right) $ where $ T \left( \cdot \right) $ is a one to one continuous transformation on the domain of $ R $.

Since it is one to one transformation it must be strictly monotone. Let's test the 2 possible cases.

The Transformation $ T \left( \cdot \right) $ Is Strictly Increasing

Utilizing the function is one to one:

$$ {F}_{S} \left( s \right) = \mathbb{P} \left( S \leq s \right) = \mathbb{P} \left( T \left( R \right) \leq s \right) = \mathbb{P} \left( R \leq {T}^{-1} \left( s \right) \right) = {F}_{R} \left( {T}^{-1} \left( s \right) \right) $$

Using the Chain Rule to compute the density function:

$$ {f}_{S} \left( s \right) = {F}^{'}_{S} \left( s \right) = \frac{d}{d s} {F}_{R} \left( {T}^{-1} \left( s \right) \right) = {f}_{R} \left( {T}^{-1} \left( s \right) \right) \frac{d}{d s} {T}^{-1} \left( s \right) $$

The Transformation $ T \left( \cdot \right) $ Is Strictly Decreasing

Utilizing the function is one to one and decreasing:

$$ {F}_{S} \left( s \right) = \mathbb{P} \left( S \leq s \right) = \mathbb{P} \left( T \left( R \right) \leq s \right) = \mathbb{P} \left( R \leq {T}^{-1} \left( s \right) \right) = 1 - {F}_{R} \left( {T}^{-1} \left( s \right) \right) $$

Using the Chain Rule to compute the density function and the fact the inverse function also decreasing hence its derivative is also negative:

$$ {f}_{S} \left( s \right) = {F}^{'}_{S} \left( s \right) = -\frac{d}{d s} {F}_{R} \left( {T}^{-1} \left( s \right) \right) = {f}_{R} \left( {T}^{-1} \left( s \right) \right) \left(- \frac{d}{d s} {T}^{-1} \left( s \right) \right) $$


Since for the first case $ \frac{d}{d s} {T}^{-1} \left( s \right) $ is positive and for the second case $ - \frac{d}{d s} {T}^{-1} \left( s \right) $ is positive we can join them both into:

$$ {f}_{S} \left( s \right) = {F}^{'}_{S} \left( s \right) = -\frac{d}{d s} {F}_{R} \left( {T}^{-1} \left( s \right) \right) = {f}_{R} \left( {T}^{-1} \left( s \right) \right) \left| \frac{d}{d s} {T}^{-1} \left( s \right) \right| $$

I guess this is needed in the section before the Histogram Equalization where similar trick is used to derive the operator.

  • $\begingroup$ Those who -1 this answer. Any reason to do so? $\endgroup$ – Royi Oct 8 '19 at 17:57
  • $\begingroup$ I +1'ed it actually. I confirm this is actually used for histogram equalization. $\endgroup$ – NTAuthority Oct 9 '19 at 4:08

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.