0
votes

I am using matlab's built in function called Procrustes to see the rotation translation and scale between two images. But, I am just using coordinates of the brightest points in the image and rotating these coordinates about the center of the image. Procrustes compares two matrices and gives you the rotation, translation, and scale. However, procrustes only works correctly if the matrices are in the same order for comparison.

I am given an image and a separate comparison coordinate matrix. The end goal is to find how much the image has been rotated, translated, and scaled compared to the coordinate matrix. I can just use Procrustes for this, but I need to correctly order the coordinates found from the image to match the order in the comparison coordinate matrix. My thought was to compare the distance between every possible combination of points in the coordinate matrix and compare it to the coordinates that I find in the picture. I just do not know how to write this code due to the fact if there is n coordinates, there will be n! possible combinations.

1
So much text and so little information! Your title can be demoed with few lines. Read How to Ask and minimal reproducible exampleAnder Biguri
Also, just have a look at the image processing literature. You want to find an affine transform, this is common in image processingAnder Biguri
@AnderBiguri: It is not so much about the transformation I think. Affine or Procrustes are both ok. It is about matching the registered points to one another. To find minimal distances between two sets of points.Gelliant
@Dalton Macres: Are there exactly N coordinates in both matrices? In other words: Is each coordinate always matched to another coordinate in the other matrix?Gelliant
Yes, both matrices contain the same number N coordinates.Dalton Macres

1 Answers

0
votes

Just searching for the shortest distance is not so hard.

A = rand(1E4,2);
B = rand(1E4,2);
tic
idx = nan(1,1E4);
for ct = 1:size(A,1)
    d = sum((A(ct,:)-B).^2,2);
    idx(ct) = find(d==min(d));
end
toc

plot(A(1:10,1),A(1:10,2),'.r',B(idx(1:10),1),B(idx(1:10),2),'.b')

takes half a second on my PC.

The problems can start when two points in set A are matched to the same location in set B.

length(unique(idx))==length(idx)

This can be solved in several ways. The best (imho) is to determine a probability that point B matches with point A based on the distance (usually something that decreases exponentially), and solve for the most probable situation.

A simpler method (but more error prone) is to remove the matched point from set B.