[Images.jl] Projective Transform based on Matrix

How I can apply an Projective Transform (or an Affine) to a image based on a transform matrix ?

In phyton I can do this using:

tform = transform.ProjectiveTransform(matrix=matrix)

An example in Python (from Documentation):

from skimage import data

from skimage import transform

from skimage import img_as_float

from skimage import transform

img= img_as_float([data.chelsea])

# Define the transformation matrix
matrix = [[1.0060923472904499, 6.8872896368778122e-002, -4.7977514755983762e+001], [-8.4231722023165673e-002, 9.8715396636307107e-001, 6.7039265228088230e+000], [1.7669387251995766e-015, -3.0176300815504264e-015, 9.9999999999999978e-001]];

# Create the projective transform

tform = transform.ProjectiveTransform(matrix=matrix)

tf_img = transform.warp(img, tform.inverse)

fig, ax = plt.subplots()


ax.set_title('Projective transformation')


It looks like a nice API for this is an outstanding feature requests in ImageTransformations.jl. The core functionality is there as warp, but it takes some doing to make it work currently.

1 Like

Swirl effect using warp operation · ImageTransformations might be a good example to start with.

Simply put, you need a coordinate map function f that receives SVector{N} and outputs SVector{N], just like the swirl_map function in the above example.

As @mbauman said, wrapping this into a function would be a good feature for ImageTransformations. I’m happy to see and merge a PR, but I don’t have time to do the devs myself.