[Insight-users] GeodesicActiveContourImageFilter nodecontainer

Dan Mueller dan.muel at gmail.com
Sat Jun 21 16:06:12 EDT 2008


Hi Rehab,

This portion of the C++ example code has the task of setting the Fast
Marching trial points. If you inspect the managed Fast Marching
filter, you will notice that the TrialPoints property expects
itkLevelSetNode[]. I recommend using a list to construct this array.
The code snippet below implements the major concepts explained in
Examples/Segmentation/GeodesicActiveContourImageFilter.cxx. I have
compiled this, and it mimics the C++ examples. I hope it helps.

Regards, Dan


using System;
using System.Collections.Generic;

using itk;

using ImageType = itk.itkImage_F2;
using FastMarchingType = itk.itkFastMarchingImageFilter_IF2IF2;
using GradientType =
itk.itkGradientMagnitudeRecursiveGaussianImageFilter_IF2IF2;
using SigmoidType = itk.itkSigmoidImageFilter_IF2IF2;
using ActiveContourType =
itk.itkGeodesicActiveContourLevelSetImageFilter_IF2IF2F;
using NodeType = itk.itkLevelSetNode;
using IndexType = itk.itkIndex;

namespace GeodesicActiveContourExample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Setup images
                ImageType input = ImageType.New();
                ImageType output = ImageType.New();
                itkPixelType pixel = itkPixelType.F;
                input.Read("D:/Temp/cthead1.png");

                // Use Fast Marching to create initial image
                FastMarchingType fastmarching = FastMarchingType.New();
                List<NodeType> nodes = new List<NodeType>();
                nodes.Add(new NodeType(-10.0, new IndexType(150, 180)));
                fastmarching.TrialPoints = nodes.ToArray();
                fastmarching.SpeedConstant = 1.0;
                fastmarching.OutputSize = input.Size;
                fastmarching.OutputSpacing = input.Spacing;
                fastmarching.Update();

                // Create speed image
                GradientType gradient = GradientType.New();
                gradient.SetInput(input);
                gradient.Sigma = 1.0;
                SigmoidType sigmoid = SigmoidType.New();
                sigmoid.SetInput(gradient.GetOutput());
                sigmoid.OutputMinimum = 0.0;
                sigmoid.OutputMaximum = 1.0;
                sigmoid.Alpha = -0.5;
                sigmoid.Beta = 3.0;
                sigmoid.Update();

                // Perform active contour segmentation
                ActiveContourType active = ActiveContourType.New();
                active.PropagationScaling = 3.0;
                active.CurvatureScaling = 1.0;
                active.AdvectionScaling = 1.0;
                active.MaximumRMSError = 0.02;
                active.NumberOfIterations = 800;
                active.SetInput(fastmarching.GetOutput());
                active.SetFeatureImage(sigmoid.GetOutput());
                active.Update();
                active.GetOutput(output);
                output.Write("D:/Temp/cthead1-active.mhd");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
    }
}


2008/6/21 Rehab Mansour <rehab_a_eg at yahoo.co.uk>:
> hi everyone,
> i need to use the GeodesicActiveContourImageFilter in the managedITK so i am
> converting the code from c++ to c#,the wrappers for the filter is all
> available till i reach this.
>
> typdef FastMarchingFilterType::NodeContainer  NodeContainer;
>
> typedef FastMarchingFilterType::NodeType       NodeType;
>
>  NodeContainer::Pointer seeds = NodeContainer::New();
>
>  InternalImageType::IndexType  seedPosition;
>
> this nodecontainer stores the values of the seed points
> fastmarchingfilter in the wrappers of managedITK doesn't contain this
> nodecontainer,should i use an array of points or what????
> thanx for helping
>
> ________________________________
> Sent from Yahoo! Mail.
> A Smarter Email.
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list