@@ -286,7 +286,11 @@ def get_mask_center(mask_array: np.array) -> Tuple[int, int]:
286
286
return None , None
287
287
288
288
289
- def get_seeds (image_array : np .array , mask_array : np .array ) -> List [Tuple [int , int ]]:
289
+ def get_seeds (
290
+ image_array : np .array ,
291
+ mask_array : np .array ,
292
+ exclusion_mask : np .array ,
293
+ ) -> List [Tuple [int , int ]]:
290
294
"""
291
295
This function takes an array that represents an image and a mask.
292
296
It returns a list of tuples with indices of seeds in the structure
@@ -295,6 +299,7 @@ def get_seeds(image_array: np.array, mask_array: np.array) -> List[Tuple[int, in
295
299
Args:
296
300
image_array (np.array): Image
297
301
mask_array (np.array): Mask
302
+ exclusion_mask (np.array): Exclusion mask
298
303
299
304
Returns:
300
305
List[Tuple[int, int]]: [(x,y), (x,y), ...]
@@ -312,32 +317,36 @@ def get_seeds(image_array: np.array, mask_array: np.array) -> List[Tuple[int, in
312
317
if not mask_array [y_center , x_center + n ]:
313
318
up = False
314
319
if not image_array [y_center , x_center + n ]:
315
- seed_pixels .append ((x_center + n , y_center ))
316
- up = False
320
+ if not exclusion_mask [y_center , x_center + n ]:
321
+ seed_pixels .append ((x_center + n , y_center ))
322
+ up = False
317
323
# Check for seeds below center
318
324
if down :
319
325
if x_center - n >= 0 :
320
326
if not mask_array [y_center , x_center - n ]:
321
327
down = False
322
328
if not image_array [y_center , x_center - n ]:
323
- seed_pixels .append ((x_center - n , y_center ))
324
- down = False
329
+ if not exclusion_mask [y_center , x_center - n ]:
330
+ seed_pixels .append ((x_center - n , y_center ))
331
+ down = False
325
332
# Check for seeds left from center
326
333
if left :
327
334
if y_center + n < image_array .shape [0 ]:
328
335
if not mask_array [y_center + n , x_center ]:
329
336
left = False
330
337
if not image_array [y_center + n , x_center ]:
331
- seed_pixels .append ((x_center , y_center + n ))
332
- left = False
338
+ if not exclusion_mask [y_center + n , x_center ]:
339
+ seed_pixels .append ((x_center , y_center + n ))
340
+ left = False
333
341
# Check for seeds right from center
334
342
if right :
335
343
if y_center - n >= 0 :
336
344
if not mask_array [y_center - n , x_center ]:
337
345
right = False
338
346
if not image_array [y_center - n , x_center ]:
339
- seed_pixels .append ((x_center , y_center - n ))
340
- right = False
347
+ if not exclusion_mask [y_center - n , x_center ]:
348
+ seed_pixels .append ((x_center , y_center - n ))
349
+ right = False
341
350
return seed_pixels
342
351
343
352
@@ -450,7 +459,9 @@ def expansion_coordination(
450
459
the mask expansion. It returns the expanded mask. The purpose of this function is
451
460
wrapping up the expansion procedure in a map function.
452
461
"""
453
- seed_pixels = get_seeds (image_array , mask_array )
462
+ seed_pixels = get_seeds (image_array ,
463
+ mask_array ,
464
+ exclusion_mask )
454
465
if seed_pixels != []:
455
466
mask_array = expand_masks (image_array , seed_pixels , mask_array , exclusion_mask )
456
467
else :
@@ -498,7 +509,7 @@ def complete_structure_mask(
498
509
499
510
if mask_array .size != 0 :
500
511
# Binarization of input image
501
- binarized_image_array = binarize_image (image_array , threshold = 0.85 )
512
+ binarized_image_array = binarize_image (image_array , threshold = 0.72 )
502
513
# Apply dilation with a resolution-dependent kernel to the image
503
514
blur_factor = (
504
515
int (image_array .shape [1 ] / 185 ) if image_array .shape [1 ] / 185 >= 2 else 2
0 commit comments