GTRefiner.GTRepresentation package

Subpackages

Submodules

GTRefiner.GTRepresentation.GroundTruth module

class GTRefiner.GTRepresentation.GroundTruth.GroundTruth(img_dim: ImageDimension)

Bases: Scalable, Showable, Croppable

GroundTruth is an abstract class that provides the provides the common interface for ground-truth classes.

crop(current_dim: ImageDimension, target_dim: ImageDimension, cut_left: bool)

Crop all ground truth information of this ground truth to a target dimension. Due to the nature of the ground truth document. :param cut_left: must be provided. :param current_dim: Current dimension :type current_dim: ImageDimension :param target_dim: Target dimension :type target_dim: ImageDimension :param cut_left: Whether or not the page is cut_left or not. :type cut_left: bool

get_dim()

Get the ground truth’s dimension. :return: dimension of the ground truth. :rtype: ImageDimension

abstract resize(current_dim: ImageDimension, target_dim: ImageDimension)

Resizes all ground-truth information of the current :class: LayoutClass to a given target dimension. :param current_dim: Current dimension :type current_dim: ImageDimension :param target_dim: Target dimension :type target_dim: ImageDimension

abstract show()

Illustrate the ground truth.

GTRefiner.GTRepresentation.ImageDimension module

class GTRefiner.GTRepresentation.ImageDimension.ImageDimension(width: 'int' = 0, height: 'int' = 0)

Bases: object

difference(other: ImageDimension) Tuple[float, float]

Method used solely for cropping. Calculates the difference for which a vector object has to be moved given another target dimension. :param other: other dimension :type other: ImageDimension :return: the difference in x,y as float tuple. :rtype: tuple

height: int = 0
scale_factor(other: ImageDimension)

Helper method for resizing. Gives the scale factor for which a given ground truth object should be resized. :param other: target dimension. :type other: ImageDimension :return: list of width scale factor and height scale factor :rtype:

to_tuple()

Get the dimension as a tuple :return: Width and height :rtype: tuple

width: int = 0

GTRefiner.GTRepresentation.LayoutClasses module

class GTRefiner.GTRepresentation.LayoutClasses.LayoutClasses(value)

Bases: Enum

Represents the different levels of the pixel level ground truth. Essential to the program. Must changed if further classes should to be added.

ASCENDER = 16
BACKGROUND = 1
BASELINE = 22
COMMENT = 2
COMMENT_AND_DECORATION = 6
COMMENT_AND_MAINTEXT = 10
DECORATION = 4
DESCENDER = 20
HEAD = 26
MAINTEXT = 8
MAINTEXT_AND_DECORATION = 12
MAINTEXT_AND_DECORATION_AND_COMMENT = 14
TAIL = 28
TEXT_REGION = 255
TOPLINE = 24
XREGION = 18
classmethod get_layout_classes_containing(layout_class: LayoutClasses)

Get all layout classes containing another one (based on the string). :param layout_class: target layout class :type layout_class: LayoutClasses :return: list of layout classes containing the target layou class as a substring. :rtype: list[LayoutClasses]

get_name() str

Return the name of a enum instance. E.g. MAINTEXT :return: Return the name :rtype: str

classmethod str_to_enum(enum_name: str) LayoutClasses

Return the matching enum based on a string. :param enum_name: :type enum_name: :return: :rtype:

GTRefiner.GTRepresentation.Page module

class GTRefiner.GTRepresentation.Page.Page(vector_gt: VectorGT, px_gt: PixelLevelGT, raw_img: RawImage, vis_table: VisibilityTable, col_table: ColorTable)

Bases: Scalable, Croppable, Showable

Stores all ground truth information of an image (including the original image, the vector gt and the pixel-based ground truth) and provides basic functionality for its manipulation such as scalability, croppability and showability. :param vector_gt: Stores polyogons of the various text elements (maintextline, decoration, textregion, etc.) :type vector_gt: VectorGT :param px_gt: Stores the original pixel level ground truth and its different information levels as :class: Layers. :type px_gt: PixelLevelGT :param raw_img: Stores the original image. :type raw_img: RawImage :param vis_table: Defines the visibility for the ground truth objects (texelements of the vector gt, levels of the pixel gt) :type vis_table: VisibilityTable :param col_table: Defines the colors for the ground truth objects (texelements of the vector gt, levels of the pixel gt) :type col_table: ColorTable

get_img_dim()

Get the ground truth’s dimension. :return: dimension of the ground truth. :rtype: ImageDimension

visit_page(visitor)

Accepts visitors to manipulate the page and add further functionalities. :param visitor: manipulates the page (or invokes it’s methods) to add specific behaviour :type visitor: Visitor

GTRefiner.GTRepresentation.Table module

class GTRefiner.GTRepresentation.Table.ColorTable(table: Dict[LayoutClasses, List[Tuple]])

Bases: Table

Defines the colors for the ground truth objects (texelements of the vector gt, levels of the pixel gt). If you want to implement iterating or all different colors you need to provide a list of colors for the target LayoutClass. Compare with the color tables in the Ressources/ColorTables/ directory. :param table: Color table :type table: Dict[LayoutClasses, List[Tuple]

class GTRefiner.GTRepresentation.Table.Table(table: Dict[LayoutClasses, Any])

Bases: object

Provides the base class for layout class :class: LayoutClasses based dictionaries. Can be dumped to JSON file. :param table: Dictionary of layout classes :type table: Dict[LayoutClasses, Any]

to_json(file_path: Path = PosixPath('../../Resources/some_table.json'))

Dumps the the table to json file with a given file path. :param file_path: Output file path :type file_path: Path

class GTRefiner.GTRepresentation.Table.VisibilityTable(table: Dict[LayoutClasses, bool])

Bases: Table

Defines the visibility for the ground truth objects (texelements of the vector gt, levels of the pixel gt). :param table: Visibility table :type table: Dict[LayoutClasses, bool]

Module contents