Rotated Slices of 3D volumes
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a 3D volume of voxels, this volume only contains integers 1,2 and 3. If I took slices parallel to principal planes ( x-y, x-z, y-z) the slice.CData only contains integers 1,2 and 3, which is correct. But if I used a rotated slice, slice.CData contains numbers inbetween and many NaNs. which may be because the slice does not cut exactly through the voxel. So my question is, is there a method to make slices that gives me the integer of the closest voxel which the slice cut through. To Clarify this , we can run the example given in Matlab documentation:
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
figure
colormap hsv
for k = 0
hsp = surf(linspace(-2,2,20),linspace(-2,2,20),...
zeros(20) + k);
rotate(hsp,[1,-1,1],30)
xd = hsp.XData;
yd = hsp.YData;
zd = hsp.ZData;
delete(hsp)
slice(x,y,z,v,[-2,2],2,-2)
hold on
S = slice(x,y,z,v,xd,yd,zd)
hold off
view(-5,10)
axis([-2.5 2.5 -2 2 -2 4])
drawnow
end
A = S.CData;
unique(A)
0 个评论
采纳的回答
Rik
2018-8-25
You can use round on the output data, although I don't see where your data would have the values you mention. The code below should help.
A = S.CData;
A(A<1)=1;
A(A>3)=3;
A=round(A);
S.CData=A;
3 个评论
Rik
2018-8-26
Glad to be of help. I don't really understand if you still have a question or not, so if you have a follow-up question, please clarify what it is in a comment.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!