[Insight-users] managed itkConfidenceConnectedImageFilter Question

Dan Mueller dan.muel at gmail.com
Thu Feb 25 10:18:06 EST 2010


Hi Ali,

Try the following code snippet:

    // Read input
    itkImageBase input = itkImage_UC3.New();
    itkImageBase output = itkImage_UC3.New();
    itkImageFileReader reader = itkImageFileReader.New(input);
    reader.FileName = "C:/Temp/input.mha";
    reader.Update();
    reader.GetOutput(input);
    input.DisconnectPipeline();

    // Create seed
    itkSize size = input.BufferedRegion.Size;
    itkIndex start = input.BufferedRegion.Index;
    itkIndex seed = new itkIndex(input.Dimension);
    for (int i=0; i<input.Dimension; i++) {
        seed[i] = start[i] + size[i] / 2;
    }

    // Run filter
    itkConfidenceConnectedImageFilter filter =
        itkConfidenceConnectedImageFilter.New(input, output);
    filter.SetInput(input);
    filter.AddSeed(seed);
    filter.InitialNeighborhoodRadius = 2U;
    filter.ReplaceValue = 128;
    filter.Update();
    filter.GetOutput(output);
    output.DisconnectPipeline();

    // Write output
    output.Write("C:/Temp/output.mha");

    // Clean up
    input.Dispose();
    output.Dispose();
    filter.Dispose();

HTH

Cheers, Dan

On 25 February 2010 15:21, Ali Habib <ali.mahmoud.habib at gmail.com> wrote:
> Dear all ,
> using managed ITK I need to simulate this part of code :
>
>     InputImageType::Pointer inputImage = reader->GetOutput();
>     InputImageType::SizeType  size  =
> inputImage->GetBufferedRegion().GetSize();
>     InputImageType::IndexType start =
> inputImage->GetBufferedRegion().GetIndex();
>     // set a seed by default in the center of the image.
>     InputImageType::IndexType seed;
>     seed[0] = start[0] + size[0] / 2;
>     seed[1] = start[1] + size[1] / 2;
>     seed[2] = start[2] + size[2] / 2;
>     filter->SetSeed( seed );
>
> using c#
>
>
> itkSize
>
> size = InputImageType.BufferedRegion.Dimension ;
>
>
>
> but it give error which is
>
> Error 1 Cannot implicitly convert type 'uint' to 'itk.itkSize
>
> also I will face the same problem in itkseed , how to work around that
>
> Best regards


More information about the Insight-users mailing list