forked from tarmiziAdam2005/Image-Signal-Processing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathALMTV_Demo.m
41 lines (32 loc) · 872 Bytes
/
ALMTV_Demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% ================ Demo for grayscale image deblurring==================
% This code demostrates the use of the ALMTV (Augmented Lagrangian Method
% Total Variation) code.
clc
clear all;
close all;
Img = im2double(imread('Lighthouse256.bmp')); %Your Image goes here
%I = double(Img);
%H = ones(9,9)/81;
H = fspecial('gaussian', [7 7], 5);
%H = fspecial('motion',20,45); %Try a motion blur
g = imfilter(Img,H,'circular');
%[g,I] = BlurCrop(Img,H);
%g = imnoise(g, 'gaussian', 0, 0.00001); % A little bit of noise
lam = 10000; %Regularization parameter
rho = 2;
Nit = 20;
tol = 1e-5;
%=============Deblurr algorithm==========
tg = tic;
[f, relchg] = ALMTV(g,H,lam,rho,Nit,tol);
tg = toc(tg);
%========================================
figure;
imshow(f);
title('Deblurred');
figure;
imshow(g);
title('Blurred');
figure;
imshow(Img);
title('Original');