HomeLanguagesPython Scipy – ndimage.interpolation.geometric_transform() function

Python Scipy – ndimage.interpolation.geometric_transform() function

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 arrays
import numpy as np
 
 
# creating an 2 dimensional array with
# 5 * 5 dimensions
a = np.arrange(25).reshape((5, 5))
 
print('a')
print(a)
 
 
# reducing dimensions function
def shift_func(output_coords):
     
    return (output_coords[0] - 0.7, output_coords[1] - 0.7)
 
# performing geometric transform operation
ndimage.geometric_transform(a, shift_func)


 

 

Output:

 

 

Example 2:

 

Python3




from scipy import ndimage
 
# importing numpy module for
# processing the arrays
import numpy as np
 
 
# create 4 * 4 dim array.
b = np.arrange(16).reshape((4, 4))
 
# reducing dimensions function
def shift_func(output_coords):
 
    return (output_coords[0] - 0.1, output_coords[1] - 0.2)
 
 
ndimage.geometric_transform(b, shift_func)


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS