Gaussian Filter without using any special function

12 visualizaciones (últimos 30 días)
Muhammed Seyda Özdemir
Muhammed Seyda Özdemir el 25 de Mzo. de 2020
Editada: DGM el 6 de Mayo de 2023
Hi,
i need to apply a gaussian filter to the image without using imgaussfilt() function,
i create a gaussian mask:
[ 1, 4, 7, 4, 1;
4, 20, 33, 20, 4;
7, 33, 55, 33, 7;
4, 20, 33, 20, 4;
1, 4, 7, 4, 1 ]
then i applied to the image and i get gaussian filtered image but i don't know to change the gaussian filter degree (sigma is 1 and i couldn't change this value),
so how can i use this mask with different sigma values.

Respuestas (1)

DGM
DGM el 6 de Mayo de 2023
Here is one example.
% specify input parameter as a scalar or 2-element vector
sigma = [4 5]; % [y x]
% expand if necessary
if isscalar(sigma); sigma = [1 1]*sigma; end
% generate kernel
r = ceil(2.5*sigma); % filter size is (2*r + 1) pixels
[xx yy] = meshgrid(-r(2):r(2),-r(1):r(1));
fk = exp(-(xx.^2/(2*sigma(2)^2) + yy.^2/(2*sigma(1)^2)));
fk = fk./sum(fk(:)); % sum-normalize
imshow(fk,[])

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by