[vtkusers] Puzzled: vtkImageReslice->reorienting a volume

David Gobbi dgobbi at irus.rri.on.ca
Fri Jun 9 18:10:48 EDT 2000


Hi Andrius,

If you just want to change the orientation, just use
SetResliceMatrix but not SetResliceTransform.

The 3x3 portion of the matrix should contain the direction cosines. If you
haven't already, take a look at the most recent man pages at
http://www.visualizationtoolkit.org/vtk/quality/Doc/manhtml/vtkImageReslice.html

As for the crash, if you could use a debugger to find the line of code
that is causing the problem then that would be great.  Otherwise, if you
can change your code so that it uses the data set in the 'vtkdata'
directory and send it to me, then I can test it for you.

My suspicion is that the problem might lie with both setting
the Origin and Extent, as well as setting OutputAlwaysCenteredOnInput.
The 'OutputAlwaysCenteredOnInput' flag is not tested by any of the
regression tests (I didn't add it, and I never use it myself).

 - David

On Fri, 9 Jun 2000, Audrius Stundzia wrote:

> Hi fellow vtker's
> 
> In my application, I'm now trying to use vtkImageReslice to re-orient
> a vtkImageData volume along a new axis set. I load a vtkMatrix4x4
> with this new axis set, but I'm not sure what the vtkTransform should
> be. Should it be the
> 1) rotation matrix defined by the direction cosines between the old and new 
> axes or should it be
> 2) just it identity matrix?
> 
> Searching the vtk mailing list archive unfortunately confused me even more 
> :)
> 
> The other problem is that the following code crashes with the error
> message:
> 
> ERROR: In vtkImageData.cxx, line 1298
> vtkImageData (0xbc85d0): Attempt to allocate scalars before scalar type was 
> set!.
> 
>    testImageData = vtkImageData::New();
>    testImageData->SetDimensions( nVoxels[X], nVoxels[Y], nVoxels[Z] );
>    testImageData->SetOrigin( 0.0, 0.0, 0.0 );
>    testImageData->SetSpacing( voxelSize[X], voxelSize[Y], voxelSize[Z] );
>    testImageData->GetPointData()->SetScalars( testVolumeScalars);
>    testImageData->Update();
> 
>    //-----I've extracted isosurfaces from testImageData so I know it's    
> //-----okay
> 
>    //------------------------------------------------
>    //-----Reorient (reslice) the 3D image data volume
>    //------------------------------------------------
> 
>    testImageReslice = vtkImageReslice::New();
>    testImageReslice->SetOutputOrigin( 0, 0, 0 );
>    testImageReslice->SetOutputSpacing( voxelSize);
>    testImageReslice->SetOutputExtent( nVoxels);
> 
>    testImageReslice->OptimizationOn();
>    testImageReslice->SetBackgroundLevel( 0);
> 
>    testImageReslice->SetInput( testImageData);
> 
>    testImageReslice->SetResliceAxes( testOrientationMatrix);
> 
>    //-----I'm not sure what the testOrientationTransform should be
> 
>    testImageReslice->SetResliceTransform( testOrientationTransform);
> 
>    testImageReslice->SetInterpolationModeToNearestNeighbor();
> 
>    testImageReslice->OutputAlwaysCenteredOnInputOn();
> 
>    testOrientedImageData = testImageReslice->GetOutput();
> 
>    //-----This next line where the code crashes with the above error      
> //-----message
>    testImageReslice->Update();
>    //-----
> 
>    testImageData->ReleaseDataFlagOn();
> 
> //-----
> 
> If I comment out the offending line, then the same error occurs later
> when I input  testOrientedImageData into vtkImageMarchingCubes
> 
> Any insight would be much appreciated.
> 
> OS: Solaris 2.6
> vtk 3.1: NR 8 June 2000
> 
> Sincerely,
> 
> Audrius Stundzia
> 
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> 
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> vtkusers mailing list
> vtkusers at public.kitware.com
> http://public.kitware.com/mailman/listinfo/vtkusers
> 

-- 
--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario





More information about the vtkusers mailing list