MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / tile_is_not_empty

Function tile_is_not_empty

extract_features.py:424–440  ·  view source on GitHub ↗
(tile, threshold_white=20)

Source from the content-addressed store, hash-verified

422 return filtered_tiles
423
424def tile_is_not_empty(tile, threshold_white=20):
425 histogram = tile.histogram()
426
427 # Take the median of each RGB channel. Alpha channel is not of interest.
428 # If roughly each chanel median is below a threshold, i.e close to 0 till color value around 250 (white reference) then tile mostly white.
429 whiteness_check = [0, 0, 0]
430 for channel_id in (0, 1, 2):
431 whiteness_check[channel_id] = np.median(
432 histogram[256 * channel_id : 256 * (channel_id + 1)][100:200]
433 )
434
435 if all(c <= threshold_white for c in whiteness_check):
436 # exclude tile
437 return False
438
439 # keep tile
440 return True
441
442def crop_rect_from_slide(slide, rect):
443 minx, miny, maxx, maxy = rect.bounds

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected