Julia:使用Compose模块进行仿射变换

时间:2017-01-18 07:45:51

标签: julia

是否可以通过Compose.jl的矩阵转换图像(如下所示)? 如果是这样,你能提供一个简单的例子吗?

我知道rotation方法中的Compose.context关键字参数,但我想知道是否存在类似于一般仿射变换的相似内容。谢谢!

shear transformation

1 个答案:

答案 0 :(得分:1)

您可以使用 Shear。例如,您可以变换

enter image description here

来自教程(下面的代码)

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")))

然后用

剪掉它
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")))

获得

enter image description here