Skip to main content

Layout Segmentation Simplifier

Project description

LSS (Layout Segmentation Simplifier)

Install

pip install https://github.com/PonteIneptique/lss/archive/refs/heads/main.zip

or

pip install layouts-segmentation-simplifier

Use

Generic use

from lss.parsers import PageXML

file = PageXML.from_file(
    # Path to your file
    "data/0002_Main_frame.xml",
    # Optional: set-up the namespace, as they tend to change a lot
    namespace="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" 
)
# Simplify your baseline: things within 10% of your line height will be discarded (Seems to be a good number)
file.simplify_lines(ratio=.10)
# Simplify your baseline: things within 15% of your mask height will be discarded (Seems to be a good number)
file.simplify_masks(ratio=.15)
# You can retrieve the xml in file.xml or dump the modified xml in file.xml
file.dump(filepath="file.xml")

Qualitatively search for best parameters

You can also get it to make multiple simulation, to chose the best value (highest ratio = bigger simplification)

from lss.parsers import PageXML

page = PageXML.from_file("./data/0002_Main_frame.xml")
page.find_namespace() # Useful in case you use PageXML as it scans for the right namespace
page.test_values(
    [(.05, .05), (.1, .1), (.15, .15), (.20, .20)],
    image="./data/0002_Main_frame.jpg",
    basename_output="./data/0002_Main_frame"
)

In this context, lines will be simplified by a ratio of 0.05, 0.10, 0.15 and 0.20. Mask will be as well. Few files will be saved. Each test will create test files with overlays (cf. folder data for all examples):

Original 15% ratio on both line and masks
Original Mask Original Mask
10% 20%
Original Mask Original Mask

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

layouts-segmentation-simplifier-0.0.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

layouts_segmentation_simplifier-0.0.2-py2.py3-none-any.whl (8.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file layouts-segmentation-simplifier-0.0.2.tar.gz.

File metadata

  • Download URL: layouts-segmentation-simplifier-0.0.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

File hashes

Hashes for layouts-segmentation-simplifier-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4585ff38257f76922f89b3b82caccbe7bfaa3c46d65c41629c2785a1f6a8fe51
MD5 9365f76ac52bce2c79faa074b54fbb7a
BLAKE2b-256 869dc9009bbf859aa6d5de8b31ba4fca2e762d6a5c47a740049eb219921c6fac

See more details on using hashes here.

File details

Details for the file layouts_segmentation_simplifier-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: layouts_segmentation_simplifier-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

File hashes

Hashes for layouts_segmentation_simplifier-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8490937c39d38e68651cce613d504d4c1a6f1514893c23c2b22e73fc4856254c
MD5 1d1a41e7421664f4a50aaef0736977cc
BLAKE2b-256 4a51319ca8322b06e3484304a7873f837258c6fa543848778fa1297b877beb58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page