[Insight-users] set the initial seeds in fast marching filter

Dan Mueller dan.muel at gmail.com
Fri May 20 16:18:32 EDT 2011


Hi Quan,

> when i run a iterator on the whole image domain,it seems the program ran a
> long time,do you know the reason?
Are you compiling in Release (optimized) mode? Debug builds are known
to be anywhere from 3 to 100 times slower than Release builds...

> y=exp(-(x-A)^2/B)  ,x is the input pixel value,y is the output value,A,B are
> given numbers
> i have a solution that is:
> 1.use a subtract Filter 2.use a square filter 3.use a divide filter 4.use a
> exponential filter
> but this solution is a little complex.you have any better method or is there
> a math function filter can cut down my work?
You should write your own Unary functor. See itkExpImageFilter or
itkAbsImageFilter for examples. Your custom functor will take one
input value (x), and two constants (A, B), apply the function, and
return a single output value (y).

HTH

Cheers, Dan

2011/5/20 Quan <mrvillage at 163.com>:
> Hi Dan,
> when i run a iterator on the whole image domain,it seems the program ran a
> long time,do you know the reason?
> another question,if i want to do a math calculation for the whole
> pixels,like
> y=exp(-(x-A)^2/B)  ,x is the input pixel value,y is the output value,A,B are
> given numbers
> i have a solution that is:
> 1.use a subtract Filter 2.use a square filter 3.use a divide filter 4.use a
> exponential filter
> but this solution is a little complex.you have any better method or is there
> a math function filter can cut down my work?
> thanks.
> Quan
>
>
> At 2011-05-20 21:01:31,"Dan Mueller" <dan.muel at gmail.com> wrote:
>
>>Hi Quan,
>>
>>You are correct -- "image" equals the contour image.
>>
>>You should be able to use reader2->GetOutput().
>>
>>Good luck.
>>
>>Regards, Dan
>>
>>2011/5/20 Quan <mrvillage at 163.com>:
>>> hi Dan:
>>> this line code
>>> IteratorType it( image, image->GetLargestPossibleRegion() );
>>> does the argument 'image' means the contour image i get ?
>>> in my code ,i write:
>>> ...................................//something
>>> reader2->SetFileName('Contour.png');//Contour.png is an Image that include a
>>> initial contour.
>>> IteratorType it( reader2->GetOutput(),
>>> reader->GetOutput()->GetLargestPossibleRegion() );
>>> am i wrong when i using reader2->GetOutPut() as  the argument?
>>> thanks
>>> Quan
>>>
>>> At 2011-05-20 16:38:17,"Dan Mueller" <dan.muel at gmail.com> wrote:
>>>
>>>>Hi Quan,
>>>>
>>>>What version of ITK are you using?
>>>>
>>>>If you are using the git ITKv4, then you can simply use
>>>>FastMarchingImageToNodePairContainerAdaptor. See the commit here:
>>>>    http://itk.org/gitweb?p=ITK.git;a=commit;h=6271a744582c413c7db57456c8ee0149930e5fd9
>>>>or a good example here:
>>>>    http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx
>>>>
>>>>If you are using ITK 3.20, you have to manually iterate the image
>>>>yourself, and create a node container. Here is a code snippet to get
>>>>you going:
>>>>  // Setup
>>>>  typedef ImageRegionConstIteratorWithIndex< LabelImageType > IteratorType;
>>>>  NodeContainer::Pointer nodes = NodeContainer::New();
>>>>  nodes->Initialize();
>>>>  IteratorType it( image, image->GetLargestPossibleRegion() );
>>>>
>>>>  // Walk image
>>>>  unsigned int count = 0;
>>>>  for (it.GoToBegin(); !it.IsAtEnd(); ++it)
>>>>    {
>>>>    if (it.Get() > NumericTraits< LabelPixelType >::Zero)
>>>>      {
>>>>      NodeType node;
>>>>      node.SetIndex( it.GetIndex() );
>>>>      nodes->InsertElement( count, node );
>>>>      count++;
>>>>      }
>>>>    }
>>>>
>>>>  // Set nodes
>>>>  fastMarching->SetTrialPoints( nodes );
>>>>
>>>>(See http://code.google.com/p/manageditk/source/browse/trunk/Source/Modules/LevelSetFilters/itkFastMarchingImageFilter.txx?r=2)
>>>>
>>>>HTH
>>>>
>>>>Cheers, Dan
>>>>
>>>>2011/5/20 Quan <mrvillage at 163.com>:
>>>>> hello everyone:
>>>>>     after i preprocessed a 2-D image and got an initial contour (saved as an
>>>>> image)while doing image segmentation,i wanna set the pixels on this contour
>>>>> as the initial seeds of the itk::FastMarchingImageFilter.what should i do
>>>>> next?
>>>
>>>
>>>
>
>
>


More information about the Insight-users mailing list