From 146d5a3f5b460de4673f1e63fef1a6b21b8b8b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Thu, 30 Aug 2012 17:13:30 +0200 Subject: [PATCH] Remove duplicate subtraction --- skimage/_shared/interpolation.pyx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/skimage/_shared/interpolation.pyx b/skimage/_shared/interpolation.pyx index fc247530..ad8aae4b 100644 --- a/skimage/_shared/interpolation.pyx +++ b/skimage/_shared/interpolation.pyx @@ -123,28 +123,27 @@ cdef inline double bicubic_interpolation(double* image, int rows, int cols, """ - cdef int r0 = r - cdef int c0 = c + cdef int r0 = r - 1 + cdef int c0 = c - 1 if r < 0: r0 -= 1 if c < 0: c0 -= 1 # scale position to range [0, 1] - cdef double xr = (r - r0 + 1) / 3 - cdef double xc = (c - c0 + 1) / 3 + cdef double xr = (r - r0) / 3 + cdef double xc = (c - c0) / 3 cdef double fc[4], fr[4] cdef int pr, pc - for pr in range(r0 - 1, r0 + 3): + # row-wise cubic interpolation + for pr in range(r0, r0 + 4): + for pc in range(c0, c0 + 4): + fc[pc - c0] = get_pixel(image, rows, cols, pr, pc, mode, cval) + fr[pr - r0] = cubic_interpolation(xc, fc) - # do row-wise cubic interpolation - for pc in range(c0 - 1, c0 + 3): - fc[pc + 1 - c0] = get_pixel(image, rows, cols, pr, pc, mode, cval) - fr[pr + 1 - r0] = cubic_interpolation(xc, fc) - - # do cubic interpolation for interpolated values of each row + # cubic interpolation for interpolated values of each row return cubic_interpolation(xr, fr)