Detect boudary of volume

1 vue (au cours des 30 derniers jours)
Hugo
Hugo le 30 Déc 2013
Hi all,
I am trying to create a 3D ROI/Area of the outer boundary from a MRI scan of the Head neck region. Therefore i made it a logical volume and created a code that detects the first and last one in each row and column. But as you might would expect there are some gaps in this boundary which i would like to close. (in other words i want to connect the found coordinates to each other). Can anybody tell me how to do this?
I will place an example image under my code, this is the code i use to detect the boundary:
if true
%
z = size (MRIt);
for j = 1: z(3);
A = squeeze (MRIt(:,:,j));
[row column] = size(A);
Edge = row * zeros(row, column);
Edge1 = row * zeros(row, column);
for i = 1:row;
B = A(i,1:end);
[x,y] = find (B, 1, 'first');
Edge(i,y)= 1 ;
end
for i = 1:row;
B = A(i,1:end);
[x,y] = find (B, 1, 'last');
Edge(i,y)= 1 ;
end
for i = 1:column;
B = A(1:end,i);
[x,y] = find (B, 1, 'first');
Edge(x,i)= 1 ;
end
for i = 1:column;
B = A(1:end,i);
[x,y] = find (B, 1, 'last');
Edge(x,i)= 1 ;
end
MRIe(:,:,j) = Edge;
end
end

Réponses (2)

Walter Roberson
Walter Roberson le 30 Déc 2013
Consider using "morphological closing", http://www.mathworks.com/help/images/ref/bwmorph.html . This would be "dilating" the existing pixels until they flow together to fill the gaps, then eroding back to give you the continuous outline.

Image Analyst
Image Analyst le 30 Déc 2013
You don't want to do it like that. Get rid of all those loops over rows and columns - they're no good as you've already found out. What you should do, if you want to create a binary "shell" of the skull is to call bwperim and assign that to MRIe:
for j = 1: z(3);
A = MRIt(:,:,j) > 0;
MRIe(:,:,j) = bwperim(A);
end

Community Treasure Hunt

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

Start Hunting!

Translated by