Chris@0: function f_featureNorm = normalizeFeature(f_feature,normP, threshold) Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: % Name: normalizeFeature Chris@0: % Date of Revision: 2011-03 Chris@0: % Programmer: Meinard Mueller, Sebastian Ewert Chris@0: % Chris@0: % Description: Chris@0: % - Normalizes a feature sequence according to the l^p norm Chris@0: % - If the norm falls below threshold for a feature vector, then the Chris@0: % normalized feature vector is set to be the unit vector. Chris@0: % Chris@0: % Input: Chris@0: % f_feature Chris@0: % normP Chris@0: % threshold Chris@0: % Chris@0: % Output: Chris@0: % f_featureNorm Chris@0: % Chris@0: % License: Chris@0: % This file is part of 'Chroma Toolbox'. Chris@0: % Chris@0: % 'Chroma Toolbox' is free software: you can redistribute it and/or modify Chris@0: % it under the terms of the GNU General Public License as published by Chris@0: % the Free Software Foundation, either version 2 of the License, or Chris@0: % (at your option) any later version. Chris@0: % Chris@0: % 'Chroma Toolbox' is distributed in the hope that it will be useful, Chris@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: % GNU General Public License for more details. Chris@0: % Chris@0: % You should have received a copy of the GNU General Public License Chris@0: % along with 'Chroma Toolbox'. If not, see . Chris@0: % Chris@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chris@0: Chris@0: f_featureNorm = zeros(size(f_feature)); Chris@0: Chris@0: % normalise the vectors according to the l^p norm Chris@0: unit_vec = ones(1,12); Chris@0: unit_vec = unit_vec/norm(unit_vec,normP); Chris@0: for k=1:size(f_feature,2); Chris@0: n = norm(f_feature(:,k),normP); Chris@0: if n < threshold Chris@0: f_featureNorm(:,k) = unit_vec; Chris@0: else Chris@0: f_featureNorm(:,k) = f_feature(:,k)/n; Chris@0: end Chris@0: end Chris@0: Chris@0: end