From 931e282654cee682c2f54694a52364e4e3599be9 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Mon, 9 May 2022 15:36:32 +0200 Subject: Adding a bounding box method. --- src/argaze/AreaOfInterest/AOIFeatures.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py index 8b93935..0d9fce0 100644 --- a/src/argaze/AreaOfInterest/AOIFeatures.py +++ b/src/argaze/AreaOfInterest/AOIFeatures.py @@ -16,6 +16,14 @@ class AreaOfInterest(numpy.ndarray): """Number of coordinates coding area points positions.""" return self.shape[1] + def bounding_box(self): + """Get area's bounding box.""" + + min_x, min_y = numpy.min(self, axis=0) + max_x, max_y = numpy.max(self, axis=0) + + return numpy.array([(min_x, min_y), (max_x, min_y), (max_x, max_y), (min_x, max_y)]) + def center(self): """Center of mass""" return self.mean(axis=0) -- cgit v1.1