【问题标题】:vector of 8-bit unsigned integer is not supported不支持 8 位无符号整数向量
【发布时间】:2015-07-19 01:13:06
【问题描述】:

我正在尝试使用 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: 像素类型:8 位无符号整数向量不是 在 2D byclass itk::simple::CannyEdgeDetectionImageFilter 中支持

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

这是对我的代码的一些补充。我尝试将 8 位无符号整数向量转换为支持的向量,但在这里我没有做到这一点。

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

sitk::ERROR: 过滤器不支持从转换向量转换 8 位无符号整数转 32 位浮点数

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

感谢任何帮助。

【问题讨论】:

  • 没问题。记住,好的格式永远是你的朋友;)

标签: c# c++ itk image-formats


【解决方案1】:

对于 2D byclass 中不支持 8 位无符号整数的错误,您可能需要在读取图像时更改一种方式,例如:

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

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

希望对你有帮助。

【讨论】:

    【解决方案2】:

    有几种方法可以将 Canny 滤镜应用于 RGB 图像。 (我假设它是 RGB 图像?)

    有很多方法可以将多分量图像转换为标量图像。一个简单的演员阵容没有很好的定义。它可能意味着亮度,矢量幅度等......

    一种选择是在图像的每个通道上独立运行算法,并获得红色边缘图像、蓝色边缘图像和绿色边缘图像。这是一些伪代码:

    for i in range(rgbimage.GetNumberOfComponentsPerPixel()):
       component_image = sitk.VectorIndexSelectionCast(rgbimage, i, sitk.sitkFloat32)
       edge_images[i] = sitk.CanneyEdgeDetection(component_image)
    
    edge_image = sitk.Compose(edge_images)
    

    或者,您可能需要标量边缘图像。您可以从 RGB 通道导出亮度、亮度或亮度,然后只运行一次 Canny 过滤器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-08
      • 2018-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      • 2016-05-08
      • 1970-01-01
      相关资源
      最近更新 更多