The given mapping function is used to find, for each point in the output, the corresponding coordinates in the input
Syntax: scipy.ndimage.interpolation.geometric_transform(input, mapping, order=3)
Parameters
- input : takes an array.
- mapping : accepts a tuple data structure similar to length of given output array rank.
- order : int parameter. which is a spline interpolation and the default value is 3.
Returns: Returns an n d array.
Example 1:
Python3
from scipy import ndimage# importing numpy module for# processing the arraysimport numpy as np# creating an 2 dimensional array with # 5 * 5 dimensionsa = np.arrange(25).reshape((5, 5))print('a')print(a)# reducing dimensions functiondef shift_func(output_coords): return (output_coords[0] - 0.7, output_coords[1] - 0.7)# performing geometric transform operationndimage.geometric_transform(a, shift_func) |
Output:
Example 2:
Python3
from scipy import ndimage# importing numpy module for# processing the arraysimport numpy as np# create 4 * 4 dim array.b = np.arrange(16).reshape((4, 4))# reducing dimensions functiondef shift_func(output_coords): return (output_coords[0] - 0.1, output_coords[1] - 0.2)ndimage.geometric_transform(b, shift_func) |
Output:

