Vectorization, check if points coordinate is exist in an image or no
이전 댓글 표시
Can anyone help me to vectorize this for loop. It is basically ckecking if the x and y coordinate of is one in N matrix or not. Thank you
for i = 1:length(coordinates)
DD = coordinates(i,:);
DDD = N(DD(1),DD(2));
if DDD ==1
%%%if the dicom point is inside the mask
signVector(i) = -1;
else
%%%if the dicom point is outside the mask
signVector(i) = +1;
end
end
채택된 답변
추가 답변 (2개)
Andrei Bobrov
2017년 10월 9일
편집: Andrei Bobrov
2017년 10월 9일
ii = coordinates;
d3 = N(ii(:,1),ii(:,2));
signVector = -ones(numel(d3),1);
signVector(d3 ~= 1) = 1;
댓글 수: 2
Mahsa
2017년 10월 9일
Image Analyst
2017년 10월 10일
Give us code, or a .mat file, to generate coordinates so we can see what you're seeing.
Image Analyst
2017년 10월 9일
0 개 추천
Be careful. If coordinates is an array of (x,y) and N is an array, then you'll need to check N(y, x), not N(x,y) as you have perhaps done. Remember (row, column) is (y, x) NOT (x,y).
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!