<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>