Skip to content

Commit

Permalink
Removed variable
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 27, 2019
1 parent 24afcc7 commit cf22a97
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/_imaging.c
Expand Up @@ -1265,10 +1265,9 @@ static PyObject*
_entropy(ImagingObject* self, PyObject* args)
{
ImagingHistogram h;
PyObject* entropy;
int idx, length;
long sum;
double fentropy, fsum, p;
double entropy, fsum, p;
union hist_extrema extrema;
union hist_extrema* ep;

Expand All @@ -1295,21 +1294,18 @@ _entropy(ImagingObject* self, PyObject* args)
/* Next, normalize the histogram data, */
/* using the histogram sum value */
fsum = (double)sum;
fentropy = 0.0;
entropy = 0.0;
for (idx = 0; idx < length; idx++) {
p = (double)h->histogram[idx] / fsum;
if (p != 0.0) {
fentropy += p * log(p) * M_LOG2E;
entropy += p * log(p) * M_LOG2E;
}
}

/* Finally, allocate a PyObject* for return */
entropy = PyFloat_FromDouble(-fentropy);

/* Destroy the histogram structure */
ImagingHistogramDelete(h);

return entropy;
return PyFloat_FromDouble(-entropy);
}

#ifdef WITH_MODEFILTER
Expand Down

0 comments on commit cf22a97

Please sign in to comment.