<div dir="ltr"><div>Hi all, I am sending this to both lists, ITK and VTK. I have trouble loading three velocity dicom images (X, Y and Z axis). The problem is that when displaying the vector field as a Glyph3D, the arrows are aligned only in one axis. I have tried to check through iterators after the itk to vtk filter and the output shows the vector is fine. Then I don't know if the problem is in the glyph3d config or in the vtk data type. I attach all my code if someone could give me a hand.</div>
<div><br></div><div>Thank you very much.</div><div><br></div><div><br></div><div><br></div><div><br></div><div>typedef short    ShortPixelType;</div><div>typedef itk::Image<ShortPixelType, 4> ImageType4D;<span class="" style="white-space:pre">                                           </span>// ITK Image</div>
<div>typedef itk::Image<ShortPixelType, 3> ImageType3D;<span class="" style="white-space:pre">                                            </span>// ITK Image</div><div>typedef itk::Image< itk::CovariantVector< ShortPixelType, 3>, 4 > VectorImageType4D;</div>
<div>typedef itk::Image< itk::CovariantVector< ShortPixelType, 3>, 3 > VectorImageType3D;</div><div>typedef itk::itkImageSeriesReader< ImageType4D>        ReaderType;</div><div>typedef itk::ImageFileWriter< VectorImageType3D>  WriterType3D;</div>
<div>typedef itk::ImageFileWriter< VectorImageType4D>  WriterType4D;</div><div>typedef itk::ExtractImageFilter<VectorImageType4D, VectorImageType3D> ReductorType;</div><div>typedef itk::ImageToVTKImageFilter<VectorImageType3D>       ConnectorType;</div>
<div>typedef itk::ComposeImageFilter< ImageType4D, VectorImageType4D > Vector4DComposer;</div><div>typedef itk::ImageFileReader< VectorImageType4D>  ReaderType4D;</div><div><br></div><div><br></div><div><br></div>
<div>    std::vector< ReaderType::Pointer > reader;</div><div>    std::vector< NamesGeneratorType::Pointer > nameGenerator;</div><div>    std::vector< ImageIOType::Pointer > dicomIO;</div><div>    reader.resize(3);</div>
<div>    nameGenerator.resize(3);</div><div>    dicomIO.resize(3);</div><div>    Vector4DComposer::Pointer vecComposer = Vector4DComposer::New();</div><div>    VectorImageType4D::Pointer m_vectorImage;</div><div><br></div>
<div>   for (int i = 0 ; i < 3 ; i++)</div><div>   {</div><div>       reader[i] = ReaderType::New();</div><div>       nameGenerator[i] = NamesGeneratorType::New();</div><div>       dicomIO[i] = ImageIOType::New();</div>
<div>       nameGenerator[i]->SetDirectory( argv[i + 1]);</div><div>       reader[i]->SetFileNames(nameGenerator[i]->GetInputFileNames());</div><div>       reader[i]->SetImageIO( dicomIO[i] );</div><div>       reader[i]->Update();</div>
<div>       vecComposer->SetInput(i,reader[i]->GetOutput());</div><div>   }</div><div><br></div><div>   vecComposer->UpdateLargestPossibleRegion();</div><div>   ImageType4D::SizeType size = vecComposer->GetOutput()->GetLargestPossibleRegion().GetSize();</div>
<div><br></div><div>   int nframes = vecComposer->GetOutput()->GetLargestPossibleRegion().GetSize()[3];</div><div>   int dim_eliminada=3;</div><div>   size[dim_eliminada]=0;</div><div>   VectorImageType4D::IndexType start = vecComposer->GetOutput()->GetLargestPossibleRegion().GetIndex();</div>
<div>   start[dim_eliminada] = 30;</div><div>   VectorImageType4D::RegionType desiredRegion;</div><div>   desiredRegion.SetSize(  size  );</div><div>   desiredRegion.SetIndex( start );</div><div><br></div><div>   ReductorType::Pointer reductor = ReductorType::New();</div>
<div>   reductor->InPlaceOn();</div><div>   reductor->SetDirectionCollapseToSubmatrix();</div><div>   reductor->SetExtractionRegion( desiredRegion );</div><div>   reductor->SetInput(vecComposer->GetOutput());</div>
<div>   reductor->Update();</div><div><br></div><div><br></div><div>   ConnectorType::Pointer m_connector = ConnectorType::New();</div><div>   m_connector->SetInput(reductor->GetOutput());</div><div>   m_connector->UpdateLargestPossibleRegion();</div>
<div>   m_connector->Update();</div><div><br></div><div><div>  std::cout << "image start " << std::endl;</div><div>   for (int i = 0; i < m_connector->GetOutput()->GetDimensions()[0]; i++)</div>
<div>   {</div><div>       for (int j = 0; j < m_connector->GetOutput()->GetDimensions()[1]; j++)</div><div>       {</div><div>           for (int k = 0; k < m_connector->GetOutput()->GetDimensions()[2]; k++)</div>
<div>           {</div><div>               myfile<< "On point " << "i, j, k: " << i<<", "<< j<<", "<< k<<</div><div>                        " Component 0: "<< m_connector->GetOutput()->GetScalarComponentAsDouble(i, j, k, 0) <<</div>
<div>                        " Component 1: "<< m_connector->GetOutput()->GetScalarComponentAsDouble(i, j, k, 1) <<</div><div>                        " Component 2: "<< m_connector->GetOutput()->GetScalarComponentAsDouble(i, j, k, 2) <<</div>
<div>                         "\n";</div><div>           }</div><div>       }</div><div>   }</div></div><div><br></div><div>   vtkSmartPointer< vtkImageDataGeometryFilter > vtkConverter = vtkSmartPointer< vtkImageDataGeometryFilter >::New();</div>
<div>   vtkConverter->SetInput(m_connector->GetOutput());</div><div>   vtkConverter->UpdateWholeExtent();</div><div><br></div><div>   vtkSmartPointer< vtkArrowSource > m_arrows = vtkSmartPointer< vtkArrowSource >::New();</div>
<div>   m_arrows->SetTipLength(.1);</div><div>   m_arrows->SetTipResolution(5);</div><div>   m_arrows->SetTipRadius(.05);</div><div>   m_arrows->SetShaftResolution(5);</div><div>   m_arrows->SetShaftRadius(.015);</div>
<div>   m_arrows->Update();</div><div><br></div><div>   vtkSmartPointer< vtkGlyph3D > m_glyphs = vtkSmartPointer< vtkGlyph3D >::New();</div><div>//   m_glyphs->SetSourceConnection(m_connector->GetOutput());</div>
<div>//   m_glyphs->SetInput(m_connector->GetOutput());</div><div>//   m_glyphs->SetInputConnection(m_connector->GetOutput() ());</div><div>   m_glyphs->SetInputConnection(vtkConverter->GetOutputPort());</div>
<div>//   m_glyphs->SetSource(m_arrows->GetOutput());</div><div>   m_glyphs->SetSourceConnection(m_arrows->GetOutputPort());</div><div>   m_glyphs->OrientOn();</div><div>//   m_glyphs->OrientOff();</div>
<div>//   m_glyphs->SetVectorModeToVectorRotationOff();</div><div>   m_glyphs->SetVectorModeToUseVector();</div><div>//   m_glyphs->SetVectorModeToUseNormal();</div><div>//   m_glyphs->SetScaleModeToDataScalingOn();</div>
<div>//   m_glyphs->SetScaleModeToDataScalingOff();</div><div>//   m_glyphs->SetColorModeToColorByVector();</div><div>//   m_glyphs->SetScaleModeToScaleByVector();</div><div>//   m_glyphs->SetColorModeToColorByScalar();</div>
<div>   m_glyphs->SetColorModeToColorByScale();</div><div>   m_glyphs->SetScaleFactor(0.2);</div><div>//   m_glyphs->SetIndexModeToVector();</div><div>//   m_glyphs->SetScaleModeToDataScalingOff();</div><div>//   m_glyphs->SetScaleFactor(.5);</div>
<div>   m_glyphs->Update();</div><div><br></div><div>   vtkSmartPointer< vtkOpenGLPolyDataMapper > glyphPolyData = vtkSmartPointer< vtkOpenGLPolyDataMapper >::New();</div><div>   glyphPolyData->SetInputConnection(m_glyphs->GetOutputPort());</div>
<div>   vtkSmartPointer< vtkOpenGLActor > glyphActor = vtkSmartPointer< vtkOpenGLActor >::New();</div><div>   glyphActor->SetMapper(glyphPolyData);</div><div><br></div><div>   vtkSmartPointer< vtkWin32OpenGLRenderWindow >  renWin = vtkSmartPointer< vtkWin32OpenGLRenderWindow>::New();</div>
<div><br></div><div>   vtkSmartPointer< vtkOpenGLRenderer>  ren1 = vtkSmartPointer< vtkOpenGLRenderer> ::New();</div><div>   renWin->AddRenderer(ren1);</div><div>   ren1->AddActor(glyphActor);</div><div>
<br></div><div>   vtkSmartPointer< vtkRenderWindowInteractor > rwi = vtkSmartPointer< vtkRenderWindowInteractor >::New();</div><div>   vtkSmartPointer<MouseInteractorStyle> styleActor = vtkSmartPointer<MouseInteractorStyle>::New();</div>
<div>   rwi->SetInteractorStyle(styleActor);</div><div><br></div><div>   rwi->SetRenderWindow(renWin);</div><div>   rwi->SetSize(640, 480);</div><div>   rwi->Initialize();</div><div>   renWin->Render();</div>
<div>   rwi->Start();</div><div><br></div><div><br></div>-- <br>José Ignacio Prieto
<div>Software developer</div><div>Biomedical Imaging Center</div><div>Pontificia Universidad Catolica de Chile</div></div>