Tracking displacement of objects from a stationary point in an image
1 次查看(过去 30 天)
显示 更早的评论
WARNING: I am VERY new to MATLAB so I apologise if this question is naive.
I currently have images (300+) such as the one attached with scattered 'black' markers. Throughout the series of images, the markers move in one direction and in fairly small amounts. The goal is to determine a stationary point (chosen by the user) then find the initial distance between the stationary marker and every other marker, then find how much each marker is displaced in reference to that stationary point.
I was able to loop through all the images and detect all the markers in each by finding their centroids. I then saved them each into cells using:
cent{i} = centroids.
I also was able to let the user choose a stationary point by using:
figure, imshow(firstImage);
stationaryPoint = ginput(1);
Now I am trying to sort out how to find that initial distance then loop through all the images and find how much that distance changes by. Any advice would be more than helpful. Thanks!
0 个评论
回答(1 个)
Image Analyst
2017-8-3
Try this
% Threshold the image
binaryImage = grayImage < 128;
% Label
[labeledImage, numRegions] = bwlabel(binaryImage);
% Find centroids.
props = regionprops(labeledImage, 'Centroid');
xyCentroids = [props.Centroid]; % [x1,y1,x2,y2,x3,y3,x4,y4,.....]
xCentroids = xyCentroids(1:2:end);
yCentroids = xyCentroids(2:2:end);
[x,y] = ginput(1);
distances = sqrt((xCentroids - x) .^ 2 + (yCentroids - y) .^ 2);
That gets the distance of every black blob's centroid to the point the user specifies with ginput().
4 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!