我想在确定正确的填充大小后创建一个高斯高通滤波器(例如,如果图像宽度和高度是 10X10,那么应该是 20X20)。
我有我试图在 OpenCV 中移植的 Matlab 代码,但我很难正确移植它。我的 Matlab 代码如下所示:
f1_seg = imread('thumb1-small-test.jpg');
Iori = f1_seg;
% Iori = imresize(Iori, 0.2);
%Convert to grayscale
I = Iori;
if length(size(I)) == 3
I = rgb2gray(Iori);
end
%
%Determine good padding for Fourier transform
PQ = paddedsize(size(I));
I = double(I);
%Create a Gaussian Highpass filter 5% the width of the Fourier transform
D0 = 0.05*PQ(1);
H = hpfilter('gaussian', PQ(1), PQ(2), D0);
% Calculate the discrete Fourier transform of the image.
F=fft2(double(I),size(H,1),size(H,2));
% Apply the highpass filter to the Fourier spectrum of the image
HPFS_I = H.*F;
我知道如何在 OpenCV 中使用 DFT,并且能够生成它的图像,但我不确定如何创建高斯滤波器。请指导我如何创建如上所示的高通高斯滤波器?