[Insight-users] itk with vtk question ?

Rodrigo Trujillo Rodrigo Trujillo" <rodrigo.trujillo at cenpra.gov.br
Fri, 26 Mar 2004 09:04:55 -0300


This is a multi-part message in MIME format.

------=_NextPart_000_0114_01C41311.68265190
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Yasser,


I also had this problem.  Try to update Insight from CVS with tag =
"ITK-1-6"
and rebuild.


Rodrigo Trujillo

  ----- Original Message -----=20
  From: yasser.khadra=20
  To: insight-users at itk.org=20
  Sent: Friday, March 26, 2004 7:10 AM
  Subject: [Insight-users] itk with vtk question ?


  Hi all,

  I compiled vtk 4.5, itk 1.6 for c++ and python and i compiled the =
application which do the connection between itk and vtk in python ...

  but when i write my first application in python i have this error :
  error message:

  > Executing: C:\Program Files\ConTEXT\ConExec.exe =
"C:\Creatis\Python22\python.exe" "F:\Programs\python\itk\2\test.py"

  Traceback (most recent call last):
    File "F:\Programs\python\itk\2\test.py", line 19, in ?
      CVIPy.ConnectVTKToITKF2(vtkExporter,itkImporter.GetPointer())
  TypeError: Type error. Expected =
_p_itk__VTKImageImportTitk__ImageTfloat_2_t_t
  > Execution finished.


  i dont know what i can do for that .

  note : i compiled the same version of vtk and itk 1.4 and the same =
application (in itk 1.4) it work ....

  this is my application in python  :

  import InsightToolkit as itk

  import vtkpython as vtk
  import ConnectVTKITKPython as CVIPy

  reader =3D vtk.vtkPNGReader()
  reader.SetFileName("Brain.png")

  imageCast =3D vtk.vtkImageCast()
  imageCast.SetOutputScalarTypeToFloat()
  imageCast.SetInput(reader.GetOutput())
  imageCast.Update()
  vtkExporter =3D vtk.vtkImageExport()
  vtkExporter.SetInput(imageCast.GetOutput())

  itkImporter =3D itk.itkVTKImageImportF2_New()

  CVIPy.ConnectVTKToITKF2(vtkExporter,itkImporter.GetPointer())

  thr=3Ditk.itkThresholdImageFilterF2_New()
  thr.SetInput(itkImporter.GetOutput())
  thr.ThresholdOutside(200,229)
  thr.SetOutsideValue(0)
  thr.Update()



  rescaler =3D itk.itkRescaleIntensityImageFilterF2US2_New()
  rescaler.SetInput(thr.GetOutput())
  rescaler.SetOutputMinimum(0)
  rescaler.SetOutputMaximum(255)
  rescaler.Update()

  itkExporter =3D itk.itkVTKImageExportUS2_New()
  itkExporter.SetInput(rescaler.GetOutput())

  vtkImporter =3D vtk.vtkImageImport()

  CVIPy.ConnectITKUS2ToVTK(itkExporter.GetPointer(), vtkImporter)

  Viewer=3Dvtk.vtkImageViewer()
  Viewer.SetInput(vtkImporter.GetOutput())
  Viewer.SetZSlice(0)

  Viewer.SetColorWindow(255)
  Viewer.SetColorLevel(128)
  Viewer.Render()

  RenWinInt=3Dvtk.vtkRenderWindowInteractor()
  Viewer.SetupInteractor  (RenWinInt)
  RenWinInt.Initialize()
  RenWinInt.Render()
  RenWinInt.Start()


  vtkwriter =3D vtk.vtkPNGWriter()
  vtkwriter.SetFileName('testout.png')
  vtkwriter.SetInput(vtkImporter.GetOutput())
  vtkwriter.Write()




  thanks in advance
  Yasser KHADRA


  ________________________________________
  Yasser KHADRA -- Doctorat Images et Syst=E8mes

  CREATIS, UMR 5515=20
  INSA - B=E2timent Blaise Pascal
  7, Rue Jean Capelle -- Campus de la Doua
  69621 Villeurbanne Cedex=20
  France
  Tel: 33 4 72 43 64 67
  Fax: 33 4 72 43 63 12
  e-mail: yasser.khadra at creatis.insa-lyon.fr=20
  http://www.creatis.insa-lyon.fr




  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.588 / Virus Database: 372 - Release Date: 13/2/2004
------=_NextPart_000_0114_01C41311.68265190
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Yasser,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I also had this problem.&nbsp;&nbsp;Try =
to update=20
Insight from CVS with tag "ITK-1-6"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and rebuild.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Rodrigo Trujillo</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dyasser.khadra at creatis.insa-lyon.fr=20
  href=3D"mailto:yasser.khadra at creatis.insa-lyon.fr">yasser.khadra</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dinsight-users at itk.org=20
  href=3D"mailto:insight-users at itk.org">insight-users at itk.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, March 26, 2004 =
7:10=20
AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Insight-users] itk =
with vtk=20
  question ?</DIV>
  <DIV><BR></DIV>Hi all,<BR><BR>I compiled vtk 4.5, itk 1.6 for c++ and =
python=20
  and i compiled the application which do the connection between itk and =
vtk in=20
  python ...<BR><BR>but when i write my first application in python i =
have this=20
  error :<BR>error message:<BR><BR>&gt; Executing: C:\Program=20
  Files\ConTEXT\ConExec.exe "C:\Creatis\Python22\python.exe"=20
  "F:\Programs\python\itk\2\test.py"<BR><BR>Traceback (most recent call=20
  last):<BR>&nbsp; File "F:\Programs\python\itk\2\test.py", line 19, in=20
  ?<BR>&nbsp;&nbsp;&nbsp;=20
  =
