Tracking displacement of objects from a stationary point in an image
조회 수: 3 (최근 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!