MATLAB Answers

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

5 views (last 30 days)
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:
a = imread('My_image.tif');
bw = a > 40000;
imshow(bw)
[centersBright,radiiBright,metricBright] = imfindcircles(bw,[20 25], ...
'ObjectPolarity','bright','Sensitivity',0.92,'EdgeThreshold',0.1);
stats = regionprops('table',bw,'Centroid',...
'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
distance = pdist2(centers(1,:),centers(2,:));

  0 Comments

Sign in to comment.

Accepted Answer

Pujitha Narra
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!

  0 Comments

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!