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.8rc4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 074c2c463f2813e12f86cbbdfb832caa7938cfc947852ea4e6f53023b2fed554 |
|
MD5 | 64f64786933d2ec6e810ef71c79cd3d0 |
|
BLAKE2b-256 | e8cb52abee2fbb1bc487882eeb295c52f76102e42697513ab317d90740abd9c2 |
Close
Hashes for teklia_line_image_extractor-0.2.8rc4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59ee3d1148e52df3a3adc4f40668936a502be96bdbf383d948d66b7778facffb |
|
MD5 | 27642391634fd9b1bf54fa2f05dac0c9 |
|
BLAKE2b-256 | 30d6e8f3bee2d52f740141fb15b7cda2924825813f8dec007fe194e56b6ef8f0 |