Added an image.entropy() method (second revision)#3608
Merged
hugovk merged 3 commits intopython-pillow:masterfrom Jun 29, 2019
Merged
Added an image.entropy() method (second revision)#3608hugovk merged 3 commits intopython-pillow:masterfrom
image.entropy() method (second revision)#3608hugovk merged 3 commits intopython-pillow:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
image.entropy() methodimage.entropy() method (second revision)
Contributor
Author
|
@homm @radarhere Might I get a review on this, if either of you get a moment? |
radarhere
reviewed
Feb 1, 2019
aaa797e to
a6424b8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hugovk
reviewed
Feb 5, 2019
a6424b8 to
0a640f8
Compare
This comment has been minimized.
This comment has been minimized.
0a640f8 to
761ec74
Compare
This comment has been minimized.
This comment has been minimized.
radarhere
reviewed
Feb 6, 2019
3ee9a4c to
bdce3f1
Compare
Contributor
Author
bdce3f1 to
b384a8d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Any chance of getting this into version 6.0.0? – q.v. issue #3618 supra. |
radarhere
reviewed
Mar 5, 2019
4030957 to
06f4bad
Compare
radarhere
reviewed
Mar 7, 2019
06f4bad to
24afcc7
Compare
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
cf22a97 to
8b447c4
Compare
Member
|
Thank you! This will be released on Monday. Please could you add release notes to https://github.com/python-pillow/Pillow/blob/master/docs/releasenotes/6.1.0.rst#api-additions? |
22 tasks
hugovk
added a commit
to hugovk/Pillow
that referenced
this pull request
Jul 1, 2019
Member
|
Release notes added in #3930. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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: #3530 (comment)
The original PR had code with issues with
log2and the use of the standard math library – @radarhere corrected these: fish2000#1The new
image.entropy()method is based onimage.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:
... A test case in the
Tests/directory, and doctest lines inselftest.py, have both been added and checked.Changes proposed in this pull request:
<math.h>include to_imaging.c,image.entropy()method to theImagePython class,_histograminto a static function, and_histogramand_entropyC functions.image.entropy()andimage.histogram()methods were also added.This resolves my earlier version of this feature, PR #3530.