-
Notifications
You must be signed in to change notification settings - Fork 6
/
getHeatmapMixtures.m
81 lines (79 loc) · 1.97 KB
/
getHeatmapMixtures.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function [hms,scales]=getHeatmapMixtures(I,models,configs)
% getHeatmapMixtures - Get the heatmap for the mixture case
%
% Synopsis
% [<Output Arguments>] = <Function Name>(<Input Arguments>)
%
% Description
% <Description>
%
% Inputs ([]s are optional)
% (matrix) I color image
% (matrix) models [NxK] cell array of trained models - N class and K mixtures
% (struct) configs configs generated by running configsgen
%
% Outputs ([]s are optional)
% (matrix) hms - the return heatmap, size(hms, 1) = N;
% (matrix) scales - the scales used when performing the filter
%
% Examples
% <Example Code>
%
% See also
% <See Also Function Name>
%
% Requirements
% None
%
% References
% <Reference List like Papers>
% ...
%
% Authors
% Phuc Xuan Nguyen [email protected]
%
% License
% <License Statement>
%
% Changes
% <Date> <Statement>
%
filters = cell(size(models,1)*configs.nMixtures,1);
% contructing the filters
curIndex = 1;
for iModel=1:size(models,1)
for iMix = 1:configs.nMixtures
model = models{iModel,iMix};
charDims = model.char_dims;
r = floor(charDims(1)/configs.bin_size);
c = floor(charDims(2)/configs.bin_size);
filter = reshape(model.w,[r,c,configs.n_orients*4]);
filters{curIndex} = single(filter);
curIndex = curIndex + 1;
end
end
pyramid = featpyramid(I,configs);
scales = pyramid.scales;
hms = cell(length(pyramid.scales),1);
for level=1:length(pyramid.scales)
hogI = pyramid.feat{level};
try
allRes = fconv(hogI,filters,1,length(filters));
res = cell(size(models,1),1);
curInd = 1;
for iModel=1:size(models,1)
temp = zeros(size(allRes{1},1),size(allRes{1},2),configs.nMixtures);
for iMix = 1:configs.nMixtures
currentRes = allRes{curInd};
temp(:,:,iMix) = currentRes;
curInd = curInd + 1;
end
maxtemp = max(temp, [], 3); % take the maximum response
res{iModel} = maxtemp;
end
catch e
res = {};
end
hms{level} = res;
end
end