Implement a function for image correlation
Afficher commentaires plus anciens

Hi, I tried to implement a function, which can calculate the correlation of a matrix within a pattern operator function.
function[output] = correlation[input,pattern]
% Calculate the half side lenghts of the operator pattern.
h1 = (length(pattern)-1)/2;
h2 = h1;
% Implement the correlation.
[m,n] = size(input);
for i = 1:m
for j = 1:n
output(i,j) = 0
for u = -h1:h1
for v = -h2:h2
output(i,j) = output(i,j)+pattern(u,v)*input(i+u,j+v);
end
end
end
end
I want to calculate the inner values and setting the outer values to zeros. But i was stuck by the negative index, Any suggestion?
Réponses (0)
Catégories
En savoir plus sur Template Matching dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!