I am trying to implement an equivalent of imagemagick perspective distort using libvips http://www.imagemagick.org/Usage/distorts/#perspective
As per this answer How to perform perspective distort transformation in VIPS? it can be achieved using mapim
However I don't understand how can I convert a set of tie points as used in imagemagick into a trasform matrix of this kind
T = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0003, 0.0001]
The transform vector can be found by solving this system of linear equations:
where x0.., y0.. are the target coordinates, u0.. v0.. are source coordinates.
Here is how to solve it using gonum package in go: