Skip to main content

A tool for extracting a text line image from the contour with different methods

Project description

Line image extractor

This is a tool and a library to be used for extracting line images. Built by Teklia and freely available as open-source under the MIT licence.

It supports different extraction methods:

  • boundingRect - bounding rectangle of the line polygon
  • polygon - exact polygon
  • min_area_rect - minimum area rectangle containing the polygon
  • deskew_polygon - deskew the polygon
  • deskew_min_area_rect - deskew the minimum area rectangle
  • skew_polygon - skew the polygon (rotate by some angle)
  • skew_min_area_rect - skew the minimum area rectangle (rotate by some angle)

Install the library using stable version from Pypi:

pip install teklia-line-image-extractor

Install the library in development mode:

pip install -e .

Test extraction:

line-image-extractor -i tests/data/page_img.jpg -o out.jpg -p tests/data/line_polygon.json -e deskew_min_area_rect --color

How to use it?:

from pathlib import Path
import numpy as np
from line_image_extractor.extractor import extract, read_img, save_img
from line_image_extractor.image_utils import polygon_to_bbox
from line_image_extractor.image_utils import Extraction

page_img = read_img(Path("tests/data/page_img.jpg"))
polygon = np.asarray([[241, 1169], [2287, 1251], [2252, 1190], [244, 1091], [241, 1169]])
bbox = polygon_to_bbox(polygon)
extracted_img = extract(
    page_img, polygon, bbox, Extraction.polygon
)
save_img("line_output.jpg", extracted_img)

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

teklia_line_image_extractor-0.6.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

teklia_line_image_extractor-0.6.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file teklia_line_image_extractor-0.6.0.tar.gz.

File metadata

File hashes

Hashes for teklia_line_image_extractor-0.6.0.tar.gz
Algorithm Hash digest
SHA256 30972322ef4fe3fbb15380ddc54ad0ce199224e501edd05a843d8f57e8d3434a
MD5 d175f297a21b923f72c2c2e6bf84229f
BLAKE2b-256 18e1556144d568b44e41599794687741264f2465e23decfede00de8a6aed6e14

See more details on using hashes here.

File details

Details for the file teklia_line_image_extractor-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for teklia_line_image_extractor-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16a76ba3878f545311260a60b3168f6e2cc7daeda9ea9fec44c8fbea6e6d9c38
MD5 096e31e2f89441acd73152cd6df23fac
BLAKE2b-256 74aa03cb9c5b29f013e6a6efab8618ac74f2d32122c776f5432d103b0faa319a

See more details on using hashes here.

Supported by

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