Skip to content Skip to sidebar Skip to footer

Numpy Interpolation To Increase Array Size

this question is related with my previous question How to use numpy interpolation to increase a vector size, but this time I'm looking for a method to do increase the 2D array size

Solution 1:

You can use the function map_coordinates from the scipy.ndimage.interpolation module.

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)

Post a Comment for "Numpy Interpolation To Increase Array Size"