How can I calculate the distance between two points?
8 views (last 30 days)
Show older comments
Rebecca Brandão
on 2 Jun 2015
Commented: Image Analyst
on 7 Jun 2015
Hello guys...
I have this https://drive.google.com/file/d/0B5c0tsKbCjUdYzFVRGpXLTBrSzg/view?usp=sharing on one side and I would like to use Matlab to identify the two blue points drawn and then I'd like to calculate the distance between this two points. (maybe using Cartesian coordinates)
Your help in this regard is highly appreciated, thank you in advance
0 Comments
Accepted Answer
Image Analyst
on 2 Jun 2015
You can use color segmentation to find the blue spots. Then use regionprops() to get the centroids of them. Then use the Pythagorean theorem or the hypot() function to get the distance. I'm attaching a demo of finding and tracking green regions in a video.
11 Comments
Image Analyst
on 7 Jun 2015
The formula is wrong. Try
d = sqrt((p1(1) - p2(1))^2 + (p1(2) - p2(2))^2);
or else use the hypot() function.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!