[vtkusers] Pixel(0, 0, 0) not in current extent
Shimizu, Kazuhide
kazuhide.shimizu06 at imperial.ac.uk
Tue Feb 6 16:39:16 EST 2007
Hello All,
I have just started learning VTK recently. My purpose at this moment is
to link VTK to ITK and vice versa in order to read vtk data (structured
points) by VTK, process the data by ITK, then display the processed data
by VTK. I am writing a simple code like attached below. It can be
compiled and built without problem, but a vtkOutputWindow comes up when
running to show an error message saying
"vtkImageData(017D9B40): GetPointer: Pixel(0, 0, 0) not in current
extent...".
But data extent is already set according to whole exetent. I checked in
debug mode that WholeExtent is set to (0, 127, 0, 127, 0, 114) and
DataExtent is the same. I have totally no idea to solve this problem.
My environment is: WinXP, MS VisualStudio.net 2003, VTK5.0.2, ITK 3.0.0
Any help will be greatly appreciated.
Best Regards,
Kaz
---
vtkStructuredPointsReader *readerVTK =
vtkStructuredPointsReader::New();
vtkContourFilter *contourFilterVTK = vtkContourFilter::New();
vtkPolyDataMapper *mapperPolyDataVTK =vtkPolyDataMapper::New();
vtkActor *actorVTK = vtkActor::New();
vtkImageImport *importerVTK = vtkImageImport::New();
vtkImageExport *exporterVTK = vtkImageExport::New();
vtkRenderer *rendererVTK = vtkRenderer::New();
vtkRenderWindow *renWinVTK = vtkRenderWindow::New();
typedef itk::Image<short, 3> ImageType3D;
typedef itk::VTKImageImport<ImageType3D> itkImageImportType3D;
itkImageImportType3D::Pointer importer3DITK;
typedef itk::VTKImageExport<ImageType3D> itkImageExportType3D;
itkImageExportType3D::Pointer exporter3DITK;
typedef itk::BinaryThresholdImageFilter<ImageType3D, ImageType3D>
itkBinThresholdFilterType;
itkBinThresholdFilterType::Pointer binThresholdFilterITK;
importer3DITK = itkImageImportType3D::New();
exporter3DITK = itkImageExportType3D::New();
binThresholdFilterITK = itkBinThresholdFilterType::New();
// read the data
readerVTK->SetFileName("CT.vtk");
readerVTK->Update();
// set to exporter of VTK
exporterVTK->SetInputConnection( readerVTK->GetOutputPort() );
// send to ITK
connectVTK2ITK( exporterVTK, importer3DITK );
// image processing by ITK
binThresholdFilterITK->SetInput( importer3DITK->GetOutput() );
binThresholdFilterITK->SetOutsideValue( 0 );
binThresholdFilterITK->SetInsideValue( 255 );
binThresholdFilterITK->SetLowerThreshold( 100 );
binThresholdFilterITK->SetUpperThreshold( 200 );
// set to exporter of ITK
exporter3DITK->SetInput( binThresholdFilterITK->GetOutput() );
// send back to VTK
connectITK2VTK( exporter3DITK, importerVTK );
// processes on imported data
importerVTK->Update();
importerVTK->SetDataExtentToWholeExtent();
importerVTK->SetDataOrigin(0, 0, 0);
// make surface
contourFilterVTK->SetInput( importerVTK->GetOutput() );
contourFilterVTK->SetValue(0, 400);
// display
mapperPolyDataVTK->SetInput( contourFilterVTK->GetOutput() );
mapperPolyDataVTK->ScalarVisibilityOff();
actorVTK->SetMapper( mapperPolyDataVTK );
actorVTK->GetProperty()->SetOpacity(1.0);
actorVTK->GetProperty()->SetDiffuseColor( 1, 1, 1 );
rendererVTK->AddActor( actorVTK );
renWinVTK->AddRenderer( rendererVTK );
renWinVTK->Render();
}
void sampleApp2::connectVTK2ITK(vtkImageExport *exporter,
itkImageImportType3D *importer)
{
importer->SetUpdateInformationCallback
(exporter->GetUpdateInformationCallback());
importer->SetPipelineModifiedCallback
(exporter->GetPipelineModifiedCallback());
importer->SetWholeExtentCallback
(exporter->GetWholeExtentCallback());
importer->SetSpacingCallback (exporter->GetSpacingCallback());
importer->SetOriginCallback (exporter->GetOriginCallback());
importer->SetScalarTypeCallback (exporter->GetScalarTypeCallback());
importer->SetNumberOfComponentsCallback
(exporter->GetNumberOfComponentsCallback());
importer->SetPropagateUpdateExtentCallback
(exporter->GetPropagateUpdateExtentCallback());
importer->SetUpdateDataCallback (exporter->GetUpdateDataCallback());
importer->SetDataExtentCallback (exporter->GetDataExtentCallback());
importer->SetBufferPointerCallback
(exporter->GetBufferPointerCallback());
importer->SetCallbackUserData (exporter->GetCallbackUserData());
return;
}
void sampleApp2::connectITK2VTK(itkImageExportType3D *exporter,
vtkImageImport *importer)
{
importer->SetUpdateInformationCallback
(exporter->GetUpdateInformationCallback());
importer->SetPipelineModifiedCallback
(exporter->GetPipelineModifiedCallback());
importer->SetWholeExtentCallback
(exporter->GetWholeExtentCallback());
importer->SetSpacingCallback (exporter->GetSpacingCallback());
importer->SetOriginCallback (exporter->GetOriginCallback());
importer->SetScalarTypeCallback (exporter->GetScalarTypeCallback());
importer->SetNumberOfComponentsCallback
(exporter->GetNumberOfComponentsCallback());
importer->SetPropagateUpdateExtentCallback
(exporter->GetPropagateUpdateExtentCallback());
importer->SetUpdateDataCallback (exporter->GetUpdateDataCallback());
importer->SetDataExtentCallback (exporter->GetDataExtentCallback());
importer->SetBufferPointerCallback
(exporter->GetBufferPointerCallback());
importer->SetCallbackUserData (exporter->GetCallbackUserData());
return;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070206/aac37eee/attachment.htm>
More information about the vtkusers
mailing list