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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for teklia-line-image-extractor-0.2.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a78b5d350bcef87448fb647959f1573914083e214cc6816a67908706bd712245 |
|
MD5 | d863b67bdc6e57aea70f56ade5545393 |
|
BLAKE2b-256 | 7f906a5e1dc45add8825182a44250c17b3e7fb56b640ba4b158dc56c4054b215 |
Close
Hashes for teklia_line_image_extractor-0.2.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6c0605e7939d6d7d433373fb5372ecbb0573cd6e42dce81c93cf5fed9c9c0d2 |
|
MD5 | 00df0c8c95b690a6a4086734d37fd876 |
|
BLAKE2b-256 | 98da4e0fc3f5768aea722a8a23c7eea3bd3e49b31c926c26aee5824f29ccd420 |