Wand affine distort() function in Python
Last Updated :
27 Feb, 2023
Affine distortion method performs shear operation to the image. Arguments are similar to perspective distortion method, but only need a pair of 3 points and 12 Real numbers in the manner shown below:
src1x, src1y, dst1x, dst1y,
src2x, src2y, dst2x, dst2y,
src3x, src3y, dst3x, dst3y
Syntax: wand.image.distort(‘affine’, arguments)
Input Image:
Example #1:
Python3
from wand.color import Color
from wand.image import Image
with Image(filename = 'gog.png' ) as img:
img.resize( 140 , 92 )
img.background_color = Color( 'skyblue' )
img.virtual_pixel = 'background'
args = (
10 , 10 , 15 , 15 ,
139 , 0 , 100 , 20 ,
0 , 92 , 50 , 80
)
img.distort( 'affine' , args)
img.save(filename = "affinegfg.png" )
|
Output:
Example #2:
changing argument values.
Python3
from wand.color import Color
from wand.image import Image
with Image(filename = 'gog.png' ) as img:
img.resize( 140 , 92 )
img.background_color = Color( 'skyblue' )
img.virtual_pixel = 'background'
args = (
20 , 21 , 12 , 11 ,
38 , 1 , 17 , 0 ,
7 , 92 , 50 , 80
)
img.distort( 'affine' , args)
img.save(filename = "affinegfg2.png" )
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...