|
a |
|
b/libraries/lib_1Shot-MaxPol/utilities/OneShotMaxPol.m |
|
|
1 |
function [deblurred_image] = OneShotMaxPol(image_scan_original, deblurring_kernel, model_type, alpha_estimate, c1_estimate, h_psf, significany) |
|
|
2 |
|
|
|
3 |
[N_1, N_2, N_3] = size(image_scan_original); |
|
|
4 |
l = (numel(h_psf(:,1))-1)/2; |
|
|
5 |
x_polynomial = [-l:l]; |
|
|
6 |
fitting_function = @(amp, alpha, beta, x) generalized_Gaussian_for_fitting(x, amp, alpha, beta); |
|
|
7 |
for channel = 1: N_3 |
|
|
8 |
switch model_type |
|
|
9 |
case 'Gaussian' |
|
|
10 |
beta = 1.8; |
|
|
11 |
sigm = alpha_estimate(channel)*0.85; |
|
|
12 |
case 'Laplacian' |
|
|
13 |
beta = 0.9; |
|
|
14 |
sigm = alpha_estimate(channel)*0.5; |
|
|
15 |
end |
|
|
16 |
% generate GG smooting filter |
|
|
17 |
h_GGaussian = fitting_function(1, sigm, beta, x_polynomial); |
|
|
18 |
h_GGaussian = h_GGaussian/sum(h_GGaussian); |
|
|
19 |
|
|
|
20 |
% generate inverse deconvolution filter |
|
|
21 |
inverse_deblurring_kernel = conv(deblurring_kernel(:, channel), h_GGaussian(:), 'same'); |
|
|
22 |
|
|
|
23 |
% apply inverse deblurring kernel on image observation |
|
|
24 |
deblurring_edges_1 = imfilter(image_scan_original(:,:,channel), inverse_deblurring_kernel, 'symmetric', 'conv'); |
|
|
25 |
deblurring_edges_2 = imfilter(image_scan_original(:,:,channel), inverse_deblurring_kernel', 'symmetric', 'conv'); |
|
|
26 |
deblurring_edges_12 = imfilter(deblurring_edges_1, inverse_deblurring_kernel', 'symmetric', 'conv'); |
|
|
27 |
deblurring_edges = deblurring_edges_1 + deblurring_edges_2 + deblurring_edges_12; |
|
|
28 |
|
|
|
29 |
% |
|
|
30 |
gamma_significance(channel) = entropy(image_scan_original(:,:,channel))/(entropy(deblurring_edges)+0.5)*significany; |
|
|
31 |
deblurred_image(:,:,channel) = image_scan_original(:,:,channel) + gamma_significance(channel) * deblurring_edges; |
|
|
32 |
end |
|
|
33 |
% convert double format into uint8 format |
|
|
34 |
deblurred_image = im2uint8(deblurred_image); |