Python Imaging Library (Fork)
Go to file
Alexander Böhn 7b815a5f1d Added an image.entropy() method
This calculates the entropy for the image, based on the histogram.

Because this uses image histogram data directly, the existing C
function underpinning the `image.histogram()` method was abstracted
into a static function to parse extrema tuple arguments, and a new
C function was added to calculate image entropy, making use of the
new static extrema function.

The extrema-parsing function was written by @homm, based on the
macro abstraction I wrote, during the discussion of my first
entropy-method pull request: https://git.io/fhodS

The new `image.entropy()` method is based on `image.histogram()`,
and will accept the same arguments to calculate the histogram data
it will use to assess the entropy of the image.

The algorithm and methodology is based on existing Python code:

* https://git.io/fhmIU

... A test case in the `Tests/` directory, and doctest lines in
`selftest.py`, have both been added and checked.

Changes proposed in this pull request:

* Added “math.h” include to _imaging.c
* The addition of an `image.entropy()` method to the `Image`
  Python class,
* The abstraction of the extrema-parsing logic of of the C
  function `_histogram` into a static function, and
* The use of that static function in both the `_histogram` and
  `_entropy` C functions.
* Minor documentation addenda in the docstrings for both the
  `image.entropy()` and `image.histogram()` methods were also
  added.
* Removed outdated boilerplate from testing code
* Removed unused “unittest” import
2019-06-26 19:15:47 +10:00
.azure-pipelines/jobs Add Docker builds to Azure Pipelines 2019-02-24 18:00:23 +02:00
.github Moved issue template into directory 2019-06-20 19:07:00 +10:00
.travis Run lint in own job, but don't let it fail build 2018-10-17 22:29:02 +03:00
depends Merge pull request #3889 from radarhere/libimagequant 2019-06-08 21:18:09 +03:00
docs Merge pull request #3910 from radarhere/xrgb 2019-06-22 10:24:24 +03:00
src Added an image.entropy() method 2019-06-26 19:15:47 +10:00
Tests Added an image.entropy() method 2019-06-26 19:15:47 +10:00
winbuild Format with Black 2019-06-13 18:54:57 +03:00
.appveyor.yml Removed use of Python 3.4 2019-04-06 12:42:21 +11:00
.codecov.yml Avoid "Missing base report" due to committing CHANGES.rst with "[CI skip]" 2018-01-10 16:33:15 +02:00
.coveragerc Don't exclude Windows code 2014-07-05 21:32:09 +03:00
.editorconfig Remove duplicate line [CI skip] 2016-09-03 12:37:47 +03:00
.gitattributes Set EPS test files as binary 2018-12-29 21:53:07 -08:00
.gitignore Ignore output of viewdoc (run by 'make release-test') 2019-01-06 17:21:08 +02:00
.landscape.yaml Set landscape max-line-length 2015-07-21 18:23:55 +10:00
.readthedocs.yml Install project using pip in ReadTheDocs build 2018-10-24 19:46:43 +11:00
.travis.yml Add new Fedora 30, remove soon-EOL 28 2019-05-02 09:21:34 +03:00
azure-pipelines.yml Add new Fedora 30, remove soon-EOL 28 2019-05-02 09:21:34 +03:00
CHANGES.rst Update CHANGES.rst 2019-06-19 17:06:18 +03:00
LICENSE Updated copyright year 2019-01-03 09:32:05 +11:00
Makefile Update Python 2 doc URLs to Python 3 2018-06-09 21:04:34 -07:00
MANIFEST.in Fix check-manifest 2019-02-24 18:00:09 +02:00
mp_compile.py Format with Black 2019-06-13 18:54:57 +03:00
README.rst Add info to README re: Tidelift [ci skip] 2019-05-11 14:33:54 -04:00
RELEASING.md Stable is now the default ReadTheDocs version [ci skip] 2019-04-03 14:02:52 +11:00
requirements.txt Add Black to requirements.txt for Python 3.6+ 2019-06-10 18:22:46 +03:00
selftest.py Added an image.entropy() method 2019-06-26 19:15:47 +10:00
setup.cfg Tell Flake8 to ignore non-PEP 8 compliant E203 and W503 2019-06-10 18:18:47 +03:00
setup.py Format with Black 2019-06-13 18:54:57 +03:00
tox.ini Format with Black 2019-06-13 18:54:57 +03:00

