1D (nx)correlation

Signal
Filter
Normalized cross-correlation

Matlab cross-correlation doc
onion = rgb2gray(imread(‘onion.png’));
peppers = rgb2gray(imread(‘peppers.png’));
imshowpair(peppers, onion,’montage’)

Matlab cross-correlation doc
c = normxcorr2(onion,peppers);
figure, surf(c), shading flat;

pkg load image;
function index = find_template_1D(t, s)

endfunction

s = [-1 0 0 1 1 1 0 -1 -1 0 1 0 0 -1];
t = [1 1 0];

disp('Signal:'), disp([1:size(s, 2); s]);
disp('Template:'), disp([1:size(t, 2); t]);

index = find_template_1D(t, s);
disp('Index:'), disp(index);