From 3eebb57b2738658109fde5fd608490f18398a906 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Apr 2022 09:57:00 +0200 Subject: [PATCH] Fixed a bug occuring if total_length/tile_size =0 --- tile_generator.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tile_generator.py b/tile_generator.py index 3f8fd4e..f81096f 100644 --- a/tile_generator.py +++ b/tile_generator.py @@ -165,10 +165,14 @@ def determine_tile_size(self, level): def get_relevant_tiles(self, tissue_mask, tile_size, min_coverage, level, show=False): - # TODO: Handling border cases using the residue rows, row_residue = divmod(tissue_mask.shape[0], tile_size) cols, col_residue = divmod(tissue_mask.shape[1], tile_size) + if row_residue: + rows += 1 + if col_residue: + cols += 1 + if self.config["use_tissue_detection"]: colored = cv2.cvtColor(tissue_mask, cv2.COLOR_GRAY2RGB) @@ -186,8 +190,8 @@ def get_relevant_tiles(self, tissue_mask, tile_size, min_coverage, level, show=F tile_nb = 0 # +1 to solve border issues - for row in range(rows+1): - for col in range(cols+1): + for row in range(rows): + for col in range(cols): tile = tissue_mask[row * tile_size:row * tile_size + tile_size, col * tile_size:col * tile_size + tile_size]