New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added an image.entropy()
method (second revision)
#3608
Merged
hugovk
merged 3 commits into
python-pillow:master
from
fish2000:image-entropy-method-revised
Jun 29, 2019
Merged
Added an image.entropy()
method (second revision)
#3608
hugovk
merged 3 commits into
python-pillow:master
from
fish2000:image-entropy-method-revised
Jun 29, 2019
Conversation
This file contains 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
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fish2000
changed the title
Added an
Added an Jan 30, 2019
image.entropy()
methodimage.entropy()
method (second revision)
@homm @radarhere Might I get a review on this, if either of you get a moment? |
radarhere
reviewed
Feb 1, 2019
fish2000
force-pushed
the
image-entropy-method-revised
branch
from
February 5, 2019 16:02
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
fish2000
force-pushed
the
image-entropy-method-revised
branch
from
February 5, 2019 16:40
a6424b8
to
0a640f8
Compare
This comment has been minimized.
This comment has been minimized.
fish2000
force-pushed
the
image-entropy-method-revised
branch
from
February 5, 2019 16:49
0a640f8
to
761ec74
Compare
This comment has been minimized.
This comment has been minimized.
radarhere
reviewed
Feb 6, 2019
fish2000
force-pushed
the
image-entropy-method-revised
branch
from
February 6, 2019 19:05
3ee9a4c
to
bdce3f1
Compare
fish2000
force-pushed
the
image-entropy-method-revised
branch
from
February 6, 2019 22:37
bdce3f1
to
b384a8d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Any chance of getting this into version 6.0.0? – q.v. issue #3618 supra. |
radarhere
reviewed
Mar 5, 2019
fish2000
force-pushed
the
image-entropy-method-revised
branch
2 times, most recently
from
March 5, 2019 13:46
4030957
to
06f4bad
Compare
radarhere
reviewed
Mar 7, 2019
radarhere
force-pushed
the
image-entropy-method-revised
branch
from
March 27, 2019 08:15
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
radarhere
force-pushed
the
image-entropy-method-revised
branch
from
June 26, 2019 09:17
cf22a97
to
8b447c4
Compare
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
Release notes added in #3930. |
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
log2
and 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 theImage
Python class,_histogram
into a static function, and_histogram
and_entropy
C functions.image.entropy()
andimage.histogram()
methods were also added.This resolves my earlier version of this feature, PR #3530.