参考官网上 ItkSoftwareGuide-ITK4.7.1 读写图像等基本操作时出现的问题:
需要指定读写图像的类型,否则程序出错,两种解决办法:
(1)
#include "itkBMPImageIO.h"
reader->SetFileName(fileName);
reader->SetImageIO(itk::BMPImageIO::New()); //指明何种类型图像
reader->Update();
(2)
#include "itkBMPImageIOFactory.h"
itk::BMPImageIOFactory::RegisterOneFactory();//将IOFactory与库连接起来
reader->Update();
感觉第二种好些。