Rotated Slices of 3D volumes
8 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Rik
on 25 Aug 2018
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 Comments
Rik
on 26 Aug 2018
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.
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!