ITK解决无法读取PNG图像的问题

需要加上以下代码:

#include <itkPNGImageIOFactory.h>// PNG对应
itk::PNGImageIOFactory::RegisterOneFactory();

完整代码: 

#include "itkImage.h"//图像类的头文件
#include "itkImageFileReader.h"//图像读取类的头文件
#include <itkPNGImageIOFactory.h>// PNG对应

int main(int, char* argv[])
{
	itk::PNGImageIOFactory::RegisterOneFactory();
	//指定表示图像的像素和维数的值来定义图像的类型
	typedef unsigned char          PixelType;//图像的像素类型
	const unsigned int             Dimension = 3;//图像的维数
	//定义图像的类型ImageType
	typedef itk::Image< PixelType, Dimension >   ImageType;
	//使用图像类型把图像读取 Reader 类实例化
	typedef itk::ImageFileReader< ImageType >  ReaderType;
	//使用ReaderType类型来创建一个对象reader
	ReaderType::Pointer reader = ReaderType::New();
	//图像的文件名通过 SetFileName( )方法来实现

   //const char * filename = argv[0];
	reader->SetFileName("VisibleWomanEyeSlice.png");
	reader->Update();

	// Reader 使用 GetOutput( )方法来访问新读取的图像
	ImageType::Pointer image = reader->GetOutput();

	return EXIT_SUCCESS;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值