ITK问题记录之SetFileName()

来源:互联网 发布:js获取select所有的值 编辑:程序博客网 时间:2024/05/22 16:55

在进行ITK程序调试时,使用官方文档的图像读写示例代码出错,出错代码如下:

    const char* filename = "D:\\FatMRISlice.bmp";    reader->SetFileName(filename);

需要指定读写图像的类型,正确的做法如下:

    #include "itkBMPImageIO.h"    const char* filename = "D:\\FatMRISlice.bmp";    reader->SetFileName(filename);    reader->SetImageIO(itk::BMPImageIO::New());   //这里需要指定读取图像的类型    reader->Update();

或者:

    #include "itkBMPImageIOFactory.h"    const char* filename = "D:\\FatMRISlice.bmp";    reader->SetFileName(filename);    itk::BMPImageIOFactory::RegisterOneFactory();//将IOFactory与库连接起来    reader->Update();
原创粉丝点击