使用热方程在matlab中对图像进行去模糊处理

时间:2016-12-11 00:23:10

标签: image matlab image-processing pde

所以我试图使用热方程对图像进行去模糊,但是当我运行代码时,我现在不能获得图像。所以我这样做是通过查看http://www4.ncsu.edu/eos/users/w/white/www/white/ma325/MVlec3.pdf来编写代码:

u0=double(imread('clock.tiff'));

[m,n,k] = size(u0); %k=conductivity
%if k==3
    %u0 = rgb2gray(u0); 
%end;
u0 = double(u0); 
subplot(1,2,1); 
imagesc(u0); 
colormap gray; 
title('Original');

dt = 0.2; %time step
T = 50; %stopping time
u = u0;

for t = 0:dt:T
    u_xx = u(:,[2:n n]) - 2*u + u(:,[1 1:n-1]); 
    u_yy = u([2:m m], :) - 2*u + u([1 1:m-1],:); 
    u = u + k*dt*(u_xx+u_yy);
% subplot(1,2,2);
% imagesc(u);
% title(['t=',num2str(t)]);
% drawnow;
temp=u;
end;
imshow(uint8(temp));
imwrite(uint8(temp),'clockmodified.tiff','TIFF');

for t = 0:dt:T
    u_xx = u(:,[2:n n]) - 2*u + u(:,[1 1:n-1]); 
    u_yy = u([2:m m], :) - 2*u + u([1 1:m-1],:); 
    L=-u_xx-u_yy;
    u = u + k*dt*L;
subplot(1,2,2);
imagesc(u);
title(['t=',num2str(t)]);
drawnow;
temp=u;
end;
% imshow(uint8(temp));
imwrite(uint8(temp),'clockdeblur1.tiff','TIFF');

0 个答案:

没有答案