<div dir="ltr"><div style><span style="font-family:verdana,sans-serif">Today </span><font face="verdana, sans-serif">I finally managed to try it myself, and it works. Below is implementation in ITK, if anyone needs it.</font></div>
<div><font face="courier new, monospace"><br></font></div><font face="courier new, monospace">typedef itk::Image<unsigned char, 3> VisualizingImageType;<br></font><div><font face="courier new, monospace">typedef itk::Image<float, 3> InternalImageType;<br>
</font></div><div><font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace">//function call example</font></div><div><font face="courier new, monospace"><div><div>std::vector<VisualizingImageType::IndexType> centers;</div>
<div>for (int i=0; i<vertebra.size(); i++)</div><div><span class="" style="white-space:pre">        </span>centers.push_back(vertebra[i]->centerIndex);</div><div>VisualizingImageType::Pointer vInfluence=multilabelDilation(region, 50, centers);</div>
</div><div><br></div><div><br></div><div><div>VisualizingImageType::Pointer multilabelDilation(itk::ImageRegion<3> region, float radius, std::vector<VisualizingImageType::IndexType> points)</div><div>{</div><div>
typedef itk::BinaryBallStructuringElement<VisualizingImageType::PixelType,3> BallType;</div><div> BallType ball;</div><div> ball.SetRadius(radius);</div><div> ball.CreateStructuringElement();</div><div>
typedef itk::BinaryDilateImageFilter<VisualizingImageType, VisualizingImageType, BallType> growType;</div><div> growType::Pointer grow=growType::New();</div><div> grow->SetKernel(ball); //grow->SetRadius(radius);</div>
<div><br></div><div> VisualizingImageType::Pointer image=VisualizingImageType::New();</div><div> image->SetRegions(region);</div><div> image->Allocate();</div><div> image->FillBuffer(0); </div><div>
for (int i=0; i<points.size(); i++)</div><div> image->SetPixel(points[i], grow->GetDilateValue());</div><div><br></div><div> grow->SetInput(image);</div><div> grow->Update();</div><div> writeImage(grow->GetOutput(), "1dilate.nrrd"); //debug</div>
<div><br></div><div> typedef itk::SignedMaurerDistanceMapImageFilter<VisualizingImageType, InternalImageType> DistanceMapType;</div><div> DistanceMapType::Pointer dm=DistanceMapType::New();</div><div> dm->SetInput(image);</div>
<div> dm->SetUseImageSpacing(true);</div><div> dm->InsideIsPositiveOff();</div><div> dm->Update();</div><div> writeImage(dm->GetOutput(), "2distanceMap.nrrd"); //debug</div><div><br></div>
<div> for (int i=0; i<points.size(); i++)</div><div> image->SetPixel(points[i], i+1); //now set index+1</div><div><br></div><div> typedef itk::MorphologicalWatershedFromMarkersImageFilter<InternalImageType, VisualizingImageType> morphoWSfMType;</div>
<div> morphoWSfMType::Pointer ws=morphoWSfMType::New();</div><div> ws->SetInput1(dm->GetOutput());</div><div> ws->SetInput2(image);</div><div> ws->Update();</div><div> writeImage(ws->GetOutput(), "3watershed.nrrd"); //debug</div>
<div><br></div><div> typedef itk::AndImageFilter<VisualizingImageType> AndType;</div><div> AndType::Pointer and=AndType::New();</div><div> and->SetInput1(ws->GetOutput());</div><div> and->SetInput2(grow->GetOutput());</div>
<div> and->Update();</div><div> writeImage(and->GetOutput(), "4multiplied.nrrd"); //debug</div><div><br></div><div> return and->GetOutput();</div><div>}</div></div></font></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Feb 8, 2013 at 11:36 AM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Unfortunately, my helpful e-mail was too big to make it to the list. So here is the important bit, which defines a function in Python with SimpleITK:<div><br></div><div><div class="im"><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:inherit;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;word-wrap:normal">
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,128,0);font-weight:bold">def</span> <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">MultilabelDilation</span>(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">img</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">radius</span>=<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,0,128)">1</span>,<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">kernel</span>=<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">sitk.BinaryDilateImageFilter.Ball</span>):</pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:inherit;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;word-wrap:normal">
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">distImg</span> = <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">sitk.SignedMaurerDistanceMap</span>(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">img</span> <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(170,34,255);font-weight:bold">!=</span> <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,0,128)">0</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">insideIsPositive</span>=<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,128,0)">False</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">squaredDistance</span>=<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,128,0)">False</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">useImageSpacing</span>=<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,128,0)">False</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:inherit;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;word-wrap:normal">
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">dilatImg</span> = <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">sitk.BinaryDilate</span>(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">img</span><span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(170,34,255);font-weight:bold">!=</span><span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,0,128)">0</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">radius</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">kernel</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:inherit;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;word-wrap:normal">
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">wsImg</span> = <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">sitk.MorphologicalWatershedFromMarkers</span>(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">distImg</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">img</span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:inherit;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;word-wrap:normal">
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(0,128,0);font-weight:bold">return</span> <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">dilatImg</span><span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(170,34,255);font-weight:bold">*</span><span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">wsImg</span></pre>
<div><br></div><div><br></div></div><div class="im"><div><br><div><div>On Feb 8, 2013, at 9:42 AM, Dženan Zukić <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>> wrote:</div><br><blockquote type="cite">
<div dir="ltr"><font><font face="verdana,sans-serif">Thanks for the interest and the provided code Brad. Hopefully I will get to work today to try it out myself :D (Blizzard warning in Boston, where I am for a couple months)</font></font>
</div><div class="gmail_extra"><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>