c# - 不支持 8 位无符号整数 vector

标签 c# c++ itk image-formats

我正在尝试使用 Simple-itk 管理的 dll 在 .bmp 图像上应用 CannyEdgeDetectionImageFilter。

这是我的代码:

itk.simple.Image image1= SimpleITK.ReadImage("Input.bmp");

ImageFileReader read = new ImageFileReader();
read.SetFileName("Input.bmp");
read.Execute();

CannyEdgeDetectionImageFilter canny = new CannyEdgeDetectionImageFilter();
itk.simple.Image image2= canny.Execute(image1);//I got below exception here.

ImageFileWriter write = new ImageFileWriter();
write.SetFileName("Output.bmp");
write.Execute(image2,"Output.bmp", true);

我在执行 CannyEdgeDetectionImageFilter 时遇到了这个异常。

sitk::ERROR: Pixel type: vector of 8-bit unsigned integer is not supported in 2D byclass itk::simple::CannyEdgeDetectionImageFilter

如何将这个不受支持的东西转换为 simpleitk 支持的东西?

这是对我的代码的一些补充。我试图将 8 位无符号整数的 vector 转换为受支持的 vector ,但在这里我没有这样做。

CastImageFilter cast = new CastImageFilter();
PixelIDValueEnum p= cast.GetOutputPixelType();
image1= SimpleITK.Cast(image1, p);//I got below exception here.

sitk::ERROR: Filter does not support casting from casting vector of 8-bit unsigned integer to 32-bit float

我还能做些什么来处理这段代码吗?

感谢任何帮助。

最佳答案

对于8-bit unsigned integer not supported in 2D byclass的错误,你可能需要在读图的时候换一种方式,比如:

image = sitk.ReadImage("input.jpg", sitk.sitkInt8)

现在 sitk.CurvatureFlowimgWhiteMatter = sitk.ConnectedThreshold 可以工作了。

希望对您有所帮助。

关于c# - 不支持 8 位无符号整数 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30118427/

相关文章:

c++ - 重载c++模板类方法

cmake - ITK:找不到 ITKConfig.cmake

c++ - 如何编译库,然后将其与 ITK 一起使用

c# - 在托盘栏中显示当前语言布局

c# - SQLite .NET 是否在 CreateTable 方法中接受接口(interface)

c# - 在斜坡上以相同的速度移动球 - Unity 3D

C# JSON 解析而不是 R

c++ - ESP 的值没有正确保存

c++ - Boost C++ 宏参数计数错误

python - 填充 3D 图像上的孔