-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdemo_image_deblurring.m
47 lines (39 loc) · 1.34 KB
/
demo_image_deblurring.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
42
43
44
45
46
47
clear all
close all
clc
%%
addpath([pwd, filesep, 'utilities'])
addpath([pwd, filesep, 'raw images'])
%%
do_export = false; % export restored images
scale = 1/4; % define the down-sampling scale (default is 1/4)
model_type = 'Gaussian'; % PSF model: 'Gaussian' or 'Laplacian'
%%
image_name = 'image_4.tif';
image_scan_original = imread(image_name);
image_scan_original = im2double(image_scan_original);
[N_1, N_2, N_3] = size(image_scan_original);
%%
[h_psf, c1_estimate, c2_estimate, alpha_estimate, amplitude_estimate] = ...
blur_kernel_estimation(image_scan_original, model_type, scale);
%%
[deblurring_kernel] = deblurring_kernel_estimation(h_psf, model_type);
%%
significany = 0.5; % edge significany control (optional) default is 0.5
tic;
[deblurred_image] = OneShotMaxPol(image_scan_original, deblurring_kernel, ...
model_type, alpha_estimate, c1_estimate, h_psf, significany);
elapsed_time=toc;
%%
figure('rend','painters','pos', [50 , 300, 1500, 600]);
subplot(1,2,1)
imshow(image_scan_original, 'border', 'tight')
title('Natural Blurred Image')
subplot(1,2,2)
imshow(deblurred_image, 'border', 'tight')
title('1Shot-MaxPol Deblurring')
%%
if do_export
imwrite(deblurred_image, [pwd, filesep, 'restored images', filesep, ...
model_type, '_', image_name], 'TIFF', 'compression', 'none')
end