largest_interior_rectangle#

rlemasklib.RLEMask.largest_interior_rectangle(aspect_ratio=None)[source][C source]#

The largest axis-aligned rectangle that fits entirely inside the foreground.

Parameters:

aspect_ratio (Optional[float]) – the desired aspect ratio of the rectangle (width/height)

Returns:

An array (x, y, width, height) of the top-left corner and dimensions of the rectangle.

Examples

Find the largest rectangle inside an L-shape (red outline shows result):

.largest_interior_rectangle() ==

See also

largest_interior_rectangle_around() for a rectangle around a given center point.