c++ - 在 ITK 中实例化 ImageToPathFilter

标签 c++ itk

我正在尝试使用 ImageToPathFilter在 ITK 中,但我无法使用普通的 ClassName::Pointer = ClassName::New(); 实例化它例行公事。

这是我的代码

typedef itk::Image<unsigned int, 3>  LabelImageType;
typedef itk::ChainCodePath<2> PathType;
typedef itk::ImageToPathFilter<LabelImageType, PathType> ImageToPathType;
ImageToPathType::Pointer filter = ImageToPathType::New();

最后一行导致以下错误

cannot convert from 'itk::SmartPointer<itk::PathSource<TOutputPath>>' to 'itk::SmartPointer<itk::ImageToPathFilter<LabelImageType,PathType>>'

此类被公布为过滤器,但它继承自 PathSource所以使用PathSource<PathType>而不是 ImageToPathFilter有效,但我不能使用 SetInput()就像我使用 ITK 过滤器一样。

我认为解决方案可能涉及一些类型转换魔法,但我在这方面非常无知。

谢谢

最佳答案

事实证明,itk::ImageToPathFilter 类是一个不打算实例化的基类。

使用智能指针的 ITK 类在它们的定义中有 itkNewMacro,但是这个类没有,在这个类上调用 New() 最终会调用父类的New() 即 itk::PathSource。这解释了错误消息。

关于c++ - 在 ITK 中实例化 ImageToPathFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36830043/

相关文章:

c++ - RTTI(运行时类型信息)是否用于静态转换?

c++ - 如何测试字符串是否具有特定的 unicode 字符?

c++ - 使用变量在C++中打开文件

c++ - 在 ubuntu 上启动 ITK/VTK 项目时出错

c++ - C++ 的 VTK 和 ITK

image-processing - dicom系列中z维度的间距值和厚度(0018、0050)有何不同?

c++ - C++/boost/thread 中可能出现死锁

c++ - cURL Windows 构建配置的说明

C++ MSVS 项目内链接器错误 LNK2019 - 声明定义不匹配?

c++ - Linux 上的 QT、VTK 项目未运行