I am doing image processing and I want to calculate the variance of a histogram of pixel intensities.
The first method I have tried: The images store the pixels values using double precision numbers, however to make a histogram, they need to be scaled so that the can be grouped in to bins. For example into bins of 0 to 255.
And I get a histogram looking like this
I can then calculate variance in the usual way
$\mu = \frac{1}{n} \sum_x xf(x)$
$ \sigma^2 = \frac{1}{n} \sum_x {(x- \mu)^2 f(x)}$
But I have suspicions that this is not very usefull for comparing variances between different images. For example, when I get an image with a wider spread of pixel intensities, the histogram is scaled over a wider range. This means that pixels that would otherwise be grouped into a different bin, get placed in the same bin.
As you can see here
It seems to defeat the purpose of a histogram to place most of the pixles into one or two bins.
Is this a job for kernel density estimation?
I need some way of comparing apples to apples.