Skip to content

Commit

Permalink
Merge pull request #116 from daviddemeij/masking
Browse files Browse the repository at this point in the history
Avoid computing masked tiles
  • Loading branch information
gfacciol authored Mar 17, 2022
2 parents a1daee5 + 83acc2e commit ca589ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions s2p/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ def is_this_tile_useful(x, y, w, h, images_sizes):
wat_msk = cfg['images'][0]['wat']
mask = masking.image_tile_mask(x, y, w, h, roi_msk, cld_msk, wat_msk,
images_sizes[0], cfg['border_margin'])
if not mask.any():
return False, None
return True, mask


Expand Down
2 changes: 2 additions & 0 deletions s2p/masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def image_tile_mask(x, y, w, h, roi_gml=None, cld_gml=None, raster_mask=None,
with rasterio.open(raster_mask, 'r') as f:
mask = np.logical_and(mask, f.read(window=((y, y+h), (x, x+w)),
boundless=True).squeeze())
if not mask.any():
return mask

# image borders mask
if img_shape is not None:
Expand Down

0 comments on commit ca589ef

Please sign in to comment.