Balázs Torma
Newbie level 3
- Joined
- Feb 28, 2014
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 41
Hi there,
I am now getting familiar with the gauss filter in image processing, playing around with it a little. I noticed that the filter in matlab is quite sensitive on the mean value of the picture pixels, which I would not expect. In particular I notice that variance on filtered image is depending on the mean value of the original image. I would expect that the filtered variance only depends on the original variance and not on the offset (= mean).
Here a matlab script to see the problem:
function testGaussianFilterOffset()
H = fspecial('gaussian', 15, 2);
for offset=0:5:40
A = offset + randn(1000, 1000) * 3;
B = imfilter(A, H);
[ mean(A)) var(A)) mean(B)) var(B))]
end
output:
ans =
-0.0013 9.0065 -0.0014 0.1773
ans =
5.0043 9.0055 4.9887 0.1999
ans =
9.9995 8.9847 9.9682 0.2668
ans =
15.0045 9.0293 14.9575 0.3763
ans =
20.0017 9.0093 19.9393 0.5345
ans =
25.0010 9.0313 24.9232 0.7299
ans =
30.0035 8.9988 29.9100 0.9766
ans =
35.0042 8.9951 34.8950 1.2593
ans =
40.0027 9.0041 39.8779 1.5867
Here you see an increasing value in the last column (resultig variance), although the original variance is fixed. I expect the filtered variance to be constant as well.
Is this a property of the Gaussian filter I do not understand? Can someone explain this dependency to me pls? Or is this some kind of a numerical matlab problem?
Thanks,
Balazs
I am now getting familiar with the gauss filter in image processing, playing around with it a little. I noticed that the filter in matlab is quite sensitive on the mean value of the picture pixels, which I would not expect. In particular I notice that variance on filtered image is depending on the mean value of the original image. I would expect that the filtered variance only depends on the original variance and not on the offset (= mean).
Here a matlab script to see the problem:
function testGaussianFilterOffset()
H = fspecial('gaussian', 15, 2);
for offset=0:5:40
A = offset + randn(1000, 1000) * 3;
B = imfilter(A, H);
[ mean(A)) var(A)) mean(B)) var(B))]
end
output:
ans =
-0.0013 9.0065 -0.0014 0.1773
ans =
5.0043 9.0055 4.9887 0.1999
ans =
9.9995 8.9847 9.9682 0.2668
ans =
15.0045 9.0293 14.9575 0.3763
ans =
20.0017 9.0093 19.9393 0.5345
ans =
25.0010 9.0313 24.9232 0.7299
ans =
30.0035 8.9988 29.9100 0.9766
ans =
35.0042 8.9951 34.8950 1.2593
ans =
40.0027 9.0041 39.8779 1.5867
mean original | variance original | mean filtered | variance filtered |
-0.0013 | 9.0065 | -0.0014 | 0.1773 |
5.0043 | 9.0055 | 4.9887 | 0.1999 |
9.9995 | 8.9847 | 9.9682 | 0.2668 |
15.0045 | 9.0293 | 14.9575 | 0.3763 |
20.0017 | 9.0093 | 19.9393 | 0.5345 |
25.0010 | 9.0313 | 24.9232 | 0.7299 |
30.0035 | 8.9988 | 29.9100 | 0.9766 |
35.0042 | 8.9951 | 34.8950 | 1.2593 |
40.0027 | 9.0041 | 39.8779 | 1.5867 |
Here you see an increasing value in the last column (resultig variance), although the original variance is fixed. I expect the filtered variance to be constant as well.
Is this a property of the Gaussian filter I do not understand? Can someone explain this dependency to me pls? Or is this some kind of a numerical matlab problem?
Thanks,
Balazs
Last edited: