mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
group crank16 and crank16p
This commit is contained in:
@@ -4,9 +4,14 @@ cimport numpy as np
|
||||
# 16 bit core kernel receives extra information about data bitdepth
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
cdef inline _core16(np.uint16_t kernel(Py_ssize_t*, float, np.uint16_t, Py_ssize_t ,Py_ssize_t,Py_ssize_t ),
|
||||
np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint16_t, ndim=2] out,
|
||||
char shift_x, char shift_y,Py_ssize_t bitdepth)
|
||||
# generic cdef functions
|
||||
cdef inline int int_max(int a, int b)
|
||||
cdef inline int int_min(int a, int b)
|
||||
|
||||
cdef inline _core16(np.uint16_t kernel(Py_ssize_t*, float, np.uint16_t,Py_ssize_t,Py_ssize_t,Py_ssize_t, float, float, Py_ssize_t, Py_ssize_t),
|
||||
np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint16_t, ndim=2] out,
|
||||
char shift_x, char shift_y,Py_ssize_t bitdepth,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1)
|
||||
+16
-11
@@ -18,6 +18,10 @@ from libc.stdlib cimport malloc, free
|
||||
# 16 bit core kernel receives extra information about data bitdepth
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# generic cdef functions
|
||||
cdef inline int int_max(int a, int b): return a if a >= b else b
|
||||
cdef inline int int_min(int a, int b): return a if a <= b else b
|
||||
|
||||
cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols,Py_ssize_t r, Py_ssize_t c,np.uint8_t* mask):
|
||||
""" returns 1 if given(r,c) coordinate are within the image frame ([0-rows],[0-cols]) and
|
||||
inside the given mask
|
||||
@@ -32,12 +36,13 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols,Py_ssize_t r,
|
||||
return 0
|
||||
|
||||
|
||||
cdef inline _core16(np.uint16_t kernel(Py_ssize_t*, float, np.uint16_t, Py_ssize_t ,Py_ssize_t,Py_ssize_t ),
|
||||
np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint16_t, ndim=2] out,
|
||||
char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
cdef inline _core16(np.uint16_t kernel(Py_ssize_t*, float, np.uint16_t,Py_ssize_t,Py_ssize_t,Py_ssize_t, float, float, Py_ssize_t, Py_ssize_t),
|
||||
np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint16_t, ndim=2] out,
|
||||
char shift_x, char shift_y,Py_ssize_t bitdepth,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
""" Main loop, this function computes the histogram for each image point
|
||||
- data is uint8
|
||||
- result is uint8 casted
|
||||
@@ -168,7 +173,7 @@ char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
c = 0
|
||||
# kernel -------------------------------------------
|
||||
out_data[r * cols + c] = kernel(histo,pop,image_data[r * cols + c],
|
||||
bitdepth,maxbin,midbin)
|
||||
bitdepth,maxbin,midbin,p0,p1,s0,s1)
|
||||
# kernel -------------------------------------------
|
||||
|
||||
# main loop
|
||||
@@ -193,7 +198,7 @@ char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
|
||||
# kernel -------------------------------------------
|
||||
out_data[r * cols + c] = kernel(histo,pop,image_data[r * cols + c ],
|
||||
bitdepth,maxbin,midbin)
|
||||
bitdepth,maxbin,midbin,p0,p1,s0,s1)
|
||||
# kernel -------------------------------------------
|
||||
|
||||
r += 1 # pass to the next row
|
||||
@@ -218,7 +223,7 @@ char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
|
||||
# kernel -------------------------------------------
|
||||
out_data[r * cols + c] = kernel(histo,pop,image_data[r * cols + c],
|
||||
bitdepth,maxbin,midbin)
|
||||
bitdepth,maxbin,midbin,p0,p1,s0,s1)
|
||||
# kernel -------------------------------------------
|
||||
|
||||
# ---> east to west
|
||||
@@ -240,7 +245,7 @@ char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
|
||||
# kernel -------------------------------------------
|
||||
out_data[r * cols + c] = kernel(histo,pop,image_data[r * cols + c ],
|
||||
bitdepth,maxbin,midbin)
|
||||
bitdepth,maxbin,midbin,p0,p1,s0,s1)
|
||||
# kernel -------------------------------------------
|
||||
|
||||
r += 1 # pass to the next row
|
||||
@@ -265,7 +270,7 @@ char shift_x, char shift_y,Py_ssize_t bitdepth):
|
||||
|
||||
# kernel -------------------------------------------
|
||||
out_data[r * cols + c] = kernel(histo,pop,image_data[r * cols + c ],
|
||||
bitdepth,maxbin,midbin)
|
||||
bitdepth,maxbin,midbin,p0,p1,s0,s1)
|
||||
# kernel -------------------------------------------
|
||||
|
||||
# release memory allocated by malloc
|
||||
|
||||
@@ -9,9 +9,9 @@ cdef inline np.uint8_t uint8_min(np.uint8_t a, np.uint8_t b)
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
cdef inline _core8(np.uint8_t kernel(Py_ssize_t*, float, np.uint8_t, float, float, Py_ssize_t, Py_ssize_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,
|
||||
np.ndarray[np.uint8_t, ndim=2] out,
|
||||
char shift_x, char shift_y, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1)
|
||||
np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint8_t, ndim=2] out,
|
||||
char shift_x, char shift_y, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1)
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols,Py_ssize_t r,
|
||||
return 0
|
||||
|
||||
cdef inline _core8(np.uint8_t kernel(Py_ssize_t*, float, np.uint8_t, float, float, Py_ssize_t, Py_ssize_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,
|
||||
np.ndarray[np.uint8_t, ndim=2] out,
|
||||
char shift_x, char shift_y, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] mask,
|
||||
np.ndarray[np.uint8_t, ndim=2] out,
|
||||
char shift_x, char shift_y, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
""" Main loop, this function computes the histogram for each image point
|
||||
- data is uint8
|
||||
- result is uint8 casted
|
||||
|
||||
+56
-28
@@ -21,7 +21,9 @@ from _core16 cimport _core16
|
||||
# kernels uint16 take extra parameter for defining the bitdepth
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
cdef inline np.uint16_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax,delta
|
||||
|
||||
if pop:
|
||||
@@ -39,7 +41,9 @@ cdef inline np.uint16_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint16
|
||||
else:
|
||||
return <np.uint16_t>(imax-imin)
|
||||
|
||||
cdef inline np.uint16_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(maxbin):
|
||||
@@ -49,7 +53,9 @@ cdef inline np.uint16_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint16
|
||||
return <np.uint16_t>(g-i)
|
||||
|
||||
|
||||
cdef inline np.uint16_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -63,7 +69,9 @@ cdef inline np.uint16_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint16_
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
if pop:
|
||||
@@ -79,7 +87,9 @@ cdef inline np.uint16_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint16_
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
@@ -89,7 +99,9 @@ cdef inline np.uint16_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint16_t
|
||||
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_mean(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_mean(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -100,7 +112,9 @@ cdef inline np.uint16_t kernel_mean(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -111,7 +125,9 @@ cdef inline np.uint16_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_median(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_median(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = pop/2.0
|
||||
|
||||
@@ -124,7 +140,9 @@ cdef inline np.uint16_t kernel_median(Py_ssize_t* histo, float pop, np.uint16_t
|
||||
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
@@ -134,7 +152,9 @@ cdef inline np.uint16_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint16_t
|
||||
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_modal(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_modal(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t hmax=0,imax=0
|
||||
|
||||
if pop:
|
||||
@@ -146,7 +166,9 @@ cdef inline np.uint16_t kernel_modal(Py_ssize_t* histo, float pop, np.uint16_t g
|
||||
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
if pop:
|
||||
@@ -165,10 +187,14 @@ cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_pop(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_pop(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
return <np.uint16_t>(pop)
|
||||
|
||||
cdef inline np.uint16_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -179,7 +205,9 @@ cdef inline np.uint16_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint16
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_tophat(Py_ssize_t* histo, float pop, np.uint16_t g, Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin):
|
||||
cdef inline np.uint16_t kernel_tophat(Py_ssize_t* histo, float pop, np.uint16_t g,
|
||||
Py_ssize_t bitdepth, Py_ssize_t maxbin, Py_ssize_t midbin,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(maxbin-1,-1,-1):
|
||||
@@ -198,7 +226,7 @@ def autolevel(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""bottom hat
|
||||
"""
|
||||
return _core16(kernel_autolevel,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_autolevel,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def bottomhat(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -207,7 +235,7 @@ def bottomhat(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""bottom hat
|
||||
"""
|
||||
return _core16(kernel_bottomhat,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_bottomhat,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def equalize(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -216,7 +244,7 @@ def equalize(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local egalisation of the gray level
|
||||
"""
|
||||
return _core16(kernel_equalize,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_equalize,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def gradient(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -225,7 +253,7 @@ def gradient(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local maximum - local minimum gray level
|
||||
"""
|
||||
return _core16(kernel_gradient,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_gradient,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def maximum(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -234,7 +262,7 @@ def maximum(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local maximum gray level
|
||||
"""
|
||||
return _core16(kernel_maximum,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_maximum,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def mean(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -243,7 +271,7 @@ def mean(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""average gray level (clipped on uint8)
|
||||
"""
|
||||
return _core16(kernel_mean,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_mean,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def meansubstraction(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -252,7 +280,7 @@ def meansubstraction(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""(g - average gray level)/2+midbin (clipped on uint8)
|
||||
"""
|
||||
return _core16(kernel_meansubstraction,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_meansubstraction,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def median(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -261,7 +289,7 @@ def median(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local median
|
||||
"""
|
||||
return _core16(kernel_median,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_median,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def minimum(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -270,7 +298,7 @@ def minimum(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local minimum gray level
|
||||
"""
|
||||
return _core16(kernel_minimum,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_minimum,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -279,7 +307,7 @@ def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""morphological contrast enhancement
|
||||
"""
|
||||
return _core16(kernel_morph_contr_enh,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_morph_contr_enh,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def modal(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -288,7 +316,7 @@ def modal(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""local mode
|
||||
"""
|
||||
return _core16(kernel_modal,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_modal,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def pop(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -297,7 +325,7 @@ def pop(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""returns the number of actual pixels of the structuring element inside the mask
|
||||
"""
|
||||
return _core16(kernel_pop,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_pop,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def threshold(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -306,7 +334,7 @@ def threshold(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""returns maxbin-1 if gray level higher than local mean, 0 else
|
||||
"""
|
||||
return _core16(kernel_threshold,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_threshold,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def tophat(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -315,4 +343,4 @@ def tophat(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8):
|
||||
"""top hat
|
||||
"""
|
||||
return _core16(kernel_tophat,image,selem,mask,out,shift_x,shift_y,bitdepth)
|
||||
return _core16(kernel_tophat,image,selem,mask,out,shift_x,shift_y,bitdepth,.0,.0,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
@@ -7,13 +7,13 @@ import numpy as np
|
||||
cimport numpy as np
|
||||
|
||||
# import main loop
|
||||
from _core16p cimport _core16p,int_min,int_max
|
||||
from _core16 cimport _core16,int_min,int_max
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# kernels uint16 (SOFT version using percentiles)
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
cdef inline np.uint16_t kernel_autolevel(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,imin,imax,sum,delta
|
||||
|
||||
if pop:
|
||||
@@ -40,7 +40,7 @@ cdef inline np.uint16_t kernel_autolevel(int* histo, float pop, np.uint16_t g,in
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
|
||||
cdef inline np.uint16_t kernel_gradient(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,imin,imax,sum,delta
|
||||
|
||||
if pop:
|
||||
@@ -63,7 +63,7 @@ cdef inline np.uint16_t kernel_gradient(int* histo, float pop, np.uint16_t g,int
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
|
||||
cdef inline np.uint16_t kernel_mean(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_mean(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,sum,mean,n
|
||||
|
||||
if pop:
|
||||
@@ -83,7 +83,7 @@ cdef inline np.uint16_t kernel_mean(int* histo, float pop, np.uint16_t g,int bit
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_mean_substraction(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_mean_substraction(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,sum,mean,n
|
||||
|
||||
if pop:
|
||||
@@ -102,7 +102,7 @@ cdef inline np.uint16_t kernel_mean_substraction(int* histo, float pop, np.uint1
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_morph_contr_enh(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,imin,imax,sum,delta
|
||||
|
||||
if pop:
|
||||
@@ -130,7 +130,7 @@ cdef inline np.uint16_t kernel_morph_contr_enh(int* histo, float pop, np.uint16_
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_percentile(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_percentile(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -144,7 +144,7 @@ cdef inline np.uint16_t kernel_percentile(int* histo, float pop, np.uint16_t g,i
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_pop(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_pop(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i,sum,n
|
||||
|
||||
if pop:
|
||||
@@ -158,7 +158,7 @@ cdef inline np.uint16_t kernel_pop(int* histo, float pop, np.uint16_t g,int bitd
|
||||
else:
|
||||
return <np.uint16_t>(0)
|
||||
|
||||
cdef inline np.uint16_t kernel_threshold(int* histo, float pop, np.uint16_t g,int bitdepth,int maxbin, int midbin, float p0, float p1):
|
||||
cdef inline np.uint16_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint16_t g,Py_ssize_t bitdepth,Py_ssize_t maxbin, Py_ssize_t midbin, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -182,7 +182,7 @@ def autolevel(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""bottom hat
|
||||
"""
|
||||
return _core16p(kernel_autolevel,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_autolevel,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
|
||||
def gradient(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
@@ -192,7 +192,7 @@ def gradient(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return p0,p1 percentile gradient
|
||||
"""
|
||||
return _core16p(kernel_gradient,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_gradient,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def mean(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -201,7 +201,7 @@ def mean(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return mean between [p0 and p1] percentiles
|
||||
"""
|
||||
return _core16p(kernel_mean,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_mean,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def mean_substraction(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -210,7 +210,7 @@ def mean_substraction(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return original - mean between [p0 and p1] percentiles *.5 +127
|
||||
"""
|
||||
return _core16p(kernel_mean_substraction,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_mean_substraction,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -219,7 +219,7 @@ def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""reforce contrast using percentiles
|
||||
"""
|
||||
return _core16p(kernel_morph_contr_enh,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_morph_contr_enh,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
|
||||
def percentile(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
@@ -229,7 +229,7 @@ def percentile(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return p0 percentile
|
||||
"""
|
||||
return _core16p(kernel_percentile,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_percentile,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
|
||||
def pop(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
@@ -239,7 +239,7 @@ def pop(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return nb of pixels between [p0 and p1]
|
||||
"""
|
||||
return _core16p(kernel_pop,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_pop,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
def threshold(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
@@ -248,4 +248,4 @@ def threshold(np.ndarray[np.uint16_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, int bitdepth=8, float p0=0., float p1=0.):
|
||||
"""return (maxbin-1) if g > percentile p0
|
||||
"""
|
||||
return _core16p(kernel_threshold,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1)
|
||||
return _core16(kernel_threshold,image,selem,mask,out,shift_x,shift_y,bitdepth,p0,p1,<Py_ssize_t>0,<Py_ssize_t>0)
|
||||
|
||||
+28
-14
@@ -21,7 +21,8 @@ from _core8 cimport _core8
|
||||
# kernels uint8
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
cdef inline np.uint8_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax,delta
|
||||
|
||||
if pop:
|
||||
@@ -41,7 +42,8 @@ cdef inline np.uint8_t kernel_autolevel(Py_ssize_t* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(256):
|
||||
@@ -51,7 +53,8 @@ cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t* histo, float pop, np.uint8_t
|
||||
return <np.uint8_t>(g-i)
|
||||
|
||||
|
||||
cdef inline np.uint8_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -65,7 +68,8 @@ cdef inline np.uint8_t kernel_equalize(Py_ssize_t* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
|
||||
@@ -82,7 +86,8 @@ cdef inline np.uint8_t kernel_gradient(Py_ssize_t* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
@@ -92,7 +97,8 @@ cdef inline np.uint8_t kernel_maximum(Py_ssize_t* histo, float pop, np.uint8_t g
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_mean(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_mean(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -103,7 +109,8 @@ cdef inline np.uint8_t kernel_mean(Py_ssize_t* histo, float pop, np.uint8_t g,fl
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -114,7 +121,8 @@ cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t* histo, float pop, np.
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_median(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_median(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float sum = pop/2.0
|
||||
|
||||
@@ -127,7 +135,8 @@ cdef inline np.uint8_t kernel_median(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
if pop:
|
||||
@@ -137,7 +146,8 @@ cdef inline np.uint8_t kernel_minimum(Py_ssize_t* histo, float pop, np.uint8_t g
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_modal(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_modal(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t hmax=0,imax=0
|
||||
|
||||
if pop:
|
||||
@@ -149,7 +159,8 @@ cdef inline np.uint8_t kernel_modal(Py_ssize_t* histo, float pop, np.uint8_t g,f
|
||||
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i,imin,imax
|
||||
|
||||
if pop:
|
||||
@@ -168,10 +179,12 @@ cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t* histo, float pop, np.u
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_pop(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_pop(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
return <np.uint8_t>(pop)
|
||||
|
||||
cdef inline np.uint8_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -182,7 +195,8 @@ cdef inline np.uint8_t kernel_threshold(Py_ssize_t* histo, float pop, np.uint8_t
|
||||
else:
|
||||
return <np.uint8_t>(0)
|
||||
|
||||
cdef inline np.uint8_t kernel_tophat(Py_ssize_t* histo, float pop, np.uint8_t g,float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef inline np.uint8_t kernel_tophat(Py_ssize_t* histo, float pop, np.uint8_t g,
|
||||
float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef Py_ssize_t i
|
||||
|
||||
for i in range(255,-1,-1):
|
||||
|
||||
Reference in New Issue
Block a user