-
Notifications
You must be signed in to change notification settings - Fork 16
/
computeFinalSaliency.m
59 lines (51 loc) · 2 KB
/
computeFinalSaliency.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
48
49
50
51
52
53
54
55
56
57
58
59
function saliency = computeFinalSaliency(img, pScale, sScale, alpha, sigma0, sigma1, p1)
% function saliency = computeFinalSaliency(image, pScale, sScale, alpha, sigma0, sigma1, p1)
%
% compute multi scale saliency over an image
%
% @input
% img - a given image to process
% pScale - precission scale (number of samples) [1xn vector]
% sScale - size scale (sampling raduis) [1xn vector]
% alpha - attenuation factor [1x1 variable]
% sigma0 : standard deviation of kernels in surround [1x1 variable]
% sigma1 : standard deviation of kernel in center [1x1 variable]
% p1 - P(1|x) [128x171 matrix]
% @output
% saliency - saliency of inputed image
%
% please refer to the following paper for details
% Rezazadegan Tavakoli H, Rahtu E & Heikkil? J,
% "Fast and efficient saliency detection using sparse sampling and kernel density estimation."
% Proc. Scandinavian Conference on Image Analysis (SCIA 2011), 2011, Ystad, Sweden.
%
% The code has been tested on Matlab 2010a (32-bit) running windows.
% This code is publicly available for demonstration and educational
% purposes, any commercial use without permission is strictly prohibited.
%
% Please contact the author in case of any questions, comments, or Bug
% reports
%
% @CopyRight: Hamed Rezazadegan Tavakoli
% @Contact Email: [email protected]
% @date : 2010
% @version: 0.1
% normalize the size of image to 128x171
img = imresize(img, [128, 171]);
[r c d] = size(p1);
if (r ~=128 || c~=171 || d~=1)
error('p1 should be of size 128x171');
end
% compute saliency over each scale
n = numel(pScale);
saliency = zeros([128, 171, n]);
for i = 1:n
saliency(:,:,i) = calculateImageSaliency(img, pScale(i), sScale(i), sigma0, sigma1, p1);
end
% merge saliency over scales
for i = 1:n
saliency(:,:,i) = imfilter(saliency(:,:,i), fspecial('Gaussian', 26, 0.2*26));
end
saliency = saliency.^alpha;
saliency = mean(saliency, 3);
saliency = (saliency - min(saliency(:))) / (max(saliency(:)) - min(saliency(:)));