[Insight-users] itk with vtk question ?

yasser.khadra yasser.khadra at creatis.insa-lyon.fr
Fri, 26 Mar 2004 11:10:25 +0100


--=====================_57997312==_.ALT
Content-Type: text/plain; charset="iso-8859-1"; format=flowed
Content-Transfer-Encoding: quoted-printable

Hi all,

I compiled vtk 4.5, itk 1.6 for c++ and python and i compiled the=20
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=20
"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=20
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
INSA - B=E2timent Blaise Pascal
7, Rue Jean Capelle -- Campus de la Doua
69621 Villeurbanne Cedex
France
Tel: 33 4 72 43 64 67
Fax: 33 4 72 43 63 12
e-mail: yasser.khadra at creatis.insa-lyon.fr
http://www.creatis.insa-lyon.fr


--=====================_57997312==_.ALT
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
Hi all,<br>
<br>
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
...<br>
<br>
but when i write my first application in python i have this error :<br>
error message:<br>
<br>
&gt; Executing: C:\Program Files\ConTEXT\ConExec.exe
&quot;C:\Creatis\Python22\python.exe&quot;
&quot;F:\Programs\python\itk\2\test.py&quot;<br>
<br>
Traceback (most recent call last):<br>
&nbsp; File &quot;F:\Programs\python\itk\2\test.py&quot;, line 19, in
?<br>
&nbsp;&nbsp;&nbsp;
CVIPy.ConnectVTKToITKF2(vtkExporter,itkImporter.GetPointer())<br>
TypeError: Type error. Expected
_p_itk__VTKImageImportTitk__ImageTfloat_2_t_t<br>
&gt; Execution finished.<br>
<br>
<br>
i dont know what i can do for that .<br>
<br>
note : i compiled the same version of vtk and itk 1.4 and the same
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 vtk<br>
import ConnectVTKITKPython as CVIPy<br>
<br>
reader =3D vtk.vtkPNGReader()<br>
reader.SetFileName(&quot;Brain.png&quot;)<br>
<br>
imageCast =3D vtk.vtkImageCast()<br>
imageCast.SetOutputScalarTypeToFloat()<br>
imageCast.SetInput(reader.GetOutput())<br>
imageCast.Update()<br>
vtkExporter =3D vtk.vtkImageExport()<br>
vtkExporter.SetInput(imageCast.GetOutput())<br>
<br>
itkImporter =3D 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,229)<br>
thr.SetOutsideValue(0)<br>
thr.Update()<br>
<br>
<br>
<br>
rescaler =3D itk.itkRescaleIntensityImageFilterF2US2_New()<br>
rescaler.SetInput(thr.GetOutput())<br>
rescaler.SetOutputMinimum(0)<br>
rescaler.SetOutputMaximum(255)<br>
rescaler.Update()<br>
<br>
itkExporter =3D itk.itkVTKImageExportUS2_New()<br>
itkExporter.SetInput(rescaler.GetOutput())<br>
<br>
vtkImporter =3D vtk.vtkImageImport()<br>
<br>
CVIPy.ConnectITKUS2ToVTK(itkExporter.GetPointer(), vtkImporter)<br>
<br>
Viewer=3Dvtk.vtkImageViewer()<br>
Viewer.SetInput(vtkImporter.GetOutput())<br>
Viewer.SetZSlice(0)<br>
<br>
Viewer.SetColorWindow(255)<br>
Viewer.SetColorLevel(128)<br>
Viewer.Render()<br>
<br>
RenWinInt=3Dvtk.vtkRenderWindowInteractor()<br>
Viewer.SetupInteractor<x-tab>&nbsp;&nbsp;</x-tab>(RenWinInt)<br>
RenWinInt.Initialize()<br>
RenWinInt.Render()<br>
RenWinInt.Start()<br>
<br>
<br>
vtkwriter =3D vtk.vtkPNGWriter()<br>
vtkwriter.SetFileName('testout.png')<br>
vtkwriter.SetInput(vtkImporter.GetOutput())<br>
vtkwriter.Write()<br>
<br>
<br>
<br>
<br>
thanks in advance<br>
Yasser KHADRA<br>
<br>
<x-sigsep><p></x-sigsep>
________________________________________<br>
<font color=3D"#000080">Yasser
</font><font color=3D"#008000">KHADRA</font><font color=3D"#000080"> --
Doctorat </font><font color=3D"#FF0000">Images</font><font color=3D"#000080"=
>
et </font><font color=3D"#0000FF">Syst=E8mes<br>
<br>
</font><font color=3D"#000080">CREATIS, UMR 5515 <br>
INSA - B=E2timent Blaise Pascal<br>
7, Rue Jean Capelle -- Campus de la Doua<br>
69621 Villeurbanne Cedex <br>
</font><font color=3D"#800000">France<br>
</font><font color=3D"#000080">Tel: 33 4 72 43 64 67<br>
Fax: 33 4 72 43 63 12<br>
e-mail: yasser.khadra at creatis.insa-lyon.fr <br>
</font><font color=3D"#0000FF"><u><a href=3D"http://www.creatis.insa-lyon.fr=
/" eudora=3D"autourl">http://www.creatis.insa-lyon.fr</a><br>
<br>
</font></u></html>

--=====================_57997312==_.ALT--