Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bounding box method to pointclouds #522

Merged
merged 3 commits into from Dec 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions menpo/shape/pointcloud.py
Expand Up @@ -169,6 +169,32 @@ def range(self, boundary=0):
min_b, max_b = self.bounds(boundary)
return max_b - min_b

def bounding_box(self):
r"""
Return the bounding box of this PointCloud as a directed graph.
The the first point (0) will be nearest the origin for an axis aligned
Pointcloud.
In the case of an image, this ordering would appear as:

::

0<--3
| |
| |
1-->2

Returns
-------
bounding_box : :map:`PointDirectedGraph`
The axis aligned bounding box of the PointCloud.
"""
from .graph import PointDirectedGraph
min_p, max_p = self.bounds()
return PointDirectedGraph(np.array([min_p, [min_p[0], max_p[1]],
max_p, [max_p[0], min_p[1]]]),
np.array([[0, 1], [1, 2], [2, 3], [3, 0]]),
copy=False)

def view(self, figure_id=None, new_figure=False, **kwargs):
return PointCloudViewer(figure_id, new_figure,
self.points).render(**kwargs)
Expand Down