[Insight-users] Questions about computing distance map using FastMarchingImageFilter

Dan Mueller dan.muel at gmail.com
Sat Oct 3 03:43:18 EDT 2009


Hi Siyi,

Good to hear my general comments helped.

Regards, Dan

2009/10/2 siyi ding <no16sylvan at hotmail.com>
>
>
> Hi Dan,
>
> I do agree with you that I should provide more detailed information or pictures. I am trying to compute the distance map of a whole image. So, your suggestion about using SignedMaurerDistanceImageFilter is a better choice. I have tried it and it works pretty fast.
>
> Thanks for your help!
>
>
> Best,
> Siyi Ding
>
>
>
>
> > Date: Fri, 2 Oct 2009 11:12:56 +0200
> > Subject: Re: [Insight-users] Questions about computing distance map using FastMarchingImageFilter
> > From: dan.muel at gmail.com
> > To: no16sylvan at hotmail.com
> > CC: insight-users at itk.org
> >
> > Hi Siyi,
> >
> > I would like to help you with the issue you reported, however I am
> > hindered by the following reasons:
> >
> > 1. I don't know what operation system you are using (Windows, Mac,
> > Linux, Solaris, etc.)
> > 2. I don't know the version of the components you are using (CMake,
> > ITK, compiler)
> > 3. I don't know the context of the task you are trying to achieve (are
> > you computing the distance map of the entire image, or only a small
> > border around specific objects?)
> > 4. There are no (small) screenshots attached to your email to evaluate
> > what you mean by "the result does not look like a correct distance
> > map"
> > 5. The source code snippet you provided does not compile or run on my
> > machine (no cmake file, not complete minimal example, no input image).
> >
> > Please help me help you. If you want a fast reply, please make it as
> > easy as possible for someone on the list to quickly experience the
> > issue you are facing by providing the above information.
> >
> > I can take a stab in the dark, and give you a few general pointers:
> >
> > a. The FastMarchingImageFilter is not the optimal way of computing a
> > distance map of an entire image. In my experience the
> > SignedMaurerDistanceImageFilter is the fastest (I think there is even
> > a multi-threaded version floating around on the Insight Journal). That
> > said, fast marching *may* be useful (ie. faster) for computing a local
> > distance map, around the borders of an object (ie. by setting the
> > stopping value to a small value). I don't know the full context of
> > your problem, so I'm not sure if these comments are helpful.
> > b. Performance can generally be improved (sometimes by 10-100 times)
> > by compiling your application in "Release" mode. Have you compiled
> > your application using optimizations?
> >
> > Regards,
> >
> > Dan
> >
> > 2009/10/2 siyi ding <no16sylvan at hotmail.com>
> > >
> > >
> > > Dear all,
> > >
> > > I am trying to use the FastMarchingImageFilter to compute the distance map of a canny edge image. I could get correct distance map when I follow the example - just give one seed point. However, when I add all the none zero points(about 9000 points) in the canny image as seeds, the program becomes very slow and the result does not look like a correct distance map. Is there any one who could help about this?
> > >
> > > Thanks a lot.
> > >
> > > //////////////////////////////////////////////////////
> > >  seeds->Initialize();
> > >  NodeType node;
> > >  const double seedValue = 0.0;
> > >  int num_seeds = 0;
> > > // If we only use one seed as below, we get the correct distance map of that point.
> > >  /*
> > >  OutputImageType::IndexType  seedPosition;
> > >  seedPosition[0] = 100;
> > >  seedPosition[1] = 100;
> > >  node.SetValue( seedValue );
> > >  node.SetIndex( seedPosition );
> > >  seeds->InsertElement(num_seeds++, node );
> > >
> > > */
> > >
> > > // If we use all the nonzeros points in the canny edge image as seeds,we can not get correct distance map and the program is slow.
> > >
> > >  for (int i = 0; i< (image->w());i++)
> > >   for (int j = 0; j< (image->h());j++)
> > >   {
> > >    OutputImageType::IndexType  seedPosition;
> > >    seedPosition[0] = i;
> > >    seedPosition[1] = j;
> > >
> > >    if ( (CannyFilter->GetOutput()->GetPixel(seedPosition))>0)
> > >    {
> > >     node.SetValue( seedValue );
> > >     node.SetIndex( seedPosition );
> > >     seeds->InsertElement(num_seeds++, node );
> > >    }
> > >   }
> > >  fastMarching->SetTrialPoints(  seeds  );
> > >  fastMarching->SetSpeedConstant(1.0);
> > >  fastMarching->SetOutputSize(  CannyFilter->GetOutput()->GetBufferedRegion().GetSize() );
> > >  fastMarching->SetOutputOrigin ( CannyFilter->GetOutput()->GetOrigin());
> > >  fastMarching->SetOutputSpacing ( CannyFilter->GetOutput()->GetSpacing());
> > >
> > > const double stoppingTime = max(image->w(),image->h());
> > >  fastMarching->SetStoppingValue(  stoppingTime  );
> > >
> > > FileWriterType::Pointer writer4 = FileWriterType::New();
> > >     writer4->SetFileName("distance.jpg");
> > >     writer4->UseCompressionOn();
> > >
> > >  rescaleFilter->SetOutputMinimum(   0 );
> > >  rescaleFilter->SetOutputMaximum( 255 );
> > >  rescaleFilter->SetInput(  fastMarching->GetOutput()  );
> > >  floatToUnsignedCharFilter ->SetInput( rescaleFilter->GetOutput() );
> > >  writer4->SetInput( floatToUnsignedCharFilter->GetOutput() );
> > >
> > >  try
> > >     {
> > >   writer4->Update();
> > >   writer4->DebugOn();
> > >     }
> > >     catch (itk::ExceptionObject &e)
> > >     {
> > >     std::cerr << e << std::endl;
> > >     }
> > >
> > > Best,
> > > Siyi Ding
> > >
> > >
> > >
> > > Best,
> > > Sylvia Siyi Ding
> > >
> > >
> > >
> > >
> > > > Date: Thu, 1 Oct 2009 13:41:21 -0400
> > > > From: mike.jackson at bluequartz.net
> > > > To: insight-users at itk.org
> > > > Subject: [Insight-users] Threaded Gaussian Filter
> > > >
> > > > Anyone have a threaded version of the Gaussian Filter? I am currently
> > > > using the example code for a Gaussian filter from the ITK distribution
> > > > and for the image size I am throwing at it, the iteration loop takes a
> > > > long time because it performs the filter serially on every pixel.
> > > >
> > > > Thanks
> > > > _________________________________________________________
> > > > Mike Jackson mike.jackson at bluequartz.net
> > > > BlueQuartz Software www.bluequartz.net
> > > > Principal Software Engineer Dayton, Ohio
> > > > _____________________________________
> > > > Powered by www.kitware.com
> > > >
> > > > Visit other Kitware open-source projects at
> > > > http://www.kitware.com/opensource/opensource.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
> > >
> > > ________________________________
> > > Lauren found her dream laptop. Find the PC that’s right for you.
> > > _____________________________________
> > > Powered by www.kitware.com
> > >
> > > Visit other Kitware open-source projects at
> > > http://www.kitware.com/opensource/opensource.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
> > >
>
> ________________________________
> Insert movie times and more without leaving Hotmail®. See how.


More information about the Insight-users mailing list