From b5ac5aa05f211e138f34f548a8492d71cc76e98f Mon Sep 17 00:00:00 2001
From: Raffaele Gaetano <raffaele.gaetano@cirad.fr>
Date: Thu, 28 Jul 2022 17:06:54 +0200
Subject: [PATCH] ENH: New tentative for tiled vectorization.

---
 VHR/segmentation.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/VHR/segmentation.py b/VHR/segmentation.py
index ec8069c..b3c7142 100644
--- a/VHR/segmentation.py
+++ b/VHR/segmentation.py
@@ -232,12 +232,21 @@ def tiled_vectorization(input_segm, nominal_tile_size, output_template):
 
     tx, ty = int(arr.shape[1] / nominal_tile_size[0]) + 1, int(arr.shape[0] / nominal_tile_size[1]) + 1
 
-    obj_to_tile = dict.fromkeys(range(tx*ty), [])
+    obj_to_tile = dict.fromkeys(range(tx*ty))
+    for i in range(tx*ty):
+        obj_to_tile[i] = []
 
     for o in rp:
-        idx = int(o.bbox[1] / nominal_tile_size[0]) * ty + int(o.bbox[0] / nominal_tile_size[1])
+        ix, iy = int(o.bbox[1] / nominal_tile_size[0]), int(o.bbox[0] / nominal_tile_size[1])
+        idx = ix * ty + iy
         obj_to_tile[idx].append(o.label)
 
+    import matplotlib.pyplot as plt
+    for i in range(tx*ty):
+        test = np.isin(arr, np.array(obj_to_tile[i]))
+        plt.figure()
+        plt.imshow(test)
+
     return obj_to_tile
 
 def get_bounding_boxes(input_segm):
-- 
GitLab