ITK可视化及GUI编程详解.pdf
讲解人:罗火灵讲解人:罗火灵 QQ:348774226 MSN: Study ITK Together 一起学习一起学习ITK Study ITK Together 1 技术顾问技术顾问:张晓东:张晓东 QQ:285249802 Email: 第第四四节节 ITK可视化及可视化及GUI编程编程 主要内容主要内容 Study ITK Together 2 1.ITK+VTK 2.ITK+VTK+MFC 3.ITK+VTK+Qt 4.ITK+VTK+FLTK 5.ITK+VTK+wxWidget 1.ITK+VTK Study ITK Together 3(1)CMakeLists.txt cmake_minimum_required(VERSION 2.8)project(itk_vtk)#-find_package(ITK)if(ITK_FOUND)include($ITK_USE_FILE)else(ITK_FOUND)message(FATAL_ERROR Cannot build without ITK,Please set ITK_DIR.)endif(ITK_FOUND)#-find_package(VTK)if(VTK_FOUND)include($VTK_USE_FILE)else(VTK_FOUND)message(FATAL_ERROR Cannot build without VTK,Please set VTK_DIR.)endif(VTK_FOUND)#-add_executable(itk_vtk main.cpp itkImageToVTKImageFilter.txx)target_link_libraries(itk_vtk itkCommon itkIO vtkRendering vtkCommon)1.ITK+VTK Study ITK Together 4(2)类itkImageToVTKImageFilter 实现ITK与VTK的连接,在InsightApplications-3.20.0Auxiliaryvtk目录下能够找到这个类的源文件,是一个模板类,实现文件后缀为txx。ITK read/process VTK visualization itkImageToVTKImageFilter 1.ITK+VTK Study ITK Together 5(3)主程序源文件main.cpp /ITK headers#include itkImage.h#include itkImageFileReader.h#include itkImageToVTKImageFilter.h /VTK headers#include vtkImageViewer2.h#include vtkRenderWindowInteractor.h#include vtkSmartPointer.h#include int main(int argc,char*argv)if(argc 2)std:coutargument error.std:endl;std:coutformat:argv0 imageFilestd:endl;return-1;const char*fileName=argv1;1.ITK+VTK Study ITK Together 6 typedef itk:Image ImageType;typedef itk:ImageFileReader ReaderType;ReaderType:Pointer reader=ReaderType:New();reader-SetFileName(fileName);reader-Update();typedef itk:ImageToVTKImageFilter ITKToVTKImageType;ITKToVTKImageType:Pointer itk2vtk=ITKToVTKImageType:New();itk2vtk-SetInput(reader-GetOutput();itk2vtk-Update();vtkSmartPointer viewer=vtkSmartPointer:New();viewer-SetInput(itk2vtk-GetOutput();vtkSmartPointer interactor=vtkSmartPointer:New();viewer-SetupInteractor(interactor);viewer-Render();interactor-Start();return 0;2.ITK+VTK+MFC Study ITK Together 7 请看程序例子 3.ITK+VTK+Qt Study ITK Together 8 请看程序例子 4.ITK+VTK+FLTK Study ITK Together 9 请看itk application里的例子 1.ITK+VTK+wxWidget Study ITK Together 10 请参考medINRIA(http:/www-sop.inria.fr/asclepios/software/MedINRIA/)