ITK问题记录之SetFileName()

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yu253/article/details/78269579

在进行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();

猜你喜欢

转载自blog.csdn.net/yu253/article/details/78269579