- Python 90.3%
- Jupyter Notebook 9.2%
- Dockerfile 0.5%
| .vscode | ||
| test | ||
| .coveragerc | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| bbox.py | ||
| CHANGELOG.md | ||
| CODEOWNERS | ||
| colors.py | ||
| docker-compose.yaml | ||
| Dockerfile | ||
| filters.py | ||
| grid.py | ||
| image.py | ||
| LICENSE | ||
| line_height_labels.py | ||
| line_heights.py | ||
| lines.py | ||
| main.py | ||
| neighbor_labels.py | ||
| outliers.py | ||
| page_boundary_labels.py | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| renovate.json | ||
| test.ipynb | ||
| test_bbox.py | ||
| test_colors.py | ||
| test_filters.py | ||
| test_grid.py | ||
| test_image.py | ||
| test_line_height_labels.py | ||
| test_line_heights.py | ||
| test_lines.py | ||
| test_main_generate_labels.py | ||
| test_main_job_handler.py | ||
| test_neighbor_labels.py | ||
| test_outliers.py | ||
| test_page_boundary_labels.py | ||
| test_text_labels.py | ||
| test_utils.py | ||
| test_validations.py | ||
| text_labels.py | ||
| utils.py | ||
| validations.py | ||
Page Regions Image Processing
A Python worker that detects page regions through advanced image processing techniques. This worker analyzes raw page images to identify and classify different content regions within documents by processing grid intersections, analyzing text overlaps, and applying computer vision algorithms.
Features
- Advanced region detection using OpenCV and image processing
- Grid-based intersection analysis for precise region boundaries
- Text overlap detection with spatial indexing (STRtree)
- Color analysis and background detection
- Line height analysis and text classification
- Integration with RabbitMQ for message queuing
- MinIO support for object storage
- Docker deployment ready
Getting Started
Local Installation
-
Clone the repository:
git clone https://gitlab.com/logius/nldoc/worker/page-regions-image-processing.git cd page-regions-image-processing -
Install dependencies:
poetry install -
For macOS users, additional dependencies are required:
brew install conda export PATH="/opt/homebrew/anaconda3/bin:$PATH" brew install tesseract conda install -c conda-forge tesserocr
Running the Worker
Using Docker Compose (Recommended)
-
Ensure Docker and Docker Compose are installed (Installation Guide)
-
Start the services:
docker compose up -
Use the included Jupyter notebook
test.ipynbto perform end-to-end testing and visualization -
Access the management interfaces:
- RabbitMQ Console:
http://localhost:15672/ - MinIO Console:
http://localhost:9001/
- RabbitMQ Console:
-
Once the
docker compose upcommand has been exited using Ctrl+C, all containers relative to this instance will have shut down automatically.
Running Directly
To run the worker without Docker:
python3 main.py
For configuration options, refer to the Python base worker config.
Testing and Development
Use the included Jupyter notebook test.ipynb to visualize processing results on sample pages:
- Ensure all dependencies are installed (follow installation steps above)
- Launch Jupyter notebook
- Open
test.ipynband run the cells to process sample pages and visualize region detection
Run the test suite:
pytest
How It Works
The worker processes page images through several stages:
- Image Processing: Loads and preprocesses images using OpenCV
- Line Detection: Identifies structural lines in the document
- Grid Analysis: Creates intersection points from detected lines
- Region Formation: Groups intersections to form content regions
- Text Overlap Detection: Uses spatial indexing to find text within regions
- Classification: Applies various labeling algorithms to classify regions:
- Text analysis and content type detection
- Color analysis for backgrounds and text colors
- Line height analysis for typography classification
- Spatial relationship analysis between regions
- Page boundary detection
Deployment
Docker Images
Pre-built Docker images are available in our container registry.
Run the latest version:
docker run --rm registry.gitlab.com/logius/nldoc/worker/page-regions-image-processing:latest
Documentation
License
This project is licensed under the European Union Public License 1.2 - see LICENSE for details.