I’m a beginner seeking guidance on using VTK and ParaView. I have a specific problem and would appreciate your help.
Objective:
Convert a 3D numpy array to a VTI file.
Save the VTI file to the hard drive.
Display the 3D volume in ParaView.
3.1. Ideally, utilize the GPU for enhanced rendering.
Data:
The 3D volume (numpy array) comprises grayscale images.
Image dimensions: 1028 x 1028.
The numpy array is created by stacking consecutive images.
System Details:
OS: Pop OS 22.04
GPU: Nvidia Geforce 3050 ti
Kernel: 6.6.7-1-liquorix-amd64 (latest version)
Problem:
Objectives 1 and 2 work as intended using the code provided below. However, ParaView encounters issues rendering my volume. Unless my code or the way I try to render the data is faulty.
Anyways, upon loading the data and changing the representation from outline to volume, I receive the following error message:
ERROR: In ./VTK/Rendering/VolumeOpenGL2/vtkVolumeTexture.cxx, line 948
vtkVolumeTexture (0x55d97d59e950): Capabilities check via proxy texture 3D allocation failed!
Which leaves me with a transparent outline of a box with white borders.
I found the following Post, which made clear that the error originates due to the fact that I’m exceeding the RAM/VRAM on my machine. So, after shrinking the volume size I was able to load the data in Paraview as expected.
Remaining problem:
The data doesn’t display the true volume representation, which opens the question if it’s a) the fault of my python script and how I convert the images or b) I’m missing some additional steps I need to perform in the Paraview software.
Perhaps my expression is not quite clear, but what I’m trying to convey is that I anticipated obtaining the RGB representation, essentially having the individual images (slices of the volumes) stacked on top of each other. However, in its current state, it appears that I’m not capturing all the features of the volume.
Again, I’ve mispoken. Sorry for the confusion. I’m interested in the grayscale representation, and not the RGB, since all the individual slices are in the grayscale color format. Hence, vti in scalar format.
Thanks for the code example create vtk image date from numpy array. I just want to mention that the flatten should be in column-major (Fortran-style) order. i.e. data.flatten(order='F'). Otherwise, the data would be disturbed.
I’m having the same issue with having a representation of a full 3d box instead of the volume represented in my binary numpy array, as if the entirety of the numpy array is foreground and i’ve checked as there are no issues with the numpy. Any new ideas on how to fix this?