# Opening and finding distance between circles in multiple images from a Tiff Stack

5 views (last 30 days)
Noah Wegley on 20 Feb 2020
Answered: Pujitha Narra on 26 Feb 2020
I am trying to write a code that would allow me to calculate the distance between circles in 100 images all from one .tif file. I was able to get the code to work for the first image in the stack, and am now stuck on how to get the code to look at the other 99 images in the stack. Any ideas?
Also, after computing the distance on all of the images, I want matlab to give me a matrix with all of the data, how do I do that?
Here is what I have so far:
bw = a > 40000;
imshow(bw)
'ObjectPolarity','bright','Sensitivity',0.92,'EdgeThreshold',0.1);
stats = regionprops('table',bw,'Centroid',...
'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
distance = pdist2(centers(1,:),centers(2,:));

Pujitha Narra on 26 Feb 2020
Hi,
You can use indexing along with 'imread' like this:
a = imread('My_image.tif', i); % ith image in the stack
Using this with a loop would help.
For the second part, you could use concatenation like this:
distance = [];
% Calculate the values for a new image
distance = [distance; new_values]; % Concatenate it the existing data
Hope that helps!