ITK 程序测试
Hello World 程序
1.在D:\I_VTK\ITK目录下新建test文件夹;在test文件夹下新建两个文件夹,如图:
在
D:\VTK_research\Programm_VTK\ITK_HelloWorld
目录下编写如下两文件:
2.在D:\I_VTK\ITK\test\HelloWorld目录下编写如下两文件:
HelloWorld.cxx 代码如下:
#include "itkImage.h"
#include
int main()
{
typedef itk::Image< unsigned
short, 3 > ImageType;
ImageType::Pointer image =
ImageType::New();
std::cout <<
"ITK Hello World !" << std::endl;
return 0;
}
CMakeLists.txt 代码如下:
# This is the root ITK CMakeLists file.
cmake_minimum_required(VERSION 2.4)
if(COMMAND CMAKE_POLICY)
cmake_policy(SET CMP0003 NEW)
endif()
# This project is designed to be built outside the Insight source
tree.
project(HelloWorld)
# Find ITK.
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(HelloWorld HelloWorld.cxx )
target_link_libraries(HelloWorld ${ITK_LIBRARIES})
可在D:\I_VTK\ITK\InsightToolkit-4.3.2\Examples\Installation目录下找到上述两文件,直接Copy过来即可 利用Cmake编译后生成HelloWorld-bin文件,Cmake设置如下:
3.利用vs
2010打开HelloWorld.sln,在解决方案资源管理器中右键HelloWorld,设为启动项目,执行程序,即出现如下画面:
|