mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-02 18:31:49 +08:00
Revert to non parallelized execution
This commit is contained in:
@@ -2,23 +2,23 @@
|
||||
cdef inline double nearest_neighbour_interpolation(double* image, int rows,
|
||||
int cols, double r,
|
||||
double c, char mode,
|
||||
double cval) nogil
|
||||
double cval)
|
||||
|
||||
cdef inline double bilinear_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil
|
||||
double cval)
|
||||
|
||||
cdef inline double quadratic_interpolation(double x, double[3] f) nogil
|
||||
cdef inline double quadratic_interpolation(double x, double[3] f)
|
||||
cdef inline double biquadratic_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil
|
||||
double cval)
|
||||
|
||||
cdef inline double cubic_interpolation(double x, double[4] f) nogil
|
||||
cdef inline double cubic_interpolation(double x, double[4] f)
|
||||
cdef inline double bicubic_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil
|
||||
double cval)
|
||||
|
||||
cdef inline double get_pixel(double* image, int rows, int cols, int r, int c,
|
||||
char mode, double cval) nogil
|
||||
char mode, double cval)
|
||||
|
||||
cdef inline int coord_map(int dim, int coord, char mode) nogil
|
||||
cdef inline int coord_map(int dim, int coord, char mode)
|
||||
|
||||
@@ -8,7 +8,7 @@ from libc.math cimport ceil, floor, round
|
||||
cdef inline double nearest_neighbour_interpolation(double* image, int rows,
|
||||
int cols, double r,
|
||||
double c, char mode,
|
||||
double cval) nogil:
|
||||
double cval):
|
||||
"""Nearest neighbour interpolation at a given position in the image.
|
||||
|
||||
Parameters
|
||||
@@ -37,7 +37,7 @@ cdef inline double nearest_neighbour_interpolation(double* image, int rows,
|
||||
|
||||
cdef inline double bilinear_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil:
|
||||
double cval):
|
||||
"""Bilinear interpolation at a given position in the image.
|
||||
|
||||
Parameters
|
||||
@@ -75,7 +75,7 @@ cdef inline double bilinear_interpolation(double* image, int rows, int cols,
|
||||
return (1 - dr) * top + dr * bottom
|
||||
|
||||
|
||||
cdef inline double quadratic_interpolation(double x, double[3] f) nogil:
|
||||
cdef inline double quadratic_interpolation(double x, double[3] f):
|
||||
"""Quadratic interpolation.
|
||||
|
||||
Parameters
|
||||
@@ -96,7 +96,7 @@ cdef inline double quadratic_interpolation(double x, double[3] f) nogil:
|
||||
|
||||
cdef inline double biquadratic_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil:
|
||||
double cval):
|
||||
"""Biquadratic interpolation at a given position in the image.
|
||||
|
||||
Parameters
|
||||
@@ -147,7 +147,7 @@ cdef inline double biquadratic_interpolation(double* image, int rows, int cols,
|
||||
return quadratic_interpolation(xr, fr)
|
||||
|
||||
|
||||
cdef inline double cubic_interpolation(double x, double[4] f) nogil:
|
||||
cdef inline double cubic_interpolation(double x, double[4] f):
|
||||
"""Cubic interpolation.
|
||||
|
||||
Parameters
|
||||
@@ -172,7 +172,7 @@ cdef inline double cubic_interpolation(double x, double[4] f) nogil:
|
||||
|
||||
cdef inline double bicubic_interpolation(double* image, int rows, int cols,
|
||||
double r, double c, char mode,
|
||||
double cval) nogil:
|
||||
double cval):
|
||||
"""Bicubic interpolation at a given position in the image.
|
||||
|
||||
Parameters
|
||||
@@ -220,7 +220,7 @@ cdef inline double bicubic_interpolation(double* image, int rows, int cols,
|
||||
|
||||
|
||||
cdef inline double get_pixel(double* image, int rows, int cols, int r, int c,
|
||||
char mode, double cval) nogil:
|
||||
char mode, double cval):
|
||||
"""Get a pixel from the image, taking wrapping mode into consideration.
|
||||
|
||||
Parameters
|
||||
@@ -251,7 +251,7 @@ cdef inline double get_pixel(double* image, int rows, int cols, int r, int c,
|
||||
return image[coord_map(rows, r, mode) * cols + coord_map(cols, c, mode)]
|
||||
|
||||
|
||||
cdef inline int coord_map(int dim, int coord, char mode) nogil:
|
||||
cdef inline int coord_map(int dim, int coord, char mode):
|
||||
"""
|
||||
Wrap a coordinate, according to a given mode.
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
cimport numpy as np
|
||||
import numpy as np
|
||||
from cython.parallel import prange
|
||||
from skimage._shared.interpolation cimport (nearest_neighbour_interpolation,
|
||||
bilinear_interpolation,
|
||||
biquadratic_interpolation,
|
||||
@@ -13,7 +12,7 @@ from skimage._shared.interpolation cimport (nearest_neighbour_interpolation,
|
||||
|
||||
|
||||
cdef inline void _matrix_transform(double x, double y, double* H, double *x_,
|
||||
double *y_) nogil:
|
||||
double *y_):
|
||||
"""Apply a homography to a coordinate.
|
||||
|
||||
Parameters
|
||||
@@ -102,9 +101,8 @@ def _warp_fast(np.ndarray image, np.ndarray H, output_shape=None, int order=1,
|
||||
out_r = output_shape[0]
|
||||
out_c = output_shape[1]
|
||||
|
||||
cdef np.ndarray[dtype=np.double_t, ndim=2, mode="c"] out = \
|
||||
cdef np.ndarray[dtype=np.double_t, ndim=2] out = \
|
||||
np.zeros((out_r, out_c), dtype=np.double)
|
||||
cdef double* out_data = <double*>out.data
|
||||
|
||||
cdef int tfr, tfc
|
||||
cdef double r, c
|
||||
@@ -112,7 +110,7 @@ def _warp_fast(np.ndarray image, np.ndarray H, output_shape=None, int order=1,
|
||||
cdef int cols = img.shape[1]
|
||||
|
||||
cdef double (*interp_func)(double*, int, int, double, double,
|
||||
char, double) nogil
|
||||
char, double)
|
||||
if order == 0:
|
||||
interp_func = nearest_neighbour_interpolation
|
||||
elif order == 1:
|
||||
@@ -122,12 +120,10 @@ def _warp_fast(np.ndarray image, np.ndarray H, output_shape=None, int order=1,
|
||||
elif order == 3:
|
||||
interp_func = bicubic_interpolation
|
||||
|
||||
for tfr in prange(out_r, nogil=True):
|
||||
# make r, c thread local variables
|
||||
r = c = 0
|
||||
for tfr in range(out_r):
|
||||
for tfc in range(out_c):
|
||||
_matrix_transform(tfc, tfr, <double*>M.data, &c, &r)
|
||||
out_data[tfr * out_r + tfc] = interp_func(<double*>img.data, rows,
|
||||
cols, r, c, mode_c, cval)
|
||||
out[tfr, tfc] = interp_func(<double*>img.data, rows, cols, r, c,
|
||||
mode_c, cval)
|
||||
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user