Chris@0
|
1 function f_featureNorm = normalizeFeature(f_feature,normP, threshold)
|
Chris@0
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
3 % Name: normalizeFeature
|
Chris@0
|
4 % Date of Revision: 2011-03
|
Chris@0
|
5 % Programmer: Meinard Mueller, Sebastian Ewert
|
Chris@0
|
6 %
|
Chris@0
|
7 % Description:
|
Chris@0
|
8 % - Normalizes a feature sequence according to the l^p norm
|
Chris@0
|
9 % - If the norm falls below threshold for a feature vector, then the
|
Chris@0
|
10 % normalized feature vector is set to be the unit vector.
|
Chris@0
|
11 %
|
Chris@0
|
12 % Input:
|
Chris@0
|
13 % f_feature
|
Chris@0
|
14 % normP
|
Chris@0
|
15 % threshold
|
Chris@0
|
16 %
|
Chris@0
|
17 % Output:
|
Chris@0
|
18 % f_featureNorm
|
Chris@0
|
19 %
|
Chris@0
|
20 % License:
|
Chris@0
|
21 % This file is part of 'Chroma Toolbox'.
|
Chris@0
|
22 %
|
Chris@0
|
23 % 'Chroma Toolbox' is free software: you can redistribute it and/or modify
|
Chris@0
|
24 % it under the terms of the GNU General Public License as published by
|
Chris@0
|
25 % the Free Software Foundation, either version 2 of the License, or
|
Chris@0
|
26 % (at your option) any later version.
|
Chris@0
|
27 %
|
Chris@0
|
28 % 'Chroma Toolbox' is distributed in the hope that it will be useful,
|
Chris@0
|
29 % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
31 % GNU General Public License for more details.
|
Chris@0
|
32 %
|
Chris@0
|
33 % You should have received a copy of the GNU General Public License
|
Chris@0
|
34 % along with 'Chroma Toolbox'. If not, see <http://www.gnu.org/licenses/>.
|
Chris@0
|
35 %
|
Chris@0
|
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Chris@0
|
37
|
Chris@0
|
38 f_featureNorm = zeros(size(f_feature));
|
Chris@0
|
39
|
Chris@0
|
40 % normalise the vectors according to the l^p norm
|
Chris@0
|
41 unit_vec = ones(1,12);
|
Chris@0
|
42 unit_vec = unit_vec/norm(unit_vec,normP);
|
Chris@0
|
43 for k=1:size(f_feature,2);
|
Chris@0
|
44 n = norm(f_feature(:,k),normP);
|
Chris@0
|
45 if n < threshold
|
Chris@0
|
46 f_featureNorm(:,k) = unit_vec;
|
Chris@0
|
47 else
|
Chris@0
|
48 f_featureNorm(:,k) = f_feature(:,k)/n;
|
Chris@0
|
49 end
|
Chris@0
|
50 end
|
Chris@0
|
51
|
Chris@0
|
52 end |