-
Notifications
You must be signed in to change notification settings - Fork 0
/
lmEncoderBoFTri.m
executable file
·44 lines (32 loc) · 1.11 KB
/
lmEncoderBoFTri.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
classdef lmEncoderBoFTri < lmAEncoderFeature
properties
mCodebook;
mNumCode;
end
methods
function OBJ = lmEncoderBoFTri(codebook)
OBJ.mCodebook = codebook;
OBJ.mNumCode = size(codebook,2);
end
function code = encode(OBJ,descriptors)
numPoint = size(descriptors,2);
numCode = OBJ.mNumCode;
code = zeros(numCode,numPoint);
for i=1:numPoint
p = descriptors(:,i);
matp = repmat(p,[1,numCode]);
dist = sum((OBJ.mCodebook - matp).^2);
dist = dist(:);
dist = mean(dist) - dist;
dist(dist<0) = 0;
code(:,i) = dist/norm(dist);
end
end
function encoded = pool( OBJ,code)
encoded = sum(code,2);
end
function numDim = codeDimension(OBJ)
numDim = OBJ.mNumCode;
end
end
end