HomeLanguagesWand affine_projection distortion method in Python

Wand affine_projection distortion method in Python

Affine Projection is very much similar to scale_rotate_translate distortion type. The only difference is that it exactly needs six real numbers for the distortion arguments.

Scalex, Rotatex, Rotatey, Scaley, Translatex, Translatey

Source Image: Example #1: 

Python3




from collections import namedtuple
# Import Color from wand.color module
from wand.color import Color
# Import Image from wand.image module
from wand.image import Image
 
Point = namedtuple('Point', ['x', 'y'])
 
with Image(filename ='gog.png') as img:
    img.background_color = Color('skyblue')
    img.virtual_pixel = 'background'
    rotate = Point(0.1, 0)
    scale = Point(0.7, 0.6)
    translate = Point(5, 5)
    args = (
        scale.x, rotate.x, rotate.y,
        scale.y, translate.x, translate.y
    )
    img.distort('affine_projection', args)
    img.save(filename ="affinegfg.png")


Output : Example #2: changing argument values. 

Python3




# Import Color from wand.color module
from wand.color import Color
# Import Image from wand.image module
from wand.image import Image
 
with Image(filename ='gog.png') as img:
    img.background_color = Color('skyblue')
    img.virtual_pixel = 'background'
    rotate = Point(0.1, 0.3)
    scale = Point(0.9, 0.2)
    translate = Point(7, 5)
    args = (
        scale.x, rotate.x, rotate.y,
        scale.y, translate.x, translate.y
    )
    img.distort('affine_projection', args)
    img.save(filename ="affinegfg2.png")


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