Fix loop ranges of rank filter kernel functions

This commit is contained in:
Johannes Schönberger
2013-08-01 08:45:11 +02:00
parent f9f405a8ba
commit d9196be3c3
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ cdef inline double _kernel_autolevel(Py_ssize_t* histo, double pop, dtype_t g,
if delta > 0:
return <double>(max_bin - 1) * (g - imin) / delta
else:
return imax - imin
return 0
else:
return 0
@@ -321,7 +321,7 @@ cdef inline double _kernel_otsu(Py_ssize_t* histo, double pop, dtype_t g,
mu1 = 0.
max_sigma_b = 0.
for i in range(1, max_bin):
for i in range(max_bin):
P = histo[i] / pop
new_q1 = q1 + P
if new_q1 > 0:
+3 -3
View File
@@ -17,7 +17,7 @@ cdef inline double _kernel_autolevel(Py_ssize_t* histo, double pop, dtype_t g,
if pop:
sum = 0
p1 = 1.0 - p1
for i in range(max_bin - 1):
for i in range(max_bin):
sum += histo[i]
if sum > p0 * pop:
imin = i
@@ -55,7 +55,7 @@ cdef inline double _kernel_gradient(Py_ssize_t* histo, double pop, dtype_t g,
imin = i
break
sum = 0
for i in range((max_bin - 1), -1, -1):
for i in range(max_bin - 1, -1, -1):
sum += histo[i]
if sum >= p1 * pop:
imax = i
@@ -135,7 +135,7 @@ cdef inline double _kernel_enhance_contrast(Py_ssize_t* histo, double pop,
imin = i
break
sum = 0
for i in range((max_bin - 1), -1, -1):
for i in range(max_bin - 1, -1, -1):
sum += histo[i]
if sum > p1 * pop:
imax = i