Clear Filters
Clear Filters

Find location of 2 black dots in the image

1 view (last 30 days)
Hi,
I have a videfile with around 330 frames in each frame I have 2 dots whose location changes in each frame. How can i find the location(x, y value) of 2 dots in a given frame. See attached frame image.
Thanks,

Accepted Answer

Walter Roberson
Walter Roberson on 6 Feb 2023
See regionprops probably with 'Centroid'
  3 Comments
Walter Roberson
Walter Roberson on 6 Feb 2023
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1286115/im1.png';
a = imread(filename);
BW = imbinarize(imcomplement(rgb2gray(a)));
BW = bwareafilt(BW, 2);
s = regionprops(BW, 'centroid');
centroids = cat(1, s.Centroid);
image(a);
hold on
scatter(centroids(:,1), centroids(:,2), 'r*')
hold off
The small black marks on the image are the place the time is written.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!