Fix bug in get_pixel3d

This commit is contained in:
Johannes Schönberger
2014-12-13 13:32:16 +01:00
parent 5e3d805cf0
commit 84871a6d6f
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -260,7 +260,7 @@ cdef inline double get_pixel2d(double* image, Py_ssize_t rows, Py_ssize_t cols,
"""
if mode == 'C':
if (r < 0) or (r > rows - 1) or (c < 0) or (c > cols - 1):
if (r < 0) or (r >= rows) or (c < 0) or (c >= cols):
return cval
else:
return image[r * cols + c]
@@ -293,14 +293,14 @@ cdef inline double get_pixel3d(double* image, Py_ssize_t rows, Py_ssize_t cols,
"""
if mode == 'C':
if (r < 0) or (r > rows - 1) or (c < 0) or (c > cols - 1):
if (r < 0) or (r >= rows) or (c < 0) or (c >= cols):
return cval
else:
return image[r * cols * dims + c * dims + d]
else:
return image[coord_map(rows, r, mode) * cols * dims
+ coord_map(cols, c, mode) * dims
+ d]
+ coord_map(dims, d, mode)]
cdef inline Py_ssize_t coord_map(Py_ssize_t dim, Py_ssize_t coord, char mode):
+1 -1
View File
@@ -99,7 +99,7 @@ def test_homography():
assert_array_almost_equal(x90, np.rot90(x))
def fast_homography():
def test_fast_homography():
img = img_as_float(rgb2gray(data.lena()))
img = img[:100, :100]