Entropy-based image border detection algorithm: finds out if your image has borders or whitespaces around and helps you to trim border providing whitespace offsets for every side of a picture, supports animated GIFs.
Algorithm (simplified)
For each side of the image starting from top, rotating image counterclockwise to keep side of interest on top:
Get upper block 25% of image height
Get lower block with the same height as the upper one
Calculate entropy for both blocks and their difference
Make upper block 1px less
Repeat from p.2 until we hit image edge
Border is between blocks with entropy difference maximum
Requirements
Python 3.5+
Setup
python-3.6 -m venv .env
source .env/bin/activate
pip install enimda
Usage
Find if image has borders:
from enimda import ENIMDA
# Load target image
em = ENIMDA(fp='test.jpg')
# Scan for borders with high precision
borders = em.scan(fast=False)
# Print found image borders (tuple): top, right, bottom, left
print(borders)
Demo
For demo please refer to ENIMDA Demo
Also it lives at Picture Instruments as ‘Remove borders’ instrument
Tests
Run tests: py.test
Metadata
Release files for enimda 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| enimda-2.1.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| enimda-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / enimda-2.1.0.tar.gz
| Download URL | enimda-2.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
597b4c8267df47b925b76c28c0435ebb3095ea8f80a03231f651d8fff367902a
|
|
BLAKE2b-256 checksum How to use checksums |
0aff41707bef9f0f20f135dd6ff4ca281eab6820b0284ff1b12d009ed746d5e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / enimda-2.1.0-py3-none-any.whl
| Download URL | enimda-2.1.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f554111ad38f416d1697fb8cbb6fb3764512dab38f4d6d949b7670d7c0a158b
|
|
BLAKE2b-256 checksum How to use checksums |
17425673f9d93d8dc3215798d9ea6ec5eb745a3b7f52965d7675bf2d41bd2916
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |