Merge pull request #1136 from juliantaylor/signed-char

BUG: add signed flag to chars
This commit is contained in:
Johannes Schönberger
2014-09-06 14:44:42 -04:00
9 changed files with 50 additions and 50 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ def _local_binary_pattern(double[:, ::1] image,
# pre-allocate arrays for computation
cdef double[::1] texture = np.zeros(P, dtype=np.double)
cdef char[::1] signed_texture = np.zeros(P, dtype=np.int8)
cdef signed char[::1] signed_texture = np.zeros(P, dtype=np.int8)
cdef int[::1] rotation_chain = np.zeros(P, dtype=np.int32)
output_shape = (image.shape[0], image.shape[1])
+6 -6
View File
@@ -87,7 +87,7 @@ def corner_moravec(image, Py_ssize_t window_size=1):
cdef inline double _corner_fast_response(double curr_pixel,
double* circle_intensities,
char* bins, char state, char n):
signed char* bins, signed char state, char n):
cdef char consecutive_count = 0
cdef double curr_response
cdef Py_ssize_t l, m
@@ -104,22 +104,22 @@ cdef inline double _corner_fast_response(double curr_pixel,
return 0
def _corner_fast(double[:, ::1] image, char n, double threshold):
def _corner_fast(double[:, ::1] image, signed char n, double threshold):
cdef Py_ssize_t rows = image.shape[0]
cdef Py_ssize_t cols = image.shape[1]
cdef Py_ssize_t i, j, k
cdef char speed_sum_b, speed_sum_d
cdef signed char speed_sum_b, speed_sum_d
cdef double curr_pixel
cdef double lower_threshold, upper_threshold
cdef double[:, ::1] corner_response = np.zeros((rows, cols),
dtype=np.double)
cdef char *rp = [0, 1, 2, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1]
cdef char *cp = [3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1, 0, 1, 2, 3]
cdef char bins[16]
cdef signed char *rp = [0, 1, 2, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1]
cdef signed char *cp = [3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -2, -1, 0, 1, 2, 3]
cdef signed char bins[16]
cdef double circle_intensities[16]
cdef double curr_response
+4 -4
View File
@@ -25,10 +25,10 @@ def _orb_loop(double[:, ::1] image, Py_ssize_t[:, ::1] keypoints,
cdef Py_ssize_t i, d, kr, kc, pr0, pr1, pc0, pc1, spr0, spc0, spr1, spc1
cdef int[:, ::1] steered_pos0, steered_pos1
cdef double angle
cdef char[:, ::1] descriptors = np.zeros((keypoints.shape[0],
POS.shape[0]), dtype=np.uint8)
cdef char[:, ::1] cpos0 = POS0
cdef char[:, ::1] cpos1 = POS1
cdef unsigned char[:, ::1] descriptors = \
np.zeros((keypoints.shape[0], POS.shape[0]), dtype=np.uint8)
cdef signed char[:, ::1] cpos0 = POS0
cdef signed char[:, ::1] cpos1 = POS1
for i in range(descriptors.shape[0]):
+3 -3
View File
@@ -80,7 +80,7 @@ def _mean(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t s0, Py_ssize_t s1,
signed char shift_x, signed char shift_y, Py_ssize_t s0, Py_ssize_t s1,
Py_ssize_t max_bin):
_core(_kernel_mean[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -91,7 +91,7 @@ def _pop(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t s0, Py_ssize_t s1,
signed char shift_x, signed char shift_y, Py_ssize_t s0, Py_ssize_t s1,
Py_ssize_t max_bin):
_core(_kernel_pop[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -102,7 +102,7 @@ def _sum(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t s0, Py_ssize_t s1,
signed char shift_x, signed char shift_y, Py_ssize_t s0, Py_ssize_t s1,
Py_ssize_t max_bin):
_core(_kernel_sum[dtype_t_out, dtype_t], image, selem, mask, out,
+1 -1
View File
@@ -22,7 +22,7 @@ cdef void _core(void kernel(dtype_t_out*, Py_ssize_t, Py_ssize_t*, double,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y,
signed char shift_x, signed char shift_y,
double p0, double p1,
Py_ssize_t s0, Py_ssize_t s1,
Py_ssize_t max_bin) except *
+5 -5
View File
@@ -49,7 +49,7 @@ cdef void _core(void kernel(dtype_t_out*, Py_ssize_t, Py_ssize_t*, double,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y,
signed char shift_x, signed char shift_y,
double p0, double p1,
Py_ssize_t s0, Py_ssize_t s1,
Py_ssize_t max_bin) except *:
@@ -112,16 +112,16 @@ cdef void _core(void kernel(dtype_t_out*, Py_ssize_t, Py_ssize_t*, double,
# build attack and release borders by using difference along axis
t = np.hstack((selem, np.zeros((selem.shape[0], 1))))
cdef char[:, :] t_e = (np.diff(t, axis=1) < 0).view(np.uint8)
cdef unsigned char[:, :] t_e = (np.diff(t, axis=1) < 0).view(np.uint8)
t = np.hstack((np.zeros((selem.shape[0], 1)), selem))
cdef char[:, :] t_w = (np.diff(t, axis=1) > 0).view(np.uint8)
cdef unsigned char[:, :] t_w = (np.diff(t, axis=1) > 0).view(np.uint8)
t = np.vstack((selem, np.zeros((1, selem.shape[1]))))
cdef char[:, :] t_s = (np.diff(t, axis=0) < 0).view(np.uint8)
cdef unsigned char[:, :] t_s = (np.diff(t, axis=0) < 0).view(np.uint8)
t = np.vstack((np.zeros((1, selem.shape[1])), selem))
cdef char[:, :] t_n = (np.diff(t, axis=0) > 0).view(np.uint8)
cdef unsigned char[:, :] t_n = (np.diff(t, axis=0) > 0).view(np.uint8)
for r in range(srows):
for c in range(scols):
+19 -19
View File
@@ -411,7 +411,7 @@ def _autolevel(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_autolevel[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -421,7 +421,7 @@ def _bottomhat(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_bottomhat[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -431,7 +431,7 @@ def _equalize(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_equalize[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -441,7 +441,7 @@ def _gradient(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_gradient[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -451,7 +451,7 @@ def _maximum(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_maximum[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -461,7 +461,7 @@ def _mean(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_mean[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -471,7 +471,7 @@ def _subtract_mean(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_subtract_mean[dtype_t_out, dtype_t], image, selem, mask,
out, shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -481,7 +481,7 @@ def _median(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_median[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -491,7 +491,7 @@ def _minimum(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_minimum[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -501,7 +501,7 @@ def _enhance_contrast(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_enhance_contrast[dtype_t_out, dtype_t], image, selem, mask,
out, shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -511,7 +511,7 @@ def _modal(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_modal[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -521,7 +521,7 @@ def _pop(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_pop[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -531,7 +531,7 @@ def _sum(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_sum[dtype_t_out, dtype_t], image, selem, mask,
out, shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -541,7 +541,7 @@ def _threshold(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_threshold[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -551,7 +551,7 @@ def _tophat(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_tophat[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -561,7 +561,7 @@ def _noise_filter(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_noise_filter[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -571,7 +571,7 @@ def _entropy(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_entropy[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -581,7 +581,7 @@ def _otsu(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_otsu[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
@@ -591,7 +591,7 @@ def _windowed_hist(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, Py_ssize_t max_bin):
signed char shift_x, signed char shift_y, Py_ssize_t max_bin):
_core(_kernel_win_hist[dtype_t_out, dtype_t], image, selem, mask, out,
shift_x, shift_y, 0, 0, 0, 0, max_bin)
+9 -9
View File
@@ -257,7 +257,7 @@ def _autolevel(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_autolevel[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -268,7 +268,7 @@ def _gradient(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_gradient[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -279,7 +279,7 @@ def _mean(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_mean[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -290,7 +290,7 @@ def _sum(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_sum[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -301,7 +301,7 @@ def _subtract_mean(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_subtract_mean[dtype_t_out, dtype_t], image, selem, mask,
@@ -312,7 +312,7 @@ def _enhance_contrast(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_enhance_contrast[dtype_t_out, dtype_t], image, selem, mask,
@@ -323,7 +323,7 @@ def _percentile(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_percentile[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -334,7 +334,7 @@ def _pop(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_pop[dtype_t_out, dtype_t], image, selem, mask, out,
@@ -345,7 +345,7 @@ def _threshold(dtype_t[:, ::1] image,
char[:, ::1] selem,
char[:, ::1] mask,
dtype_t_out[:, :, ::1] out,
char shift_x, char shift_y, double p0, double p1,
signed char shift_x, signed char shift_y, double p0, double p1,
Py_ssize_t max_bin):
_core(_kernel_threshold[dtype_t_out, dtype_t], image, selem, mask, out,
+2 -2
View File
@@ -11,7 +11,7 @@ from libc.stdlib cimport malloc, free
def _dilate(np.uint8_t[:, :] image,
np.uint8_t[:, :] selem,
np.uint8_t[:, :] out=None,
char shift_x=0, char shift_y=0):
signed char shift_x=0, signed char shift_y=0):
"""Return greyscale morphological dilation of an image.
Morphological dilation sets a pixel at (i,j) to the maximum over all pixels
@@ -88,7 +88,7 @@ def _dilate(np.uint8_t[:, :] image,
def _erode(np.uint8_t[:, :] image,
np.uint8_t[:, :] selem,
np.uint8_t[:, :] out=None,
char shift_x=0, char shift_y=0):
signed char shift_x=0, signed char shift_y=0):
"""Return greyscale morphological erosion of an image.
Morphological erosion sets a pixel at (i,j) to the minimum over all pixels