[Insight-users] Problem in visualization of the deformation field using vtk

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 9 12:23:31 EST 2009


Hi Vidhya,

Thanks for posting the .vtk file with the deformation field
and the screen shot of the visualization that you get so far.

I did the following:

1) Loaded your .vtk file in ParaView,

2) Use the "Calculator" in order to compose the
    new image:

            scalars_X*iHat + scalars_Y*jHat

    that yields an image of 3 components.

3)  Then use the Glyph filter , and select
     Glyph type :  "2D Glyph"  that opens
     a new frame with sub-options, in which
     I selected :  "Glyph type" = "Arrow"


That produces the attached visualization.


In short, I believe, that even if you are generating
a 2D deformation field visualization, you still need
to provide an image with 3 components.


     Regards,


         Luis



---------------------------------------------------------------------
On Tue, Dec 8, 2009 at 11:17 AM, vidhyadhari <vgondle at gmail.com> wrote:
> Thanx for the reply. But I'm afraid, its not working. i am sending the
> input .vtk file and a screenshot of the output in the attachment of
> this email. Please point me towards the probable mistakes that i have
> made.
>
> regards,
> Vidhya
>
> On Tue, Dec 8, 2009 at 6:52 PM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>> Hi Vidhayadhari
>>
>>
>> Since you are doing this in 2D,
>>
>> You may want to replace the vtkArrowSource (as the Glyph source)
>> with the vtkGlyphSource2D class:
>>
>> http://www.vtk.org/doc/release/4.0/html/classvtkGlyphSource2D.html
>>
>> and to set it to produce arrows, by calling its method:
>>
>>                     SetGlyphTypeToArrow ()
>>
>>
>>     Regards,
>>
>>
>>          Luis
>>
>>
>> --------------------------------------------------------------------------------------
>> On Tue, Dec 8, 2009 at 5:00 AM, vidhyadhari <vgondle at gmail.com> wrote:
>>> hi,
>>>   I am new to ITK. I have a problem in visualization of the
>>> deformation field from a .vtk file using vtk. The following is my code
>>> -----------------------------------------------------------------------------------------------
>>>
>>> int main( int argc, char **argv )
>>> {  const unsigned int ImageDimension = 2;
>>>  typedef float PixelType;
>>>
>>>  typedef itk::Vector < float, ImageDimension > VectorType;
>>>  typedef itk::Image <VectorType, ImageDimension > ImageType;
>>>  typedef itk::ImageFileReader < ImageType > FieldReaderType;
>>>
>>>  FieldReaderType::Pointer reader = FieldReaderType::New ();
>>>  reader->SetFileName( argv[1] );
>>>  reader->Update();
>>>
>>>  typedef itk::VTKImageExport< ImageType > ExportFilterType;
>>>  ExportFilterType::Pointer itkExporter = ExportFilterType::New();
>>>
>>>  itkExporter->SetInput( reader->GetOutput() );
>>>
>>>  vtkImageImport* vtkImporter = vtkImageImport::New();
>>>  ConnectPipelines(itkExporter, vtkImporter);
>>>
>>>  vtkArrowSource *arrow = vtkArrowSource::New();
>>>  vtkMaskPoints *masker = vtkMaskPoints::New();
>>>
>>>  masker->SetOnRatio( 1000 );
>>>  masker->RandomModeOff();
>>>  masker->SetInputConnection( vtkImporter->GetOutputPort() );
>>>
>>>  vtkGlyph2D *glyph = vtkGlyph2D::New();
>>>  glyph->SetInputConnection( masker->GetOutputPort() );
>>>  glyph->SetSourceConnection( arrow->GetOutputPort() );
>>>  glyph->SetVectorModeToUseVector();
>>>  glyph->SetColorModeToColorByScalar();
>>>  glyph->SetScaleModeToDataScalingOff();
>>>  glyph->OrientOn();
>>>  glyph->SetScaleFactor( 0.2 );
>>>
>>>  vtkPolyDataMapper *glyphmapper = vtkPolyDataMapper::New();
>>>  glyphmapper->SetInputConnection(glyph->GetOutputPort());
>>>  glyphmapper->ScalarVisibilityOn();
>>>
>>>   vtkActor *glyphactor = vtkActor::New();
>>>   glyphactor->SetMapper(glyphmapper);
>>>
>>>   vtkRenderer *renderer = vtkRenderer::New();
>>>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>>>   renWin->AddRenderer(renderer);
>>>
>>>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>>>   iren->SetRenderWindow(renWin);
>>>
>>>  renderer->AddActor(glyphactor);
>>>  renderer->SetBackground(0,0,0);
>>>  renderer->ResetCamera();
>>>  renderer->GetActiveCamera()->Elevation(60.0);
>>>  renderer->GetActiveCamera()->Azimuth(30.0);
>>>  renderer->GetActiveCamera()->Zoom(1.25);
>>>  renWin->SetSize(100,100);
>>>
>>>
>>>  renWin->Render();
>>>  iren->Start();
>>>
>>>  renderer->Delete();
>>>  renWin->Delete();
>>>  iren->Delete();
>>>
>>>  return 0;
>>> }
>>>
>>>
>>> void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
>>> {
>>>
>>> importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
>>>
>>> importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
>>>  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
>>>  importer->SetSpacingCallback(exporter->GetSpacingCallback());
>>>  importer->SetOriginCallback(exporter->GetOriginCallback());
>>>  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
>>>
>>> importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
>>>
>>> importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
>>>  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
>>>  importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
>>>  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
>>>  importer->SetCallbackUserData(exporter->GetCallbackUserData());
>>> }
>>>
>>> -------------------------------------------------------------
>>>
>>> I get a set of white arrows along some diagonal which remains same
>>> even if I change the input file. Could you please give me some
>>> suggestions on how to view the deformation field using vtk.
>>>
>>> regards,
>>> vidhyadhari.
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VectorField.png
Type: image/png
Size: 15678 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091209/0ac0b22a/attachment.png>


More information about the Insight-users mailing list