用ITK做三维图像处理时候,原始数据一般都是序列图像,那么序列图像的读取就是我们完成三维图像处理重要的起点。
序列图像读取用到了一下几个类:
#include<itkImageSeriesReader.h>
#include<itkNumericSeriesFileNames.h>
代码如下:
//声明像素类型和图像维数
typedef float InputPixelType;
typedef unsigned char OutputPixelType;
const unsigned int Dimension=2;
//实例化
typedef itk::Image<InputPixelType,3> InputImageType; //读取序列图像 图像类型应该为3维 第三个维度存储图片序列号
typedef itk::ImageSeriesReader<InputImageType> ReaderType;
ReaderType::Pointer reader=ReaderType::New();
//实例化文件名生成器
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer NameGenerator=NameGeneratorType::New();
//设置文件名模式 初始值 最后值 增加值
NameGenerator->SetSeriesFormat("E:/RootImgs/01C/HRAW/01C%04d.hraw");
NameGenerator->SetStartIndex(0);
NameGenerator->SetEndIndex