An unsigned 8-bit integer vector is not supported

I am trying to apply CannyEdgeDetectionImageFilter on a .bmp image using Simple-itk-driven dll.

here is my code:

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); 

I got this exception by executing CannyEdgeDetectionImageFilter.

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

How can I use this unsupported thing to support simpleitk?

here is some kind of audit of my code. I tried to use an unsigned 8-bit integer vector in a supported one, but here I cannot do it.

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

sitk :: ERROR: the filter does not support casting from a cast vector an 8-bit unsigned integer with a 32-bit float

Is there anything else I could do to work with this code?

Any help is appreciated.

+5
source share
2 answers

There are several ways to apply the Canny filter to an RGB image. (I assume this is an RGB image?)

There are many ways to convert a multi-component image to a scalar image. A simple listing is not defined. This may mean brightness, vector magnitude, etc.

One option is to run the algorithm independently on each channel of the image and get an image with a red edge, an image with a blue edge and an image with a green edge. Here are a few pseudo codes:

 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) 

Alternatively, you may need a scalar edge image. You can get brightness, brightness or brightness through RGB channels, and then run the Canny filter only once.

0
source

An 8-bit unsigned integer is not supported in a 2D subclass

you need to solve the problem while you read the image image = sitk.ReadImage ('AAT137 B7.jpg', sitk.sitkInt8) # 'AAT137 B7.jpg' is the image file in the directory

Now sitk.CurvatureFlow, imgWhiteMatter = sitk.ConnectedThreshold everything will work

hope this helps

0
source

All Articles