[vtkusers] Connecting ITK to VTK

HEUDE Jean j.heude at yahoo.fr
Fri May 31 04:31:11 EDT 2013


Dear VTK users,

I'm new to VTK and ITK, and I still have problems.
I'm working as a trainee on an existing project. So I can't really show you all of my code because it's cut in a lot of classes, and it's hard for me to find how the existing project works.
Here is my problem:

I'm trying to connect ITK and VTK: i get an ITK image, apply itk::ConnectedThresholdImageFilter to it, then connect the pipeline to vtk to stock it in a vtkVolume.

But the software crashes, and in debug mode I see it crashes in vtkImageImport::InvokeUpdateInformationCallbacks().

I'm using VTK 5.1 and ITK 3.2.0.
Here is my code:

    typedef signed short      PixelType;
    const   unsigned int        Dimension = 3;


    typedef itk::Image< PixelType, Dimension >   ImageType;
    typedef itk::ImageToVTKImageFilter< ImageType > ITKToVTKConnector;


    //The itk Image

    ImageType::Pointer image = this->dicom->getImagePointer();

    //The connected filter, using a random seed, just to test

    typedef itk::ConnectedThresholdImageFilter< ImageType, ImageType > ConnectedFilterType;
    ConnectedFilterType::Pointer connectedThreshold = ConnectedFilterType::New();
    connectedThreshold->SetInput( image);
    connectedThreshold->SetLower(  150 );
    connectedThreshold->SetUpper(  350  );
    connectedThreshold->SetReplaceValue( 255 );
    ImageType::IndexType  index;
    index[0] = 150;
    index[1] = 250;
    index[2] = 150;
    connectedThreshold->SetSeed( index );
    connectedThreshold->ReleaseDataFlagOn();
    connectedThreshold->Update();

    //The Connector. I first used it like it's normally used but, as it didn't work, i tried toget the exporter and importer, and see if it works. It doesn't.

    ITKToVTKConnector::Pointer connect2=ITKToVTKConnector::New();
    //connect2->SetInput(connectedThreshold->GetOutput());
    //connect2->ReleaseDataFlagOn();
    //connect2->Update();
    connect2->GetExporter()->SetInput( connectedThreshold->GetOutput() );
    connect2->GetImporter()->Update();

    //The mapper, a class attribute

    volumeRayCastMapper->SetInput(connect2->GetImporter()->GetOutput());
    volumeRayCastMapper->ReleaseDataFlagOn();
    volumeRayCastMapper->Update();
    
    //The volume, a class attribute
    this->getVolume()/*m_lastVolumeCreated*/->SetMapper( volumeRayCastMapper );
    this->getVolume()/*m_lastVolumeCreated*/->SetProperty( this->volumeProperty );

After that, the volume is used in some other classes which Render the volume. The problem seems to be in the end of the ITK pipeline. I don't know what to try anymore.

Any kind of help would be appreciated and, please, excuse my english.

Thank you,

                            Crampon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130531/7c418798/attachment.htm>


More information about the vtkusers mailing list