Hi Bill,<br><br>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.<br>
<br>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.<br>
<br>Thanks,<br>Mark<br><br><div class="gmail_quote">On Sun, Oct 17, 2010 at 5:43 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm pretty sure that ImageViewer2 does not change the spacing. It also<br>
does not interpolate between slices. Your calculation of the slice #<br>
works on integer slice numbers and not in physical coordinates. If you<br>
want to display slices between the original data, then you need to run<br>
vtkImageResample.<br>
<font color="#888888"><br>
Bill<br>
</font><div><div></div><div class="h5"><br>
On Wed, Oct 13, 2010 at 1:53 PM, Mark Roden <<a href="mailto:mmroden@gmail.com">mmroden@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> I have a medical image dataset that has a z spacing of 3.0 pixels (1.17 in<br>
> the x and y dimensions). I'm using Java wrapping vtk and gdcm on 64 bit<br>
> windows 7.<br>
><br>
> I load the image using vtkGDCMImageReader and the IPPSorter, and in the end,<br>
> do this to set the proper z spacing:<br>
><br>
> double[] spacing = new double[3];<br>
> spacing = gdcmReader.GetOutput().GetSpacing();<br>
> spacing[2] = sorter.GetZSpacing();<br>
> imageData = gdcmReader.GetOutput();<br>
> imageData.SetSpacing(spacing);<br>
><br>
> Then I try to load three views on the data with vtkImageViewer2. The<br>
> following functions reset the z spacing to be 1.0:<br>
><br>
> vtkImageViewer2 imageViewer = new vtkImageViewer2();<br>
> imageViewer.SetInput(imageData); //resets z spacing to 1.0<br>
> imageData.SetSpacing(spacing); //attempt to fix<br>
><br>
> imageViewer.SetSlice((imageViewer.GetSliceMax() + imageViewer.GetSliceMin())<br>
> / 2); //resets z spacing to 1.0<br>
> imageData.SetSpacing(spacing); //attempt to fix<br>
><br>
> //navigation slider on display<br>
> slider = new JSlider();<br>
> slider.setOrientation(JSlider.VERTICAL);<br>
> slider.setMinimum(imageViewer.GetSliceMin());//resets<br>
> slider.setMaximum(imageViewer.GetSliceMax());//resets<br>
> imageViewer.GetInput().SetSpacing(spacing);//attempt to fix<br>
><br>
> Even with all those attempts to fix, the XZ and YZ orientations still<br>
> display the image as if the z spacing is 1.0, instead of 3.0.<br>
><br>
> What's going on? Why is vtkImageViewer2 changing ANYTHING to do with the<br>
> original image, rather than just straight up displaying what it's told to<br>
> display?<br>
><br>
> Thanks,<br>
> Mark<br>
><br>
><br>
><br>
</div></div><div><div></div><div class="h5">> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
</div></div></blockquote></div><br>