Regarding the Gaussian filtering function imgaussfilt and the filter function fspecial.
I want to perform Gaussian filtering on an image, but the size of the filter will continue to increase as the program progresses, while the image is getting smaller and smaller. This inevitably leads to a situation where the image size is smaller than the filter size. So, I used these two functions to give a simple example to see if they can work properly.
Now that the execution has ended, I find that the results of the two functions are not the same. I would like to ask if these two functions have different ways of handling the issue of exceeding the matrix boundary? And which function would be more recommended for Gaussian filtering of images in image processing?
a = [1 2 1; 2 1 2; 1 2 1];
% imgaussfilt函数滤波对于边界像素的处理
b = imgaussfilt(a, 1.6);
disp(b);
% 使用same约束矩阵大小,对边界像素的处理
sigma = 1.6;
size = 9;
gaussian_kernel = fspecial(‘gaussian’, size, sigma);
% disp(gaussian_kernel);
c = conv2(a, gaussian_kernel, ‘same’);
disp(c);I want to perform Gaussian filtering on an image, but the size of the filter will continue to increase as the program progresses, while the image is getting smaller and smaller. This inevitably leads to a situation where the image size is smaller than the filter size. So, I used these two functions to give a simple example to see if they can work properly.
Now that the execution has ended, I find that the results of the two functions are not the same. I would like to ask if these two functions have different ways of handling the issue of exceeding the matrix boundary? And which function would be more recommended for Gaussian filtering of images in image processing?
a = [1 2 1; 2 1 2; 1 2 1];
% imgaussfilt函数滤波对于边界像素的处理
b = imgaussfilt(a, 1.6);
disp(b);
% 使用same约束矩阵大小,对边界像素的处理
sigma = 1.6;
size = 9;
gaussian_kernel = fspecial(‘gaussian’, size, sigma);
% disp(gaussian_kernel);
c = conv2(a, gaussian_kernel, ‘same’);
disp(c); I want to perform Gaussian filtering on an image, but the size of the filter will continue to increase as the program progresses, while the image is getting smaller and smaller. This inevitably leads to a situation where the image size is smaller than the filter size. So, I used these two functions to give a simple example to see if they can work properly.
Now that the execution has ended, I find that the results of the two functions are not the same. I would like to ask if these two functions have different ways of handling the issue of exceeding the matrix boundary? And which function would be more recommended for Gaussian filtering of images in image processing?
a = [1 2 1; 2 1 2; 1 2 1];
% imgaussfilt函数滤波对于边界像素的处理
b = imgaussfilt(a, 1.6);
disp(b);
% 使用same约束矩阵大小,对边界像素的处理
sigma = 1.6;
size = 9;
gaussian_kernel = fspecial(‘gaussian’, size, sigma);
% disp(gaussian_kernel);
c = conv2(a, gaussian_kernel, ‘same’);
disp(c); fspecial,imgaussfilt,gauss,filter MATLAB Answers — New Questions