Merge pull request #1 from radarhere/image-entropy-method

Removed log2
This commit is contained in:
Alexander Böhn 2019-01-02 19:38:49 -05:00 committed by GitHub
commit 6cc7a99ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,6 +85,9 @@
#include "py3.h"
#define _USE_MATH_DEFINES
#include <math.h>
/* Configuration stuff. Feel free to undef things you don't need. */
#define WITH_IMAGECHOPS /* ImageChops support */
#define WITH_IMAGEDRAW /* ImageDraw support */
@ -1274,7 +1277,7 @@ _entropy(ImagingObject* self, PyObject* args)
fentropy = 0.0;
for (idx = 0; idx < length; idx++) {
p = (double)h->histogram[idx] / fsum;
fentropy += p != 0.0 ? (p * log2(p)) : 0.0;
fentropy += p != 0.0 ? (p * log(p) * M_LOG2E) : 0.0;
}
/* Finally, allocate a PyObject* for return */