Octave/Matlab 高升压过滤
Octave/Matlab High Boost filtering
我必须在模糊步骤中使用高斯低通滤波器,然后我必须使用高增强滤波来提高结果的清晰度。
这是我目前所拥有的:
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)
我觉得我在 high boost 上做错了什么。但我想我做的是高斯滤波器吗?
有人可以帮忙解决高增益滤波器问题吗?
此致!
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')
我必须在模糊步骤中使用高斯低通滤波器,然后我必须使用高增强滤波来提高结果的清晰度。 这是我目前所拥有的:
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)
我觉得我在 high boost 上做错了什么。但我想我做的是高斯滤波器吗? 有人可以帮忙解决高增益滤波器问题吗?
此致!
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')