[vtkusers] error when connecting ITK with VTK

Ralf.Denhof ralf.denhof at gmx.de
Sun Dec 4 16:34:27 EST 2011


I think this reproduces the error, but I had to run it in Debug-Mode. 
Then it went into the part where the described error is generated.

/typedef itk::Image<unsigned char,2> imagetype;
     vtkSmartPointer<vtkJPEGReader> 
reader=vtkSmartPointer<vtkJPEGReader>::New();
     reader->SetFileName("1.jpg");

     vtkSmartPointer<vtkImageActor> 
actor=vtkSmartPointer<vtkImageActor>::New();
     actor->SetInput(reader->GetOutput());

     vtkSmartPointer<vtkImageCast> 
caster=vtkSmartPointer<vtkImageCast>::New();
     caster->SetInput(actor->GetInput());
     caster->SetOutputScalarTypeToUnsignedChar();

     itk::VTKImageToImageFilter<imagetype>::Pointer 
vtk2itk=itk::VTKImageToImageFilter<imagetype>::New();
     vtk2itk->SetInput(caster->GetOutput());
     vtk2itk->Update();

     itk::BinaryThresholdImageFilter<imagetype,imagetype>::Pointer 
binaryfilter=itk::BinaryThresholdImageFilter<imagetype,imagetype>::New();
     binaryfilter->SetLowerThreshold(125*(-1));
     binaryfilter->SetInput(vtk2itk->GetOutput());
     binaryfilter->Update();

     itk::ImageToVTKImageFilter<imagetype>::Pointer 
itk2vtk=itk::ImageToVTKImageFilter<imagetype>::New();
     itk2vtk->SetInput(binaryfilter->GetOutput());
     itk2vtk->Update();

     vtkSmartPointer<vtkRenderWindowInteractor> 
interactor=vtkSmartPointer<vtkRenderWindowInteractor>::New();

     vtkSmartPointer<vtkImageViewer2> 
viewer=vtkSmartPointer<vtkImageViewer2>::New();
     viewer->SetInput(itk2vtk->GetOutput());
     viewer->SetupInteractor(interactor);

     interactor->Initialize();
     viewer->Render();
     interactor->Start();
/
Am 04.12.2011 19:25, schrieb David Doria:
> On Sun, Dec 4, 2011 at 1:20 PM, Ralf.Denhof<ralf.denhof at gmx.de>  wrote:
>> Am 04.12.2011 19:18, schrieb David Doria:
>>
>>> Did you call imageImport->SetNumberOfScalarComponents (4); ?
>> No, never in the whole project.
> Try to setup an as-small-as-possible project that compiles to give
> this error. The error seems to indicate there is something wrong with
> the number of components of the input image vs the number of
> components the import filter is expecting. Try to simulate the
> conditions you have and produce the error so we can more easily help
> you debug it.
>
> David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111204/d85904ab/attachment.htm>


More information about the vtkusers mailing list