[Insight-users] itk::ImageToVTKImageFilter throwing error about "Input scalar type"

Dženan Zukić dzenanz at gmail.com
Tue Jan 24 06:32:13 EST 2012


Hi guys,

I hope you can help me with this. I have the following implementation
of voxelization
using ITK
typedef itk::Image<unsigned char, 3> VisualizingImageType;
VisualizingImageType::Pointer Vertebra::getMask()
{
    MeshType::Pointer mesh=qe2itkMesh(qe);
    typedef itk::TriangleMeshToBinaryImageFilter<MeshType,VisualizingImageType>
MeshFilterType;
     MeshFilterType::Pointer meshFilter = MeshFilterType::New();
    meshFilter->SetInfoImage(logic.visualizing);
    meshFilter->SetInput(mesh);
    meshFilter->Update();
    mask=meshFilter->GetOutput();
    return mask;
}

Since there is a bug <https://itk.icts.uiowa.edu/jira/browse/ITK-2882>
in TriangleMeshToBinaryImageFilter,
I created the following implementation using VTK voxelization method:
VisualizingImageType::Pointer Vertebra::getMask()
{
    typedef itk::ImageToVTKImageFilter<VisualizingImageType>
itkVtkConverter;
    itkVtkConverter::Pointer conv=itkVtkConverter::New();
    conv->SetInput(logic.visualizing);
    conv->Update();

    vtkImageStencil *stencil=vtkImageStencil::New();
    vtkPolyDataToImageStencil *voxelizer=vtkPolyDataToImageStencil::New();
    voxelizer->SetInput(qe2vtk(qe));
    voxelizer->SetInformationInput(conv->GetOutput());
    stencil->SetStencil(voxelizer->GetOutput());
    stencil->Update();

    typedef itk::VTKImageToImageFilter<VisualizingImageType>
vtk2itkConverter;
     vtk2itkConverter::Pointer conv2=vtk2itkConverter::New();
    conv2->SetInput(stencil->GetOutput());
    conv2->Update();
    mask=conv2->GetOutput();
    return mask;
}

However this alternative implementation causes 2 errors. The first one:
ERROR: In vtkDemandDrivenPipeline.cxx, line 727
vtkStreamingDemandDrivenPipeline (00000000321AEB50): Input port 0 of
algorithm vtkImageStencil(0000000003947240) has 0 connections but is not
optional.

and the second one:
d:\sdk\itk4\modules\bridge\vtk\include\itkVTKImageImport.hxx:251:
itk::ERROR: VTKImageToImageFilter(000000000394CF50): Input scalar type is
double but should be unsigned char

What am I doing wrong?

Regards,
Dženan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120124/96c41e36/attachment.htm>


More information about the Insight-users mailing list