<!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.2800.1479" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2><FONT face="Times New Roman" 
size=3>&gt;Hi,<BR><FONT face=Arial size=2>&gt;</FONT><BR>&gt;i'm trying to 
connect itk and vtk in python. I tried:<BR>&nbsp;&gt;&gt;&gt;&gt; 
conector=itkVTKImageExportUS2_New()<BR><FONT face=Arial 
size=2>&gt;</FONT><BR>&gt;but<BR><FONT face=Arial 
size=2>&gt;</FONT><BR>&nbsp;&gt;&gt;&gt;&gt; 
dir(conector)<BR>&gt;['AbortGenerateDataOff',... 
&gt;'GetNumberOfValidRequiredInputs', <BR>&gt;'GetOutputs', 
'GetPipelineModifiedCallback',... ]<BR><FONT face=Arial 
size=2>&gt;</FONT><BR>&gt;I didn't find a 'GetOutput' method, but a 'MakeOutput' 
&gt;and 'GetOutputs'. <BR>&gt;On the other hand, i have seen the Insight 
Application <BR>&gt;'ConnectVTKITKPython' in the itk examples.<BR><FONT 
face=Arial size=2>&gt;</FONT><BR>&gt;What is the right way to do the connection 
in python? Is &gt;the <BR>&gt;itkVTKImageExport still working? What<BR><FONT 
face=Arial size=2>&gt;</FONT><BR>&gt;Thanks a lot,<BR><FONT face=Arial 
size=2>&gt;</FONT><BR>&gt;-Eduardo</FONT><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Hi Eduardo,</DIV></FONT>
<DIV><FONT face=Arial size=2><FONT size=2>
<P>First you'll need compile InsightApplication ..... so you con use 
ConnectVTKITK !!!! </P>
<P>For example try this code :</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>##################################################</P>
<P>import vtk</P>
<P>import InsightToolkit as itk</P>
<P>import ConnectVTKITK as vtkitk</P>
<P>reader = vtk.vtkImageReader()</P>
<P>...</P>
<P>&nbsp;</P>
<P># </FONT><FONT face="Times New Roman" size=3>transform in </FONT><FONT 
size=2>FLOAT</P>
<P>imageCast = vtk.vtkImageCast()</P>
<P>imageCast.SetInput(reader.GetOutput())</P>
<P>imageCast.SetOutputScalarTypeToFloat()</P>
<P>imageCast.Update()</P>
<P>#VTK export</P>
<P>vtkExporter = vtk.vtkImageExport()</P>
<P>vtkExporter.SetInput(imageCast.GetOutput())</P>
<P>itkImporter = itk.itkVTKImageImportF2_New()</P>
<P>vtkitk.ConnectVTKToITKF2(vtkExporter, itkImporter.GetPointer())</P>
<P>itkImporter.Update()</P>
<P>&nbsp;</P>
<P># filter</P>
<P>otsu = itk.itkOtsuThresholdImageCalculatorF2_New()</P>
<P>otsu.SetImage(itkImporter.GetOutput())</P>
<P>otsu.Compute()</P>
<P>&nbsp;</P>
<P># ITK - &gt; VTK</P>
<P>itkExporter = itk.itkVTKImageExportF2_New()</P>
<P>itkExporter.SetInput(itkImporter.GetOutput())</P>
<P>vtkImporter = vtk.vtkImageImport()</P>
<P>vtkitk.ConnectITKF2ToVTK(itkExporter.GetPointer(), vtkImporter)</P>
<P>vtkImporter.Update()</P>
<P># print</P>
<P>mapper2D = vtk.vtkImageMapper()</P>
<P>mapper2D.SetInput(vtkImporter.GetOutput())#thresh.GetOutput())</P>
<P>mapper2D.SetColorLevel(level)</P>
<P>mapper2D.SetColorWindow(window)</P>
<P>imageActor2D = vtk.vtkActor2D()</P>
<P>imageActor2D.SetMapper(mapper2D)</P>
<P>ren2D = vtk.vtkRenderer()</P>
<P>ren2D.AddActor(imageActor2D)</P>
<P>win2D = vtk.vtkRenderWindow()</P>
<P>win2D.AddRenderer(ren2D)</P>
<P>win2D.Render()</P>
<P>&nbsp;</P>
<P>##################################################</P>
<P>to work with this you will have set PYTHONPATH with InsightToolkit 
,Application and VTK</P>
<P>Bruno Cassaro</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P></FONT></DIV></FONT></BODY></HTML>