Rotated Slices of 3D volumes

8 visualizaciones (últimos 30 días)
Ahmed Zankoor
Ahmed Zankoor el 25 de Ag. de 2018
Comentada: Ahmed Zankoor el 22 de Oct. de 2018
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)

Respuesta aceptada

Rik
Rik el 25 de Ag. de 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 comentarios
Rik
Rik el 26 de Ag. de 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.
Ahmed Zankoor
Ahmed Zankoor el 22 de Oct. de 2018
Hello rik, it has been a while since this discussion, but I just wanted to say that using 'nearest' option in slicing can be useful to avoid the previous interpolation. S = slice(V,Xp,Yp,Zp,'nearest');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by