Are these two formulas equals?

69 Views Asked by At

I'm on Mathematics because I would like to get some help to understand few things about a couple of formulas.
I got thes two formulas from two different books on image processing, and they are about the image's histogram equalization. The following is the formula from the first book (let call it Exp.1):

$ g_{i} = \frac{M-1}{n_{t}}\sum_{j=0}^{i}n_{i} $

In the formula above, $n_{t}$ is the total number of the image's pixels, $n_{i}$ is the number of pixels at grey level i, and M is the number of possible grey level values. The second book explains:

The basic idea of histogram equalization is to find the intensity transform such that the histogram of the transformed image is uniform. Of the existing probabilistic theories, there exists such an intensity transform. Suppose that we have an image $f(x,y)$, and its histogram $h(i)$, we have the accumulative function of $h(i)$ as follows:

$c(i)=\int_{0}^{i}h(t)dt$

It can be proved that such a transform makes the variable $y = c(i)$ follow a uniform distribution. Thus, for a 256 grey level image, the histogram equalization can be performed by the following equation:

$ t = \frac{256}{n}*c(f(x,y)) $

the one above is my second formula (let call it Exp.2)

I'm trying to understand if Exp.1 and Exp.2 are equals, and if this is the case, I want to know if it's correct saying that:

$ \sum_{j=0}^{i}n_{i} $

defines the cumulative distribution function in Exp.1.

By now, I think it's very clear that my understanding of Math it's way below the average of Mathematics' users, even though I have learnt to put in code the above methods. So, please, be kind and less theoretical possible.

Thanks

EDIT: Exp.1 is taken from: The pocket handbook of image processing algorithms in C by Harley R. Myler and Arthur R. Weeks, Central Florida Univ., from Prentice Hall.

Exp.2 is taken from: Digital Image Processing – Part I by Huiyu Zhou, Jiahua Wu, Jianguo Zhang & Ventus Publishing ApS.

EDIT AFTER MICHAEL COHEN SUGGESTIONS: This is the book code ported to Python (just the part relative to Exp.1)

    HISTEQ = [0 for i in range(256)]
    SUM = 0.0
    HIST = histogram(input_image)
    for i in range(256):
        SUM = 0.0
        for j in range(i):
            SUM += HIST[j]
        HISTEQ[i] = int(255*SUM+0.5)