largest_interior_rectangle_around#

rlemasklib.RLEMask.largest_interior_rectangle_around(center_point, aspect_ratio=None)[source]#

The largest axis-aligned foreground rectangle with a given center point.

Without aspect_ratio, the rectangle will have odd height and odd width and have the pixel at position center_point as its central pixel. When aspect_ratio is given, the rectangle may have non-integer dimensions.

If the output is r, the following will hold:

  • center_point[0] == r[0] + (r[2]-1) / 2

  • center_point[1] == r[1] + (r[3]-1) / 2

  • r[2] / r[3] == aspect_ratio

  • the region defined by r is entirely inside the foreground

Parameters:
  • center_point (Sequence[int]) – the (x,y) center pixel coordinates of the rectangle

  • 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.

See also

largest_interior_rectangle() for the largest rectangle without specifying the center point.