Friday, November 14, 2025
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
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6837 POSTS0 COMMENTS
Umr Jansen
6839 POSTS0 COMMENTS