mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-06 05:16:40 +08:00
remplace int by Py_ssize_t and for rank8
This commit is contained in:
@@ -4,7 +4,7 @@ cimport numpy as np
|
||||
# 8 bit core kernel
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
cdef inline _core8(np.uint8_t kernel(int*, float, np.uint8_t),
|
||||
cdef inline _core8(np.uint8_t kernel(Py_ssize_t*, float, np.uint8_t),
|
||||
np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
|
||||
@@ -18,7 +18,7 @@ from libc.stdlib cimport malloc, free
|
||||
# 8 bit core kernel
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
cdef inline _core8(np.uint8_t kernel(int*, float, np.uint8_t),
|
||||
cdef inline _core8(np.uint8_t kernel(Py_ssize_t*, float, np.uint8_t),
|
||||
np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
@@ -86,7 +86,7 @@ char shift_x, char shift_y):
|
||||
cdef Py_ssize_t num_se_n, num_se_s, num_se_e, num_se_w
|
||||
|
||||
# the current local histogram distribution
|
||||
cdef int* histo = <int*>malloc(256 * sizeof(int))
|
||||
cdef Py_ssize_t* histo = <Py_ssize_t*>malloc(256 * sizeof(Py_ssize_t))
|
||||
|
||||
# these lists contain the relative pixel row and column for each of the 4 attack borders
|
||||
# east, west, north and south
|
||||
|
||||
+27
-27
@@ -21,8 +21,8 @@ from _core8 cimport _core8
|
||||
# kernels uint8
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
cdef inline np.uint8_t kernel_autolevel(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i,imin,imax,delta
|
||||
cdef inline np.uint8_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i,imin,imax,delta
|
||||
|
||||
if pop:
|
||||
for i in range(255,-1,-1):
|
||||
@@ -41,8 +41,8 @@ cdef inline np.uint8_t kernel_autolevel(int* histo, float pop, np.uint8_t g):
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_bottomhat(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(256):
|
||||
if histo[i]:
|
||||
@@ -51,8 +51,8 @@ cdef inline np.uint8_t kernel_bottomhat(int* histo, float pop, np.uint8_t g):
|
||||
return <np.uint8_t>(g-i)
|
||||
|
||||
|
||||
cdef inline np.uint8_t kernel_equalize(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = 0.
|
||||
|
||||
if pop:
|
||||
@@ -65,8 +65,8 @@ cdef inline np.uint8_t kernel_equalize(int* histo, float pop, np.uint8_t g):
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_gradient(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i,imin,imax
|
||||
cdef inline np.uint8_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
|
||||
if pop:
|
||||
@@ -82,8 +82,8 @@ cdef inline np.uint8_t kernel_gradient(int* histo, float pop, np.uint8_t g):
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_maximum(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
for i in range(255,-1,-1):
|
||||
@@ -92,8 +92,8 @@ cdef inline np.uint8_t kernel_maximum(int* histo, float pop, np.uint8_t g):
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_mean(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_mean(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
if pop:
|
||||
@@ -103,8 +103,8 @@ cdef inline np.uint8_t kernel_mean(int* histo, float pop, np.uint8_t g):
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_meansubstraction(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
if pop:
|
||||
@@ -114,8 +114,8 @@ cdef inline np.uint8_t kernel_meansubstraction(int* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_median(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_median(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = pop/2.0
|
||||
|
||||
if pop:
|
||||
@@ -127,8 +127,8 @@ cdef inline np.uint8_t kernel_median(int* histo, float pop, np.uint8_t g):
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_minimum(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
for i in range(256):
|
||||
@@ -137,8 +137,8 @@ cdef inline np.uint8_t kernel_minimum(int* histo, float pop, np.uint8_t g):
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_modal(int* histo, float pop, np.uint8_t g):
|
||||
cdef int hmax=0,imax=0
|
||||
cdef inline np.uint8_t kernel_modal(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t hmax=0,imax=0
|
||||
|
||||
if pop:
|
||||
for i in range(256):
|
||||
@@ -149,8 +149,8 @@ cdef inline np.uint8_t kernel_modal(int* histo, float pop, np.uint8_t g):
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_morph_contr_enh(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i,imin,imax
|
||||
cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
if pop:
|
||||
for i in range(255,-1,-1):
|
||||
@@ -168,11 +168,11 @@ cdef inline np.uint8_t kernel_morph_contr_enh(int* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_pop(int* histo, float pop, np.uint8_t g):
|
||||
cdef inline np.uint8_t kernel_pop(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
return <np.uint8_t>(pop)
|
||||
|
||||
cdef inline np.uint8_t kernel_threshold(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
if pop:
|
||||
@@ -182,8 +182,8 @@ cdef inline np.uint8_t kernel_threshold(int* histo, float pop, np.uint8_t g):
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_tophat(int* histo, float pop, np.uint8_t g):
|
||||
cdef int i
|
||||
cdef inline np.uint8_t kernel_tophat(Py_ssize_t* histo, float pop, np.uint8_t g):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(255,-1,-1):
|
||||
if histo[i]:
|
||||
|
||||
Reference in New Issue
Block a user