From: <car...@us...> - 2012-08-24 02:45:40
|
Revision: 10904 http://octave.svn.sourceforge.net/octave/?rev=10904&view=rev Author: carandraug Date: 2012-08-24 02:45:33 +0000 (Fri, 24 Aug 2012) Log Message: ----------- xcorr2: new option to normalize cross correlation Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/xcorr2.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-23 20:09:51 UTC (rev 10903) +++ trunk/octave-forge/main/signal/NEWS 2012-08-24 02:45:33 UTC (rev 10904) @@ -16,8 +16,11 @@ ** The function `rceps' was fixed to work correctly with odd-length inputs. ** Bugfix in `xcorr2' introduced in 1.1.2 that would not accept "none" as - sacle option. + scale option. + ** `xcorr2' accepts a new scale option, "norm", to return the normalized + cross correlation. + ** The following functions are new: movingrms schtrig clustersegment Modified: trunk/octave-forge/main/signal/inst/xcorr2.m =================================================================== --- trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-23 20:09:51 UTC (rev 10903) +++ trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-24 02:45:33 UTC (rev 10904) @@ -1,5 +1,6 @@ ## Copyright (C) 2000 Dave Cogdell <cog...@as...> ## Copyright (C) 2000 Paul Kienzle <pki...@us...> +## Copyright (C) 2012 Carnë Draug <car...@gm...> ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software @@ -31,6 +32,9 @@ ## Scales the raw cross-correlation by the maximum number of elements of @var{a} ## and @var{b} involved in the generation of any element of @var{c}. ## +## @item "none" +## No scaling (this is the default). +## ## @item "unbiased" ## ## Scales the raw correlation by dividing each element in the cross-correlation @@ -42,9 +46,9 @@ ## Normalizes the sequence so that the largest cross-correlation element is ## identically 1.0. ## -## @item "none" +## @item "norm" ## -## No scaling (this is the default). +## Returns the normalized cross-correlation. ## @end itemize ## @seealso{conv2, corr2, xcorr} ## @end deftypefn @@ -66,6 +70,8 @@ ## bias routines by Dave Cogdell (cog...@as...) ## optimized by Paul Kienzle (pki...@us...) switch lower (biasflag) + case {"none"} + ## do nothing, it's all done case {"biased"} c = c / ( min ([ma, mb]) * min ([na, nb]) ); case {"unbiased"} @@ -82,10 +88,14 @@ case {"coeff"} c = c/max(c(:))'; - case {"none"} - ## do nothing, it's all done + + case {"norm"} + a = conv2 (a.^2, ones (size (b))); + b = dot (b(:), b(:)); + c(:,:) = c(:,:) ./ sqrt (a(:,:) * b); + otherwise - error ("invalid type of scale %s", biasflag); + error ("xcorr2: invalid type of scale %s", biasflag); endswitch endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |