[Insight-users] Geodesic Active Contours Segmentation with 3D volumes

Rehab Mansour rehab_a_eg at yahoo.co.uk
Wed Jul 9 00:55:19 EDT 2008


Hi everyone,
I am using ManagedITK with c#,i am still a  begginer so i have lots of questions in my hand....i have applied Level set Geodesic Active Contours Segmentation on an image and it worked effectively thank God...now i am trying to  apply it on a 3D volume(series of images) ,this is the code i am using

                itkImageBase DicomSeries = itkImage_SS3.New();
                itkImageBase PNGSeries = itkImage_F3.New();
                itkImageBase Segmented = itkImage_UC3.New();
                DicomSeries.ReadDicomDirectory(@"C:\Rehab\p6\1");
                itkRescaleIntensityImageFilter_ISS3IF3 ConvertDCMtoPNG =                             itkRescaleIntensityImageFilter_ISS3IF3.New();              
                ConvertDCMtoPNG.SetInput(DicomSeries);
                ConvertDCMtoPNG.OutputMinimum = 0;
                ConvertDCMtoPNG.OutputMaximum = 255;
                ConvertDCMtoPNG.GetOutput(PNGSeries);
                ConvertDCMtoPNG.Update();
                itkBinaryThresholdImageFilter_IF3IUC3 ThresholdingFilterType = itkBinaryThresholdImageFilter_IF3IUC3.New();
                ThresholdingFilterType.SetInput(PNGSeries);
                ThresholdingFilterType.LowerThreshold = -1000.0;
                ThresholdingFilterType.UpperThreshold = 0.0;
                ThresholdingFilterType.OutsideValue = 0;
                ThresholdingFilterType.InsideValue = 255;
                itkRescaleIntensityImageFilter_IF3IUC3 CastFilterType1 = itkRescaleIntensityImageFilter_IF3IUC3.New();
                itkRescaleIntensityImageFilter_IF3IUC3 CastFilterType2 = itkRescaleIntensityImageFilter_IF3IUC3.New();
                itkRescaleIntensityImageFilter_IF3IUC3 CastFilterType3 = itkRescaleIntensityImageFilter_IF3IUC3.New();
                itkRescaleIntensityImageFilter_IF3IUC3 CastFilterType4 = itkRescaleIntensityImageFilter_IF3IUC3.New();
                itkCurvatureAnisotropicDiffusionImageFilter_IF3IF3 SmoothingFilterType = itkCurvatureAnisotropicDiffusionImageFilter_IF3IF3.New();
                SmoothingFilterType.TimeStep = 0.0625;
                SmoothingFilterType.NumberOfIterations = 5;
                SmoothingFilterType.ConductanceParameter = 9.0;

                
                itkGradientMagnitudeRecursiveGaussianImageFilter_IF3IF3 GradientFilterType = itkGradientMagnitudeRecursiveGaussianImageFilter_IF3IF3.New();
                itkSigmoidImageFilter_IF3IF3 SigmoidFilterType = itkSigmoidImageFilter_IF3IF3.New();
                SigmoidFilterType.OutputMinimum = 0.0;
                SigmoidFilterType.OutputMaximum = 1.0;
                GradientFilterType.Sigma = double.Parse(v4);
                SigmoidFilterType.Alpha = double.Parse(v5);
                SigmoidFilterType.Beta = double.Parse(v6);
                itkFastMarchingImageFilter_IF3IF3 FastMarchingFilterType = itkFastMarchingImageFilter_IF3IF3.New();
                itkGeodesicActiveContourLevelSetImageFilter_IF3IF3F geodesicActivecontour = itkGeodesicActiveContourLevelSetImageFilter_IF3IF3F.New();


                //command line variable
                geodesicActivecontour.PropagationScaling = int.Parse(v7);
                geodesicActivecontour.CurvatureScaling = 1.0;
                geodesicActivecontour.AdvectionScaling = 1.0;
                geodesicActivecontour.MaximumRMSError = 0.02;
                geodesicActivecontour.NumberOfIterations = 800;
                ///////////////The pipeline\\\\\\\\\\\\\\\\\\\\\\\\
                SmoothingFilterType.SetInput(PNGSeries);
                GradientFilterType.SetInput(SmoothingFilterType.GetOutput());
                SigmoidFilterType.SetInput(GradientFilterType.GetOutput());
                List<NodeType> Seeds = new List<NodeType>();
                double SeedValue = -double.Parse(v3);
                IndexType SeedPosition = new IndexType(int.Parse(v1), int.Parse(v2));
                Seeds.Add(new NodeType(SeedValue, SeedPosition));
                FastMarchingFilterType.TrialPoints = Seeds.ToArray();
                FastMarchingFilterType.SpeedConstant = 1.0;
                FastMarchingFilterType.OutputSize = PNGSeries.Size;
                FastMarchingFilterType.OutputSpacing = PNGSeries.Spacing;
                //////////////////////////////////////////////////////////////////////
                FastMarchingFilterType.OutputSize = PNGSeries.BufferedRegion.Size;
                FastMarchingFilterType.SetInput(SigmoidFilterType.GetOutput());
                geodesicActivecontour.SetInput(FastMarchingFilterType.GetOutput());
                geodesicActivecontour.SetFeatureImage(SigmoidFilterType.GetOutput());
                ThresholdingFilterType.SetInput(geodesicActivecontour.GetOutput());
                ThresholdingFilterType.Update();
                ThresholdingFilterType.GetOutput(Segmented);
                Segmented.WriteSeries("segmented_{0}.png","00");

i am having a problem at the fast marching filter...it doesn't accept the seeds,i am giving it for it's trial point,
this line:  FastMarchingFilterType.TrialPoints = Seeds.ToArray();
this is the exception i am getting:
System.IndexOutOfRangeException was caught
  Message="Index was outside the bounds of the array."
  Source="ManagedITK.Common"
  StackTrace:
       at itk.itkArray`1.get_Item(Int32 index)
       at itk.ManagedTypes.ToNativeLevelSetNode<float,3>(LevelSetNode<float\,3>* , itkLevelSetNode managedNode)
       at itk.ManagedTypes.ToNativeLevelSetNodeContainer<float,3>(itkLevelSetNode[] managedContainer)
       at itk.itkFastMarchingImageFilter_IF3IF3.set_TrialPoints(itkLevelSetNode[] value)
       at LevelSetActiveContour.Form1.button5_Click(Object sender, EventArgs e) in C:\Users\HP\Documents\Visual Studio 2005\Projects\LevelSetActiveContour\LevelSetActiveContour\Form1.cs:line 551



Any idea anyone??!!
i have also two questions:
	1. when i tried this code and before the fastmarching filter...it took so much processing time to update the filters...is taking a 3D volume was a wrong idea to start with???should i make a loop and apply the pipleine for each slice individually..will this make it any fast???
	2. the other question is ....why the filters only accept float values??..the major extension we all would be working on is Dicom..so shouln't it accept dicom from the start??.....(i am sorry for this silly question i am just wondering)...my technique is to convert the dicom series i have into any other series but when i give it a large range it takes a huge processing time so i thought i will only stick to 0-->255,but it's so much waste of information
Thanx for the hep in advance 



      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080709/93a5b70d/attachment.htm>


More information about the Insight-users mailing list