Thursday 24 December 2015

cross correlation - Matlab normxcorr for 1D signals


I am very surprised not to find a version of normxcorr2 for 1D signals in Matlab ! I implemented something like that by hand (with 2 for loops, and normalizing the template as well as the window under the template (in the 1D signal in which the template is searched).


Did I just not find it or does it not exist? (A normalized cross correlation (NCC) for 1D signals, i.e., like normxcorr2 but for vectors)


(cf. https://ch.mathworks.com/help/images/ref/normxcorr2.html for the 2D version )


e.g.:


template=[1 2 3]

signal=[0 1 4 8 9 3 7 7 1 2 3 0 5 5 0]


the NCC should find the max at a lag of 9 (because you can see that the pattern [1 2 3] starts at pos 9). I consider here sliding the template starting at the template positioned over the window [0 1 4] of the signal and finishes at [5 5 0] , like that I obtain an output signal of length:


 outputLen=length(signal)-length(template)+1.

P.S. and it seems clearly that corr or xcorr does not do the same thing even with the 'normalization' argument because what I am looking for is something that normalized the kernel and the window in the signal at each step, which is quite cumbersome but needed for the NCC as mentioned in : http://www.cse.psu.edu/~rtc12/CSE486/lecture07.pdf for example)




No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...