In what order should quadrilateral sampling corners be supplied?

QUAD describes the source area with corners ordered upper left, lower left, lower right and upper right for mapping into a rectangle.

Pixel experiment and interpretation

Start with an identity warp of a square with distinct corners. Swapping corners can distort the content while the output shape still looks valid.

from PIL import Image

im=Image.frombytes('L',(2,2),bytes([10,20,30,40]))
out=im.transform((2,2),Image.Transform.QUAD,(0,0,0,2,2,2,2,0))
list(out.tobytes())

Result [10, 20, 30, 40]

中文

四边形采样时四个角应按什么顺序给出?

QUAD 用左上、左下、右下、右上四个源角点描述将要映射到矩形的区域。

像素实验与适用边界

先用四角各异的方形做恒等映射测试。调换相邻角可能扭曲内容,同时仍然输出一张尺寸正确的图片。

from PIL import Image

im=Image.frombytes('L',(2,2),bytes([10,20,30,40]))
out=im.transform((2,2),Image.Transform.QUAD,(0,0,0,2,2,2,2,0))
list(out.tobytes())

结果 [10, 20, 30, 40]

References / 参考来源

Keep reading / 继续阅读