Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
fix a center of gravity loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BA
el 27 de Jul. de 2022
Cerrada: Image Analyst
el 28 de Jul. de 2022
imshow(matrix(:,:,1))
%identify axes
[x, y] = ginput(2);
% preallocate matrices
cog = zeros(size(matrix,3),1);
% the loop does not work and the error in the cog(i) line
% loop start
for i = 1:size(matrix,3)
I = matrix(:,:,i);
test = improfile(I,[x(1) x(2)],[y(1) y(2)]);
%the error comes from this line
cog(i) = sum((1:length(test)).*test)/sum(test);
% loop end
end
scog = (cog - min(cog)) / (max(cog) - min(cog));
1 comentario
Respuesta aceptada
David Hill
el 27 de Jul. de 2022
cog(i) = sum((1:length(test)).*test')/sum(test); %need to transpose test' to match dimensions
Más respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!