I am working in the field of digital image processing and currently i am reading this paper and I have two questions about it....

After applying a gaussian filter to a histogram, will the pixel values of the new histogram be changed or not? And will the sum of pixels in new histogram be the same or not?


1 Answer 1


For you questions: 1. After applying gaussian filter on a histogram, the pixel value of new histogram will be changed. 2. The sum of pixels in new histogram is almost impossible to remain unchanged.

Visually speaking, after your applying the gaussian filter (low pass), the histogram shall become more smooth than before. Thus, the new histogram is definitely changed. With regards to the sum of pixels in new histogram, you may consider the problem a little bit differently.

Assume that you have a normalized image histogram $$p(x) = {\# {\rm pixels\,\, of\,\, value\,\,} x\over N},$$where $N$ is the total number of pixels in an image. Then $p(x)$ is also a p.m.f., because $\sum_{x}p(x)=1$. Then the sum of pixels $$S=E[x]\times N,$$ where $E[x]=\sum_{x}xp(x)$ is the mean pixel value over the entire image.

Let's say your have a 1D gaussian filter as $$f(y)={1\over \sqrt{2\pi}\sigma_y}\exp\left(-{(y-\mu_y)^2\over 2\sigma_y^2}\right).$$ Commonly, people set $\mu_y=0$ as a zero-mean gaussian, and $\sigma_y^2$ is the variance. As a result, the new histogram after applying the gaussian filter can be written as $$p'(x) = \sum_zp(z)f(x-z),$$ which can be considered as the gaussian weighted sum of the original neighbor histogram stems. Alternative, you may consider the relationship among the new histogram, the old histogram and the gaussian filter as $$p'(x) = p(x)*f(x)$$ where $*$ denotes the convolution operator.

This notation then brings out an alternative interpretation from random variables (r.v.). Assume r.v. $a\sim p(a)$, and r.v. $b\sim f(b)$, then r.v. $$c=a+b \,\sim\, p'(c),$$ when $a$ and $b$ are independent. Though it is somewhat hard to believe at the first glance, this interpretation tells you that the theoretical histogram of a noisy image (which is corrupt by the noise following the same gaussian distribution you used in filtering) is the identical to the histogram that you filtering the original histogram with that gaussian filter. One thing that I need to point out here is that even though $c\sim p'(c)$ doesnot mean that you will see the exact same distribution, because all what you can see is realizations of this distribution, but not itself directly. Please see the following figures for details. As you can see, red and green curves match very well, but they are still slightly different.

Finally, we are ready to answer your second questions whether the sum of pixels changes before and after filtering. Using our previous derivations, you will see this question is equivalent to ask whether $$E[c] =E[a] ?$$ where $c\sim p'(c)$ and $a\sim p(a)$. If $b$ follows a zero-mean gaussian, then $E[c]=E[a]+E[b]=E[a]$. Otherwise, they are not equal. Once again, you may not expect to see these values are identical, because $E[c]$ is only a theoretical value, and the actual observed mean value can be deviate from this theoretical value (the degree of how much the observed mean deviate from the theoretical one depends on the number of pixels, the more pixels the closer these two means).

imageshistograms Here is some Matlab code that generates the above figures. Play this demo, and you will see what I mean.

I = imread('cameraman.tif');
[p,val] = imhist(I);
p = p./numel(I); % <== p(x) original histogram
sigma = 5;
f = normpdf(-20:20,0,sigma); % <== f(x) gaussian distribution
p1 = conv(p,f); % <== p'(x) new histogram after applying gaussian filtering
hold on, plot(val(1)-20:val(end)+20,p1,'r--','Marker','o')

% alternative interpreation 
N = randn(256)*sigma; % <== white gaussian noise following p.d.f f(x)
I2 = N+double(I); % <== a noisy observation by adding noise to the original image
[p2,val] = hist(I2(:),val(1)-20:val(end)+20); % <== p''(x) the hisogram of the noisy image
p2 = p2./numel(I);
hold on, plot(val,p2,'g-.','Marker','*')
legend('original histogram', 'histogram after applying gaussian filter', 'histogram after adding gaussian noise')

subplot(131),imagesc(I),axis image,colormap(gray),title('original image I');
subplot(132),imagesc(N),axis image,colormap(gray),title('white gausian noise N');
subplot(133),imagesc(I2),axis image,colormap(gray),title('noisy image I2 = I+N');
  • $\begingroup$ The derivation is sound, but of what possible use is this technique? $\endgroup$ Commented Jul 25, 2013 at 17:43
  • $\begingroup$ Here are some of applications: $\endgroup$
    – pitfall
    Commented Jul 25, 2013 at 19:55
  • $\begingroup$ I think you forgot to include the links... $\endgroup$ Commented Jul 25, 2013 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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