Motion blur image not working

조회 수: 6 (최근 30일)
peymanTGH
peymanTGH 2020년 3월 25일
댓글: Eirik Kvernevik 2021년 3월 7일
I want to simulate motion blur kernel as in Gonzalez book.My code below works perfectly well for horizontal and vertical direction but doesn't work in diagonal direction.
Does anyone know where is the problem?
% Degrade the image to produce motion blurred images
% shown in Figures 5.26 of text book
clear; clc;
f=imread('cover.jpg');
[M N] = size(f);
%[u,v]=freqspace([M N]);
%[u,v]=meshgrid(u,v);
T=1;a=0.1;b=0.1;r=(-1)^.5;
%center=ceil(N/2);
for u=1:M
for v=1:N
s=(pi*(a*u+b*v));
H(u,v)=(T/s)*sin(s)*exp(-r*s);
end
end
F=(fft2(f));
%Degrading the original image by multiplying H by F in frequency domain.
G=F.*H;
g=abs(ifft2(G));
%Displaying results
subplot(2,2,1);imshow(mat2gray(f)); title('f: Original');
subplot(2,2,2);imshow(mat2gray(g));title('Degraded Image by motion');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Vertical Motion
for u=1:M
for v=1:N
H1(u,v)=(T/(pi*(a*u)))*sin(pi*(a*u))*exp(-r*pi*(a*u));
end
end
%Degrading the original image by multiplying H by F in frequency domain.
G1=F.*H1;
g1=abs(ifft2(G1));
%Displaying results
subplot(2,2,3);imshow(g1,[]); title('Vertical Motion');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Horizontal Motion
for u=1:M
for v=1:N
H2(u,v)=(T/(pi*(b*v)))*sin(pi*(b*v))*exp(-r*pi*(b*v));
end
end
%Degrading the original image by multiplying H by F in frequency domain.
G2=F.*H2;
g2=abs(ifft2(G2));
%Displaying results
subplot(2,2,4);imshow(g2,[]); title('Horizontal Motion');
  댓글 수: 1
Eirik Kvernevik
Eirik Kvernevik 2021년 3월 7일
I have the same problem here, any advice ?

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by