swtloc.abstractions.Letter

class swtloc.abstractions.Letter(label: int, image_height: int, image_width: int)[source]

Bases: swtloc.base.IndividualComponentBase

Letter class represents, a letter - an individual component which houses various properties of that individual letter.

Methods

Letter.__init__(label, image_height, image_width)

Create an Letter object which will house the components properties such as : - Minimum Bounding Box & its related properties - External Bounding Box & its related properties - Outline (Contour) - Original Image Properties - Stroke Width Properties :param label: A unique identifier for this Component :type label: int :param image_height: Height of the image in which this component resides :type image_height: int :param image_width: Width of the image in which this component resides :type image_width: int

Letter.addLocalization(image, localize_type, ...)

Add a specific localize_type of localization to the input image.

addLocalization(image: numpy.ndarray, localize_type: str, fill: bool, radius_multiplier: float = 1.0) numpy.ndarray

Add a specific localize_type of localization to the input image. fill parameter tells whether to fill the component or not.

Parameters
  • image (np.ndarray) – Image on which localization needs to be added

  • localize_type (str) –

    Type of the localization that will be added. Can be only one of [‘min_bbox’, ‘ext_bbox’, ‘outline’, ‘circular’]. Where :

    • min_bbox : Minimum Bounding Box

    • ext_bbox : External Bounding Box

    • outline : Contour

    • circular : Circle - With Minimum Bounding Box Centre coordinate and

    radius = Minimum Bounding Box Circum Radius * radius_multiplier

  • fill (bool) – Whether to fill the added localization or not

  • radius_multiplier (float) – Minimum Bounding Box Circum Radius inflation parameter. [default = 1.0].

Returns

(np.ndarray) - annotated image