主要实现的部分是利用NameGeneratorType读入系列图像,见头文件#include "itkNumericSeriesFileNames.h"。
需要包含的头文件有:
#include "itkImage.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"#include "itkNumericSeriesFileNames.h"
#include "itkPNGImageIO.h"//转成JPG格式,将PNG替换成JPEG就可以。
int main( int argc, char ** argv )
{
// 需要四个参数,分别是程序起点,第一张图像的编号和最后一张图像的变化,输出文件的名称(包含路径)
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " firstSliceValue lastSliceValue outputImageFile " << std::endl;
return EXIT_FAILURE;
}