-
Notifications
You must be signed in to change notification settings - Fork 0
/
lmExtractorBinary.m
executable file
·65 lines (51 loc) · 1.79 KB
/
lmExtractorBinary.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
classdef lmExtractorBinary < lmAExtractorFeature
%LMEXTRACTORGABOR Summary of this class goes here
% Detailed explanation goes here
properties
end
methods
function obj = lmExtractorBinary()
name = 'Binary';
description = 'Binary feature';
obj = obj@lmAExtractorFeature(name,description);
end
function [featureVec,obj] = extractFromMat(obj,img,varargin)
if size(img,3)>1
img = rgb2gray(img);
end
map = double(img);
map(map<128) = 0;
map(map>=128) = 1;
hist1 = hist(reshape(map,[],1),[0,1]);
xf = [-1,1];
yf = [-1;1];
mapx = imfilter(map,xf);
mapy = imfilter(map,yf);
diff1 = [-1,0,1];
cent = obj.generateCent(diff1);
temp1 = reshape(mapx,1,[]);
temp2 = reshape(mapy,1,[]);
temp = [temp1;temp2];
hist2 = hist(temp,cent);
featureVec = [hist1(:);hist2(:)];
end
function nDim = featureDimension(obj,img)
nDim = 2;
end
function histo = computeHistogram(preMap, level)
xf = [-1,1];
yf = [-1;1];
mapx = imfilter(preMap,xf);
end
function cent = generateCent(obj,diff)
cent = zeros(2,length(diff)^2);
index = 1;
for i=1:length(diff)
for j=1:length(diff)
cent(:,index) = [diff(i);diff(j)];
index = index + 1;
end
end
end
end
end