From 8eb208616cd8b45ba35d0a3f855c3fea95d49f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 22 Jan 2013 19:16:39 +0100 Subject: [PATCH] Rename Py_ssize_t to ssize_t for consistency within skimage --- skimage/filter/rank/_core16.pxd | 10 +- skimage/filter/rank/_core16.pyx | 54 ++--- skimage/filter/rank/_core8.pxd | 10 +- skimage/filter/rank/_core8.pyx | 50 ++--- skimage/filter/rank/_crank16.pyx | 212 +++++++++---------- skimage/filter/rank/_crank16_bilateral.pyx | 16 +- skimage/filter/rank/_crank16_percentiles.pyx | 84 ++++---- skimage/filter/rank/_crank8.pyx | 140 ++++++------ skimage/filter/rank/_crank8_percentiles.pyx | 48 ++--- 9 files changed, 312 insertions(+), 312 deletions(-) diff --git a/skimage/filter/rank/_core16.pxd b/skimage/filter/rank/_core16.pxd index 5f7de9df..96f34121 100644 --- a/skimage/filter/rank/_core16.pxd +++ b/skimage/filter/rank/_core16.pxd @@ -6,12 +6,12 @@ cdef int int_min(int a, int b) # 16-bit core kernel receives extra information about data bitdepth -cdef void _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), +cdef void _core16(np.uint16_t kernel(ssize_t *, float, np.uint16_t, + ssize_t, ssize_t, ssize_t, float, + float, ssize_t, 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) except * + char shift_x, char shift_y, ssize_t bitdepth, + float p0, float p1, ssize_t s0, ssize_t s1) except * diff --git a/skimage/filter/rank/_core16.pyx b/skimage/filter/rank/_core16.pyx index aa959fd0..323692ec 100644 --- a/skimage/filter/rank/_core16.pyx +++ b/skimage/filter/rank/_core16.pyx @@ -17,38 +17,38 @@ cdef inline int int_min(int a, int b): return a if a <= b else b -cdef inline void histogram_increment(Py_ssize_t * histo, float * pop, +cdef inline void histogram_increment(ssize_t * histo, float * pop, np.uint16_t value): histo[value] += 1 pop[0] += 1 -cdef inline void histogram_decrement(Py_ssize_t * histo, float * pop, +cdef inline void histogram_decrement(ssize_t * histo, float * pop, np.uint16_t value): histo[value] -= 1 pop[0] -= 1 -cdef void _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), +cdef void _core16(np.uint16_t kernel(ssize_t *, float, np.uint16_t, + ssize_t, ssize_t, ssize_t, float, + float, ssize_t, 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) except *: + char shift_x, char shift_y, ssize_t bitdepth, + float p0, float p1, ssize_t s0, ssize_t s1) except *: """Compute histogram for each pixel neighborhood, apply kernel function and use kernel function return value for output image. """ - cdef Py_ssize_t rows = image.shape[0] - cdef Py_ssize_t cols = image.shape[1] - cdef Py_ssize_t srows = selem.shape[0] - cdef Py_ssize_t scols = selem.shape[1] + cdef ssize_t rows = image.shape[0] + cdef ssize_t cols = image.shape[1] + cdef ssize_t srows = selem.shape[0] + cdef ssize_t scols = selem.shape[1] - cdef Py_ssize_t centre_r = int(selem.shape[0] / 2) + shift_y - cdef Py_ssize_t centre_c = int(selem.shape[1] / 2) + shift_x + cdef ssize_t centre_r = int(selem.shape[0] / 2) + shift_y + cdef ssize_t centre_c = int(selem.shape[1] / 2) + shift_x # check that structuring element center is inside the element bounding box assert centre_r >= 0 @@ -61,8 +61,8 @@ cdef void _core16(np.uint16_t kernel(Py_ssize_t *, float, np.uint16_t, midbin_list = [0, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048] # set maxbin and midbin - cdef Py_ssize_t maxbin = maxbin_list[bitdepth] - cdef Py_ssize_t midbin = midbin_list[bitdepth] + cdef ssize_t maxbin = maxbin_list[bitdepth] + cdef ssize_t midbin = midbin_list[bitdepth] assert (image < maxbin).all() @@ -72,30 +72,30 @@ cdef void _core16(np.uint16_t kernel(Py_ssize_t *, float, np.uint16_t, cdef np.uint8_t * mask_data = mask.data # define local variable types - cdef Py_ssize_t r, c, rr, cc, s, value, local_max, i, even_row + cdef ssize_t r, c, rr, cc, s, value, local_max, i, even_row # number of pixels actually inside the neighborhood (float) cdef float pop # allocate memory with malloc - cdef Py_ssize_t max_se = srows * scols + cdef ssize_t max_se = srows * scols # number of element in each attack border - cdef Py_ssize_t num_se_n, num_se_s, num_se_e, num_se_w + cdef ssize_t num_se_n, num_se_s, num_se_e, num_se_w # the current local histogram distribution - cdef Py_ssize_t * histo = malloc(maxbin * sizeof(Py_ssize_t)) + cdef ssize_t * histo = malloc(maxbin * sizeof(ssize_t)) # these lists contain the relative pixel row and column for each of the 4 # attack borders east, west, north and south e.g. se_e_r lists the rows of # the east structuring element border - cdef Py_ssize_t * se_e_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_e_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_w_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_w_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_n_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_n_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_s_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_s_c = malloc(max_se * sizeof(Py_ssize_t)) + cdef ssize_t * se_e_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_e_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_w_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_w_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_n_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_n_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_s_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_s_c = malloc(max_se * sizeof(ssize_t)) # build attack and release borders # by using difference along axis diff --git a/skimage/filter/rank/_core8.pxd b/skimage/filter/rank/_core8.pxd index 38236b87..6ee2e0a3 100644 --- a/skimage/filter/rank/_core8.pxd +++ b/skimage/filter/rank/_core8.pxd @@ -5,18 +5,18 @@ cdef np.uint8_t uint8_max(np.uint8_t a, np.uint8_t b) cdef np.uint8_t uint8_min(np.uint8_t a, np.uint8_t b) -cdef np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, - Py_ssize_t r, Py_ssize_t c, +cdef np.uint8_t is_in_mask(ssize_t rows, ssize_t cols, + ssize_t r, ssize_t c, np.uint8_t * mask) # 8-bit core kernel receives extra information about data inferior and superior # percentiles -cdef void _core8(np.uint8_t kernel(Py_ssize_t *, float, np.uint8_t, float, - float, Py_ssize_t, Py_ssize_t), +cdef void _core8(np.uint8_t kernel(ssize_t *, float, np.uint8_t, float, + float, ssize_t, 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) except * + ssize_t s0, ssize_t s1) except * diff --git a/skimage/filter/rank/_core8.pyx b/skimage/filter/rank/_core8.pyx index 9f4bc693..7dbd4524 100644 --- a/skimage/filter/rank/_core8.pyx +++ b/skimage/filter/rank/_core8.pyx @@ -16,20 +16,20 @@ cdef inline np.uint8_t uint8_min(np.uint8_t a, np.uint8_t b): return a if a <= b else b -cdef inline void histogram_increment(Py_ssize_t * histo, float * pop, +cdef inline void histogram_increment(ssize_t * histo, float * pop, np.uint8_t value): histo[value] += 1 pop[0] += 1 -cdef inline void histogram_decrement(Py_ssize_t * histo, float * pop, +cdef inline void histogram_decrement(ssize_t * histo, float * pop, np.uint8_t value): histo[value] -= 1 pop[0] -= 1 -cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, - Py_ssize_t r, Py_ssize_t c, +cdef inline np.uint8_t is_in_mask(ssize_t rows, ssize_t cols, + ssize_t r, ssize_t c, np.uint8_t * mask): """Check whether given coordinate is within image and mask is true.""" if r < 0 or r > rows - 1 or c < 0 or c > cols - 1: @@ -41,25 +41,25 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, return 0 -cdef void _core8(np.uint8_t kernel(Py_ssize_t *, float, np.uint8_t, float, - float, Py_ssize_t, Py_ssize_t), +cdef void _core8(np.uint8_t kernel(ssize_t *, float, np.uint8_t, float, + float, ssize_t, 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) except *: + ssize_t s0, ssize_t s1) except *: """Compute histogram for each pixel neighborhood, apply kernel function and use kernel function return value for output image. """ - cdef Py_ssize_t rows = image.shape[0] - cdef Py_ssize_t cols = image.shape[1] - cdef Py_ssize_t srows = selem.shape[0] - cdef Py_ssize_t scols = selem.shape[1] + cdef ssize_t rows = image.shape[0] + cdef ssize_t cols = image.shape[1] + cdef ssize_t srows = selem.shape[0] + cdef ssize_t scols = selem.shape[1] - cdef Py_ssize_t centre_r = int(selem.shape[0] / 2) + shift_y - cdef Py_ssize_t centre_c = int(selem.shape[1] / 2) + shift_x + cdef ssize_t centre_r = int(selem.shape[0] / 2) + shift_y + cdef ssize_t centre_c = int(selem.shape[1] / 2) + shift_x # check that structuring element center is inside the element bounding box assert centre_r >= 0 @@ -74,31 +74,31 @@ cdef void _core8(np.uint8_t kernel(Py_ssize_t *, float, np.uint8_t, float, cdef np.uint8_t * mask_data = mask.data # define local variable types - cdef Py_ssize_t r, c, rr, cc, s, value, local_max, i, even_row + cdef ssize_t r, c, rr, cc, s, value, local_max, i, even_row # number of pixels actually inside the neighborhood (float) cdef float pop # allocate memory with malloc - cdef Py_ssize_t max_se = srows * scols + cdef ssize_t max_se = srows * scols # number of element in each attack border - cdef Py_ssize_t num_se_n, num_se_s, num_se_e, num_se_w + cdef ssize_t num_se_n, num_se_s, num_se_e, num_se_w # the current local histogram distribution - cdef Py_ssize_t * histo = malloc(256 * sizeof(Py_ssize_t)) + cdef ssize_t * histo = malloc(256 * sizeof(ssize_t)) # these lists contain the relative pixel row and column for each of the 4 # attack borders east, west, north and south e.g. se_e_r lists the rows of # the east structuring element border - cdef Py_ssize_t * se_e_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_e_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_w_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_w_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_n_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_n_c = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_s_r = malloc(max_se * sizeof(Py_ssize_t)) - cdef Py_ssize_t * se_s_c = malloc(max_se * sizeof(Py_ssize_t)) + cdef ssize_t * se_e_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_e_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_w_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_w_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_n_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_n_c = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_s_r = malloc(max_se * sizeof(ssize_t)) + cdef ssize_t * se_s_c = malloc(max_se * sizeof(ssize_t)) # build attack and release borders # by using difference along axis diff --git a/skimage/filter/rank/_crank16.pyx b/skimage/filter/rank/_crank16.pyx index e81bf81f..b5dda3c2 100644 --- a/skimage/filter/rank/_crank16.pyx +++ b/skimage/filter/rank/_crank16.pyx @@ -14,12 +14,12 @@ from skimage.filter.rank._core16 cimport _core16 # ----------------------------------------------------------------- -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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i, imin, imax, delta + ssize_t s0, ssize_t s1): + cdef ssize_t i, imin, imax, delta if pop: for i in range(maxbin - 1, -1, -1): @@ -37,12 +37,12 @@ cdef inline np.uint16_t kernel_autolevel(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i if pop: for i in range(maxbin): @@ -53,12 +53,12 @@ cdef inline np.uint16_t kernel_bottomhat(Py_ssize_t * histo, float pop, else: return < np.uint16_t > (0) -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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float sum = 0. if pop: @@ -72,12 +72,12 @@ cdef inline np.uint16_t kernel_equalize(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i, imin, imax + ssize_t s0, ssize_t s1): + cdef ssize_t i, imin, imax if pop: for i in range(maxbin - 1, -1, -1): @@ -93,12 +93,12 @@ cdef inline np.uint16_t kernel_gradient(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i if pop: for i in range(maxbin - 1, -1, -1): @@ -108,12 +108,12 @@ cdef inline np.uint16_t kernel_maximum(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float mean = 0. if pop: @@ -124,15 +124,15 @@ cdef inline np.uint16_t kernel_mean(Py_ssize_t * histo, float pop, return < np.uint16_t > (0) -cdef inline np.uint16_t kernel_meansubstraction(Py_ssize_t * histo, +cdef inline np.uint16_t kernel_meansubstraction(ssize_t * histo, float pop, np.uint16_t g, - Py_ssize_t bitdepth, - Py_ssize_t maxbin, - Py_ssize_t midbin, + ssize_t bitdepth, + ssize_t maxbin, + ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float mean = 0. if pop: @@ -143,12 +143,12 @@ cdef inline np.uint16_t kernel_meansubstraction(Py_ssize_t * histo, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float sum = pop / 2.0 if pop: @@ -161,12 +161,12 @@ cdef inline np.uint16_t kernel_median(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i if pop: for i in range(maxbin): @@ -176,12 +176,12 @@ cdef inline np.uint16_t kernel_minimum(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t hmax = 0, imax = 0 + ssize_t s0, ssize_t s1): + cdef ssize_t hmax = 0, imax = 0 if pop: for i in range(maxbin): @@ -193,15 +193,15 @@ cdef inline np.uint16_t kernel_modal(Py_ssize_t * histo, float pop, return < np.uint16_t > (0) -cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t * histo, +cdef inline np.uint16_t kernel_morph_contr_enh(ssize_t * histo, float pop, np.uint16_t g, - Py_ssize_t bitdepth, - Py_ssize_t maxbin, - Py_ssize_t midbin, + ssize_t bitdepth, + ssize_t maxbin, + ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i, imin, imax + ssize_t s0, ssize_t s1): + cdef ssize_t i, imin, imax if pop: for i in range(maxbin - 1, -1, -1): @@ -220,20 +220,20 @@ cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t * histo, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float mean = 0. if pop: @@ -244,12 +244,12 @@ cdef inline np.uint16_t kernel_threshold(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i if pop: for i in range(maxbin - 1, -1, -1): @@ -260,12 +260,12 @@ cdef inline np.uint16_t kernel_tophat(Py_ssize_t * histo, float pop, else: return < np.uint16_t > (0) -cdef inline np.uint16_t kernel_entropy(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_entropy(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): - cdef Py_ssize_t i + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float e, p if pop: @@ -289,132 +289,132 @@ def autolevel(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def bottomhat(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_bottomhat, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def equalize(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_equalize, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def gradient(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_gradient, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def maximum(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_maximum, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def mean(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_mean, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def meansubstraction(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_meansubstraction, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def median(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_median, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def minimum(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_minimum, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def modal(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_modal, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def pop(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_pop, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def threshold(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_threshold, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def tophat(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_tophat, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) def entropy(np.ndarray[np.uint16_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] selem, np.ndarray[np.uint8_t, ndim=2] mask=None, np.ndarray[np.uint16_t, ndim=2] out=None, - char shift_x=0, char shift_y=0, Py_ssize_t bitdepth=8): + char shift_x=0, char shift_y=0, ssize_t bitdepth=8): _core16(kernel_entropy, image, selem, mask, out, shift_x, shift_y, - bitdepth, 0, 0, 0, 0) + bitdepth, 0, 0, 0, 0) diff --git a/skimage/filter/rank/_crank16_bilateral.pyx b/skimage/filter/rank/_crank16_bilateral.pyx index c71ccc5c..82236d63 100644 --- a/skimage/filter/rank/_crank16_bilateral.pyx +++ b/skimage/filter/rank/_crank16_bilateral.pyx @@ -13,11 +13,11 @@ 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, +cdef inline np.uint16_t kernel_mean(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, bilat_pop = 0 cdef float mean = 0. @@ -35,11 +35,11 @@ cdef inline np.uint16_t kernel_mean(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, bilat_pop = 0 diff --git a/skimage/filter/rank/_crank16_percentiles.pyx b/skimage/filter/rank/_crank16_percentiles.pyx index 220d2386..e8836b5b 100644 --- a/skimage/filter/rank/_crank16_percentiles.pyx +++ b/skimage/filter/rank/_crank16_percentiles.pyx @@ -13,11 +13,11 @@ from skimage.filter.rank._core16 cimport _core16, int_min, int_max # ----------------------------------------------------------------- -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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta @@ -46,11 +46,11 @@ cdef inline np.uint16_t kernel_autolevel(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta @@ -74,11 +74,11 @@ cdef inline np.uint16_t kernel_gradient(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, mean, n @@ -100,14 +100,14 @@ cdef inline np.uint16_t kernel_mean(Py_ssize_t * histo, float pop, return < np.uint16_t > (0) -cdef inline np.uint16_t kernel_mean_substraction(Py_ssize_t * histo, +cdef inline np.uint16_t kernel_mean_substraction(ssize_t * histo, float pop, np.uint16_t g, - Py_ssize_t bitdepth, - Py_ssize_t maxbin, - Py_ssize_t midbin, + ssize_t bitdepth, + ssize_t maxbin, + ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, mean, n @@ -128,14 +128,14 @@ cdef inline np.uint16_t kernel_mean_substraction(Py_ssize_t * histo, return < np.uint16_t > (0) -cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t * histo, +cdef inline np.uint16_t kernel_morph_contr_enh(ssize_t * histo, float pop, np.uint16_t g, - Py_ssize_t bitdepth, - Py_ssize_t maxbin, - Py_ssize_t midbin, + ssize_t bitdepth, + ssize_t maxbin, + ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta @@ -165,11 +165,11 @@ cdef inline np.uint16_t kernel_morph_contr_enh(Py_ssize_t * histo, 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, +cdef inline np.uint16_t kernel_percentile(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i cdef float sum = 0. @@ -185,11 +185,11 @@ cdef inline np.uint16_t kernel_percentile(Py_ssize_t * histo, float pop, 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(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, n @@ -205,11 +205,11 @@ cdef inline np.uint16_t kernel_pop(Py_ssize_t * histo, float pop, 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, +cdef inline np.uint16_t kernel_threshold(ssize_t * histo, float pop, + np.uint16_t g, ssize_t bitdepth, + ssize_t maxbin, ssize_t midbin, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i cdef float sum = 0. @@ -239,7 +239,7 @@ def autolevel(np.ndarray[np.uint16_t, ndim=2] image, """bottom hat """ _core16(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def gradient(np.ndarray[np.uint16_t, ndim=2] image, @@ -251,7 +251,7 @@ def gradient(np.ndarray[np.uint16_t, ndim=2] image, """return p0,p1 percentile gradient """ _core16(kernel_gradient, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def mean(np.ndarray[np.uint16_t, ndim=2] image, @@ -263,7 +263,7 @@ def mean(np.ndarray[np.uint16_t, ndim=2] image, """return mean between [p0 and p1] percentiles """ _core16(kernel_mean, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def mean_substraction(np.ndarray[np.uint16_t, ndim=2] image, @@ -276,7 +276,7 @@ def mean_substraction(np.ndarray[np.uint16_t, ndim=2] image, """ _core16( kernel_mean_substraction, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image, @@ -288,7 +288,7 @@ def morph_contr_enh(np.ndarray[np.uint16_t, ndim=2] image, """reforce contrast using percentiles """ _core16(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def percentile(np.ndarray[np.uint16_t, ndim=2] image, @@ -300,7 +300,7 @@ def percentile(np.ndarray[np.uint16_t, ndim=2] image, """return p0 percentile """ _core16(kernel_percentile, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def pop(np.ndarray[np.uint16_t, ndim=2] image, @@ -312,7 +312,7 @@ def pop(np.ndarray[np.uint16_t, ndim=2] image, """return nb of pixels between [p0 and p1] """ _core16(kernel_pop, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) def threshold(np.ndarray[np.uint16_t, ndim=2] image, @@ -324,4 +324,4 @@ def threshold(np.ndarray[np.uint16_t, ndim=2] image, """return (maxbin-1) if g > percentile p0 """ _core16(kernel_threshold, image, selem, mask, out, shift_x, shift_y, - bitdepth, p0, p1, 0, 0) + bitdepth, p0, p1, 0, 0) diff --git a/skimage/filter/rank/_crank8.pyx b/skimage/filter/rank/_crank8.pyx index 8bff9703..582bcbb7 100644 --- a/skimage/filter/rank/_crank8.pyx +++ b/skimage/filter/rank/_crank8.pyx @@ -14,11 +14,11 @@ from skimage.filter.rank._core8 cimport _core8 # ----------------------------------------------------------------- -cdef inline np.uint8_t kernel_autolevel(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_autolevel(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i, imin, imax, delta + cdef ssize_t i, imin, imax, delta if pop: for i in range(255, -1, -1): @@ -38,11 +38,11 @@ cdef inline np.uint8_t kernel_autolevel(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_bottomhat(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i if pop: for i in range(256): @@ -54,11 +54,11 @@ cdef inline np.uint8_t kernel_bottomhat(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_equalize(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_equalize(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i cdef float sum = 0. if pop: @@ -72,11 +72,11 @@ cdef inline np.uint8_t kernel_equalize(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_gradient(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_gradient(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i, imin, imax + cdef ssize_t i, imin, imax if pop: for i in range(255, -1, -1): @@ -92,11 +92,11 @@ cdef inline np.uint8_t kernel_gradient(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_maximum(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_maximum(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i if pop: for i in range(255, -1, -1): @@ -106,11 +106,11 @@ cdef inline np.uint8_t kernel_maximum(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_mean(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i cdef float mean = 0. if pop: @@ -121,11 +121,11 @@ cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_meansubstraction(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i cdef float mean = 0. if pop: @@ -136,11 +136,11 @@ cdef inline np.uint8_t kernel_meansubstraction(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_median(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_median(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i cdef float sum = pop / 2.0 if pop: @@ -153,11 +153,11 @@ cdef inline np.uint8_t kernel_median(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_minimum(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_minimum(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i if pop: for i in range(256): @@ -167,11 +167,11 @@ cdef inline np.uint8_t kernel_minimum(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_modal(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_modal(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t hmax = 0, imax = 0 + cdef ssize_t hmax = 0, imax = 0 if pop: for i in range(256): @@ -183,11 +183,11 @@ cdef inline np.uint8_t kernel_modal(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_morph_contr_enh(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i, imin, imax + cdef ssize_t i, imin, imax if pop: for i in range(255, -1, -1): @@ -206,18 +206,18 @@ cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_pop(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_pop(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): return < np.uint8_t > (pop) -cdef inline np.uint8_t kernel_threshold(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_threshold(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i cdef float mean = 0. if pop: @@ -228,11 +228,11 @@ cdef inline np.uint8_t kernel_threshold(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_tophat(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_tophat(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i + cdef ssize_t i if pop: for i in range(255, -1, -1): @@ -243,12 +243,12 @@ cdef inline np.uint8_t kernel_tophat(Py_ssize_t * histo, float pop, else: return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_noise_filter(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_noise_filter(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): - cdef Py_ssize_t i - cdef Py_ssize_t min_i + cdef ssize_t i + cdef ssize_t min_i # early stop if at least one pixel of the neighborhood has the same g if histo[g] > 0: @@ -267,10 +267,10 @@ cdef inline np.uint8_t kernel_noise_filter(Py_ssize_t * histo, float pop, return < np.uint8_t > min_i -cdef inline np.uint8_t kernel_entropy(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_entropy(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 + ssize_t s0, ssize_t s1): + cdef ssize_t i cdef float e, p if pop: @@ -285,11 +285,11 @@ cdef inline np.uint8_t kernel_entropy(Py_ssize_t * histo, float pop, else: return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_otsu(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 Py_ssize_t max_i +cdef inline np.uint8_t kernel_otsu(ssize_t * histo, float pop, np.uint8_t g, + float p0, float p1, ssize_t s0, + ssize_t s1): + cdef ssize_t i + cdef ssize_t max_i cdef float P, mu1, mu2, q1, new_q1, sigma_b, max_sigma_b cdef float mu = 0. @@ -334,7 +334,7 @@ def autolevel(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def bottomhat(np.ndarray[np.uint8_t, ndim=2] image, @@ -343,7 +343,7 @@ def bottomhat(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_bottomhat, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def equalize(np.ndarray[np.uint8_t, ndim=2] image, @@ -352,7 +352,7 @@ def equalize(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_equalize, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def gradient(np.ndarray[np.uint8_t, ndim=2] image, @@ -361,7 +361,7 @@ def gradient(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_gradient, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def maximum(np.ndarray[np.uint8_t, ndim=2] image, @@ -370,7 +370,7 @@ def maximum(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_maximum, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def mean(np.ndarray[np.uint8_t, ndim=2] image, @@ -379,7 +379,7 @@ def mean(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_mean, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def meansubstraction(np.ndarray[np.uint8_t, ndim=2] image, @@ -388,7 +388,7 @@ def meansubstraction(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_meansubstraction, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def median(np.ndarray[np.uint8_t, ndim=2] image, @@ -397,7 +397,7 @@ def median(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_median, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def minimum(np.ndarray[np.uint8_t, ndim=2] image, @@ -406,7 +406,7 @@ def minimum(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_minimum, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image, @@ -415,7 +415,7 @@ def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def modal(np.ndarray[np.uint8_t, ndim=2] image, @@ -424,7 +424,7 @@ def modal(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_modal, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def pop(np.ndarray[np.uint8_t, ndim=2] image, @@ -433,7 +433,7 @@ def pop(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_pop, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def threshold(np.ndarray[np.uint8_t, ndim=2] image, @@ -442,7 +442,7 @@ def threshold(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, 0, 0, - 0, 0) + 0, 0) def tophat(np.ndarray[np.uint8_t, ndim=2] image, @@ -451,7 +451,7 @@ def tophat(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_tophat, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def noise_filter(np.ndarray[np.uint8_t, ndim=2] image, @@ -460,7 +460,7 @@ def noise_filter(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_noise_filter, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def entropy(np.ndarray[np.uint8_t, ndim=2] image, @@ -469,7 +469,7 @@ def entropy(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_entropy, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) def otsu(np.ndarray[np.uint8_t, ndim=2] image, @@ -478,4 +478,4 @@ def otsu(np.ndarray[np.uint8_t, ndim=2] image, np.ndarray[np.uint8_t, ndim=2] out=None, char shift_x=0, char shift_y=0): _core8(kernel_otsu, image, selem, mask, out, shift_x, shift_y, - 0, 0, 0, 0) + 0, 0, 0, 0) diff --git a/skimage/filter/rank/_crank8_percentiles.pyx b/skimage/filter/rank/_crank8_percentiles.pyx index 31b00742..bd48c78b 100644 --- a/skimage/filter/rank/_crank8_percentiles.pyx +++ b/skimage/filter/rank/_crank8_percentiles.pyx @@ -13,9 +13,9 @@ from skimage.filter.rank._core8 cimport _core8, uint8_max, uint8_min # ----------------------------------------------------------------- -cdef inline np.uint8_t kernel_autolevel(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_autolevel(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta if pop: @@ -45,9 +45,9 @@ cdef inline np.uint8_t kernel_autolevel(Py_ssize_t * histo, float pop, return < np.uint8_t > (128) -cdef inline np.uint8_t kernel_gradient(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_gradient(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta if pop: @@ -70,9 +70,9 @@ cdef inline np.uint8_t kernel_gradient(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_mean(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, mean, n if pop: @@ -92,11 +92,11 @@ cdef inline np.uint8_t kernel_mean(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_mean_substraction(Py_ssize_t * histo, +cdef inline np.uint8_t kernel_mean_substraction(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, mean, n if pop: @@ -116,10 +116,10 @@ cdef inline np.uint8_t kernel_mean_substraction(Py_ssize_t * histo, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t * histo, +cdef inline np.uint8_t kernel_morph_contr_enh(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, imin, imax, sum, delta if pop: @@ -148,9 +148,9 @@ cdef inline np.uint8_t kernel_morph_contr_enh(Py_ssize_t * histo, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_percentile(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_percentile(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i cdef float sum = 0. @@ -165,9 +165,9 @@ cdef inline np.uint8_t kernel_percentile(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_pop(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_pop(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i, sum, n if pop: @@ -182,9 +182,9 @@ cdef inline np.uint8_t kernel_pop(Py_ssize_t * histo, float pop, return < np.uint8_t > (0) -cdef inline np.uint8_t kernel_threshold(Py_ssize_t * histo, float pop, +cdef inline np.uint8_t kernel_threshold(ssize_t * histo, float pop, np.uint8_t g, float p0, float p1, - Py_ssize_t s0, Py_ssize_t s1): + ssize_t s0, ssize_t s1): cdef int i cdef float sum = 0. @@ -212,7 +212,7 @@ def autolevel(np.ndarray[np.uint8_t, ndim=2] image, """autolevel """ _core8(kernel_autolevel, image, selem, mask, out, shift_x, shift_y, p0, p1, - 0, 0) + 0, 0) def gradient(np.ndarray[np.uint8_t, ndim=2] image, @@ -223,7 +223,7 @@ def gradient(np.ndarray[np.uint8_t, ndim=2] image, """return p0,p1 percentile gradient """ _core8(kernel_gradient, image, selem, mask, out, shift_x, shift_y, p0, p1, - 0, 0) + 0, 0) def mean(np.ndarray[np.uint8_t, ndim=2] image, @@ -234,7 +234,7 @@ def mean(np.ndarray[np.uint8_t, ndim=2] image, """return mean between [p0 and p1] percentiles """ _core8(kernel_mean, image, selem, mask, out, shift_x, shift_y, p0, p1, - 0, 0) + 0, 0) def mean_substraction(np.ndarray[np.uint8_t, ndim=2] image, @@ -245,7 +245,7 @@ def mean_substraction(np.ndarray[np.uint8_t, ndim=2] image, """return original - mean between [p0 and p1] percentiles *.5 +127 """ _core8(kernel_mean_substraction, image, selem, mask, out, shift_x, shift_y, - p0, p1, 0, 0) + p0, p1, 0, 0) def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image, @@ -256,7 +256,7 @@ def morph_contr_enh(np.ndarray[np.uint8_t, ndim=2] image, """reforce contrast using percentiles """ _core8(kernel_morph_contr_enh, image, selem, mask, out, shift_x, shift_y, - p0, p1, 0, 0) + p0, p1, 0, 0) def percentile(np.ndarray[np.uint8_t, ndim=2] image, @@ -267,7 +267,7 @@ def percentile(np.ndarray[np.uint8_t, ndim=2] image, """return p0 percentile """ _core8(kernel_percentile, image, selem, mask, out, shift_x, shift_y, - p0, p1, 0, 0) + p0, p1, 0, 0) def pop(np.ndarray[np.uint8_t, ndim=2] image, @@ -278,7 +278,7 @@ def pop(np.ndarray[np.uint8_t, ndim=2] image, """return nb of pixels between [p0 and p1] """ _core8(kernel_pop, image, selem, mask, out, shift_x, shift_y, p0, p1, - 0, 0) + 0, 0) def threshold(np.ndarray[np.uint8_t, ndim=2] image, @@ -289,4 +289,4 @@ def threshold(np.ndarray[np.uint8_t, ndim=2] image, """return 255 if g > percentile p0 """ _core8(kernel_threshold, image, selem, mask, out, shift_x, shift_y, p0, p1, - 0, 0) + 0, 0)