How to find best match between points in image and a set points ?
2 views (last 30 days)
Show older comments
Hello,
I am a student and have a problem in my project. So I have set of ultrasound images and after thresholding I have a black and white image with 9 points as shown. Now I have a virtual phantom whose geometry is known. So I have created the phantom which have N number of 2D point plane. Now I need to match the image to 2d point plain. I understand that I have to implement RANSAC or similar algorithm but I do not understand how to implement.
2d point plane :
Image:
0 Comments
Answers (1)
Image Analyst
on 4 Oct 2021
I don't think RANSAC is what I'd use. Can't you just say the matching blob is the one that has the closest centroid to the reference? So just use regionprops() to get the centroids. Untested code:
propsRef = regionprops(maskRef, 'Centroid');
xyRef = vertcat(propsRef.Centroid)
propsTest = regionprops(maskTest, 'Centroid');
xyTest = vertcat(propsTest.Centroid)
% Then find the closest blob to each reference blob
for k = 1 : numel(propsTest)
allDistances = sqrt((xyRef(k, 1) - xyTest(:, 1)) .^ 2 + (xyRef(k, 2) - xyTest(:, 2)) .^ 2);
[minDistance, indexOfClosest(k)] = min(allDistances);
% Draw a line between the blobs
line([xyRef(k, 1), xyTest(indexOfClosest(k), 2)], [xyRef(k, 2), xyTest(indexOfClosest(k, 2)], 'Color', 'r', 'LineWidth', 2);
end
Now for each reference blob you know the index of the closest test blob.
You could probably also use knnsearch() instead of the for loop.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!