Is histogram "function" linear?

252 Views Asked by At

I was ask to prove/disprove if for two given images $f_1(x,y)$ and $f_2(x,y)$ the histogram of $f_1(x,y)-f_2(x,y)$ and $h_1-h_2$ are equal, where $h_i$ is the histogram of image i.

Intuitively it seems to be correct, as if we look at the images as matrices, the histogram is a function that take the matrix values and count the number of repetitions ("losing" the indices of each value)

But is there a proper mathematically proof?

2

There are 2 best solutions below

0
On

Consider one-dimensional images $$f_1=[0,0,0,1]$$ $$f_2=[0,1,0,0]$$ Then we can say that $$h_1=\begin{bmatrix}(-1,0)\\(0,3)\\(1,1)\end{bmatrix}$$ $$h_2=\begin{bmatrix}(-1,0)\\(0,3)\\(1,1)\end{bmatrix}$$ $$h_1-h_2=\begin{bmatrix}(-1,0)\\(0,0)\\(1,0)\end{bmatrix}$$ $$f_1-f_2=[0,-1,0,1]$$ $$h_{1-2}=\begin{bmatrix}(-1,1)\\(0,2)\\(1,1)\end{bmatrix}$$

In general, if two images are different from each other but have the same histogram, then the histogram of the difference of the images will not be equal to the difference of the histograms.

Have I misunderstood something? I don't know if there's even a rigorous idea of "histogram subtraction".

0
On

No, the difference of histograms of images is not equal to the histogram of difference of images.

Consider the following counter example:

  • $f_1$ image of dimensions $1 \times 1$ with $f_1(0,0) = 0$,
  • $f_2$ image of dimensions $1 \times 1$ with $f_2(0,0) = 1$.

Define $f_d(0,0) = f_1(0,0) - f_2(0,0) = 0 - 1 = -1$. Now take the histograms:

  • $h[f_1](x) = \begin{cases} 0 & \text{for } x = 1,\\ 1 & \text{for } x = 0,\\ 0 & \text{for } x = -1, \end{cases}$
  • $h[f_2](x) = \begin{cases} 1 & \text{for } x = 1,\\ 0 & \text{for } x = 0,\\ 0 & \text{for } x = -1, \end{cases}$
  • $h[f_1 - f_2](x) = \begin{cases} 0 & \text{for } x = 1,\\ 0 & \text{for } x = 0,\\ 1 & \text{for } x = -1. \end{cases}$

The histogram difference results to be

  • $(h[f_1] - h[f_2])(x) = \begin{cases} -1 & \text{for } x = 1,\\ 1 & \text{for } x = 0,\\ 0 & \text{for } x = -1. \end{cases}$

Hence we deduce that the histogram operator is not linear: $$ h[f_1 - f_2] \neq h[f_1] - h[f_2].$$