Utilities

Utility functions and classes used by custom transforms.

source

round_up_to_multiple

 round_up_to_multiple (val, divisor=32)

Round val up to the nearest multiple of divisor.


source

find_largest_rectangle_coords

 find_largest_rectangle_coords (binary_mask:numpy.ndarray)

*Use a row-by-row ‘largest rectangle in histogram’ approach to find the largest rectangle of True cells in a 2D binary numpy array.

Returns: (row_slice, col_slice) indicating the largest rectangle found.*


source

largest_rectangle_in_histogram

 largest_rectangle_in_histogram (row_heights:numpy.ndarray)

*Given a 1D array ‘row_heights’, returns the area of the largest rectangle in this histogram plus the (top, bottom, left, right) indices.

Note: In this context, ‘top’ and ‘bottom’ are placeholders, because the actual vertical extent is determined later using the 2D ‘heights’ array.*