-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract.m
22 lines (21 loc) · 931 Bytes
/
extract.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
% extract features for single img X
% filters determine what kind of features
% scale determine grid size ???
function [features] = extract(conf, X, scale, filters)
% Compute one grid for all filters
grid = sampling_grid(size(X), ...
conf.window, conf.overlap, conf.border, scale);
feature_size = prod(conf.window) * numel(conf.filters); %9*numel(filters)
%% Current image features extraction [feature x index]
if isempty(filters)
f = X(grid);
features = reshape(f, [size(f, 1) * size(f, 2) size(f, 3)]); % no filter, then just vectorization
else
features = zeros([feature_size size(grid, 3)], 'single'); % a feature column for each pacth, which contains some features
for i = 1:numel(filters)
f = conv2(X, filters{i}, 'same');
f = f(grid);
f = reshape(f, [size(f, 1) * size(f, 2) size(f, 3)]);
features((1:size(f, 1)) + (i-1)*size(f, 1), :) = f;
end
end