-
Notifications
You must be signed in to change notification settings - Fork 11
/
SaliencyObjectness.m
65 lines (51 loc) · 1.55 KB
/
SaliencyObjectness.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
60
61
62
63
64
65
function [ wCtr ] = SaliencyObjectness(bbox_filename,H,W,idxImg,pixelList,adjcMatrix,colDistM,clipVal)
% SAI SRIVATSA R
% Email: saisrivatsan12@gmail.com
% Date: 12/09/2015
N = length(pixelList);
% Set the number of proposals to consider
% For fast mode, set nProposals to 200. For more accurate results but
% at a slower rate, set nProposals to 1000.
nProposals = 1000;
% Reads Objectness Proposals
A = dlmread([ 'BingBoxes/' bbox_filename '.txt']);
X = A(2:end,:);
MAT = zeros(H,W);
spMAP = zeros(N,1);
for i = 1:nProposals,
hwin = X(i,5)-X(i,3)+1;
wwin = X(i,4)-X(i,2)+1;
wMat = gausswin(hwin,2)*gausswin(wwin,2)';
for x = X(i,2):X(i,4),
for y = X(i,3):X(i,5),
spMAP(idxImg(y,x)) = spMAP(idxImg(y,x)) + X(i,1)*wMat(y-X(i,3)+1,x-X(i,2)+1);
end
end
end
for i = 1:N,
MAT(pixelList{i,1}) = spMAP(i);
end
% Objectness Threshold Map
ta = 1.5*sum(MAT(:))/(H*W);
isFG = spMAP>ta;
geoDistMatrix = CalGeoDist(adjcMatrix, colDistM, clipVal);
FGscore = zeros(N,1);
BGscore = zeros(N,1);
for i = 1:N,
for j = 1:N,
if isFG(j) == 1,
FGscore(i) = FGscore(i) + geoDistMatrix(i,j);
else
BGscore(i) = BGscore(i) + geoDistMatrix(i,j);
end
end
end
wCtr = zeros(N,1);
for i = 1:N,
MAT(pixelList{i,1}) = BGscore(i)/FGscore(i);
wCtr(i) = BGscore(i)/FGscore(i);
end
wCtr = (wCtr - min(wCtr)) / (max(wCtr) - min(wCtr) + eps);
thresh = graythresh(wCtr); %automatic threshold
wCtr(wCtr < thresh) = 0;
end