<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi Robert:<br><br>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.<br><br>I also tested it and got the following experience and want to share it with all users.<br><br>1. The length of the "spurs" being removed is decided by the value of iteration.<br>2. All "branch" tips will be removed during the iteration process.<br>3. According to the source code of the algorithm<br><br><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: 'DejaVu Sans', sans-serif, helvetica; "><pre style="font-family: 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace, courier; font-size: inherit; "> 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;
</pre></span></span><br class="Apple-interchange-newline">The algorithm evaluates the 8-neighborhood points of the current pixel (foreground) and decides if remove the current pixel (setCenterPixel(0)) from a branch.<br><br>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.<br>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.<br><br>Regards,<br><br>Di<br><br><br><hr id="stopSpelling">Date: Wed, 8 Jun 2011 07:24:45 -0400<br>Subject: Re: [Insight-users] How to use itkBinaryPruningImageFilter<br>From: robert.tamburo@gmail.com<br>To: xiaodi68@hotmail.com<br>CC: insight-users@itk.org<br><br>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). <div><br></div><div>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.<div>
<br></div><div>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).</div><div><br></div><div><div><div> if (ot.GetCenterPixel())</div>
<div> {</div><div> PixelType genus; </div><div> genus = ot.GetPixel(offset1) + ot.GetPixel(offset2);</div><div> genus += ot.GetPixel(offset3) + ot.GetPixel(offset4);</div><div> genus += ot.GetPixel(offset5) + ot.GetPixel(offset6);</div>
<div> genus += ot.GetPixel(offset7) + ot.GetPixel(offset8);</div><div> if (genus < 2)</div><div> {</div><div> genus = 0;</div><div> ot.SetCenterPixel( genus );</div><div>
}</div><br><div class="ecxgmail_quote">2011/6/7 di xiao <span dir="ltr"><<a href="mailto:xiaodi68@hotmail.com">xiaodi68@hotmail.com</a>></span><br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">
<div>
Dear all:<br><br>Anyone successfully used the itkBinaryPruningImageFilter? I searched the Insight-users but no solution about it.<br><br>My codes:<br><br> //Pruning the thinning image<br> typedef itk::BinaryPruningImageFilter<ReaderImageType, ReaderImageType> BinaryPruningImageFilterType;<br>
BinaryPruningImageFilterType::Pointer binaryPruningFilter = BinaryPruningImageFilterType::New();<br> binaryPruningFilter->SetInput(binaryThinningFilter->GetOutput());<br> binaryPruningFilter->SetIteration(10);<br>
binaryPruningFilter->Update();<br> binaryPruningFilter->Print(std::cout, 0);<br><br>imageWriter->SetInput(binaryPruningFilter->GetPruning());<br><br>My thinning image is a binary image (background = 0, thinning skeleton = 255).<br>
But I didn't get any changes after put the thinning image through the pruning filter.<br><br>Did I understand wrongly to using the filter?<br><br>Thanks,<br><font color="#888888"><br>Di<br>                                           
</font></div><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div></div></div>                                            </body>
</html>