I need to apply a FFT on a 3D image (.nii.gz .nii files). Therefore I’d need a 3D/4D tensor representation of the vtkNIFTIImageReader in some way.

I’ve found this, but having a tensor for each cell I think is not efficient for my specific problem.

In other words: is there a way to, given a vtkImageReader, retrieve a 3D/4D tensor? If yes, how? I didn’t found much about that and is first time using vtk in c++.

The closest thing I had is: split the image by a verical plane to get the array of 2D images but is not very elegant and maybe not very performant.

vtkNIFTIImageReader can read nii and nii.gz 3D images without problems. These 3D images do not contain tensors, they are simple scalar-valued images with 3 spatial dimensions.

reader->Update();
vtkImageData* data = reader->GetOutput();
vtkPointData* point = data->GetPointData();
vtkDataArray *tensors;
tensors = point->GetScalars();
tensors->Print(std::cout);
double tensor[9];
tensors->GetTuple(28900, tensor);
for(int i = 0; i < 9 ; i++) std::cout << tensor[i] << std::endl;

But printing out I get that size is 62475, when printing the extent I find out that image is 34x50x34 which is not 62475. Am I getting something conceptual wrong or the code to get the scalar valued images wrong?

And also, in the tensor value for whatever point I put I get always the same numbers except the first one:

I need to apply an FFT algorithm of mine that I wrote, not library FFT, on the 3D representation of image. so I’d need the nifti image to be processed pixel by pixel. Storing the pixels in some tensor/3D matrix due to algorithm charateristics.