[Insight-users] How to use itkBinaryPruningImageFilter

di xiao xiaodi68 at hotmail.com
Thu Jun 9 22:39:32 EDT 2011


Hi Robert:

Thanks for pointing out that. After going back to the source code, I realized the filter actually was designed for a binary image with 0-background and 1-foreground.

I also tested it and got the following experience and want to share it with all users.

1. The length of the "spurs" being removed is decided by the value of iteration.
2. All "branch" tips will be removed during the iteration process.
3. According to the source code of the algorithm

  typename NeighborhoodIteratorType::RadiusType radius;
  radius.Fill(1);
  NeighborhoodIteratorType ot( radius, pruneImage, region );

  typename NeighborhoodIteratorType::OffsetType offset1 = {{-1,-1}};
  typename NeighborhoodIteratorType::OffsetType offset2 = {{-1,0}};
  typename NeighborhoodIteratorType::OffsetType offset3 = {{-1,1 }};
  typename NeighborhoodIteratorType::OffsetType offset4 = {{0,1}};
  typename NeighborhoodIteratorType::OffsetType offset5 = {{1,1}};
  typename NeighborhoodIteratorType::OffsetType offset6 = {{1,0}};
  typename NeighborhoodIteratorType::OffsetType offset7 = {{1,-1}};
  typename NeighborhoodIteratorType::OffsetType offset8 = {{0,-1}};


  
  unsigned int count = 0;
  while(count < m_Iteration)
    {
    ot.GoToBegin();
    while( ! ot.IsAtEnd() )
      {
      if (ot.GetCenterPixel())
       {
         PixelType genus;
         genus  = ot.GetPixel(offset1) + ot.GetPixel(offset2);
         genus += ot.GetPixel(offset3) + ot.GetPixel(offset4);
         genus += ot.GetPixel(offset5) + ot.GetPixel(offset6);
         genus += ot.GetPixel(offset7) + ot.GetPixel(offset8);
         if (genus < 2)
           {
             genus = 0;
             ot.SetCenterPixel( genus );
           }
       }

      ++ot;
  }
    ++count;
The algorithm evaluates the  8-neighborhood points of the current pixel (foreground) and decides if remove the current pixel (setCenterPixel(0)) from a branch.

Because the removing condition for the current foreground pixel is "genus < 2 ", a removing process for a "branch" will stop if there are two neighborhood foreground points in the 8-neighborhood template of the current foreground pixel.
So if a foreground pixel on a branch has 2 neighborhood "branch" points (for example at offset1 and offset2. It is very common after using itkBinaryThinningImageFilter), the removing process will stop there for that branch.

Regards,

Di


Date: Wed, 8 Jun 2011 07:24:45 -0400
Subject: Re: [Insight-users] How to use itkBinaryPruningImageFilter
From: robert.tamburo at gmail.com
To: xiaodi68 at hotmail.com
CC: insight-users at itk.org

I'm not too familiar with this filter, but a quick scan of the source leads me to believe that it expects a binary image containing zeroes and ones (see below). 
Genus is of type PixelType. If it is unsigned char and foreground pixels are 255, the result will be overflow errors during the genus calculation never satisfying the pruning condition.

Perhaps there should be a set foreground value function then genus can be of type int and the pruning condition can be changed to if(genus/m_ForegroundValue < 2).
      if (ot.GetCenterPixel())
       {         PixelType genus;          genus  = ot.GetPixel(offset1) + ot.GetPixel(offset2);         genus += ot.GetPixel(offset3) + ot.GetPixel(offset4);         genus += ot.GetPixel(offset5) + ot.GetPixel(offset6);
         genus += ot.GetPixel(offset7) + ot.GetPixel(offset8);         if (genus < 2)           {             genus = 0;             ot.SetCenterPixel( genus );
           }
2011/6/7 di xiao <xiaodi68 at hotmail.com>






Dear all:

Anyone successfully used the itkBinaryPruningImageFilter? I searched the Insight-users but no solution about it.

My codes:

  //Pruning the thinning image
  typedef itk::BinaryPruningImageFilter<ReaderImageType, ReaderImageType> BinaryPruningImageFilterType;

  BinaryPruningImageFilterType::Pointer binaryPruningFilter = BinaryPruningImageFilterType::New();
  binaryPruningFilter->SetInput(binaryThinningFilter->GetOutput());
  binaryPruningFilter->SetIteration(10);

  binaryPruningFilter->Update();
  binaryPruningFilter->Print(std::cout, 0);

imageWriter->SetInput(binaryPruningFilter->GetPruning());

My thinning image is a binary image (background = 0, thinning skeleton = 255).

But I didn't get any changes after put the thinning image through the pruning filter.

Did I understand wrongly to using the filter?

Thanks,

Di
 		 	   		  

_____________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at

http://www.kitware.com/opensource/opensource.html



Kitware offers ITK Training Courses, for more information visit:

http://www.kitware.com/products/protraining.html



Please keep messages on-topic and check the ITK FAQ at:

http://www.itk.org/Wiki/ITK_FAQ



Follow this link to subscribe/unsubscribe:

http://www.itk.org/mailman/listinfo/insight-users



 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110610/53b13353/attachment-0001.htm>


More information about the Insight-users mailing list