I am having trouble looping through this. I have 20 images of rising bubbles against a black background that I am looking to loop through. The images are of blobs and each blob has it's own centroid. (about 50 or so per image). What I am trying to do is record the nearest blob from image to image. I have been able to do this manually from one image to the next but I am having trouble getting this into a for loop. I am sending all of this to an index matrix that looks something like this:
with the first number being the original blob in the first image and the second number being the closest blob in the next image (presumably the same blob that is moving upwards).
Below is my code snippet:
for k = 1:20
k = k
j = k+1;
index_matrix = [1:1:length(centroid(k).X)]';
for m = 1:length(centroid(k).X)
for ii = 1:length(centroid(j).X)
Dist(ii) = sqrt( (centroid(k).X(m)-centroid(j).X(ii))^2 + (centroid(k).Y(m)-centroid(j).Y(ii))^2);
[dumb, ind] = min(Dist);
index_matrix(m,j) = ind;
The error that I am getting is that the Index exceeds the number of array elements .