Reputation: 29
I am new to python. I would like to warp an image such that it fills the closed path (closed path and imported image is shown in the image below). The given closed path has a shape of truncated pie. The outer diameter of truncated pie is 15 units and inner diameter of it is 5 units, and the angle of that pie is 60 degrees. I've added the external shape as an example. Is it possible to fill the image within any kind of closed path. Can you please suggest python libraries to be used or it'd be great if you can share some code.
I was also trying to work with corner detection algorithms and making them to stick with map function, but I can't.
Upvotes: 1
Views: 2200
Reputation: 53091
You can do that in Python Wand, which is based upon Imagemagick.
Input:
from wand.image import Image
from wand.display import display
with Image(filename='taj_mahal.jpg') as img:
print(img.size)
img.virtual_pixel = 'white'
img.distort('arc', (60,180))
img.save(filename='taj_mahal_arc.jpg')
display(img)
Result:
The first argument in the arc is the arc angular spread. The second argument is the rotation on the circle where the arc is generated. See https://imagemagick.org/Usage/distorts/#arc
Upvotes: 7