motion blur without fspecial (real vs theory)
3 次查看(过去 30 天)
显示 更早的评论
I am writing a simple program to simulate motion blur by using convolution matrix and try to deblur it. Here is my code. the requirement is to blur a picture 3 pixel with horizontal direction.
if true
% code
function Blur (im)
%Read in the image and convert to gray
orig = imread ('dot3.jpg');
grayscale = rgb2gray(orig);
M2 = grayscale;
% Display the original and gray image
figure (1);
imshow (grayscale);
%figure (2);
%imshow (orig);
% Define the Blur kernels
% Blur picture 3 pixel
k_b = [0 0 0
1 1 1
0 0 0];
%Convolve the gray image with Blur Kernels, store result in M1
M1 = conv2(double(grayscale),double(k_b2));
%Display the blur image
figure (2);
imshow ((M1.^2).^0.5, []);
[x y] = size(M2);
% Using FFT to deblur picture
f_blurred = fft2(M2);
f_kernel = fft2(k_b2,x,y);
f_unblurred = f_blurred ./ (f_kernel + eps);
ret = ifft2(f_unblurred);
figure (3);
imshow ((ret.^2).^0.5,[]);
end
end
Is this code true following requirement above ? I made an real experiment by shooting a picture with 3 pixel blur by my camera. But when I input the blur picture to my code, the program cannot deblur it as the picture created by conv2. Please tell me where I am wrong ?
English is not my mother tongue; please excuse any errors on my part Thanks.
1 个评论
Image Analyst
2016-10-3
How do you know the motion blur from your camera was exactly 3 pixels horizontally?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!