Keypoint based image registration using ImageTransformations.jl warp

I have given two images that I want to warp on top of on another based on a number (here 6) of key points. The key point coordinates are measured using ImageJ.

test_img_1
test_img_2

First, I load the images, and the key points.

using Images 
img1 = Images.load("test_img_1.png");
img2 = Images.load("test_img_2.png");

img1_points = [209.1667 164.5; 139.5 124.1667; 141.1667 201.5; 88.1667 80.8333; 83.1667 164.8333; 82.1667 231.8333]
img2_points = [203.8333 277.1667; 247.5 196.1667; 158.5 193.1667; 296.1667 124.1667; 201.1667 125.8333; 123.8333 124.8333];

Using Julia’s linear solve, I get the affine linear transform:

using ImageTransformations, PyPlot, StaticArrays, CoordinateTransformations
X = hcat(img1_points, ones(6,1))
Y = img2_points

c = (X \ Y)'
b = c[:, 3]
A = c[:, 1:2]

For the images and keypoints I gave above, I get A = [0.0197 -1.1425; 1.2220 0.03]; b = [386.975, 17.312];

Now I define an AffineMap using CoordinateTransformations.jl tform = AffineMap(A, SVector(b...)) and confirm that it maps the original points onto one another.

figure(figsize=(2,2))
for i in 1:6
    scatter(img2_points[i,:]..., c="blue", s=2)
    scatter(tform(img1_points[i,:])..., c="red", s=2)
end
xlim(0,446); ylim(410,0);

image_2024-09-07_050745088

However, when I now try to warp my images onto one another, the key points do not match (bottom-right image).

img1w = warp(img1, tform, axes(img1))

output for img1w .+ img2
image_2024-09-07_050959828

I tried many different images, and it seems that the rotation generally matches, but the scale and translation are off. Maybe I am missing something extremely simple here, but I would appreciate any help to why the image warping does not work in the way I expect it to.

OK, I found the solution myself now.
Basically this: Ordering of axes & dimensions · Issue #173 · JuliaImages/juliaimages.github.io · GitHub
So apparently the x and y axes of the warp function are swapped.
Therefore creating the linear transformation using img1_points[:, [2,1]] and img2_points[:, [2,1]] works.