Commit Graph

42 Commits

Author SHA1 Message Date
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
Hugo
471220093b Format with Black 2019-06-13 18:54:57 +03:00
Hugo
91da8ff31d flake8: F401 imported but unused 2018-11-11 19:01:10 +02:00
Hugo
e33dd498f5 Prefer more conventional __version__ rather than PILLOW_VERSION 2018-04-25 11:21:38 +03:00
wiredfool
7619018257 remove --installed tweaking in selftest.py 2017-12-28 14:51:55 +00:00
Jason Douglas
c18d26b04b - Conditonally compile animation support, only if the mux.h and demux.h headers meet the ABI version requirements
- Add WEBPMUX support back to WebPDecode_wrapper (to support older versions of libwebp that have mux support, but not animation)
- Add HAVE_WEBPANIM flag, and use it appropriately
- Update documentation / tests
2017-09-27 19:04:24 -07:00
wiredfool
42831098ac Fix RAQM feature detection 2017-06-21 14:00:15 -07:00
shamsa
fcd20da3cb Testing complex text layout. 2017-06-21 14:00:14 -07:00
Eric Soroos
d012f50975 Simplify feature checking, fix transparent webp detection, add webpmux detection 2017-06-13 04:20:21 -07:00
Andrew Murray
57bab081b9 Set executable flag on selftest.py and added shebang line 2016-12-11 12:30:11 +11:00
Andrew Murray
86828ffd2a Replaced del with pop 2016-06-18 11:25:39 +10:00
Andrew Murray
0907f423ca Removed unused variable from selftest 2016-03-29 22:53:48 +11:00
Andrew Murray
a9efd7ad98 Stopped modules from importing themselves 2015-12-02 16:37:50 +11:00
Andrew Murray
aed878e7d1 Adjusted selftest feature label to be in sync with setup 2015-05-15 07:42:22 +10:00
Andrew Murray
98fa49ea37 Changed module and codec names 2015-05-14 20:57:01 +10:00
Andrew Murray
799e8312cb Separated out feature checking from selftest 2015-05-14 19:43:28 +10:00
hugovk
699b662511 Update selftest.py for hopper 2014-09-04 09:50:47 +03:00
Hugo
d7f7965aa2 Replace lena.gif with hopper.gif 2014-09-04 08:44:46 +03:00
hugovk
78003ca473 Update paths to Tests/images/ instead of Images/ 2014-06-23 09:19:29 +03:00
Alastair Houghton
ac8ebccfa6 Added tests and fixed a few bugs that the tests threw up. 2014-03-19 12:16:14 +00:00
cgohlke
e06a0d6139 Report availability of LIBTIFF during selftest 2013-12-29 19:12:06 -08:00
wiredfool
e9e5599412 buildable, selftest registers properly 2013-10-01 23:05:56 -07:00
Alex Clark
26995d7b02 Support selftest.py --installed, fixes #263
Courtesy of @Arfrever
2013-06-30 19:16:27 -04:00
Christoph Gohlke
c48590bfba Fix ImportError during selftest. Remove path silliness.
Also apply PEP8 and print Pillow version during test.
2013-06-29 19:13:55 -07:00
wiredfool
b3752ca053 merge from master 2013-05-21 21:29:58 -07:00
Alex Clark
cb28745049 Wording 2013-05-21 17:44:21 -04:00
wiredfool
a5499170f9 Feature for transparent webp 2013-05-15 17:22:41 -07:00
wiredfool
7f178bc0b6 selftests pass with namespaces on py2.7/3.2 2013-04-08 22:42:49 -07:00
wiredfool
517e0210ab webp to PIL in selftest 2013-04-08 22:41:31 -07:00
wiredfool
c774f9ab4c merged pull request #88 to master, resolved conflicts 2013-04-08 20:31:28 -07:00
Christoph Gohlke
8b440811b5 Fix support not installed messages during selftest
The extension modules are currently not installed in PIL but sys.path.
2013-03-14 12:34:56 -07:00
Christoph Gohlke
45b99b45f5 Check for webp extension during selftest 2013-03-13 17:36:41 -07:00
wiredfool
7226d0dc26 Merge branch 'master' into g4_support 2013-03-12 22:24:36 -07:00
Oliver Tonnhofer
c60bb09fcd Revert "Added support for PNG images with transparency palette"
This reverts commit 5baa1ac1b8.
2013-03-11 19:02:54 +01:00
wiredfool
5ba6564e26 initial merge of wiredfool/Python-Imaging-Library-G4-Tiff-Support 2013-03-08 19:51:59 -08:00
Alex Clark
58321b2f10 Revert "Load extensions from PIL package"
This reverts commit dd80ba22cd.
2013-03-08 18:36:59 -05:00
Christoph Gohlke
dd80ba22cd Load extensions from PIL package 2013-03-08 13:32:09 -08:00
Alex Clark
525de9b14a Don't specify version in tests ; add pillow ref 2013-03-06 19:14:31 -05:00
David Schmidt
5baa1ac1b8 Added support for PNG images with transparency palette 2013-02-01 17:52:22 +01:00
Mikhail Korobov
decabcf96a Fix tox test running: port selftest.py to Python 3; make it clear Python 2.5 is no longer supported (its support is broken in many ways in this branch); remove bundled doctest.py module (it is in stdlib since forever); remove extra stuff from tox.ini 2013-01-10 08:50:52 -06:00
Brian Crowell
78575798d7 py3k: Update exception usage to modern syntax 2013-01-10 08:46:33 -06:00
Alex Clark
9a640e3157 Forking PIL 2010-07-30 22:52:47 -04:00