How to find length or perimeter of a irregular boundary

조회 수: 3 (최근 30일)
Gopichandh Danala
Gopichandh Danala 2016년 9월 1일
댓글: Akshay Rao 2017년 6월 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
Gopichandh Danala 2016년 9월 2일
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
Akshay  Rao
Akshay Rao 2017년 6월 30일
Thanks for the help! I found this useful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by