Tracking displacement of objects from a stationary point in an image

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

Image Analyst
Image Analyst il 3 Ago 2017
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 Commenti
Kimberly Morales
Kimberly Morales il 8 Ago 2017
Modificato: Kimberly Morales il 8 Ago 2017
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!

Accedi per commentare.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by