Twelve, ITK routines - Medical image registration program HelloWorld

I. Description

  Medical image registration is an important element of ITK, and a program we want to say today is the equivalent of one of the HelloWorld program.

  Program source code here:

InsightToolkit-5.0.1\Examples\RegistrationITKv4\\ImageRegistration1.cxx

 Two, ITK registration framework

  

Third, the main idea of ​​the program

  The main idea of ​​the program may be represented by the following block diagram:

  

  Where we need input and output files are as follows:

  

 

   But here, in order to facilitate reading program, this time I put all the parameters are all written in the program inside.

Fourth, the engineering building

 1- build the project

  According to previous methods, the use of already have the source file to build a project, and add property sheets and dynamic link library files.

 2- program modification

  Source program is not usable at this time, need minor modifications

  2.1 The location of each argv parameters directly modify the file name

  Parameters are as follows:

parameter content
argv[1] reference picture
argv[2] Pictures to be registered
argv[3] Output to be registered images (format output reference picture)
argv[4] Two input picture after picture of the difference between registration
argv[5] Two input images misregistration is shown when the difference between the picture

   Inside the actual program modifications:

// reference picture position 
fixedImageReader-> SetFileName ( " D: \\ FilesSetup of ITK \\ \\ \\ InsightToolkit-5.0.1 Examples \\ \\ BrainProtonDensitySliceBorder20.png the Data " ); //待配准图片位置
movingImageReader
->SetFileName("D:\\FilesSetup\\ITK\\InsightToolkit-5.0.1\\Examples\\Data\\BrainProtonDensitySliceShifted13x17y.png");
//文件写入位置,这三张图片全部都写入到本工程目录下
writer->SetFileName("D:\\Files\\ITKFiles\\ITK_6_Registration\\Data\OutputData\\Moving13x17yInputType.png");
writer2->SetFileName("D:\Files\ITKFiles\ITK_6_Registration\Data\OutputData\Moving13x17yInputType.png");
writer2->SetFileName("D:\\Files\\ITKFiles\\ITK_6_Registration\\Data\\OutputData\\DifferenceBeforeRegistration.png");

  2.2添加头文件

  因为要阅读png文件,所以需要添加png文件的IOFactory

#include "itkPNGImageIOFactory.h"

  初始化IOFactory:

itk::PNGImageIOFactory::RegisterOneFactory();

  2.3添加命令行参数

  因为程序里面有对输入参数的判断,当我们修改以后,还是要满足输入参数的个数(虽然我们已经不用这个参数了,但是这个判断条件是程序运行的触发条件)

  打开调试-属性:

  

 

   在调试-命令参数里面输入六个随意数字,以空格间隔:

 

 五、运行结果

  得到的几张图片与参考书吻合:

  

 

      控制台输出如下:

  

 

     可以看到,一共经过了36次迭代,最后计算出来的测度函数值为0.0007,然后得到的偏移量是(13,17),和图片的真实偏移量是符合的

六、参考

  InsightSoftwareGuide-Book2-5.0.1 Page189(书籍页码)

七、问题

  今天出了一个糗事,我在构建工程的时候,由于偷懒,直接复制的另外一个工程,然后程序都已经修改好了,不论怎么运行,都没有输出。

  还以为是函数复制出了问题,但是这个时候我才发现,我根本没有把这个main.cpp文件添加到工程里面。

  害的我特地对比了一下是不是函数复制的时候出了问题。

  ......

  不注重细节害死人啊。

Guess you like

Origin www.cnblogs.com/fantianliang/p/12079316.html