[vtkusers] vtkImageViewer2 is resetting the z spacing
Mark Roden
mmroden at gmail.com
Wed Oct 13 13:53:56 EDT 2010
Hi all,
I have a medical image dataset that has a z spacing of 3.0 pixels (1.17 in
the x and y dimensions). I'm using Java wrapping vtk and gdcm on 64 bit
windows 7.
I load the image using vtkGDCMImageReader and the IPPSorter, and in the end,
do this to set the proper z spacing:
double[] spacing = new double[3];
spacing = gdcmReader.GetOutput().GetSpacing();
spacing[2] = sorter.GetZSpacing();
imageData = gdcmReader.GetOutput();
imageData.SetSpacing(spacing);
Then I try to load three views on the data with vtkImageViewer2. The
following functions reset the z spacing to be 1.0:
vtkImageViewer2 imageViewer = new vtkImageViewer2();
imageViewer.SetInput(imageData); //resets z spacing to 1.0
imageData.SetSpacing(spacing); //attempt to fix
imageViewer.SetSlice((imageViewer.GetSliceMax() + imageViewer.GetSliceMin())
/ 2); //resets z spacing to 1.0
imageData.SetSpacing(spacing); //attempt to fix
//navigation slider on display
slider = new JSlider();
slider.setOrientation(JSlider.VERTICAL);
slider.setMinimum(imageViewer.GetSliceMin());//resets
slider.setMaximum(imageViewer.GetSliceMax());//resets
imageViewer.GetInput().SetSpacing(spacing);//attempt to fix
Even with all those attempts to fix, the XZ and YZ orientations still
display the image as if the z spacing is 1.0, instead of 3.0.
What's going on? Why is vtkImageViewer2 changing ANYTHING to do with the
original image, rather than just straight up displaying what it's told to
display?
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101013/c5e66d96/attachment.htm>
More information about the vtkusers
mailing list