Tracking displacement of objects from a stationary point in an image

조회 수: 3 (최근 30일)
Kimberly Morales
Kimberly Morales 2017년 8월 2일
댓글: Rajindu Goonewardena 2018년 1월 24일
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!

답변 (1개)

Image Analyst
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
Kimberly Morales
Kimberly Morales 2017년 8월 8일
편집: Kimberly Morales 2017년 8월 8일
Ah yes, I forgot to display an image. I added that in and made sure I am only allowing the user to pick a point in the initial image. However, I am still lost on how to 'store' that initial distance value and how to calculate the distances for every following image.
Right now, I have done everything in a for loop that goes through all of the images. I think I am just getting very confused as to what I should leave in the loop and when I should exit it to perform any calculations. Is this calculating the distance from the stationary point to every marker for ever image? If so, how can I perform calculations on this and export the values into spreadsheets?
distances = sqrt((xCentroids - x) .^ 2 + (yCentroids - y) .^ 2)
You have been a tremendous help!
Rajindu Goonewardena
Rajindu Goonewardena 2018년 1월 24일
is it possible to run the above coins demo in real time ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by