GTRefiner.Builder package¶
Submodules¶
GTRefiner.Builder.Builder module¶
- class GTRefiner.Builder.Builder.GTBuilder¶
Bases:
object
The builder provides an interface for manipulating an instance of :class: Page class. It serves to construct the ground truth and is based on the builder design pattern. It improves code readability, complexity, and thus safety by replacing large constructors with many, different, optional input parameters with an auxiliary class. The auxiliary class is called Director and serves the methods provided by the builder in the desired order. If a new ground truth is to be built, developers:inside can write their own directors. Methods of the Builder can be called iteratively and are therefore superior to large constructors from this perspective as well. For example, if page objects of the vector GT are to be regrouped first and then sorted, this can be instructed in a few lines of code thanks to the builder pattern, see ClientExamples: RegionIllustratorDirector.py.
- abstract crop(cropper: Cropper)¶
Visit the Page with the :class: Cropper given. :param cropper: crop the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the cropper’s implementation. :type cropper: Cropper
- abstract decorate(decorator: TextLineDecorator)¶
Visit the Page with the :class: TextLineDecorator given. :param resizer: decorate the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the decorator’s :class: TextLineDecorator implementation. :type resizer: TextLineDecorator
- abstract get_GT() Page ¶
Get the new ground truth :return: Return the modified page :class: Page :rtype: Page
- abstract group(grouper: Grouper)¶
Visit the Page with the :class: Grouper given. :param grouper: group the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the grouper’s :class: Grouper implementation. :type grouper: Grouper
- abstract illustrate(illustrator: Illustrator)¶
Visit the Page with the :class: Illustrator given. :param illustrator: illustrate the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the illustrator’s :class: Illustrator implementation. :type illustrator: Illustrator
- abstract layer(layerer: Layerer)¶
Visit the Page with the :class: Layerer given. :param layerer: combines the two ground-truths vector-gt :class: VectorGT and pixel-level-gt
PixelLevelGT
and stores the newly generated pixel-based ground-truth based on the Layerer’s implementation in the pagePage
. :type layerer: Layerer
- abstract read(vector_gt_path: Path, px_gt_path: Path, orig_img: Path, vis_table: Path, col_table: Path)¶
Constructor Method :param vector_gt_path: path to the vector ground truth :type vector_gt_path: Path :param px_gt_path: path to the pixel-level ground truth :type px_gt_path: Path :param orig_img: path to the original image ground truth :type orig_img: Path :param vis_table: path to the visibility table to be applied to the ground truth :class: Page :type vis_table: VisibilityTable :param col_table: path to the color table to be applied to the ground truth :class: Page :type col_table: ColorTable
- resize(resizer: Resizer)¶
Visit the Page with the :class: Resizer given. :param resizer: resize the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the resizer’s :class: Resizer implementation. :type resizer: Resizer
- abstract set_color(colorer: ~GTRefiner.BuildingTools.Visitors.Colorer.Colorer = <GTRefiner.BuildingTools.Visitors.Colorer.Colorer object>)¶
Set the color of both the vector_gt objects and the vector_gt.
- abstract set_visible()¶
- abstract sort(sorter: Sorter)¶
Visit the Page with the :class: Sorter given. :param grouper: sort the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the sorter’s :class: Sorter implementation. :type grouper: Sorter
- abstract write(output_path: Path)¶
Visit the Page with the :class: Writer given. :param output_path: writes the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT to the :class: Path out_put_path to the format :class: Writer. :type output_path: Path
GTRefiner.Builder.Builder_v1 module¶
- class GTRefiner.Builder.Builder_v1.BuilderV1(vector_gt_path: Path, px_gt_path: Path, orig_img: Path, vis_table: Path, col_table: Path)¶
Bases:
GTBuilder
This class provides an example for concrete :class: Builder.
- crop(cropper: Cropper)¶
Visit the Page with the :class: Cropper given. :param cropper: crop the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the cropper’s implementation. :type cropper: Cropper
- decorate(decorator: TextLineDecorator)¶
Visit the Page with the :class: TextLineDecorator given. :param resizer: decorate the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the decorator’s :class: TextLineDecorator implementation. :type resizer: TextLineDecorator
- get_GT() Page ¶
Get the new ground truth :return: Return the modified page :class: Page :rtype: Page
- group(grouper: Grouper)¶
Visit the Page with the :class: Grouper given. :param grouper: group the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the grouper’s :class: Grouper implementation. :type grouper: Grouper
- illustrate(illustrator: Illustrator)¶
Visit the Page with the :class: Illustrator given. :param illustrator: illustrate the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the illustrator’s :class: Illustrator implementation. :type illustrator: Illustrator
- layer(layerer: Layerer)¶
Visit the Page with the :class: Layerer given. :param layerer: combines the two ground-truths vector-gt :class: VectorGT and pixel-level-gt
PixelLevelGT
and stores the newly generated pixel-based ground-truth based on the Layerer’s implementation in the pagePage
. :type layerer: Layerer
- read(vector_gt_path: Path, px_gt_path: Path, orig_img: Path, vis_table: Path, col_table: Path) Page ¶
Initialization method. Take all input paths :class: Path and returns a :class: Page :param vector_gt_path: path to the vector ground truth :type vector_gt_path: Path :param px_gt_path: path to the pixel-level ground truth :type px_gt_path: Path :param orig_img: path to the original image ground truth :type orig_img: Path :param vis_table: path to the visibility table to be applied to the ground truth :class: Page :type vis_table: VisibilityTable :param col_table: path to the color table to be applied to the ground truth :class: Page :type col_table: ColorTable :return: Returns a page :class: Page based on the paths :class: Path. :rtype: Page
- resize(resizer: Resizer)¶
Visit the Page with the :class: Resizer given. :param resizer: resize the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the resizer’s :class: Resizer implementation. :type resizer: Resizer
- set_color(colorer: ~GTRefiner.BuildingTools.Visitors.Colorer.Colorer = <GTRefiner.BuildingTools.Visitors.Colorer.Colorer object>)¶
Set the color of both the vector_gt objects and the vector_gt.
- set_visible(visibilitor: ~GTRefiner.BuildingTools.Visitors.VisibilityVisitor.VisibilityVisitor = <GTRefiner.BuildingTools.Visitors.VisibilityVisitor.VisibilityVisitor object>)¶
- sort(sorter: Sorter)¶
Visit the Page with the :class: Sorter given. :param grouper: sort the pages image :class: Image, vector-gt :class: VectorGT and pixel-level-gt :class: PixelLevelGT according to the sorter’s :class: Sorter implementation. :type grouper: Sorter
- write(output_path)¶
Write :class: Page Page as JSON and GIF. :param output_path: :type output_path: :return: :rtype:
GTRefiner.Builder.Director module¶
- class GTRefiner.Builder.Director.Factory(builder: <module 'GTRefiner.Builder.Builder' from '/Users/loverboy99/PycharmProjects/BachelorThesis/HisDB_GT_Refinement/GTRefiner/Builder/Builder.py'>, color_table: ~GTRefiner.GTRepresentation.Table.ColorTable, vis_table: ~GTRefiner.GTRepresentation.Table.VisibilityTable, root_directory: ~pathlib.Path)¶
Bases:
Director
Calls the given Builder on all the GT_files in the root directory.
- class GTRefiner.Builder.Director.Prototyper(builder: <module 'GTRefiner.Builder.Builder' from '/Users/loverboy99/PycharmProjects/BachelorThesis/HisDB_GT_Refinement/GTRefiner/Builder/Builder.py'>, color_table: ~GTRefiner.GTRepresentation.Table.ColorTable, vis_table: ~GTRefiner.GTRepresentation.Table.VisibilityTable, vector_gt: ~pathlib.Path, px_gt: ~pathlib.Path, ori_img: ~pathlib.Path)¶
Bases:
Director
Creates prototypes of the given ColorTable, VisibilityTable, Paths, and Builder and shows it. Once pleased, the client can should use the factory :class: Factory class.