Python Scipy – ndimage.interpolation.geometric_transform() function
Last Updated :
06 Jul, 2021
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
import numpy as np
a = np.arrange( 25 ).reshape(( 5 , 5 ))
print ( 'a' )
print (a)
def shift_func(output_coords):
return (output_coords[ 0 ] - 0.7 , output_coords[ 1 ] - 0.7 )
ndimage.geometric_transform(a, shift_func)
|
Output:
Example 2:
Python3
from scipy import ndimage
import numpy as np
b = np.arrange( 16 ).reshape(( 4 , 4 ))
def shift_func(output_coords):
return (output_coords[ 0 ] - 0.1 , output_coords[ 1 ] - 0.2 )
ndimage.geometric_transform(b, shift_func)
|
Output:
Share your thoughts in the comments
Please Login to comment...