CVIPy.ConnectVTKToITKF2(vtkExporter,itkImporter.GetPointer())<BR>TypeErro=
r:=20
  Type error. Expected =
_p_itk__VTKImageImportTitk__ImageTfloat_2_t_t<BR>&gt;=20
  Execution finished.<BR><BR><BR>i dont know what i can do for that=20
  .<BR><BR>note : i compiled the same version of vtk and itk 1.4 and the =
same=20
  application (in itk 1.4) it work ....<BR><BR>this is my application in =

  python&nbsp; :<BR><BR>import InsightToolkit as itk<BR><BR>import =
vtkpython as=20
  vtk<BR>import ConnectVTKITKPython as CVIPy<BR><BR>reader =3D=20
  vtk.vtkPNGReader()<BR>reader.SetFileName("Brain.png")<BR><BR>imageCast =
=3D=20
  =
vtk.vtkImageCast()<BR>imageCast.SetOutputScalarTypeToFloat()<BR>imageCast=
.SetInput(reader.GetOutput())<BR>imageCast.Update()<BR>vtkExporter=20
  =3D=20
  =
vtk.vtkImageExport()<BR>vtkExporter.SetInput(imageCast.GetOutput())<BR><B=
R>itkImporter=20
  =3D=20
  =
itk.itkVTKImageImportF2_New()<BR><BR>CVIPy.ConnectVTKToITKF2(vtkExporter,=
itkImporter.GetPointer())<BR><BR>thr=3Ditk.itkThresholdImageFilterF2_New(=
)<BR>thr.SetInput(itkImporter.GetOutput())<BR>thr.ThresholdOutside(200,22=
9)<BR>thr.SetOutsideValue(0)<BR>thr.Update()<BR><BR><BR><BR>rescaler=20
  =3D=20
  =
itk.itkRescaleIntensityImageFilterF2US2_New()<BR>rescaler.SetInput(thr.Ge=
tOutput())<BR>rescaler.SetOutputMinimum(0)<BR>rescaler.SetOutputMaximum(2=
55)<BR>rescaler.Update()<BR><BR>itkExporter=20
  =3D=20
  =
itk.itkVTKImageExportUS2_New()<BR>itkExporter.SetInput(rescaler.GetOutput=
())<BR><BR>vtkImporter=20
  =3D=20
  =
vtk.vtkImageImport()<BR><BR>CVIPy.ConnectITKUS2ToVTK(itkExporter.GetPoint=
er(),=20
  =
vtkImporter)<BR><BR>Viewer=3Dvtk.vtkImageViewer()<BR>Viewer.SetInput(vtkI=
mporter.GetOutput())<BR>Viewer.SetZSlice(0)<BR><BR>Viewer.SetColorWindow(=
255)<BR>Viewer.SetColorLevel(128)<BR>Viewer.Render()<BR><BR>RenWinInt=3Dv=
tk.vtkRenderWindowInteractor()<BR>Viewer.SetupInteractor<X-TAB>&nbsp;&nbs=
p;</X-TAB>(RenWinInt)<BR>RenWinInt.Initialize()<BR>RenWinInt.Render()<BR>=
RenWinInt.Start()<BR><BR><BR>vtkwriter=20
  =3D=20
  =
vtk.vtkPNGWriter()<BR>vtkwriter.SetFileName('testout.png')<BR>vtkwriter.S=
etInput(vtkImporter.GetOutput())<BR>vtkwriter.Write()<BR><BR><BR><BR><BR>=
thanks=20
  in advance<BR>Yasser KHADRA<BR><BR><X-SIGSEP>
  <P></X-SIGSEP>________________________________________<BR><FONT=20
  color=3D#000080>Yasser </FONT><FONT color=3D#008000>KHADRA</FONT><FONT =

  color=3D#000080> -- Doctorat </FONT><FONT =
color=3D#ff0000>Images</FONT><FONT=20
  color=3D#000080> et </FONT><FONT =
color=3D#0000ff>Syst=E8mes<BR><BR></FONT><FONT=20
  color=3D#000080>CREATIS, UMR 5515 <BR>INSA - B=E2timent Blaise =
Pascal<BR>7, Rue=20
  Jean Capelle -- Campus de la Doua<BR>69621 Villeurbanne Cedex =
<BR></FONT><FONT=20
  color=3D#800000>France<BR></FONT><FONT color=3D#000080>Tel: 33 4 72 43 =
64=20
  67<BR>Fax: 33 4 72 43 63 12<BR>e-mail: =
yasser.khadra at creatis.insa-lyon.fr=20
  <BR></FONT><FONT color=3D#0000ff><U><A =
href=3D"http://www.creatis.insa-lyon.fr/"=20
  =
eudora=3D"autourl">http://www.creatis.insa-lyon.fr</A><BR><BR></P></U></F=
ONT></BLOCKQUOTE>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"><FONT=20
  color=3D#0000ff><U><BR>---<BR>Outgoing mail is certified Virus =
Free.<BR>Checked=20
  by AVG anti-virus system (<A=20
  =
href=3D"http://www.grisoft.com">http://www.grisoft.com</A>).<BR>Version: =
6.0.588=20
  / Virus Database: 372 - Release Date:=20
13/2/2004</FONT></U></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0114_01C41311.68265190--