[vtkusers] vtkImageReslice and vtkImageResample, different behaviour between 32-bit and 64-bit platform

David Gobbi david.gobbi at gmail.com
Thu Jan 27 09:09:38 EST 2011


Hi Jimmi,

Setting the Z extent to 0,1 isn't needed (as you probably guessed, it
causes two slices to be produced instead of just one slice).

Other than the zero spacing, the only unusual thing about your code is this:

      vtkImageData* map = resample->GetOutput();
      map->GetPointData()->GetArray(0)->SetName("cellvar");

Renaming arrays in any filter's output is not guaranteed to work,
because the filter can create a new array on the next update.  Also,
GetArray(0) is not guaranteed to return the correct array.  For image
filters, you should use GetScalars() to get the pixels.

However, I don't think that this is why you are seeing problems with
the output.  There is probably something else going on in your
program.  The 64-bit system on the VTK dashboard aren't showing any
failures for vtkImageReslice or vtkImageResample.

 - David



On Thu, Jan 27, 2011 at 1:25 AM, jimmigoo <jimmigoo at gmail.com> wrote:
>
> Hi David!
> Thanks for the fast reply!
> I tried to change just these two code lines
>      reslice->SetOutputSpacing(xResolution,yResolution,1);
>      resample->SetAxisOutputSpacing(2, 1);
> but it didn't work again.
> So, I tried to change other two code lines
>      reslice->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>      resample->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
> but it didn't work again.
>
> Do you know how I have to change the code to make it workable?
> I'm looking for your reply!
> Best regards,
> jimmigoo
>
>
> void ResampleDTM()
> {
>      //------------- open original file ----------------------------------
>      vtkStructuredPointsReader* imageReader =
> vtkStructuredPointsReader::New();
>      imageReader->SetFileName(“SaintHelene.vtk”);
>      imageReader->Update();
>      //------------- reslice original vtkImageData ------------------------
>      vtkImageReslice* reslice = vtkImageReslice::New();
>      reslice->SetInput(imageReader->GetOutput());
>      reslice->SetOutputOrigin(X0,Y0,0);
>      reslice->SetOutputSpacing(xResolution,yResolution,1);
>      int XExtent = (int)((Xmax_new- Xmin_new)/xResolution);
>      int YExtent = (int)((Ymax_new- Ymin_new)/yResolution);
>      reslice->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>      reslice->Update();
>      //------------- resample original vtkImageData
> ------------------------
>      vtkImageResample * resample = vtkImageResample::New();
>      resample->SetInputConnection(0, reslice->GetOutputPort());
>      resample->SetDimensionality(3);
>      resample->SetAxisMagnificationFactor(0,1.0);
>      resample->SetAxisMagnificationFactor(1,1.0);
>      resample->SetAxisMagnificationFactor(2,1.0);
>
>      XExtent = (int)((Xmax_new- Xmin_new)/xResolution_new);
>      YExtent = (int)((Ymax_new- Ymin_new)/yResolution_new);
>
>      resample->SetOutputOrigin(X0_new,Y0_new,0);
>      resample->SetOutputExtent(0,XExtent-1,0,YExtent-1,0,1);
>      resample->SetAxisOutputSpacing(0, xResolution_new);
>      resample->SetAxisOutputSpacing(1, yResolution_new);
>      resample->SetAxisOutputSpacing(2, 1);
>      resample->Update();
>      vtkImageData* map = resample->GetOutput();
>      map->GetPointData()->GetArray(0)->SetName("cellvar");
>      //------------- write resampled file
> ----------------------------------
>      vtkStructuredPointsWriter* fileWriter =
> vtkStructuredPointsWriter::New();
>      fileWriter->SetFileTypeToBinary();
>      fileWriter->SetInput(resample->GetOutput());
>      fileWriter->SetFileName(“output.vtk”);
>      fileWriter->Write();
>      //----------------- clean up
> ------------------------------------------
>      fileWriter->Delete();
>      resample->Delete();
>      reslice->Delete();
>      imageReader->Delete();
>
> //---------------------------------------------------------------------
> }
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/vtkImageReslice-and-vtkImageResample-different-behaviour-between-32-bit-and-64-bit-platform-tp3358830p3359347.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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