[Insight-users] itkBinaryThinningImageFilter3D support

Sergiy Volkovych volkovych at gmail.com
Wed Jul 7 06:43:05 EDT 2010


Here is the example when the filter doesn't work properly:

 const unsigned int dimension = 3;
 typedef ubyte ImagePixelType;
 typedef itk::Image<ImagePixelType, dimension> ImageType;

 ImageType::Pointer p_image = ImageType::New();

 ImageType::IndexType start;
 ImageType::SizeType size;
 start[0] = 0; start[1] = 0; start[2] = 0;
 size[0] = 50; size[1] = 50; size[2] = 50;

 ImageType::RegionType region;
 region.SetIndex(start);
 region.SetSize(size);

 p_image->SetRegions(region);
 p_image->Allocate();

 for (start[0] = 0; start[0] < size[0]; ++start[0])
   for (start[1] = 0; start[1] < size[1]; ++start[1])
     for(start[2] = 0; start[2] < size[2]; ++start[2])
       p_image->SetPixel(start, 0);

 //Set the ribbon: 1 voxel thick, 10 voxels length, 2 voxels wide.
 start[1] = 25;
 for (start[0] = 20; start[0] < 22; ++start[0])
   for(start[2] = 20; start[2] < 30; ++start[2])
     p_image->SetPixel(start, 1);

 typedef itk::BinaryThinningImageFilter3D< ImageType, ImageType >
ThinningFilterType;
 ThinningFilterType::Pointer thinningFilter = ThinningFilterType::New();
 thinningFilter->SetInput(p_image);
 thinningFilter->Update();

 ImageType::Pointer skeleton_image = thinningFilter->GetThinning();

 size_t counter = 0;
 for (start[0] = 0; start[0] < size[0]; ++start[0])
   for (start[1] = 0; start[1] < size[1]; ++start[1])
     for(start[2] = 0; start[2] < size[2]; ++start[2])
       if (skeleton_image->GetPixel(start))
         ++counter;

 CString str;
 str.Format(_T("The number of the skeleton points is: %d"), counter
); // for the given object we have 0 here
 AfxMessageBox(str);

The resulted skeleton is formed by 0 voxels, so the object completely
disappears.
-- 
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/itkBinaryThinningImageFilter3D-support-tp5259748p5264598.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list