How to find length or perimeter of a irregular boundary

8 次查看(过去 30 天)
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

采纳的回答

KSSV
KSSV 2016-9-2
If you have boundary in hand....calculate the distances of successive points and sum up...wont his give perimeter?
  2 个评论
Gopichandh Danala
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

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by