Distance between 2 points in an image.

20 ビュー (過去 30 日間)
TheBlackComet
TheBlackComet 2013 年 4 月 24 日
I am trying to figure out how to quickly select two points in an image and determine the distance between the two points in x,y coordinates. I am unsure how to easily accomplish this without having to convert the image. Ideally I would like to be able to use mouse input to select the two points.

回答 (3 件)

Joe S
Joe S 2013 年 4 月 24 日
Check ginput function
can get multiple x & y,
then do
(pseudocode)
distance = sqrt((x1-x2).^2+(y1-y2).^2)
check hypot function as well.

Daniell Algar
Daniell Algar 2013 年 4 月 24 日
You could be more specific but..
The simplest case might be to just use the Data Cursor. It's in the toolbar already.. Click it, place the cursor where you want.. Right-click on the image and select 'Create New Datatip', place that second cursor where you want it. Then again, right click on picture and 'Export Cursor Data to Workspace...'. That will save the (x,y)-vectors to the variable of your choice.

Image Analyst
Image Analyst 2013 年 4 月 24 日
If you have the Image Processing Toolbox, you can use imdistline(). It's meant for exactly this kind of thing.
If you'd also like the intensity profile between the two points, use improfile().

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by