<div dir="ltr"><div><div>Hi all, I solved my previous post about ExtractImageFilter with vectors, but now I have trouble building this code. I load a 4 different 4d objects in iTK, then transform them to a vector using ComposeImageFilter, then I select one time frame of the 4d objects ( getting  a 3D vector of 4 components image). Finally I want to cast it to VTK  to show it as a glyph, but it seems that the connector ImageToVTKImageFilter only works for scalar images, because it cannot create the object I am asking through the New macro. What can I do?<br>
</div>I attach the code and the error I am getting.<br><br></div>Thank you very much<br><div><div><div><br>typedef unsigned short    PixelType;<br>typedef   float           InternalPixelType;<br>typedef itk::Image&lt; InternalPixelType, 4&gt;  InternalImageType;<br>
typedef itk::Image&lt; PixelType, 3&gt;         ImageType3D;<br>typedef itk::Image&lt; PixelType, 4 &gt;         ImageType;<br>typedef itk::VectorImage&lt;PixelType,4&gt; VectorImageType;<br>typedef itk::VectorImage&lt;PixelType,3&gt; VectorImageType3D;<br>
typedef itk::ComposeImageFilter &lt;ImageType&gt; ImageToVectorImageFilter;<br>typedef jip::jipItkImageSeriesReader&lt; ImageType &gt;        ReaderType;<br>typedef VectorImageType InputImageType;<br>typedef VectorImageType3D OutputImageType;<br>
typedef itk::ExtractImageFilter&lt;InputImageType, OutputImageType&gt; ReductorType;<br>typedef itk::ImageToVTKImageFilter&lt;VectorImageType3D&gt;       ConnectorType;<br>typedef itk::DCMTKSeriesFileNames NamesGeneratorType;<br>
typedef itk::DCMTKImageIO       ImageIOType;<br><br><br><br><br><br>int main( int argc, char *argv[] )<br>{<br>    if( argc != 5 )<br>    {<br>        PrintCommandLineUsage(argc, argv);<br>        return EXIT_FAILURE;<br>
    }<br><br>    ImageType::Pointer vectorImage[4];<br>    ReaderType::Pointer vectorReader[4];<br>    ImageToVectorImageFilter::Pointer imagetovec;<br>    imagetovec=ImageToVectorImageFilter::New();<br>    NamesGeneratorType::Pointer nameGenerator[4];<br>
    ImageIOType::Pointer dicomIO[4];<br><br><br>    for (int i=0;i&lt;4;i++)<br>    {<br>        nameGenerator[i]= NamesGeneratorType::New();<br>        vectorImage[i]=ImageType::New();<br>        vectorReader[i]=ReaderType::New();<br>
        dicomIO[i]= ImageIOType::New();<br><br><br>        nameGenerator[i]-&gt;SetDirectory( argv[1+i]);<br>        vectorReader[i]-&gt;SetFileNames(nameGenerator[i]-&gt;GetInputFileNames());<br>        vectorReader[i]-&gt;SetImageIO( dicomIO[i] );<br>
<br><br><br>        imagetovec-&gt;SetInput(i,vectorReader[i]-&gt;GetOutput());<br>  <br>    }<br><br>    VectorImageType::Pointer  vectorim2= imagetovec-&gt;GetOutput();<br>    vectorim2-&gt;Update();<br>    VectorImageType::RegionType region =vectorim2-&gt;GetLargestPossibleRegion();<br>
    VectorImageType::SizeType size = region.GetSize();<br><br>    ReductorType::Pointer reductor=ReductorType::New();<br>    reductor-&gt;InPlaceOn();<br>    reductor-&gt;SetDirectionCollapseToSubmatrix();<br><br>    int nframes=size[3];<br>
    int dim_eliminada=3;<br>    size[dim_eliminada]=0;<br><br>    InputImageType::IndexType start = region.GetIndex();<br>    unsigned int sliceNumber = 0;<br>    start[dim_eliminada] = sliceNumber;<br><br>    InputImageType::RegionType desiredRegion;<br>
    desiredRegion.SetSize(  size  );<br>    desiredRegion.SetIndex( start );<br><br>    reductor-&gt;SetExtractionRegion( desiredRegion );<br>    reductor-&gt;SetInput(imagetovec-&gt;GetOutput());<br><br>    reductor-&gt;Update();<br>
<br>    int nrenderers=1;<br>    ConnectorType::Pointer connector[nrenderers];<br>    for ( int i =0;i&lt;nrenderers ;i++ )<br>    {<br>        connector[i]= ConnectorType::New();<br>        connector[i]-&gt;SetInput(reductor-&gt;GetOutput());<br>
        connector[i]-&gt;Update();<br>    }<br><br>    vtkSmartPointer&lt;vtkArrowSource&gt; arrowSource = vtkSmartPointer&lt;vtkArrowSource&gt;::New();<br>    arrowSource-&gt;Update();<br><br>    vtkSmartPointer&lt;vtkGlyph3D&gt; glyphFilter = vtkSmartPointer&lt;vtkGlyph3D&gt;::New();<br>
    glyphFilter-&gt;SetSourceConnection(arrowSource-&gt;GetOutputPort());<br>    glyphFilter-&gt;OrientOn();<br>    glyphFilter-&gt;SetVectorModeToUseVector();<br><br><br>    glyphFilter-&gt;SetInput(connector[0]-&gt;GetOutput());<br>
<br>//    vtkSmartPointer&lt;vtkGlyph3DMapper&gt; glyph3DMapper =vtkSmartPointer&lt;vtkGlyph3DMapper&gt;::New();<br>//    glyph3DMapper-&gt;SetInputConnection(glyphFilter-&gt;GetOutput());<br><br>    vtkSmartPointer&lt;vtkPolyDataMapper&gt; vectorMapper = vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();<br>
    vectorMapper-&gt;SetInputConnection(glyphFilter-&gt;GetOutputPort());<br>    vtkSmartPointer&lt;vtkActor&gt; vectorActor = vtkSmartPointer&lt;vtkActor&gt;::New();<br>    vectorActor-&gt;SetMapper(vectorMapper);<br><br>
<br>//    vtkSmartPointer&lt;vtkActor&gt; actor =vtkSmartPointer&lt;vtkActor&gt;::New();<br>//    actor-&gt;SetMapper(glyph3DMapper);<br><br>    // Create a renderer, render window, and interactor<br>    vtkSmartPointer&lt;vtkRenderer&gt; renderer =      vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
<br>    vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =      vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<br>    renderWindow-&gt;AddRenderer(renderer);<br>    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor =      vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
    renderWindowInteractor-&gt;SetRenderWindow(renderWindow);<br><br>    // Add the actor to the scene<br>//    renderer-&gt;AddActor(actor);<br>    renderer-&gt;AddViewProp(vectorActor);<br>    // Render and interact<br>
    renderWindow-&gt;Render();<br>    renderWindowInteractor-&gt;Start();<br><br>    return EXIT_SUCCESS;<br><br><br><br><br>
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(20,20,190)">16:43:07: Running build steps for project Vector4DFlow...</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(20,20,190)">16:43:07: Starting: &quot;/usr/bin/make&quot; -j 8</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(60,60,60)">Scanning dependencies of target Vector4DFlow</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(60,60,60)">[ 20%] Building CXX object CMakeFiles/Vector4DFlow.dir/Vector4DFlow.cxx.o</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">In file included from /opt/itk/vtk5/debug8/include/ITK-4.5/itkConceptChecking.h:31:0,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /opt/itk/vtk5/debug8/include/ITK-4.5/itkMath.h:33,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /opt/itk/vtk5/debug8/include/ITK-4.5/itkIndex.h:23,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /opt/itk/vtk5/debug8/include/ITK-4.5/itkContinuousIndex.h:22,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /opt/itk/vtk5/debug8/include/ITK-4.5/itkImageRegion.h:34,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /opt/itk/vtk5/debug8/include/ITK-4.5/itkImage.h:21,</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">                 from /home/cib/ejemplos/EjemplosItk/IO/Vector4DFlow/Vector4DFlow.cxx:36:</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkPixelTraits.h: In instantiation of ‘itk::PixelTraits&lt;itk::VariableLengthVector&lt;short unsigned int&gt; &gt;’:</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkVTKImageExport.hxx:35:56:   instantiated from ‘itk::VTKImageExport&lt;TInputImage&gt;::VTKImageExport() [with TInputImage = itk::VectorImage&lt;short unsigned int, 3u&gt;]’</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkVTKImageExport.h:69:3:   instantiated from ‘static itk::VTKImageExport&lt;TInputImage&gt;::Pointer itk::VTKImageExport&lt;TInputImage&gt;::New() [with TInputImage = itk::VectorImage&lt;short unsigned int, 3u&gt;, itk::VTKImageExport&lt;TInputImage&gt;::Pointer = itk::SmartPointer&lt;itk::VTKImageExport&lt;itk::VectorImage&lt;short unsigned int, 3u&gt; &gt; &gt;]’</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkImageToVTKImageFilter.hxx:34:3:   instantiated from ‘itk::ImageToVTKImageFilter&lt;TInputImage&gt;::ImageToVTKImageFilter() [with TInputImage = itk::VectorImage&lt;short unsigned int, 3u&gt;]’</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkImageToVTKImageFilter.h:56:3:   instantiated from ‘static itk::ImageToVTKImageFilter&lt;TInputImage&gt;::Pointer itk::ImageToVTKImageFilter&lt;TInputImage&gt;::New() [with TInputImage = itk::VectorImage&lt;short unsigned int, 3u&gt;, itk::ImageToVTKImageFilter&lt;TInputImage&gt;::Pointer = itk::SmartPointer&lt;itk::ImageToVTKImageFilter&lt;itk::VectorImage&lt;short unsigned int, 3u&gt; &gt; &gt;]’</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/home/cib/ejemplos/EjemplosItk/IO/Vector4DFlow/Vector4DFlow.cxx:386:38:   instantiated from here</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">/opt/itk/vtk5/debug8/include/ITK-4.5/itkPixelTraits.h:49:3: error: ‘Length’ is not a member of ‘itk::VariableLengthVector&lt;short unsigned int&gt;’</span></p>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">make[2]: *** [CMakeFiles/Vector4DFlow.dir/Vector4DFlow.cxx.o] Error 1</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">make[1]: *** [CMakeFiles/Vector4DFlow.dir/all] Error 2</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">make: *** [all] Error 2</span></p>
<p style="margin:0px;text-indent:0px"><span style="font-weight:600;color:rgb(190,20,20)">16:43:10: The process &quot;/usr/bin/make&quot; exited with code 2.</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">Error while building project Vector4DFlow (target: Desktop)</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(190,20,20)">When executing build step &#39;Make&#39;</span></p><br clear="all"><br>-- <br>José Ignacio Prieto<br>celular(nuevo): 94348182
</div></div></div></div>