Rotated Slices of 3D volumes
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Rik
le 25 Août 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 commentaires
Rik
le 26 Août 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!