how to get the actual distance between two points
이전 댓글 표시
I have a rectangular arena ,the length and breadth of the rectangle is known in units of centimeters ,I have an image(521*441) of the arena .How can we calculate the distance between any two points in the arena if I know the coordinates of the points in the image??
채택된 답변
추가 답변 (1개)
Renato Agurto
2015년 12월 17일
This should do the job:
length_cm = 30;
width_cm = 20;
length_px = 521;
width_px = 441;
length_cm_pro_px = length_cm/length_px;
width_cm_pro_px = width_cm/width_px;
% point1: (x1, y1)
% point2: (x2, y2)
dx = x2-x1;
dy = y2-y1;
distance_in_cm = sqrt((dx*length_cm_pro_px)^2 + (dy*width_cm_pro_px)^2);
cheers!
Renato
댓글 수: 3
Soumya Behera
2015년 12월 17일
Renato Agurto
2015년 12월 17일
Hi. I'm not sure if the answer helped you or not. If your are asking a new question you should create a new topic
Soumya Behera
2015년 12월 17일
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!