-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalc_sharpness_map.m
46 lines (32 loc) · 952 Bytes
/
calc_sharpness_map.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
function [Idepth] = calc_sharpness_map(images, N)
type = 'sobel';
SMOOTH = true;
ROWS = size(images, 1);
COLS = size(images, 2);
sharps = zeros(ROWS, COLS, N);
sobel_x = fspecial('sobel');
sobel_y = sobel_x';
sigmagauss = 25;
if (strcmp('sobel', type))
for i=1:N
I = images(:,:,i);
Idepth = conv2(I, sobel_x, 'same').^2 + conv2(I, sobel_y, 'same').^2;
if (SMOOTH)
Idepth = imgaussfilt(Idepth, sigmagauss);
end
sharps(:,:,i) = Idepth;
end
elseif (strcmp('paper', type))
SIGMA = 13;
for i=1:N
I = images(:,:,i);
Igradient = conv2(I, sobel_x, 'same').^2 + conv2(I, sobel_y, 'same').^2;
Iexpgradient = exp(Igradient);
Idepth = imgaussfilt(Iexpgradient, SIGMA);
if (SMOOTH)
Idepth = imgaussfilt(Idepth, sigmagauss);
end
sharps(:,:,i) = Idepth;
end
end
[~, Idepth] = max(sharps, [], 3);