[vtkusers] vtkImageViewer2 is resetting the z spacing

Mark Roden mmroden at gmail.com
Sun Oct 17 13:26:11 EDT 2010


Hi Bill,

When I stepped through the code I originally provided, the double[] returned
by the image changed.  The Z Spacing was changed from 3.0 back to 1.0.  I
don't know what, exactly, was doing the changing, all I know is that when I
called functiosn on the ImageViewer2 the spacing changed.

Mathieu pointed out the flaw in my logic:in VTK, the change will only happen
if the image is original, rather than derived from a filter.  Since I was
loading my image via a reader, changing the spacing by a call on the image
itself would do nothing when subsequent operations are used.  It might be
helpful to novices in the library, such as myself, to remove those functions
that don't only work if the dataset is 'original' (ie, not derived from
something else)-- in this case, the vtkChangeImageInformation should be
used, and having the other function call there only serves to add to
confusion.

Thanks,
Mark

On Sun, Oct 17, 2010 at 5:43 AM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> 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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101017/99ff8116/attachment.htm>


More information about the vtkusers mailing list