Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neurophant/enimda
Entropy-based image border detection
https://github.com/neurophant/enimda
Last synced: 3 days ago
JSON representation
Entropy-based image border detection
- Host: GitHub
- URL: https://github.com/neurophant/enimda
- Owner: neurophant
- License: mit
- Created: 2016-05-20T20:11:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-21T21:13:52.000Z (over 2 years ago)
- Last Synced: 2024-10-13T17:49:01.956Z (about 1 month ago)
- Language: Python
- Size: 92.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
ENIMDA
======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.|pypi| |travisci|
.. |pypi| image:: https://badge.fury.io/py/enimda.svg
:target: https://badge.fury.io/py/enimda
:alt: pypi version
.. |travisci| image:: https://travis-ci.org/embali/enimda.svg?branch=master
:target: https://travis-ci.org/embali/enimda
:alt: travis ci build statusAlgorithm (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.. image:: https://raw.githubusercontent.com/embali/enimda/master/algorithm.gif
:alt: Sliding from center to edge - searching for maximum entropy difference
:width: 300
:height: 300Requirements
------------Python 3.5+
Setup
-----.. code-block:: bash
python-3.6 -m venv .env
source .env/bin/activate
pip install enimdaUsage
-----Find if image has borders:
.. code-block:: python
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'
instrumentTests
-----Run tests: py.test