mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
cut long line, autopep8
This commit is contained in:
@@ -9,7 +9,7 @@ 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.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,
|
||||
|
||||
@@ -47,7 +47,7 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, Py_ssize_t r
|
||||
|
||||
|
||||
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.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,
|
||||
|
||||
@@ -9,7 +9,7 @@ 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.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,
|
||||
|
||||
@@ -47,7 +47,7 @@ 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.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,
|
||||
|
||||
@@ -22,7 +22,10 @@ from skimage.filter.rank._core16 cimport _core16
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
|
||||
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 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, bilat_pop = 0
|
||||
cdef float mean = 0.
|
||||
|
||||
@@ -39,7 +42,10 @@ cdef inline np.uint16_t kernel_mean(Py_ssize_t * histo, float pop, np.uint16_t g
|
||||
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, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
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, bilat_pop = 0
|
||||
|
||||
if pop:
|
||||
|
||||
@@ -13,7 +13,10 @@ from skimage.filter.rank._core16 cimport _core16, int_min, int_max
|
||||
# kernels uint16 (SOFT version using percentiles)
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
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 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 +43,10 @@ cdef inline np.uint16_t kernel_autolevel(Py_ssize_t * histo, float pop, np.uint1
|
||||
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, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
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 +69,10 @@ cdef inline np.uint16_t kernel_gradient(Py_ssize_t * histo, float pop, np.uint16
|
||||
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, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
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 +92,10 @@ 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_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 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 +114,10 @@ cdef inline np.uint16_t kernel_mean_substraction(Py_ssize_t * histo, float pop,
|
||||
else:
|
||||
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, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
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 +145,10 @@ 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_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 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 +162,10 @@ cdef inline np.uint16_t kernel_percentile(Py_ssize_t * histo, float pop, np.uint
|
||||
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, float p0, float p1, Py_ssize_t s0, Py_ssize_t s1):
|
||||
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 +179,10 @@ cdef inline np.uint16_t kernel_pop(Py_ssize_t * histo, float pop, np.uint16_t g,
|
||||
else:
|
||||
return < np.uint16_t > (0)
|
||||
|
||||
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 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.
|
||||
|
||||
@@ -184,7 +208,9 @@ 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 _core16(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -194,7 +220,9 @@ 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 _core16(kernel_gradient, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -204,7 +232,9 @@ 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 _core16(kernel_mean, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -214,7 +244,9 @@ 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 _core16(kernel_mean_substraction, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -224,7 +256,9 @@ 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 _core16(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -234,7 +268,9 @@ 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 _core16(kernel_percentile, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -244,7 +280,9 @@ 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 _core16(kernel_pop, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
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,
|
||||
@@ -254,4 +292,6 @@ 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 _core16(kernel_threshold, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core16(
|
||||
kernel_threshold, image, selem, mask, out, shift_x, shift_y, bitdepth, p0, p1,
|
||||
< Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
|
||||
@@ -22,8 +22,9 @@ from skimage.filter.rank._core8 cimport _core8
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
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):
|
||||
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:
|
||||
@@ -44,8 +45,9 @@ cdef inline np.uint8_t kernel_autolevel(
|
||||
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):
|
||||
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):
|
||||
@@ -56,8 +58,9 @@ cdef inline np.uint8_t kernel_bottomhat(
|
||||
|
||||
|
||||
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):
|
||||
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.
|
||||
|
||||
@@ -72,8 +75,9 @@ cdef inline np.uint8_t kernel_equalize(
|
||||
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):
|
||||
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:
|
||||
@@ -90,8 +94,9 @@ cdef inline np.uint8_t kernel_gradient(
|
||||
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):
|
||||
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:
|
||||
@@ -101,8 +106,10 @@ cdef inline np.uint8_t kernel_maximum(
|
||||
|
||||
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.
|
||||
|
||||
@@ -114,8 +121,9 @@ cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, np.uint8_t g,
|
||||
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):
|
||||
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.
|
||||
|
||||
@@ -127,8 +135,9 @@ cdef inline np.uint8_t kernel_meansubstraction(
|
||||
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):
|
||||
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
|
||||
|
||||
@@ -142,8 +151,9 @@ cdef inline np.uint8_t kernel_median(
|
||||
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):
|
||||
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:
|
||||
@@ -154,8 +164,8 @@ cdef inline np.uint8_t kernel_minimum(
|
||||
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):
|
||||
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:
|
||||
@@ -168,8 +178,9 @@ cdef inline np.uint8_t kernel_modal(
|
||||
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):
|
||||
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:
|
||||
@@ -188,13 +199,16 @@ cdef inline np.uint8_t kernel_morph_contr_enh(
|
||||
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):
|
||||
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.
|
||||
|
||||
@@ -206,8 +220,9 @@ cdef inline np.uint8_t kernel_threshold(
|
||||
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):
|
||||
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):
|
||||
@@ -228,7 +243,9 @@ def autolevel(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""bottom hat
|
||||
"""
|
||||
return _core8(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_autolevel, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def bottomhat(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -238,7 +255,9 @@ def bottomhat(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""bottom hat
|
||||
"""
|
||||
return _core8(kernel_bottomhat, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_bottomhat, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def equalize(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -248,7 +267,9 @@ def equalize(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""local egalisation of the gray level
|
||||
"""
|
||||
return _core8(kernel_equalize, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_equalize, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def gradient(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -258,7 +279,9 @@ def gradient(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""local maximum - local minimum gray level
|
||||
"""
|
||||
return _core8(kernel_gradient, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_gradient, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def maximum(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -288,7 +311,9 @@ def meansubstraction(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""(g - average gray level)/2+127 (clipped on uint8)
|
||||
"""
|
||||
return _core8(kernel_meansubstraction, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_meansubstraction, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def median(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -318,7 +343,9 @@ def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""morphological contrast enhancement
|
||||
"""
|
||||
return _core8(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def modal(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -348,7 +375,9 @@ def threshold(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""returns 255 if gray level higher than local mean, 0 else
|
||||
"""
|
||||
return _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_threshold, image, selem, mask, out, shift_x, shift_y, .0, .0, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def tophat(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
|
||||
@@ -13,7 +13,9 @@ from skimage.filter.rank._core8 cimport _core8, uint8_max, uint8_min
|
||||
# kernels uint8 (SOFT version using percentiles)
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
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 int i, imin, imax, sum, delta
|
||||
|
||||
if pop:
|
||||
@@ -42,7 +44,9 @@ cdef inline np.uint8_t kernel_autolevel(Py_ssize_t * histo, float pop, np.uint8_
|
||||
return < np.uint8_t > (128)
|
||||
|
||||
|
||||
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 int i, imin, imax, sum, delta
|
||||
|
||||
if pop:
|
||||
@@ -65,7 +69,9 @@ cdef inline np.uint8_t kernel_gradient(Py_ssize_t * histo, float pop, np.uint8_t
|
||||
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 int i, sum, mean, n
|
||||
|
||||
if pop:
|
||||
@@ -84,7 +90,9 @@ cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, np.uint8_t g,
|
||||
else:
|
||||
return < np.uint8_t > (0)
|
||||
|
||||
cdef inline np.uint8_t kernel_mean_substraction(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_substraction(
|
||||
Py_ssize_t * histo, float pop, np.uint8_t g, float p0, float p1,
|
||||
Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i, sum, mean, n
|
||||
|
||||
if pop:
|
||||
@@ -103,7 +111,9 @@ cdef inline np.uint8_t kernel_mean_substraction(Py_ssize_t * histo, float pop, n
|
||||
else:
|
||||
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 int i, imin, imax, sum, delta
|
||||
|
||||
if pop:
|
||||
@@ -131,7 +141,9 @@ cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t * histo, float pop, np.
|
||||
else:
|
||||
return < np.uint8_t > (0)
|
||||
|
||||
cdef inline np.uint8_t kernel_percentile(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_percentile(
|
||||
Py_ssize_t * histo, float pop, np.uint8_t g, float p0, float p1,
|
||||
Py_ssize_t s0, Py_ssize_t s1):
|
||||
cdef int i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -145,7 +157,9 @@ cdef inline np.uint8_t kernel_percentile(Py_ssize_t * histo, float pop, np.uint8
|
||||
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):
|
||||
cdef int i, sum, n
|
||||
|
||||
if pop:
|
||||
@@ -159,7 +173,9 @@ cdef inline np.uint8_t kernel_pop(Py_ssize_t * histo, float pop, np.uint8_t g, f
|
||||
else:
|
||||
return < np.uint8_t > (0)
|
||||
|
||||
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 int i
|
||||
cdef float sum = 0.
|
||||
|
||||
@@ -185,7 +201,9 @@ def autolevel(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""autolevel
|
||||
"""
|
||||
return _core8(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_autolevel, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def gradient(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -195,7 +213,9 @@ def gradient(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""return p0,p1 percentile gradient
|
||||
"""
|
||||
return _core8(kernel_gradient, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_gradient, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def mean(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -215,7 +235,9 @@ def mean_substraction(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""return original - mean between [p0 and p1] percentiles *.5 +127
|
||||
"""
|
||||
return _core8(kernel_mean_substraction, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_mean_substraction, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -225,7 +247,9 @@ def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""reforce contrast using percentiles
|
||||
"""
|
||||
return _core8(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def percentile(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -235,7 +259,9 @@ def percentile(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""return p0 percentile
|
||||
"""
|
||||
return _core8(kernel_percentile, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_percentile, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
|
||||
def pop(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
@@ -255,4 +281,6 @@ def threshold(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
char shift_x=0, char shift_y=0, float p0=0., float p1=0.):
|
||||
"""return 255 if g > percentile p0
|
||||
"""
|
||||
return _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0, < Py_ssize_t > 0)
|
||||
return _core8(
|
||||
kernel_threshold, image, selem, mask, out, shift_x, shift_y, p0, p1, < Py_ssize_t > 0,
|
||||
< Py_ssize_t > 0)
|
||||
|
||||
Reference in New Issue
Block a user