Octave / Matlab High Boost过滤

时间:2018-04-22 11:51:43

标签: matlab image-processing filtering octave gaussian

我必须使用高斯低通滤波器进行模糊步骤,然后我必须使用高增强滤波来提高结果的清晰度。 以下是我到目前为止的情况:

I=imread('blurry-moon.tif');

A = fft2(double(I));
Ashift=fftshift(A);

[m n]=size(A); 
R=10; 
X=0:n-1;
Y=0:m-1;
[X Y]=meshgrid(X,Y);
Cx=0.5*n;
Cy=0.5*m;
LoF=exp(-((X-Cx).^2+(Y-Cy).^2)./(2*R).^2);

Gauss=Ashift.*LoF;
GaussShift=ifftshift(Gauss);
InverseGauss=ifft2(GaussShift);

%High boost
f = double(InverseGauss);
[m n]=size(f);
J0 = f;
for i=3:m-2
    for j=3:n-2
        J0(i,j) = (-8*f(i,j))+(1*f(i-1,j))+(1*f(i+1,j))+(1*f(i,j-1))+(1*f(i,j+1))...
    +(1*f(i-1,j-1))+(1*f(i+1,j+1))+(1*f(i-1,j+1))+(1*f(i+1,j-1)); 
    end
end

%----visualizing the results----------------------------------------------

figure(1)
imshow(I);colormap gray
title('original image','fontsize',14)

figure(2)
imshow(abs(Ashift),[-12 300000]), colormap gray
title('fft of original image','fontsize',14)


figure(3)
imshow(abs(InverseGauss),[12 290]), colormap gray
title('low pass filtered image','fontsize',14)

figure(4)
imshow(abs(J0),[12 290]), colormap gray
title('final image','fontsize',14)

我认为我在高助推中做错了什么。但我想我正在做高斯滤波器吗? 有人可以帮助使用高增压滤波器吗?

祝你好运!

1 个答案:

答案 0 :(得分:0)

img = imread('moon.tif');

% create gaussian filter
h = fspecial('gaussian',5,2.5);
% blur the image
blurred_img = imfilter(img,h);
% subtract blurred image from original
diff_img = img - blurred_img;
% add difference to the original image
highboost_img = img + 3*diff_img;

subplot 221
imshow(img,[]);
title('Original Image')

subplot 222
imshow(blurred_img,[]);
title('Blurred Image')

subplot 223
imshow(diff_img,[]);
title('Difference Image')

subplot 224
imshow(highboost_img,[]);
title('HighBoosted Image')