[Insight-users] how to load package in tcl for itk
Luis Ibanez
luis.ibanez at kitware.com
Fri, 09 Apr 2004 16:58:30 -0400
Hi Henkjan,
That day has come !
http://www.itk.org/cgi-bin/cvsweb.cgi/Insight/Examples/Visualization/?cvsroot=Insight
Thanks for contributing your code to ITK.
Regards,
Luis
-------------------------
Henkjan Huisman wrote:
> Attached tcl script will be in InsightToolkit/Examples/Visualization
> someday. It demonstrates how to use both itk and vtk in a tcl-scripting
> environment. You need the latest ConnectVTKITK from InsightApplications.
> The pkgIndex.tcl files of vtk, itk and ConnectVTKITK should be in your
> TCLLIB_PATH. See attached example.
>
> Happy tcl-ing
>
> Henkjan
>
> On Fri, 2004-03-26 at 04:38, wavelethe at pku.org.cn wrote:
>
>>that means, if i have NOT use tcl wrapers in vtk compiling, it would not work.
>>could you tell me the steps using tcl in itk/vtk?
>>(1) compile itk with tcl wrapers
>>(2) compile vtk with tcl wrapers
>>...
>>
>>
>>
>>>-----Original Message-----
>>>发件人: Brad King <brad.king at kitware.com>
>>>日期: Thu, 25 Mar 2004 09:03:45 -0500
>>>收件人: wavelethe at pku.org.cn
>>>抄送: "insight-users at itk.org" <insight-users at itk.org>
>>>主题: Re: [Insight-users] how to load package in tcl for itk
>>>wavelethe at pku.org.cn wrote:
>>>
>>>
>>>>after compiling SimpleLevelSetsExample seccessfully,
>>>>I was told that "Result:can't find package vtkinteraction" when i run View2DOutputInVTK.tcl in ASED
>>>>Errorinfo: can't find package vtkinteraction while execting
>>>>"package require vtkinteraction" invoked from within "interp eval $interp $command"
>>>>
>>>>I am newbie and learning them, and i need some direction
>>>>I have searched the file named "vtkinteraction", but only found one in vtkwrap directory
>>>
>>>This example depends on VTK for visualization. In order to run it
>>>correctly, you need to have the VTK tcl wrappers in your TCLLIBPATH.
>>>You should set the TCLLIBPATH variable to point at the Wrapping/Tcl
>>>directory in the VTK build tree.
>>>
>>>-Brad
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>---------------------------------------------------------------
>>欢迎使用北京大学校友网(PKUAA)电子邮件系统 http://www.pku.org.cn
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
>
>
>
> ------------------------------------------------------------------------
>
> # This file demonstrates how to connect VTK and ITK pipelines together
> # in scripted languages with the new ConnectVTKITK wrapping functionality.
> # Data is loaded in with VTK, processed with ITK and written back to disc
> # with VTK.
> #
> # For this to work, you have to build InsightApplications/ConnectVTKITK
> # as well.
> #
> # -- Charl P. Botha <cpbotha AT ieee.org>
> # -- Modified to Tcl version by H.J.Huisman (25 March 2004)
> # Execute this script by:
> # tclsh CannyEdgeDetectionImageFilterConnectVTKITK.tcl
> # You must set the environment variable TCLLIB_DIR to where the tcl
> # libraries are on your system. For example:
> # export TCLLIB_DIR="/data/usr/itk16/lib/InsightToolkit /data/usr/vtk422/lib/vtk /data/prog/InsightApplications-1.6.0/ConnectVTKITK/"
> #
> puts "Loading VTK package [package require vtk]"
> puts "Loading InsightToolkit [package require InsightToolkit]"
> puts "Loading ConnectVTKITK [package require ConnectVTKITK]"
> wm withdraw .
>
> # VTK will read the PNG image for us
> vtkPNGReader reader
> reader SetFileName "../../Testing/Data/Input/cthead1.png"
>
> # it has to be a single component, itk::VTKImageImport doesn't support more
> vtkImageLuminance lum
> lum SetInput [reader GetOutput]
>
> # let's cast the output to float
> vtkImageCast imageCast
> imageCast SetOutputScalarTypeToFloat
> imageCast SetInput [lum GetOutput]
>
> # the end-point of this VTK pipeline segment is a vtkImageExport
> vtkImageExport vtkExporter
> vtkExporter SetInput [imageCast GetOutput]
>
> # it connects to the itk::VTKImageImport at the beginning of
> # the subsequent ITK pipeline; two-dimensional float type
> set itkImporter [itkVTKImageImportF2_New]
>
> # Call the magic function that connects the two. This will only be
> # available if you built ITK with ITK_CSWIG_CONNECTVTKITK set to ON.
> ConnectVTKToITKF2 vtkExporter [$itkImporter GetPointer]
>
> # perform a canny edge detection and rescale the output
> set canny [itkCannyEdgeDetectionImageFilterF2F2_New]
> set rescaler [itkRescaleIntensityImageFilterF2US2_New]
> $canny SetInput [$itkImporter GetOutput]
> $rescaler SetInput [$canny GetOutput]
> $rescaler SetOutputMinimum 0
> $rescaler SetOutputMaximum 65535
>
> # this will form the end-point of the ITK pipeline segment
> set itkExporter [itkVTKImageExportUS2_New]
> $itkExporter SetInput [$rescaler GetOutput]
>
> # the vtkImageImport will bring our data back into VTK-land
> vtkImageImport vtkImporter
> # do the magic connection call (once again: only available if you built
> # ITK with ITK_CSWIG_CONNECTVTKITK set to ON)
> ConnectITKUS2ToVTK [$itkExporter GetPointer] vtkImporter
>
> # finally write the image to disk using VTK
> vtkPNGWriter writer
> writer SetFileName "testout.png"
> writer SetInput [vtkImporter GetOutput]
>
> # before we call Write() on the writer, it is prudent to give
> # our ITK pipeline an Update() call... this is not necessary
> # for normal error-less operation, but ensures that exceptions
> # thrown by ITK get through to us in the case of an error;
> # This is because the VTK wrapping system does not support
> # C++ exceptions.
> $rescaler Update
>
> # write the file to disk...
> writer Write
>
> puts "\n\nWrote testout.png to current directory."
> exit