필터 지우기
필터 지우기

inverse filtering image restoration

조회 수: 25 (최근 30일)
asim asrar
asim asrar 2019년 11월 7일
답변: Alex Zhang 2020년 9월 12일
clc;
clear all;
close all;
f=rgb2gray(im2double(imread('cameraman.tif')));
f=imresize(f,[256 256])
figure,(imshow(f))
[M,N]=size(f);
% k=2.5;
% for i=1:size(f,1)
% for j=1:size(f,2)
% h(i,j)=exp((-k)*((i-M/2)^2+(j-N/2)^2)^(5/6));
% end
% end
h=fspecial('gaussian',260,2);
g=(imfilter(f,h,'circular'));
figure,imshow(g,[]);
G = fftshift(fft2(g));
figure,imshow(log(abs(G)),[]);
H = fftshift(fft2(h));
figure,imshow(log(abs(H)),[]);
F = zeros(size(f));
R=70;
for u=1:size(f,2)
for v=1:size(f,1)
du = u - size(f,2)/2;
dv = v - size(f,1)/2;
if du^2 + dv^2 <= R^2;
F(v,u) = G(v,u)./H(v,u);
end
end
end
figure,imshow(log(abs(F)),[]);
fRestored = abs(ifft2(ifftshift(F)));
figure,imshow(fRestored, []);
this is my code for inverse filtering
in which restored image is getting fragmented into 4 parts and getting aligned arbitrarily can someone help me fix this

답변 (2개)

Robert D Jordan
Robert D Jordan 2020년 4월 2일
편집: Robert D Jordan 2020년 4월 2일
It looks like your second last line is out of order.
If the line reads:
fRestored = abs(ifftshift(ifft2(F)));
It works for me.
You were shifting before you did your IFFT.
Rob

Alex Zhang
Alex Zhang 2020년 9월 12일
Hi friend, you met this because of the second last code, it should be:
fRestored = abs(ifftshift(ifft2(F)));
I also met similar problems when I do the image restoration. The fftshif() function should always be used after fft2() or ifft2().

카테고리

Help CenterFile Exchange에서 Frequency Transformations에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by