필터 지우기
필터 지우기

motion blur without fspecial (real vs theory)

조회 수: 3 (최근 30일)
dao
dao 2016년 10월 3일
댓글: Image Analyst 2016년 10월 3일
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
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!

Translated by