aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/AreaOfInterest/AOIFeatures.py17
-rw-r--r--src/argaze/AreaOfInterest/AOIFeatures.py12
2 files changed, 29 insertions, 0 deletions
diff --git a/src/argaze.test/AreaOfInterest/AOIFeatures.py b/src/argaze.test/AreaOfInterest/AOIFeatures.py
index 6df33ca..cb8fb52 100644
--- a/src/argaze.test/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze.test/AreaOfInterest/AOIFeatures.py
@@ -208,6 +208,23 @@ class TestAOISceneClass(unittest.TestCase):
self.assertEqual(len(aoi_2d_scene_AB.items()), 4)
self.assertEqual(list(aoi_2d_scene_AB.keys()), ["A", "B", "C", "D"])
self.assertEqual(len(vars(aoi_2d_scene_AB)), 2 + len(aoi_2d_scene_AB.items()))
+
+ def test_expand(self):
+ """Test AOIScene expand method."""
+
+ # Create 2D scene
+ aoi_2d_scene = AOIFeatures.AOIScene(2,)
+ aoi_2d_scene["A"] = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
+ aoi_2d_scene["B"] = AOIFeatures.AreaOfInterest([[0, 0], [0, 2], [2, 2], [2, 0]])
+
+ # Expand to 3D scene
+ aoi_3d_scene = aoi_2d_scene.expand()
+
+ self.assertEqual(aoi_3d_scene.dimension, 3)
+ self.assertEqual(len(aoi_3d_scene.items()), 2)
+ self.assertEqual(list(aoi_3d_scene.keys()), ["A", "B"])
+ self.assertEqual(aoi_3d_scene["A"].shape[1], 3)
+ self.assertEqual(aoi_3d_scene["B"].shape[1], 3)
def test___repr__(self):
"""Test AOIScene string representation."""
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py
index 2d5b9b1..5637baa 100644
--- a/src/argaze/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze/AreaOfInterest/AOIFeatures.py
@@ -479,6 +479,18 @@ class AOIScene():
return self.__dimension
+ def expand(self) -> AOISceneType:
+ """Add 1 dimension to the AOIs in scene."""
+
+ new_areas = {}
+
+ for name, area in self.__areas.items():
+
+ zeros = numpy.zeros((len(self.__areas[name]), 1))
+ new_areas[name] = numpy.concatenate((self.__areas[name], zeros), axis=1)
+
+ return AOIScene(dimension = self.__dimension + 1, areas = new_areas)
+
@property
def bounds(self) -> numpy.array:
"""Get scene's bounds."""