kopia lustrzana https://github.com/proto17/dji_droneid
Added normalized crosscorrelation function
This is to help Octave handle the MATLAB scriptsgr-droneid-3.8
rodzic
9b3e5d020f
commit
9b74213161
|
@ -0,0 +1,19 @@
|
|||
%% Computes the normalized cross correlation of two vectors
|
||||
% Used https://www.researchgate.net/post/How-can-one-calculate-normalized-cross-correlation-between-two-arrays
|
||||
% as the reference for this implementation
|
||||
function [score] = normalized_xcorr(window_one, window_two)
|
||||
assert(length(window_one) == length(window_two), "Windows must be equal length");
|
||||
assert(isrow(window_one) || iscolumn(window_one), "Windows must be row/column vectors");
|
||||
assert(isrow(window_two) || iscolumn(window_two), "Windows must be row/column vectors");
|
||||
|
||||
% Make both windows zero mean
|
||||
window_one = window_one - mean(window_one);
|
||||
window_two = window_two - mean(window_two);
|
||||
|
||||
% Cross correlate and get the average
|
||||
xcorr_value = sum(window_one .* conj(window_two)) / length(window_one);
|
||||
|
||||
% Final step in normalization
|
||||
score = xcorr_value / sqrt(var(window_one) * var(window_two));
|
||||
end
|
||||
|
Ładowanie…
Reference in New Issue