From 923363f53b8b4908a2c01cc2561dfed40f060ca9 Mon Sep 17 00:00:00 2001
From: "raffaele.gaetano" <raffaele.gaetano@cirad.fr>
Date: Fri, 21 Apr 2023 16:43:03 +0200
Subject: [PATCH] ENH: optimizing tiepoint search.

---
 Common/geometry.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Common/geometry.py b/Common/geometry.py
index 5b64213..21622c6 100644
--- a/Common/geometry.py
+++ b/Common/geometry.py
@@ -116,6 +116,10 @@ def compute_displacement_with_masks(_src: otb.Application, _tgt: otb.Application
     mask = np.all((mask, ref_mask), axis=0).astype(int)
     H, W = mask.shape
     ratio = np.sum(mask)/(H*W) #scale number of bins based on coverage ratio
+
+    if ratio == 0:
+        return None, 0
+
     cnt, cov, cov_ext = get_patch_centers(mask, geobin_size, max(1,int(ratio*num_geobins)), margin=margin)
     _src_msk.FreeRessources()
     _tgt_msk.FreeRessources()
-- 
GitLab