Skip to content

Commit

Permalink
Fixed a bug occuring if total_length/tile_size =0
Browse files Browse the repository at this point in the history
  • Loading branch information
marjohe committed Apr 8, 2022
1 parent 565530b commit 3eebb57
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tile_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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]
Expand Down

0 comments on commit 3eebb57

Please sign in to comment.