Effacer les filtres
Effacer les filtres

Rotate bounding boxes w.r.t the object orientation to get the length and width of objects in an image

23 vues (au cours des 30 derniers jours)
Hi
I want to calculate the length and width of objects in an image by approximating them as rectangles. For this I used the regionprops() function to plot the bounding boxes around all objects, and get their dimensions. But I want all the bounded box to rotate w.r.t the object orientation.
(See image attached)
Object: Pink
Bounding Box plotted by using regionprops: Red
Bounding box I want: Green

Réponses (2)

Prathamesh
Prathamesh le 28 Juil 2023
Hi,
I understand that you want the bounding box to rotate with respect to the orientation of the image.
You can achieve that by rotating the image first with “imrotate” function and then plotting the bounding box around the rotated image with “regionprops which will give new bounding box.
You can refer the documentation of these functions to get more information.

Image Analyst
Image Analyst le 28 Juil 2023
You don't need to rotate the bounding boxes.
regionprops will find the red box. Rotating that square red box will not give you the rectangular green box. To do that you'd have to ask regionprops for the orientation and then rotate the image and call regionprops again (like @Prathamesh mentioned). However if you have several blobs, you're going to have to do that several times.
I believe a simpler way is to just call bwferet directly or call it from regionprops. That will give you the caliper dimensions you are asking for.

Community Treasure Hunt

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

Start Hunting!

Translated by