Размытое изображение не работает в диагональном направлении - PullRequest
0 голосов
/ 25 марта 2020

Я хочу смоделировать ядро ​​размытия движения, как в книге Гонсалеса. Мой код, приведенный ниже, прекрасно работает для горизонтального и вертикального направления, но не работает в диагональном направлении. Кто-нибудь знает, в чем проблема?

% 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'); 

enter image description here

Правильный вывод: enter image description here

...