Pillow
======

Python Imaging Library (Fork)
-----------------------------

Pillow is the friendly PIL fork by `Alex Clark and Contributors <https://github.com/python-pillow/Pillow/graphs/contributors>`_. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. As of 2019, Pillow development is `supported by Tidelift <https://tidelift.com/subscription/pkg/pypi-pillow>`_.

.. start-badges

.. list-table::
    :stub-columns: 1

    * - docs
      - |docs|
    * - tests
      - |linux| |macos| |windows| |coverage|
    * - package
      - |zenodo| |tidelift| |version| |downloads|
    * - social
      - |gitter| |twitter|

.. end-badges

More Information
----------------

- `Documentation <https://pillow.readthedocs.io/>`_

  - `Installation <https://pillow.readthedocs.io/en/latest/installation.html>`_
  - `Handbook <https://pillow.readthedocs.io/en/latest/handbook/index.html>`_

- `Contribute <https://github.com/python-pillow/Pillow/blob/master/.github/CONTRIBUTING.md>`_

  - `Issues <https://github.com/python-pillow/Pillow/issues>`_
  - `Pull requests <https://github.com/python-pillow/Pillow/pulls>`_

- `Changelog <https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst>`_

  - `Pre-fork <https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst#pre-fork>`_

Report a Vulnerability
----------------------

To report a security vulnerability, please follow the procedure described in the `Tidelift security policy <https://tidelift.com/docs/security>`_.

.. |docs| image:: https://readthedocs.org/projects/pillow/badge/?version=latest
   :target: https://pillow.readthedocs.io/?badge=latest
   :alt: Documentation Status

.. |linux| image:: https://img.shields.io/travis/python-pillow/Pillow/master.svg?label=Linux%20build
   :target: https://travis-ci.org/python-pillow/Pillow
   :alt: Travis CI build status (Linux)

.. |macos| image:: https://img.shields.io/travis/python-pillow/pillow-wheels/master.svg?label=macOS%20build
   :target: https://travis-ci.org/python-pillow/pillow-wheels
   :alt: Travis CI build status (macOS)

.. |windows| image:: https://img.shields.io/appveyor/ci/python-pillow/Pillow/master.svg?label=Windows%20build
   :target: https://ci.appveyor.com/project/python-pillow/Pillow
   :alt: AppVeyor CI build status (Windows)

.. |coverage| image:: https://codecov.io/gh/python-pillow/Pillow/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/python-pillow/Pillow
   :alt: Code coverage

.. |zenodo| image:: https://zenodo.org/badge/17549/python-pillow/Pillow.svg
   :target: https://zenodo.org/badge/latestdoi/17549/python-pillow/Pillow

.. |tidelift| image:: https://tidelift.com/badges/github/python-pillow/Pillow?style=flat
   :target: https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi-pillow&utm_medium=referral&utm_campaign=readme

.. |version| image:: https://img.shields.io/pypi/v/pillow.svg
   :target: https://pypi.org/project/Pillow/
   :alt: Latest PyPI version

.. |downloads| image:: https://img.shields.io/pypi/dm/pillow.svg
   :target: https://pypi.org/project/Pillow/
   :alt: Number of PyPI downloads

.. |gitter| image:: https://badges.gitter.im/python-pillow/Pillow.svg
   :target: https://gitter.im/python-pillow/Pillow?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
   :alt: Join the chat at https://gitter.im/python-pillow/Pillow

.. |twitter| image:: https://img.shields.io/badge/tweet-on%20Twitter-00aced.svg
   :target: https://twitter.com/PythonPillow
   :alt: Follow on https://twitter.com/PythonPillow