[ITK] ConnectedComponentImageFilter and RelabelComponentImageFilter
Bradley Lowekamp
blowekamp at mail.nih.gov
Fri Apr 15 10:58:17 EDT 2016
Hello,
I have done this workflow many time to weed out the small islands, with great success.
What do yo mean you program “crashes”? Is it a segfault? Is an ITK exception thrown? Where in the code does it crash? There are many types of crashes, you should be a little more specific.
What is the typedef for “ImageType”? Perhaps you are only using uchar and there is not enough values for the number of components. Using the type “unsigned int” may be better for this type.
Just a guess.
The alternative approach would be to use the LabelMap framework. You would start with a filter like “BinaryImageToShapeLabelMap” or “BinaryImageToStatisticsLableMap”, this would compute a variety of statistics beyond just size for each label object. This may allow better filtering of the desired attributes.
HTH,
Brad
> On Apr 15, 2016, at 10:36 AM, Zein Salah <zeinsalah at gmail.com> wrote:
>
> Hi,
>
> I am doing kind of thresholding on CT images. The result is a binary image
> with the parts of the images I need. However, the resulting image contains
> a large number of small pieces (sparkle-like) that I want to remove. I thought,
> the combination of ConnectedComponentImageFilter and RelabelComponentImageFilter
> would accomplish the tast.
>
> Si, I tried the code below to get rid of pieces that are smaller than
> 1000 voxels.
>
> typedef itk::ConnectedComponentImageFilter<BinaryImageType,
> ImageType> ConnectedComponentImageFilterType;
> ConnectedComponentImageFilterType::Pointer connectedComponent =
> ConnectedComponentImageFilterType::New();
> connectedComponent->SetInput(segmentedImage);
> connectedComponent->ReleaseDataFlagOn();
>
> typedef itk::RelabelComponentImageFilter<ImageType, ImageType>
> RelabelFilterType;
> RelabelFilterType::Pointer relabel = RelabelFilterType::New();
> relabel->SetInput(connectedComponent->GetOutput());
> relabel->SetMinimumObjectSize(1000);
> relabel->Update();
>
> Principally, this works. However, In some situations, the program craches
> and I think this is due to a huge number of components, some of which are
> probably few voxels in size.
>
> 1. Does the ConnectedComponentImageFilter compute the size of component?
> Is there a way to force it ignore small ones?
>
> 2. If anybody had a better idea to doing the task I described, I would
> be thankful.
>
> Best,
>
>
> Zeno
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
More information about the Community
mailing list