[vtkusers] vtkImageViewer2 is resetting the z spacing

Bill Lorensen bill.lorensen at gmail.com
Sun Oct 17 08:43:17 EDT 2010


I'm pretty sure that ImageViewer2 does not change the spacing. It also
does not interpolate between slices. Your calculation of the slice #
works on integer slice numbers and not in physical coordinates. If you
want to display slices between the original data, then you need to run
vtkImageResample.

Bill

On Wed, Oct 13, 2010 at 1:53 PM, Mark Roden <mmroden at gmail.com> wrote:
> 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
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list