コード例 #1
0
    static void Main(String[] args)
    {
        try
        {
            // Setup input and output images
            itkImageBase input = itkImage.New(args[0]);
            itkImageBase output = itkImage.New(input);

            // Read the input image
            input.Read(args[1]);

            // Apply the filter
            FilterType filter = FilterType.New(input, output);
            filter.SetInput(input);
            filter.Update();
            filter.GetOutput(output);

            // Write the output to disk
            output.Write(args[2]);

            // Clean up
            filter.Dispose();
            input.Dispose();
            output.Dispose();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    } // end main
コード例 #2
0
        public void Apply()
        {
            if (this.SelectedImageGraphicProvider == null)
            {
                return;
            }

            ImageGraphic image = this.SelectedImageGraphicProvider.ImageGraphic;

            if (image == null)
            {
                return;
            }

            if (!(image is GrayscaleImageGraphic))
            {
                return;
            }

            itkImageBase input  = ItkHelper.CreateItkImage(image as GrayscaleImageGraphic);
            itkImageBase output = itkImage.New(input);

            ItkHelper.CopyToItkImage(image as GrayscaleImageGraphic, input);

            FilterType filter = FilterType.New(input, output);

            filter.SetInput(input);

            String mangledType = input.MangledTypeString;
            intensityFilterType intensityFilter = intensityFilterType.New(mangledType + mangledType);

            intensityFilter.SetInput(filter.GetOutput());
            intensityFilter.OutputMinimum = 0;
            if (image.BitsPerPixel == 16)
            {
                intensityFilter.OutputMaximum = 32767;
            }
            else
            {
                intensityFilter.OutputMaximum = 255;
            }
            intensityFilter.Update();

            intensityFilter.GetOutput(output);
            ItkHelper.CopyFromItkImage(image as GrayscaleImageGraphic, output);
            image.Draw();

            filter.Dispose();
            intensityFilter.Dispose();
            input.Dispose();
            output.Dispose();
        }