Note to readers: This is the next question, refer to them for background:
The process is similar to what I showed earlier. Below I use the images from your previous question (since you provided only one, I created the other by first turning it 10 degrees).
Let's start by defining lines for two images. We do this using the Hough transform function . This is what looks like both images:
Next, we want to perform image registration using the endpoints of the line as control points. Firstly, we guarantee that the dots match each other in two images. I do this by calculating the convex hull using convhull
, which automatically sorts them clockwise (or is it in the opposite direction!). The numbers shown above indicate the order.
Finally, we use the cp2tform
function to get the transformation matrix that we use to align the image and extract translation, rotation and scaling.
Below is the full code:
%% # Step 1: read and prepare images %
And here is a function that extracts the endpoints of lines:
function points = getCross(I) %
with the result:
scale = 1.0025 rotation = -9.7041 translation = 32.5270 -38.5021
The rotation is restored by almost 10 degrees (with some unavoidable error), and scaling is effective 1 (which means no scaling). Note that in the example above there was a translation component because the rotation was not performed around the center of the cross sign).
source share