@@ -281,8 +281,6 @@ def __init__(
281
281
id ,
282
282
x ,
283
283
y ,
284
- base_width ,
285
- base_height ,
286
284
tissue_id ,
287
285
image ,
288
286
annot_mask = None ,
@@ -292,22 +290,26 @@ def __init__(
292
290
self .id = id
293
291
self .x = x
294
292
self .y = y
295
- self .base_width = base_width
296
- self .base_height = base_height
297
293
self .tissue_id = tissue_id
298
294
self .image = image
299
295
self .annot_mask = annot_mask
300
296
self .annot_shapes = annot_shapes
301
297
self .annot_labels = annot_labels
302
298
299
+ @property
300
+ def width (self ):
301
+ return self .image .shape [1 ]
302
+
303
+ @property
304
+ def height (self ):
305
+ return self .image .shape [0 ]
306
+
303
307
@cached_property
304
308
def norm_annot_shapes (self ):
305
309
if self .annot_shapes is not None :
306
310
new_shapes = []
307
311
for shape , name , label in self .annot_shapes :
308
- norm_shape = _normalize_polygon (
309
- shape , (0 , 0 , self .base_width , self .base_height )
310
- )
312
+ norm_shape = _normalize_polygon (shape , (0 , 0 , self .width , self .height ))
311
313
new_shapes .append ((norm_shape , name , self .annot_labels [name ]))
312
314
return new_shapes
313
315
@@ -662,7 +664,7 @@ def tile_images(
662
664
if create_annot_mask :
663
665
annot_shapes = []
664
666
sel = annot_tb .geometry .intersects (tile_bbox ) # return a boolean mask
665
- anno_mask = np .zeros (mask_size , dtype = mask_dtype )
667
+ annot_mask = np .zeros (mask_size , dtype = mask_dtype )
666
668
if sel .sum () > 0 :
667
669
sel = sel .values
668
670
geos = annot_tb .geometry [sel ]
@@ -681,8 +683,8 @@ def tile_images(
681
683
holes = [
682
684
np .array (h .coords , dtype = np .int32 ) for h in geo .interiors
683
685
]
684
- cv2 .fillPoly (anno_mask , [cnt ], int (label )) # noqa
685
- cv2 .fillPoly (anno_mask , holes , 0 ) # noqa
686
+ cv2 .fillPoly (annot_mask , [cnt ], int (label )) # noqa
687
+ cv2 .fillPoly (annot_mask , holes , 0 ) # noqa
686
688
# Clip the annotation by the tile
687
689
# May not be valid after clipping
688
690
output_geo = clip_by_rect (geo , 0 , 0 , * mask_size )
@@ -699,8 +701,6 @@ def tile_images(
699
701
id = ix ,
700
702
x = x ,
701
703
y = y ,
702
- base_width = tile_spec .base_width ,
703
- base_height = tile_spec .base_height ,
704
704
tissue_id = tix ,
705
705
image = img ,
706
706
annot_mask = annot_mask ,
0 commit comments