Borrar filtros
Borrar filtros

Template matching between 1d frequency curves using normxcorr2

36 visualizaciones (últimos 30 días)
David Santos
David Santos el 1 de Jul. de 2024 a las 19:33
Comentada: David Santos el 2 de Jul. de 2024 a las 8:03
Hi,
I'm trying to use 2d cross correlation between 1d dimensional frequency curves (frequencies between 6000 and 22000 Hz) to find if a template curve is present in a test one which is bigger:
Template curve:
Test curve:
I'm willing to use two dimensional cross correlation between both curves using normxcorr2 but I'm not quite sure the most efficient way to do this.
I've tried to convert both curves to binary image arrays, and then applying nomxcorr2 using:
img_template=bsxfun(@eq, 1:22000,curve_template);
img_test=bsxfun(@eq, 1:22000,curve_test);
c=normxcorr2(img_template,img_test);
but this way the 2d arrays are huge (77x22000 and 5703x22000) and the results are difficult to plot ( because of memory issues) and so to analize:
figure;mesh(img_template');hold on;
view([0 90]);
mesh(img_test);
figure;
surf(c)
Any clue on how to do this template matching between curves in a more efficcient way?
  2 comentarios
Matt
Matt el 1 de Jul. de 2024 a las 21:34
Hi,
If you want to detect, in a 1D signal, a certain pattern you can simply use 1D correlation. No need, except if I missed your goal, to convert the data like you are.
% normxcorr2 works on 1d data:
plot(normxcorr2(curve_template,curve_test))
% but it also work on N signals of length M
n = 512;
m=1024;
imagesc(normxcorr2(curve_template,rand(m,n)))
and if you want to go faster on many signals, you can drop the normalisation part and simply do a convolution between your signals, and the pattern.
imagesc(conv2(curve_template,rand(m,n),'valid'))
David Santos
David Santos el 2 de Jul. de 2024 a las 8:03
Thanks for you answer @Matt.
I'm talking about a 1D array but as you can see in the pictures the representation is two dimensional and because the template that I'm looking for can be streched in time and frequency I guess that a 2D correlation would get a better matching, don't you?
All the best

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by