VolkerH / np_obb

Calculate oriented bounding boxes for label images in python
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

3D support #2

Open VolkerH opened 5 years ago

VolkerH commented 5 years ago

implement 3D support (should work with minor changes)

GenevieveBuckley commented 5 years ago

This is 3D only, but it might also be useful to look at: https://github.com/pboechat/pyobb It doesn't have nice features like you do for handling many labels in one image, though.

cc @jni (it's MIT licensed, I think you were looking for ways to expand scikit-image in this direction)

VolkerH commented 5 years ago

pyobb is very similar to the code that I used here (from quasiomondo): using the eigenvectors of the covariance matrix to determine the orientation. It might even be that the code here works already in 3D (I haven't tried).

However, I would not recommend the covariance-based method for scikit-image. The covariance gives a reasonable approximation by finding the dominant orientation but it does not necessarily give the optimal bounding box.

There are algorithms that will find the optimal obb (rotating calipers in 2D and some other algorithm for 3D, see the list of links in #3).

Also bear in mind that there are many shapes where the solution is degenerate, with a circle being the prime example.