[Insight-users] Multilabel dilation

Dženan Zukić dzenanz at gmail.com
Wed Feb 13 12:29:10 EST 2013


I read your DICTA article, as well as the IJ article.

I ran your examples with my test data, using the following command line
arguments: "-r 50 -i image.mha -o out.mha".

labelSetsDilate creates an artifact, when compared to others (such as
WaterShed variant). I tried looking at the code, but it is not easy to find
this bug myself. Images are attached.

Your implementation is significantly faster (I have not measured how much
exactly). Lastly, thank you for sharing the code.


On Wed, Feb 13, 2013 at 4:34 AM, Richard Beare <richard.beare at gmail.com>wrote:

> The parallel classes for this are now on InsightJournal. Article
> includes some comparisons - hope it helps:
>
> http://hdl.handle.net/10380/3399
>
>
> On Tue, Feb 12, 2013 at 8:20 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
> > Today I finally managed to try it myself, and it works. Below is
> > implementation in ITK, if anyone needs it.
> >
> > typedef itk::Image<unsigned char, 3> VisualizingImageType;
> > typedef itk::Image<float, 3> InternalImageType;
> >
> > //function call example
> > std::vector<VisualizingImageType::IndexType> centers;
> > for (int i=0; i<vertebra.size(); i++)
> > centers.push_back(vertebra[i]->centerIndex);
> > VisualizingImageType::Pointer vInfluence=multilabelDilation(region, 50,
> > centers);
> >
> >
> > VisualizingImageType::Pointer multilabelDilation(itk::ImageRegion<3>
> region,
> > float radius, std::vector<VisualizingImageType::IndexType> points)
> > {
> >     typedef
> > itk::BinaryBallStructuringElement<VisualizingImageType::PixelType,3>
> > BallType;
> >     BallType ball;
> >     ball.SetRadius(radius);
> >     ball.CreateStructuringElement();
> >     typedef itk::BinaryDilateImageFilter<VisualizingImageType,
> > VisualizingImageType, BallType> growType;
> >     growType::Pointer grow=growType::New();
> >     grow->SetKernel(ball); //grow->SetRadius(radius);
> >
> >     VisualizingImageType::Pointer image=VisualizingImageType::New();
> >     image->SetRegions(region);
> >     image->Allocate();
> >     image->FillBuffer(0);
> >     for (int i=0; i<points.size(); i++)
> >         image->SetPixel(points[i], grow->GetDilateValue());
> >
> >     grow->SetInput(image);
> >     grow->Update();
> >     writeImage(grow->GetOutput(), "1dilate.nrrd"); //debug
> >
> >     typedef itk::SignedMaurerDistanceMapImageFilter<VisualizingImageType,
> > InternalImageType> DistanceMapType;
> >     DistanceMapType::Pointer dm=DistanceMapType::New();
> >     dm->SetInput(image);
> >     dm->SetUseImageSpacing(true);
> >     dm->InsideIsPositiveOff();
> >     dm->Update();
> >     writeImage(dm->GetOutput(), "2distanceMap.nrrd"); //debug
> >
> >     for (int i=0; i<points.size(); i++)
> >         image->SetPixel(points[i], i+1); //now set index+1
> >
> >     typedef
> > itk::MorphologicalWatershedFromMarkersImageFilter<InternalImageType,
> > VisualizingImageType> morphoWSfMType;
> >     morphoWSfMType::Pointer ws=morphoWSfMType::New();
> >     ws->SetInput1(dm->GetOutput());
> >     ws->SetInput2(image);
> >     ws->Update();
> >     writeImage(ws->GetOutput(), "3watershed.nrrd"); //debug
> >
> >     typedef itk::AndImageFilter<VisualizingImageType> AndType;
> >     AndType::Pointer and=AndType::New();
> >     and->SetInput1(ws->GetOutput());
> >     and->SetInput2(grow->GetOutput());
> >     and->Update();
> >     writeImage(and->GetOutput(), "4multiplied.nrrd"); //debug
> >
> >     return and->GetOutput();
> > }
> >
> >
> > On Fri, Feb 8, 2013 at 11:36 AM, Bradley Lowekamp <
> blowekamp at mail.nih.gov>
> > wrote:
> >>
> >> 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:
> >>
> >>
> >> def MultilabelDilation(img,
> >> radius=1,kernel=sitk.BinaryDilateImageFilter.Ball):
> >>
> >>     distImg = sitk.SignedMaurerDistanceMap(img != 0,
> >> insideIsPositive=False, squaredDistance=False, useImageSpacing=False)
> >>
> >>     dilatImg = sitk.BinaryDilate(img!=0, radius, kernel)
> >>
> >>     wsImg = sitk.MorphologicalWatershedFromMarkers(distImg, img)
> >>
> >>     return dilatImg*wsImg
> >>
> >>
> >>
> >>
> >> On Feb 8, 2013, at 9:42 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
> >>
> >> 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)
> >>
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.png
Type: image/png
Size: 3927 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: outWS.png
Type: image/png
Size: 3840 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: outWS.mha
Type: application/octet-stream
Size: 20114 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.mha
Type: application/octet-stream
Size: 3431 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.mha
Type: application/octet-stream
Size: 20392 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130213/38b0f75b/attachment-0002.obj>


More information about the Insight-users mailing list