[vtkusers] Reading nrrd files

Moreland, Kenneth kmorel at sandia.gov
Fri Jan 17 11:08:45 EST 2014


Sam,

I haven't bothered to try to compile your example code, but it looks right. The only issue is that the image viewer is going to expect a 2D image and will probably fail if the output from the NRRD reader is 3D. If you use SetDataVOI to extract a single slice (set the last two extent numbers to be the same), then that should work.

-Ken

From: Sam Raby <rabysam28 at gmail.com<mailto:rabysam28 at gmail.com>>
Date: Thursday, January 16, 2014 9:16 PM
To: Kenneth Moreland <kmorel at sandia.gov<mailto:kmorel at sandia.gov>>
Cc: "vtkusers at vtk.org<mailto:vtkusers at vtk.org>" <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: [EXTERNAL] Re: [vtkusers] Reading nrrd files

Thanks Ken for the reply.
In general, I wanted to know what the typical way of reading a NRRD file is. I thought I should use vtkNrrdReader, but I could not figure it out.

Thanks


On Tue, Jan 14, 2014 at 9:42 PM, Moreland, Kenneth <kmorel at sandia.gov<mailto:kmorel at sandia.gov>> wrote:
Have you tried calling SetDataVOI on the vtkNrrdReader? I don't think it works on ASCII files, but it should work on raw binary encoding.

-Ken

From: Sam Raby <rabysam28 at gmail.com<mailto:rabysam28 at gmail.com>>
Date: Tuesday, January 14, 2014 1:51 PM
To: "vtkusers at vtk.org<mailto:vtkusers at vtk.org>" <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: [EXTERNAL] [vtkusers] Reading nrrd files

Hello

I would like to read a nrrd file and be able to scroll through slices. Is there an example online that can help on how to use vtknrrdreader in order to do that?

The following is what I have written so far.

Thanks
Sam


vtkSmartPointer<vtkNrrdReader> reader = vtkSmartPointer<vtkNrrdReader>::New();
reader->SetFileName(argv[1]);

vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputConnection(reader->GetOutputPort());

vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();

imageViewer->SetupInteractor(renderWindowInteractor);
imageViewer->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->Render();

renderWindowInteractor->Start();

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140117/32b0321a/attachment.html>


More information about the vtkusers mailing list