图像增强是数字图像处理中的重要技术之一,它旨在改善图像的质量和视觉效果。
高斯同态滤波是一种常用的频域滤波技术,它通过将图像的频谱进行分解和调整来增强图像的对比度和亮度。下面是使用MATLAB实现高斯同态滤波的代码:
function enhancedImage = gaussianHomomorphicFilter(image, cutoffFrequency, gammaL, gammaH)
% 转换图像为双精度浮点型
image = im2double(image);
% 获取图像尺寸
[rows, cols] = size(image);
% 对图像进行对数变换
imageLog = log(1 + image);
% 应用二维傅里叶变换
imageFFT = fft2(imageLog);
% 创建高斯滤波器
filter = zeros(rows, cols);
centerRow = floor(rows / 2) + 1;
centerCol = floor(cols / 2) + 1;
% 根据截止频率和参数gammaL、gammaH计算滤波器
for i = 1:rows
for j = 1:cols
distance = sqrt((i - centerRow)^2 + (j - centerCol)^2);
filter(i, j) = (gammaH - gammaL) * (1 - exp(-cutoffFrequency * distance^2)) + gammaL;
end
end
% 应用滤波器
filteredImageFFT = imageFFT .* filter;
% 对滤波结果进行反傅里叶变换
filteredImage = real(ifft2(