如何通过matlab绘制具有手动分段点的曲面

时间:2016-03-24 16:15:42

标签: matlab

我有一系列MRI图像和这些图像的手动分割点。我从这些点为每个图像绘制轮廓,然后创建从MRI图像分割的2D切片,然后创建表面(但不是封闭的表面)。绘制曲面的代码:

a=manual_seg_32points{4,1};%base slices 
find(a(:,1)==0); a(33,:)=a(1,:);
c=a(1:33,1); r=a(1:33,2); I=zeros(256,256);
BW = roipoly(I,c,r);
c=a(34:end,1); r=a(34:end,2); 
BW2 = roipoly(I,c,r); img1=BW2-BW;
J1=regiongrowing(img1,127,106,0); A(:,:,1)=J1;
...% other slices

 a=manual_seg_32points{12,1};% apex slices that is my problem 
 a(33,:)=a(1,:); c=a(1:33,1); r=a(1:33,2);
 I=zeros(256,256); BW = roipoly(I,c,r);
 c=a(34:end,1); r=a(34:end,2); BW2 = roipoly(I,c,r);
 img9=BW2-BW; J =imfill(img9); A(:,:,9)=J;
 figure, A = smooth3(A,'box',5); isosurface(A)

链接到我的表面:

https://www.dropbox.com/s/t5rfubul9jo7p7a/surface.jpg?dl=0

我的问题是表面的顶点不是封闭的表面。

manual_seg_32points{12,1}:

a=[124.290398397716 112.993589922720
123.360490116899    113.433024223630
122.696554618553    114.228142491073
122.240659419179    115.164892151512
121.904330627003    116.148292419361
121.629809184732    117.151412898677
121.411119701070    118.171577347662
121.361312489319    119.209208611855
121.795577123414    120.125155520359
122.730360311063    120.553614196853
123.752784629366    120.752546298127
124.777931633153    120.931783414993
125.785845971722    121.187051100475
126.811137309477    121.350267436071
127.777549541786    121.024236032707
128.550585388039    120.329119485313
129.279626787266    119.587463114350
130.054430557738    118.885677440694
130.894112048940    118.261603943323
131.759534051351    117.676977241775
132.611320069990    117.069868307924
133.354306198596    116.342500487078
133.487240066053    115.356656677064
132.871142112696    114.524745574922
132.053534989248    113.880005777936
131.168806238237    113.326813950244
130.237617352358    112.862512508353
129.252981953731    112.533666553374
128.219873783528    112.389529552802
127.181889931242    112.453162176211
126.173379517507    112.698535358198
125.324482620276    113.026654609951
0   0
116.280357730133    116.131510683795
116.639418206333    118.611026823933
117.100706035106    121.080625476942
117.592381123267    123.542050022617
118.770583155496    125.679083715477
121.209002506250    126.151896521635
123.697934849829    126.416506763601
126.078512618489    127.174954091598
128.440236818969    128.003195701707
130.929466771853    128.206913366612
133.079191573862    127.040996916388
134.522421847287    124.996272941743
135.939542795101    122.924398485659
137.493423666004    120.943177015647
138.972751773194    118.922242048752
140.031123651962    116.659103101640
140.288302576391    114.166657546469
140.072524390763    111.665956316405
138.979477960158    109.449345102212
137.369518593923    107.530296576928
135.746118466862    105.615414177897
133.958538214113    103.859807668618
131.831269799620    102.552395299518
129.358786281538    102.364684995799
126.862435245289    102.301635326567
124.360602132170    102.153088846784
122.156685894142    103.307274881140
120.390308539596    105.103678086996
118.684672826086    106.956294970030
117.386644708586    109.049527895091
116.729976296552    111.469329028667
116.227150836323    113.588103102600];

如何用这些点绘制像我的图像一样的闭合曲面?或者,如何在MRI图像中放置手动分割点并获得分割图像?

1 个答案:

答案 0 :(得分:0)

在Matlab上做一个封闭的isosurface,只需

B=zeros( size(A)+2 );
B(2:end-1,2:end-1;2:end-1)=A;
[ v, f ]  = isosurface( B );
h = patch('Faces',f,'Vertices',v);

因此零填充。