<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Mengda,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>why do you want to save the ITK
deformation field to disk and </FONT></DIV>
<DIV><FONT face=Arial size=2>read it with a vtk reader???</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>You can translate the ITK vectorimage directly
to VTK using</FONT></DIV>
<DIV><FONT face=Arial size=2>itk::ImageToVTKImageFilter and display
it.</FONT></DIV>
<DIV><FONT face=Arial size=2>This way, you can use ITK Imagereaders and writers
to read and</FONT></DIV>
<DIV><FONT face=Arial size=2>write your vectordata.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>You can do this by the following
code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>typedef itk::Image<float,3>
DeformationFieldType;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>void
visualizeDeformationField(DeformationFieldType::Pointer
defField)<BR>{</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>try {</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> m_DefConnector =
itk::ImageToVTKImageFilter<DeformationFieldType>::New();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
m_DefConnector->SetInput(defField);<BR>
m_DefConnector->SetReleaseDataFlag(true); <BR>
m_DefConnector->Update();<BR> vtkImageData* m_vtkImage =
m_DefConnector->GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
m_outline->SetInput(m_vtkImage);<BR>
m_outlineMapper->SetInput(m_outline->GetOutput());</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
m_outlineActor->SetMapper(m_outlineMapper);<BR>
m_outlineActor->GetProperty()->SetColor(0.7, 0.3,
0.1);<BR> <BR> <BR> m_pointData =
m_vtkImage->GetPointData();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> if ( m_pointData ==
NULL )<BR>
{<BR> itkWarningMacro( <<
"vtkImage->GetPointData() returns NULL!"
);<BR> return
;<BR> }<BR> if (
m_pointData->GetNumberOfArrays() == 0 )<BR>
{<BR> itkWarningMacro( <<
"vtkImage->GetPointData()->GetNumberOfArrays() is 0!"
);<BR> return
;<BR> }<BR> else if
( m_pointData->GetArrayName( 0 ) == NULL )<BR>
{<BR>
m_vtkImage->GetPointData() ->GetArray( 0 ) ->SetName( "vectors"
);<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV><BR> m_arrowSource->Update();<BR>
<BR> m_maskPoints->SetInput(m_vtkImage);<BR>
m_maskPoints->SetMaximumNumberOfPoints(1000);<BR>
m_maskPoints->RandomModeOn();<BR>
m_maskPoints->Update();</DIV>
<DIV> </DIV>
<DIV>
m_deformationData->SetPoints(m_maskPoints->GetOutput()->GetPoints());<BR>
m_deformationData->GetPointData()->SetVectors(m_maskPoints->GetOutput()->GetPointData()->GetArray(0));</DIV>
<DIV> </DIV>
<DIV> double* range =
m_maskPoints->GetOutput()->GetPointData()->GetArray(0)->GetRange();<BR>
range[0] = 0;</DIV>
<DIV> </DIV>
<DIV> m_lut->RemoveAllPoints();<BR>
m_lut->AddRGBPoint(range[0],
0.0, 0.0, 1.0);<BR>
m_lut->AddRGBPoint(range[0]+(range[1]-range[0])/4, 0.0, 0.5,
0.5);<BR> m_lut->AddRGBPoint(range[0]+(range[1]-range[0])/2, 0.0,
1.0, 0.0);<BR> m_lut->AddRGBPoint(range[1]-(range[1]-range[0])/4,
0.5, 0.5, 0.0);<BR> m_lut->AddRGBPoint(range[1], 1.0, 0.0,
0.0);</DIV>
<DIV> </DIV>
<DIV> m_scalarBar->SetLookupTable( m_lut );<BR>
m_scalarBar->SetTitle("Vector magnitude value");<BR>
m_scalarBar->SetOrientationToVertical();<BR>
m_scalarBar->GetLabelTextProperty()->SetColor(0,0,1);<BR>
m_scalarBar->GetTitleTextProperty()->SetColor(0,0,1);</DIV>
<DIV> </DIV>
<DIV> m_glyph->SetSource(
m_arrowSource->GetOutput() );<BR>
m_glyph->SetInput(m_deformationData);<BR>
m_glyph->OrientOn();<BR>
m_glyph->SetVectorModeToUseVector();<BR>
m_glyph->ScalingOn();<BR>
m_glyph->SetScaleModeToScaleByVector();<BR>
m_glyph->SetColorModeToColorByVector();<BR> m_glyph->SetScaleFactor(
5.0 );<BR> m_glyph->Update();
<BR> <BR>
m_spikeMapper->SetInput(m_glyph->GetOutput());<BR>
m_spikeMapper->SetLookupTable( m_lut );<BR>
m_spikeMapper->Update();<BR>
<BR>
m_spikeActor->SetMapper(m_spikeMapper);<BR>
m_spikeActor->GetProperty()->SetColor(0.0, 0.79, 0.34);</DIV>
<DIV> </DIV>
<DIV> m_3DRenderer->AddActor( m_spikeActor
);<BR> m_3DRenderer->AddActor( m_outlineActor
);<BR> m_3DRenderer->AddActor( m_scalarBar
);<BR> <BR>
m_3DRenderer->GetActiveCamera()->SetViewUp(0, 0, -1);<BR>
m_3DRenderer->GetActiveCamera()->SetPosition(-2, -2, -2);<BR>
m_3DRenderer->GetActiveCamera()->SetFocalPoint(0, 0, 0);<BR>
m_3DRenderer->GetActiveCamera()->ComputeViewPlaneNormal();<BR>
m_3DRenderer->ResetCamera();<BR>
m_3DRenderer->ResetCameraClippingRange();<BR>
m_3DRenderer->SetBackground(0.0, 0.0, 0.0);</DIV>
<DIV> </DIV>
<DIV> m_3DRenderWindow->Start();<BR>
m_3DRenderer->Render();<BR> <BR>
m_3DRenderWindowInteractor->redraw();<BR></DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Kind Regards,</DIV>
<DIV>Markus</DIV></FONT></BODY></HTML>