Install ITK and VTK on Windows

Before downloading and installing ITK and VTK you need to know some facts and make some decisions.

 

1. ITK is a very powerful tool for processing and analyzing medical images. It is not a visualization tool. This means that you will need some other tools for viewing your data. After playing with VolView, DicomWorks and 3D Slicer you may decide that they will do for now. If this is the case you only need ITK. However if you want to create your own 3D models and in general, you have more sophisticated visualization needs, VTK is just the tool for you: go for both ITK and VTK.

 

2. ITK and VTK are C++ libraries. You can use Visual Studio to write your applications in C++. However both ITK and VTK are cross-platform applications and developers can create software using a variety of programming languages such as Tcl, Python and Java. So, what to use?

     I write my ITK applications in C++ using Visual Studio 2008 compiler. Because I expect to do most of my work in ITK I need to be comfortable with my working environment and I guess this means C++ for me. Plus, ITK comes with a lot of very handy examples and most of them are written in C++. They help a lot in understanding different techniques and make a good starting point for my own applications.

    VTK is a different story. Right now I use VTK only to support my ITK work. I could use C++ for VTK too, but I don't. I prefer Tcl, which I don't even know, really... There are several reasons for this: Tcl is very easy to read and quite intuitive for small scripts and more importantly, all VTK examples are written in Tcl. If you don't know Tcl it may sound like a very bad idea to do the same, but here is an example of the same script written in both Tcl and C++. I find Tcl code cleaner. And you don't have to deal with pointers. This must count for something...

 

3. Some dependencies you must be aware of: CMake is needed to manage the compilation process for both ITK and VTK. Other then that ITK stands alone. VTK depends on ITK and Tcl (if you decide to use it). InsightApplications (a separate CVS repository that contains a wide variety of sample code, that demonstrates how to build complete applications with ITK.) depends on ITK, VTK and Tcl.

 

4. There are several ways to get the software. You can download official or interim releases or you can access the CVS source-code repository.

    In order to take advantages of the changes done between versions I do the latest. This way I can update my ITK, VTK or InsightApplications repository at any time and I don't need to repeat the download and install process with every new release.

 

5. You need at least 2 GB free disk space to install Visual Studio and 4 GB to install ITK, VTK and Insight Applications.

 

Before starting:

  • install Visual Studio

  •  if you decide to access CVS repository you need a cvs client. I use WinCvs, but you can also use a command-line client. WinCvs requires that you have Pyton installed on your machine.

 

Step 1:

  • download and install CMake

 

Step 2:

  •  download and install Tcl - this is tricky. The current release is ActiveTcl 8.4.11. I found that there may be a version incompatibility between new Tcl releases and VTK. To be on the safe side I use Tcl 8.3. If you decide to use the latest version and get weird errors later (something like: "procedure entry point could not be located in the dynamic library vtkCommon.dll") come back and download the old version.

 

Step 3:

 

 

Step 4:

  •  download VTK

 

Step 5: build ITK

  • run CMake to generate Visual Studio workspaces. Running CMake requires two pieces of information: where the source code directory is located (the directory containing ITK on your machine) and where the object code is to be produced. Click "Configure" button. When the configuration is done, click "OK" to generate Visual Studio projects.

 

          CMakeSetup interface for Windows:

         

          Pic 1  set "BUILD_EXAMPLES" and "BUILD_TESTING" off, because compiling examples and testing will

                     take  a lot of time and need large space to store. Istead, we can select any single examples to build 

                     in our daily use.

                   "BUILD_SHARE_LIBS" : if set off, the compiler will only generate ".lib"(static library), I thick it's enough

                    for most of us. if set on, the compiler will generate .dll ,which size is smaller and the Applications(.exe) are

                    dependent to use.

 

  • go to the object code directory and click on ITK.sln to open the ITK project in Visual Studio. Build the solutions. This is going to take a while (an hour or so).

 

 

Step 6: build VTK

  •  run CMake to generate Visual Studio workspaces. First CMake requires two pieces of information: where the source code directory is located (the directory containing VTK on your machine) and where the object code is to be produced. Then you will need to provide information about where ITK and Tcl are installed on your machine. See the screenshot for my cache values. They should serve you as a guide. Click "Configure" button. When the configuration is done, click "OK" to generate Visual Studio projects.

 

          CMakeSetup interface for Windows:

 

 

 

CMake tries to find all the paths it needs. However, you may also be asked to provide some of them.

For instance, these are the cache values for Tcl on my machine.

 

TCL_INCLUDE_PATH: C:/Tcl/include8.3

TCL_LIBRARY: C:/Tcl/lib/tcl83.lib

TCL_TCLSH: C:/Tcl/bin/tclsh.exe

TK_LIBRARY: C:/Tcl/lib/tk83.lib

TK_XLIB_PATH: C:/Tcl/include8.3/X11

 

  •  go to the object code directory and click on VTK.sln to open the project in Visual Studio. Build the solutions.

 

Step 7: build InsightApplications

  • run CMake to generate Visual Studio workspaces. First CMake requires two pieces of information: where the source code directory is located (the directory containing InsightApplications on your machine) and where the object code is to be produced. Then you will need to provide information about where ITK, VTK and Tcl are installed on your machine. See the screenshot for my cache values. They should serve you as a guide. Click "Configure" button. When the configuration is done, click "OK" to generate Visual Studio projects.

 

          CMakeSetup interface for Windows:

 

 

  • go to the object code directory and click on InsightApplications.sln to open the project in Visual Studio. Build the solutions.

 

Step 8: update PATH

  •  add to your PATH system variable paths to the new libraries. On my machine these are:

           C:/Tcl/bin;
           C:/ITK/Insight_BIN/bin/debug;
           C:/VTK/VTK_BIN/bin/debug;
           C:/ITK/InsightApplications_BIN/vtkITK/Wrapping/Tcl/Debug;

  • create a new system variable TCLLIBPATH and to set it to C:/VTK/VTK_BIN/Wrapping/Tcl

 

      Remember that these paths are specific to my machine. You need to change them accordingly.

 

Step 9: build your work

  •  to create a new project with ITK you need at least two files. First is "CMakeLists.txt" which is used by CMake to generate your Visual Studio project. In ITK examples directory you can find several examples of this file. The second file you need is a C++ file. Once you have these files, run CMake and then build your solution in Visual Studio.

 

 

Good luck and enjoy ITK!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值