Add (bi-)cubic interpolation

This commit is contained in:
Johannes Schönberger
2012-08-30 09:28:03 +02:00
parent 7a0e0b8f33
commit abe5dc3cec
5 changed files with 113 additions and 14 deletions
+1 -1
View File
@@ -834,7 +834,7 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
# use fast Cython version for specific parameters
fast_modes = ('constant', 'reflect', 'wrap')
if order in (0, 1) and mode in fast_modes and not map_args:
if order in (0, 1, 3) and mode in fast_modes and not map_args:
matrix = None
if isinstance(inverse_map, HOMOGRAPHY_TRANSFORMS):
matrix = inverse_map._matrix
+6 -3
View File
@@ -5,8 +5,9 @@
cimport numpy as np
import numpy as np
from skimage._shared.interpolation cimport (nearest_neighbour,
bilinear_interpolation)
from skimage._shared.interpolation cimport (nearest_neighbour_interpolation,
bilinear_interpolation,
bicubic_interpolation)
cdef inline void _matrix_transform(double x, double y, double* H, double *x_,
@@ -108,9 +109,11 @@ def _warp_fast(np.ndarray image, np.ndarray H, output_shape=None, int order=1,
cdef double (*interp_func)(double*, int, int, double, double,
char, double)
if order == 0:
interp_func = nearest_neighbour
interp_func = nearest_neighbour_interpolation
elif order == 1:
interp_func = bilinear_interpolation
elif order == 3:
interp_func = bicubic_interpolation
for tfr in range(out_r):
for tfc in range(out_c):
+1 -1
View File
@@ -57,7 +57,7 @@ def test_fast_homography():
tform = ProjectiveTransform(H)
coords = warp_coords(tform.inverse, (img.shape[0], img.shape[1]))
for order in range(2):
for order in range(4):
for mode in ('constant', 'reflect', 'wrap'):
p0 = map_coordinates(img, coords, mode=mode, order=order)
p1 = warp(img, tform, mode=mode, order=order)