otx.api.entities.image#

This module implements the Image entity.

Classes

Image([data, file_path, size])

Represents a 2D image.

class otx.api.entities.image.Image(data: ndarray | Callable[[], ndarray] | None = None, file_path: str | None = None, size: Tuple[int, int] | Callable[[], Tuple[int, int]] | None = None)[source]#

Bases: IMedia2DEntity

Represents a 2D image.

The image must be instantiated with either a NumPy array containing the image data or a path to an image file.

Parameters:
  • data (Optional[np.ndarray]) – NumPy data.

  • file_path (Optional[str]) – Path to image file.

roi_numpy(roi: Annotation | None = None) ndarray[source]#

Obtains the numpy representation of the image for a selection region of interest (roi).

Parameters:

roi (Optional[Annotaiton]) – The region of interest can be Rectangle in the relative coordinate system of the full-annotation.

Returns:

Selected region as numpy array.

Return type:

np.ndarray

property height: int#

Returns the height of the image.

property numpy: ndarray#

Numpy representation of the image.

For color images the dimensions are (height, width, color) with RGB color channel order.

Returns:

NumPy representation of the image.

Return type:

np.ndarray

property path: str | None#

Returns the file path of the image.

property width: int#

Returns the width of the image.