<!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>>Hi,<BR><FONT face=Arial size=2>></FONT><BR>>i'm trying to
connect itk and vtk in python. I tried:<BR> >>>>
conector=itkVTKImageExportUS2_New()<BR><FONT face=Arial
size=2>></FONT><BR>>but<BR><FONT face=Arial
size=2>></FONT><BR> >>>>
dir(conector)<BR>>['AbortGenerateDataOff',...
>'GetNumberOfValidRequiredInputs', <BR>>'GetOutputs',
'GetPipelineModifiedCallback',... ]<BR><FONT face=Arial
size=2>></FONT><BR>>I didn't find a 'GetOutput' method, but a 'MakeOutput'
>and 'GetOutputs'. <BR>>On the other hand, i have seen the Insight
Application <BR>>'ConnectVTKITKPython' in the itk examples.<BR><FONT
face=Arial size=2>></FONT><BR>>What is the right way to do the connection
in python? Is >the <BR>>itkVTKImageExport still working? What<BR><FONT
face=Arial size=2>></FONT><BR>>Thanks a lot,<BR><FONT face=Arial
size=2>></FONT><BR>>-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> </P>
<P> </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> </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> </P>
<P># filter</P>
<P>otsu = itk.itkOtsuThresholdImageCalculatorF2_New()</P>
<P>otsu.SetImage(itkImporter.GetOutput())</P>
<P>otsu.Compute()</P>
<P> </P>
<P># ITK - > 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> </P>
<P>##################################################</P>
<P>to work with this you will have set PYTHONPATH with InsightToolkit
,Application and VTK</P>
<P>Bruno Cassaro</P>
<P> </P>
<P> </P>
<P> </P></FONT></DIV></FONT></BODY></HTML>