[vtkusers] vtkImageReslice Nearest vs. Linear

Todd Baker tbaker at claritysolutionsllc.com
Fri Jul 11 14:24:25 EDT 2003


Hello:
    
    I'm trying to use a vtkImageReslice to resample a 3D dataset along
the Z axis. The code works fine until I change the interp mode to linear
or cubic: then I just get junk data. Am I missing a step?
 
vtkImageImport* Importer = vtkImageImport::New();

vtkImageExport* Exporter = vtkImageExport::New();

vtkImageReslice* Resampler = vtkImageReslice::New();

vtkImageData* InData = vtkImageData::New();

vtkImageFlip* InFlip = vtkImageFlip::New();

float InOrigin[3];

InOrigin[0] = - InDim[0] * InSpacing[0] * 0.5;

InOrigin[1] = - InDim[1] * InSpacing[1] * 0.5;

InOrigin[2] = - InDim[2] * InSpacing[2] * 0.5;

float OutOrigin[3];

OutOrigin[0] = - OutDim[0] * OutSpacing[0] * 0.5;

OutOrigin[1] = - OutDim[1] * OutSpacing[1] * 0.5;

OutOrigin[2] = - OutDim[2] * OutSpacing[2] * 0.5;

 

Importer->SetDataExtent(0,InDim[0] - 1, 0, InDim[1] - 1, 0, InDim[2] -
1);

Importer->SetWholeExtent(0,InDim[0] - 1, 0, InDim[1] - 1, 0, InDim[2] -
1);

Importer->SetDataOrigin(InOrigin[0], InOrigin[1], InOrigin[2]);

Importer->SetDataScalarType(VTK_UNSIGNED_SHORT);

Importer->SetImportVoidPointer(InArray, 1);

Importer->Update();

Importer->UpdateWholeExtent();

InData = Importer->GetOutput();

InData->SetSpacing(InSpacing);

InData->SetOrigin(InOrigin[0], InOrigin[1], InOrigin[2]);

InData->SetWholeExtent(Importer->GetWholeExtent());

InData->Update();

InData->SetUpdateExtentToWholeExtent();

Resampler->SetInput(InData);

Resampler->SetOutputDimensionality(3);

// Resampler->SetInterpolationModeToLinear();

Resampler->AutoCropOutputOn();

Resampler->SetBackgroundLevel(125);

Resampler->SetOutputOrigin(OutOrigin);

Resampler->SetOutputSpacing(OutSpacing[0], OutSpacing[1],
OutSpacing[2]);

Resampler->SetOutputExtent(0, OutDim[0] - 1, 0, OutDim[1] - 1, 0,
OutDim[2] - 1);

Resampler->ReleaseDataFlagOff();

Resampler->UpdateWholeExtent();

Exporter->SetInput(Resampler->GetOutput());

Exporter->SetExportVoidPointer(OutArray);

Exporter->Export();

    
 
Todd Baker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030711/1ba79ad3/attachment.htm>


More information about the vtkusers mailing list