scistag.imagestag.bounding.Bounding2D

class Bounding2D(value=None, pos=None, lr=None, size=None)[source]

Bases: object

Defines the 2D-bounding of a visual element by it’s upper left and lower right corner.

Parameters
  • value (Bounding2DTypes | None) – The bounding value (or a bounding to copy) as defined by Bounding2DTypes.

  • pos (Pos2DTypes | None) – The explicit upper left coordinate

  • lr (Pos2DTypes | None) – The explicit lower right coordinate

  • size (Size2DTypes | None) – The size, relative to the upper left coordinate or lower right coordinate.

Methods

copy

Creates a copy of the bounding :rtype: Bounding2D :return: The copy

get_int_size_tuple

Returns the element's size as int tuple

get_size

Returns the element's size as Size2D object

get_size_tuple

Returns the element's size as float tuple

height

Returns the element's height

is_empty

Returns if the bounding is zero

to_coord_size_tuple

Returns the bounding as 1D coordinate, width, height tuple

to_coord_tuple

Returns the bounding as 1D coordinate tuple

to_int_coord_size_tuple

Returns the bounding as 1D coordinate, width, height tuple

to_int_coord_tuple

Returns the bounding as 1D coordinate tuple

to_nested_coord_size_tuple

Returns the bounding as 1D coordinate, width, height tuple

to_nested_coord_tuple

Returns the bounding as 1D coordinate tuple

width

Returns the element's width

Attributes

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__hash__

__module__

__weakref__

list of weak references to the object (if defined)

pos

The position of the upper left coordinate.

lr

The position of the lower right coordinate.

copy()[source]

Creates a copy of the bounding :rtype: Bounding2D :return: The copy

get_int_size_tuple()[source]

Returns the element’s size as int tuple

Return type

tuple[float, float]

Returns

The size in pixels

get_size()[source]

Returns the element’s size as Size2D object

Return type

Size2D

Returns

The size in pixels

get_size_tuple()[source]

Returns the element’s size as float tuple

Return type

tuple[float, float]

Returns

The size in pixels

height()[source]

Returns the element’s height

Return type

float

Returns

The height in pixels

is_empty()[source]

Returns if the bounding is zero

Return type

bool

Returns

True if width and height are zero

to_coord_size_tuple()[source]

Returns the bounding as 1D coordinate, width, height tuple

Returns

A tuple in the format x, y, width, height

to_coord_tuple()[source]

Returns the bounding as 1D coordinate tuple

Returns

A tuple in the format x, y, x2, y2

to_int_coord_size_tuple()[source]

Returns the bounding as 1D coordinate, width, height tuple

Returns

A tuple in the format x, y, width, height

to_int_coord_tuple()[source]

Returns the bounding as 1D coordinate tuple

Returns

A tuple in the format x, y, x2, y2

to_nested_coord_size_tuple()[source]

Returns the bounding as 1D coordinate, width, height tuple

Returns

A tuple in the format (x, y), (width, height)

to_nested_coord_tuple()[source]

Returns the bounding as 1D coordinate tuple

Returns

A tuple in the format (x, y), (x2, y2)

width()[source]

Returns the element’s width

Return type

float

Returns

The width in pixels

lr: Pos2D

The position of the lower right coordinate. x and y should always be equal or greater than x and y of pos.

pos: Pos2D

The position of the upper left coordinate. x and y should always be equal or smaller than x and y of lr