Shape Operations

[BETA: the API and behavior will be changed in the future.]

Starting from v0.2, Layout Parser provides supports for two types of shape operations, union and intersection, across all BaseCoordElements and TextBlock. We’ve made some design choices to construct a set of generalized APIs across different shape classes, detailed as follows:

The union Operation

Illustration of Union Operations ▲ The Illustration of Union Operations. The resulting matrix are symmetric so only the lower triangular region is left empty. Each cell shows the visualization of the shape objects, their coordinates, and their object class. For the output visualization, the gray and dashed line delineates the original obj1 and obj2, respectively, for reference.

Notes:

  1. The x-interval and y-interval are both from the Interval Class but with different axes. It’s ill-defined to union two intervals from different axes so in this case Layout Parser will raise an InvalidShapeError.

  2. The union of two rectangles is still a rectangle, which is the minimum covering rectangle of the two input rectangles.

  3. For the outputs associated with Quadrilateral inputs, please see details in the Problems related to the Quadrilateral Class section.

The intersect Operation

Illustration of Intersection Operations ▲ The Illustration of Union Operations. Similar to the previous visualization, the resulting matrix are symmetric so only the lower triangular region is left empty. Each cell shows the visualization of the shape objects, their coordinates, and their object class. For the output visualization, the gray and dashed line delineates the original obj1 and obj2, respectively, for reference.