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.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e42729b4df5a1eafce8624579edd29b57a98596d9710dde0954407ddbc22e8f |
|
MD5 | 398c5a90d7b50abcedd7fd7006adb3e3 |
|
BLAKE2b-256 | 93cc03066293519140d4e7500ed92c48a4b2e25d0ff5ff08069377f40e6eb91a |
Close
Hashes for teklia_line_image_extractor-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ead5c5de6d525645a6c0afd98084e46cd0d010bf49e1658b63b2f9809ccec407 |
|
MD5 | 8c2de20de0e18461077d90d24d1de7f4 |
|
BLAKE2b-256 | 0eddadbb17c850102ec20d7444f6a60366de7ed49bfdcf067c11beb84a0a96d8 |