Skip to content
/ np_obb Public

Calculate oriented bounding boxes for label images in python

License

Notifications You must be signed in to change notification settings

VolkerH/np_obb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

np_obb calculate oriented bounding boxes in python

About

np_obb is a python package to calculate oriented bounding boxes from:

  • mask images (boolean numpy arrays)
  • label images (integer numpy arrays labeling connected components)
  • point lists

Author: Volker Hilsenstein based on a stackoverflow post by Mario Klingemann.

Installation

Install directly from this repo using:

pip install git+https://github.com/VolkerH/np_obb.git

Usage

Binder

See the examples in the Jupyter notebook in the example folder.

Limitations

This implementation uses the approach of finding the dominant orientation of the object using the covariance or eigenvectors. This works extremely well for elongated objects such as the ones in the sample image but may not be optimal for more symmetric objects. An optimal algorithm should search for the smallest (in area or volume) oriented box that fits the whole object. Such an optimization does not necessarily have a unique solution, as exemplified by the degenrate case of a perfectly symmetric object such as a circle.

This issue gives links to algorithms for calulcating optimal and approximatations of optimal bounding boxes and existing implementations for 2D and 3D in Matlab and C++. Note that these are anything but trivial. I am not aware of any python implementations.

About

Calculate oriented bounding boxes for label images in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published