Difference between manually-created gaussian filter and fspecial
6 ビュー (過去 30 日間)
古いコメントを表示
I am wondering why there is difference between these two, and how could the max vaule in fspecial (0.4026) is larger than manually-created gaussian (0.3989) when x = 0?
manually-created gaussian filter code:
x = [-2 -1 0 1 2];
gauss_filter = 1/(sqrt(2*pi)*sigma)*exp(-x.^2/(2*sigma^2))
gauss_filter =
0.0540 0.2420 0.3989 0.2420 0.0540
while the fspecial create gaussian filter:
gauss_filter = 1/(sqrt(2*pi)*sigma)*exp(-x.^2/(2*sigma^2))'
gauss_filter =
0.0545 0.2442 0.4026 0.2442 0.0545
0 件のコメント
回答 (1 件)
DGM
2024 年 10 月 24 日 23:57
編集済み: DGM
2024 年 10 月 24 日 23:58
I believe the original question was pasted incorrectly, since both examples appear to be identical (except a transpose). Neither shows the use of fspecial().
However, the difference between the two results is simple. For the filters to not alter the image mean, their sum must be 1.
sigma = 1;
x = [-2 -1 0 1 2];
fk1 = 1/(sqrt(2*pi)*sigma)*exp(-x.^2/(2*sigma^2)) % as calculated
sum(fk1) % not sum-normalized
fk1 = fk1/sum(fk1) % normalize it
sum(fk1) % sum-normalized
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!