Clear Filters
Clear Filters

How to find length or perimeter of a irregular boundary

8 views (last 30 days)
Hi,
I work with medical images for some application I have to segment tumors out of CT slices then compute the length of the boundary.
I did the segmentation part and computed the boundaries of slices now how can I compute the perimeter of that boundary. I added a tumor boundary slice for reference. More Info:
These Dicom images even come with pixel spacing which is the distance between each pixel lets say pixelSpacing is 0.7mm Now I have to compute the perimeter length respect to pixel spacing
Please give me some ideas about this
Thanks Gopi

Accepted Answer

KSSV
KSSV on 2 Sep 2016
If you have boundary in hand....calculate the distances of successive points and sum up...wont his give perimeter?
  2 Comments
Gopichandh Danala
Gopichandh Danala on 2 Sep 2016
Yes, u r correct Thanks.I was initially worried about diagonal and adjacent pixels in the boundary but I figured it out. posting the code for reference if anyone needs it
The code for this is:
boundary_dist = 0;
BW = thisBinaryImage;
B = bwboundaries(BW);
imshow(BW, [min(min(BW)) max(max(BW))]); hold on;
for k=1:length(B)
boundary = B{k};
cidx = mod(k,length(colors))+1;
plot(boundary(:,2), boundary(:,1),...
colors(cidx),'LineWidth',2);
end
hold off;
for i = 1:length(boundary)
if i ~= length(boundary)
pixel1 = boundary(i,:);
pixel2 = boundary(i+1,:);
else
pixel1 = boundary(i,:);
pixel2 = boundary(1,:); % when it reaches the last boundary pixel
end
pixel_dist = ((pixel1(1,1) - pixel2(1,1)).^2 + (pixel1(1,2) - pixel2(1,2)).^2).^0.5;
boundary_dist = boundary_dist + pixel_dist;
end
display(boundary_dist)
Output:
boundary_dist =
97.3969696196699
Comment on it if any suggestions.. Thanks, Gopi

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!