This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp5/Project_5_Maggioni_Claudio/deblurring.m

69 lines
1.2 KiB
Matlab

close all;
clear; clc;
addpath /Users/maggicl/Git/matlab2tikz/src/;
%% Load Default Img Data
load('blur_data/B.mat');
B=double(B);
load('blur_data/A.mat');
A=double(A);
% Show Image
figure;
im_l=min(min(B));
im_u=max(max(B));
imshow(B,[im_l,im_u])
title('Blurred Image')
matlab2tikz('showInfo', false, '../img_orig.tex');
% Vectorize the image (row by row)
b=B';
b=b(:);
AT = A' * A;
bt = A' * b;
IL = ichol(AT, struct('type', 'nofill', 'diagcomp', 0.01));
[x, rvec] = myCG(AT, bt, zeros(size(b)), 200, 1e-6);
[x2, flag, ~, ~, rvec2] = pcg(AT, bt, 1e-6, 200, IL, IL');
X2 = zeros(250, 250);
for i = 0:249
for j = 1:250
X2(i + 1, j) = x2(i * 250 + j);
end
end
figure;
im_l=min(min(X2));
im_u=max(max(X2));
imshow(X2,[im_l,im_u])
title('Sharp Image (rcg)')
matlab2tikz('showInfo', false, '../img_rcg.tex');
X = zeros(250, 250);
for i = 0:249
for j = 1:250
X(i + 1, j) = x(i * 250 + j);
end
end
figure;
im_l=min(min(X));
im_u=max(max(X));
imshow(X,[im_l,im_u])
title('Sharp Image (myCG)')
matlab2tikz('showInfo', false, '../img_my.tex');
figure;
semilogy(rvec / norm(bt));
hold on;
semilogy(rvec2 / norm(bt));
hold off;
title('Residual norms over iteration (y is log)')
matlab2tikz('showInfo', false, '../res_log.tex');