Skip to content
Related Articles

Related Articles

Improve Article

Python PIL | ImagePath.Path.map() method

  • Last Updated : 02 Aug, 2019

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImagePath module is used to store and manipulate 2-dimensional vector data. Path objects can be passed to the methods on the ImageDraw module.

ImagePath.Path.map() maps the path through the function.

Syntax: ImagePath.Path.map(function)

Parameters:
arguments-creating a list.
range– assigning a range.



Returns: (x0, y0)




   
  
# from PIL importing ImagePath
from PIL import ImagePath
  
# creating a list to map
getbox = list(zip(range(3, 41, 1), range(11, 22, 2)))
result = ImagePath.Path(getbox)
  
# using map function
b = result.map(lambda x, y: (x + 2, y + 2))
a = result.tolist()
print(a)

Output:

[(5.0, 13.0), (6.0, 15.0), (7.0, 17.0), (8.0, 19.0), (9.0, 21.0), (10.0, 23.0)]

Another Example: changing parameters.




   
# from PIL importing ImagePath
from PIL import ImagePath
  
# creating a list to map
getbox = list(zip(range(3, 41, 1), range(11, 22, 2)))
result = ImagePath.Path(getbox)
  
# using map function
b = result.map(lambda x, y: (x + 12, y + 12))
a = result.tolist()
print(a)

Output:

[(15.0, 23.0), (16.0, 25.0), (17.0, 27.0), (18.0, 29.0), (19.0, 31.0), (20.0, 33.0)]

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :