this question is related with my previous question <a href="https://stackoverflow.com/questions/32724546/numpy-interpolation-to-increase-a-vector-size" rel="nofollow">How to use numpy interpolation to increase a vector size</a>, but this time I'm looking for a method to do increase the 2D array size and not a vector.
The idea is that I have couples of coordinates
(x;y) and I want to smooth the line with a desired number of
for a Vector solution I use the answer of @AGML user with very good results
from scipy.interpolate import UnivariateSpline def enlargeVector(vector, size): old_indices = np.arange(0,len(a)) new_length = 11 new_indices = np.linspace(0,len(a)-1,new_length) spl = UnivariateSpline(old_indices,a,k=3,s=0) return spl(new_indices)Answer1:
You can use the function <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.interpolation.map_coordinates.html" rel="nofollow">
map_coordinates</a> from the
import numpy as np from scipy.ndimage.interpolation import map_coordinates A = np.random.random((10,10)) new_dims =  for original_length, new_length in zip(A.shape, (100,100)): new_dims.append(np.linspace(0, original_length-1, new_length)) coords = np.meshgrid(*new_dims, indexing='ij') B = map_coordinates(A, coords)