How to Interpolate between ROIs in 3D space

13 ビュー (過去 30 日間)
Kyeong Min Kim
Kyeong Min Kim 2021 年 9 月 8 日
編集済み: darova 2021 年 9 月 8 日
In my code, I want to make code like "Manully Interpolate" in "Volume segmenter app".
The problem occurred when I proceeded in the following order.
1. Draw a star-shaped ROI on the 250th image and a 260th square-shaped ROI.
2. Use the "griddata" command to interpolate between ROIs.
3. In the 250th image, the star-shaped ROI in the before is transformed the pentagonal shape.
I want the star-shaped ROI in the 250th image become a square-shaped ROI as it goes to the 260th image.
My test code:
i=250;
[S.x,S.y,S.z] = ind2sub(size(VOI(:,:,i)),find(VOI(:,:,i) == 1));
S.z(:,1) = i;
i=260;
[E.x,E.y,E.z] = ind2sub(size(VOI(:,:,i)),find(VOI(:,:,i) == 1));
E.z(:,1) = i;
R.x = [S.x;E.x];
R.y = [S.y;E.y];
R.z = [S.z;E.z];
[M.Xq,M.Yq,M.Zq] = meshgrid(1:1:size(VOI,1),1:1:size(VOI,2),250:1:260);
Vq = griddata(R.x,R.y,R.z,ones(size(R.z)),M.Xq,M.Yq,M.Zq);
Vq(Vq>0)=1;
VOI(:,:,250:1:260) = Vq;
result:
Thanks for all cooperation in advance.

回答 (1 件)

darova
darova 2021 年 9 月 8 日
編集済み: darova 2021 年 9 月 8 日
Maybe it will be helpfull
t = linspace(0,2*pi,11)+pi/2;
r = 3 + sin(5*t); % create a start
[x,y] = pol2cart(t,r);
k = convhull(x,y); % find convhull (pentagon)
k(end) = []; % remove last duplicate point
% interpolate the star and pentagon to make the same number of points
p = [0 cumsum(hypot(diff(x),diff(y)))];
p1 = linspace(p(1),p(end));
x1 = interp1(p,x,p1);
y1 = interp1(p,y,p1);
x2 = interp1(p(k),x(k),p1);
y2 = interp1(p(k),y(k),p1);
% create surface
X = [x1;x2];
Y = [y1;y2];
Z = [x1*0;x2*0+5];
contour3(X,Y,Z,5,'linewidth',3)
surface(X,Y,Z,'edgecolor','none')
axis equal
light
view(45,45)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by