Reputation: 79
I am trying to write a simple program to read or visualise nifti image using ITK libraries.
using PixelType = unsigned char;
using ImageType = itk::Image< PixelType, Dimension >;
using ReaderType = itk::ImageFileReader< ImageType >;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
From these code lines, I can access number of dimensions, and pixel type. But, I am still lost how I can access the pixels values of the image? I imagine I should have 3D array contains different values of pixels (which represents the nifti image). Which methods I should address?
Also, I have tried to use VTK to visualize the image, and create new format (PNG, or PPM) for the image, but I couldn't do it. Any code example is much appreciated. Thank you!
Edit:
I can now get the pixel values after casting the DS PixelType to int. Thank you.
But, When I used the class ImageToVTKImageFilter.cxx
, I got the screenshot attached, where I can't see any image. And it gets brighter if I moved the mouse over it. Do you have any explanation for that?
Upvotes: 1
Views: 754