Open sudip5052 opened 3 years ago
Consider stacking stacking the 2d images into a 3d Numpy array. You can then move forward to plotting your data as desired in Pyvista. I can provide further suggestions later when I finish optimizing my own code for a similar process.
hi@Jbum21, thanks for the reply. I also need to voxelized each image slice before stacking them. For voxelization, I have a thickness in Z-direction.
hi@Jbum21, thanks for the reply. I also need to voxelized each image slice before stacking them. For voxelization, I have a thickness in Z-direction.
You can open you images into Numpy arrays, assuming that they are of a suitable file format.
Try this code out.
import SimpleITK as sitk
file = 'example/file/path/image.nii'
reader = sitk.ImageFileReader()
reader.SetFileName(file)
image = reader.Execute()
data = sitk.GetArrayFromImage(image)
GetArrayFromImage returns a Numpy array. You can then manipulate your arrays as needed.
hi@Jbum21, thanks for the reply. I also need to voxelized each image slice before stacking them. For voxelization, I have a thickness in Z-direction.
Did you ever get this solution figured out? Probably best to close the issue if so.
@JacobBumgarner no not yet. I would be very thankful if you could help me. Thanks.
What issue are you having? Did you try the example code I pasted for you above?
Hi! I have two queries!! 1)can we voxelize the 2d images? or can we change pixel into voxel?? 2) can we create 3d model by stacking 2d images along z-direction in pyvista ??