高斯高通滤波器matlab代码
时间: 2023-11-25 13:15:41 浏览: 102
function [output_image] = gauss_highpass_filter(input_image, D0)
% Gaussian high-pass filter implementation in MATLAB
% input_image: input image
% D0: cutoff frequency
% output_image: filtered image
% Convert input image to double precision for calculations
input_image = im2double(input_image);
% Size of input image
[M, N] = size(input_image);
% Create meshgrid for image coordinates
[X, Y] = meshgrid(1:N, 1:M);
% Center of the image
centerX = ceil(N/2);
centerY = ceil(M/2);
% Calculate Euclidean distance from each pixel to the center of the image
distance = sqrt((X - centerX).^2 + (Y - centerY).^2);
% Calculate Gaussian high-pass filter
H = 1 - exp(-(distance.^2)/(2*(D0^2)));
% Shift H so that the center is at the top-left corner
H = fftshift(H);
% Apply the filter in the frequency domain using FFT
F = fft2(input_image);
F_filtered = F .* H;
output_image = real(ifft2(F_filtered));
% Scale the output image to the range [0, 1]
output_image = (output_image - min(output_image(:))) / (max(output_image(:)) - min(output_image(:)));
end
阅读全文
相关推荐


















