Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia: Affine Transformations with Compose module

Tags:

julia

Is it possible to transform images (as shown below) via matrices with Compose.jl? If so, could you please provide a simple example?

I'm aware of the rotation keyword argument in the Compose.context method, but I was wondering if there was something similar for general affine transformations. Thanks!

shear transformation

like image 567
Alain Avatar asked Nov 08 '22 03:11

Alain


1 Answers

You can use Shear. For example, you can transform

enter image description here

from the tutorials (code below)

julia> composition = compose(context(),
               (context(units=UnitBox(0, 0, 1000, 1000)),
                polygon([(0, 1000), (500, 1000), (500, 0)]),
                fill("tomato")),
               (context(),
                polygon([(1, 1), (0.5, 1), (0.5, 0)]),
                fill("bisque")))

and shear it with

julia> composition_sheared = compose(context(shear=Shear(0.3,0.0,0.5,1.0)),
               (context(units=UnitBox(0, 0, 1000, 1000)),
                polygon([(0, 1000), (500, 1000), (500, 0)]),
                fill("tomato")),
               (context(),
                polygon([(1, 1), (0.5, 1), (0.5, 0)]),
                fill("bisque")))

to obtain

enter image description here

like image 102
Benoit Pasquier Avatar answered Nov 15 '22 06:11

Benoit Pasquier