Distance between bounding corners

15 views (last 30 days)
r_com3
r_com3 on 17 Dec 2019
Commented: Adam Danz on 22 Dec 2019
Hello, i am struggling with task of finding the distance between corners of bounding boxes of objects.
My image with bounding box around the objetcs looks like this:
im.jpg
The oriented bounding box is taken from the algorythm in this link :
My task is to find the green and blue distances on the image.
Anyone has idea how to perform it ?
Thanks in advance :)
im2.jpg

Answers (1)

Adam Danz
Adam Danz on 17 Dec 2019
Edited: Adam Danz on 17 Dec 2019
You could probably achieve the same results using regionprops from the Image Processing Toolbox (see BoundingBox property). In either case, you need to get the coordinates of the rectangle from the function output. Then you can use the pythagorean distance formula [video][literature] or Matlab's, pdist2() to compute the distance between the corners of each bounding box. It's probably easiest just to compute the distance between all 4 corners of box N and box N+1 and then the two closest corners are the ones you're interested in.
If you get stuck, show us how far you got and we can help out with the next steps.
  7 Comments
Image Analyst
Image Analyst on 21 Dec 2019
Which bounding box do you mean? Like:
  1. one from regionprops(), or
  2. the tilted one you got somehow, or
  3. the corners of the entire image?
You might also be interested in simply Using John D'Errico's bounding rectangle app: A suite of minimal bounding objects. It's a "Suite of tools to compute minimal bounding circles, rectangles, triangles, spheres, incircles, etc."
screenshot.jpg

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!