[vtkusers] resample issue

Karl bulkmailaddress at gmail.com
Wed Dec 2 16:01:53 EST 2009


Hi,

I am attempting unsuccessfully to use vtkImageResample to change the spacing
of an image.
I have a 3D volume that is being resliced with a vtkImagePlaneWidget.  I am
then requesting the slice.
The code works fine until I add this filter, can anyone tell me what I am
doing wrong.

Thanks
KB

Code before filter is added (executes with no problem):
_________________________________________
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData(QString
sliceName)
{
        // use vtkImageMapToColors to map to 8-bit for output
        vtkImageMapToColors* colorMap = vtkImageMapToColors::New();
        colorMap->PassAlphaToOutputOff();
        colorMap->SetActiveComponent(0);
        colorMap->SetOutputFormatToLuminance();
        colorMap->SetInput(planeWidget->GetResliceOutput());
        colorMap->SetLookupTable(planeWidget->GetLookupTable());

        vtkSmartPointer<vtkImageData> slice = colorMap->GetOutput();

        colorMap->Delete();
        return slice;
}



Code after filter is added:
__________________________________________
vtkSmartPointer<vtkImageData> ImageSliceInfo::GetSliceData()
{
        // resample to isotropic spacing
        vtkImageResample* resample = vtkImageResample::New();
        resample->SetInput(planeWidget->GetResliceOutput());
        resample->SetDimensionality(2);
        resample->SetAxisOutputSpacing(0,1);
        resample->SetAxisOutputSpacing(1,1);

        // use vtkImageMapToColors to map to 8-bit for output
        vtkImageMapToColors* colorMap = vtkImageMapToColors::New();
        colorMap->PassAlphaToOutputOff();
        colorMap->SetActiveComponent(0);
        colorMap->SetOutputFormatToLuminance();
        colorMap->SetInput(resample->GetOutput());
        colorMap->SetLookupTable(planeWidget->GetLookupTable());

        vtkSmartPointer<vtkImageData> slice = colorMap->GetOutput();

        resample->Delete();
        colorMap->Delete();
        return slice;
}




More information about the vtkusers mailing list