필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

fix a center of gravity loop

조회 수: 2 (최근 30일)
BA
BA 2022년 7월 27일
마감: Image Analyst 2022년 7월 28일
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
Matt J
Matt J 2022년 7월 27일
You need to demonstrate the code and show us the error messages.

채택된 답변

David Hill
David Hill 2022년 7월 27일
cog(i) = sum((1:length(test)).*test')/sum(test); %need to transpose test' to match dimensions
  댓글 수: 1
BA
BA 2022년 7월 27일
편집: BA 2022년 7월 27일
Fab. it works perfectly. I have another question: what is the equivalent of 'improfile' in octave? I mean to change the 'improfile' line to work in octave

추가 답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by