Ejemplo n.º 1
0
 public Image wczytajObraz(string sciezka)
 {
     ImageFileReader r = new ImageFileReader();
     r.SetFileName(sciezka);
     r.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkInt16);
     var image = r.Execute();
     nazwaObrazu = Path.GetFileName(r.GetFileName());
     obraz = image;
     return obraz;
 }
Ejemplo n.º 2
0
        public Image wczytajObraz(string sciezka)
        {
            ImageFileReader r = new ImageFileReader();

            r.SetFileName(sciezka);
            r.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkInt16);
            var image = r.Execute();

            nazwaObrazu = Path.GetFileName(r.GetFileName());
            obraz       = image;
            return(obraz);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: %s <fixedImageFilter> <movingImageFile> <outputTransformFile>\n", "ImageRegistrationMethod2");
                return;
            }

            ImageFileReader reader = new ImageFileReader();

            reader.SetOutputPixelType(PixelIDValueEnum.sitkFloat32);

            reader.SetFileName(args[0]);
            Image fixedImage = reader.Execute();

            fixedImage = SimpleITK.Normalize(fixedImage);
            SimpleITK.DiscreteGaussian(fixedImage, 2.0);

            reader.SetFileName(args[1]);
            Image movingImage = reader.Execute();

            movingImage = SimpleITK.Normalize(movingImage);
            movingImage = SimpleITK.DiscreteGaussian(movingImage, 2.0);

            ImageRegistrationMethod R = new ImageRegistrationMethod();

            R.SetMetricAsJointHistogramMutualInformation();

            double learningRate            = 1;
            uint   numberOfIterations      = 200;
            double convergenceMinimumValue = 1e-4;
            uint   convergenceWindowSize   = 5;

            R.SetOptimizerAsGradientDescentLineSearch(learningRate,
                                                      numberOfIterations,
                                                      convergenceMinimumValue,
                                                      convergenceWindowSize);

            R.SetInitialTransform(new TranslationTransform(fixedImage.GetDimension()));
            R.SetInterpolator(InterpolatorEnum.sitkLinear);

            IterationUpdate cmd = new IterationUpdate(R);

            R.AddCommand(EventEnum.sitkIterationEvent, cmd);

            Transform outTx = R.Execute(fixedImage, movingImage);

            outTx.WriteTransform(args[2]);
        }
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Usage: %s <fixedImageFilter> <movingImageFile> <outputTransformFile>\n", "ImageRegistrationMethod1");
                return;
            }

            ImageFileReader reader = new ImageFileReader();

            reader.SetOutputPixelType(PixelIDValueEnum.sitkFloat32);

            reader.SetFileName(args[0]);
            Image fixedImage = reader.Execute();

            reader.SetFileName(args[1]);
            Image movingImage = reader.Execute();

            ImageRegistrationMethod R = new  ImageRegistrationMethod();

            R.SetMetricAsMeanSquares();
            double maxStep            = 4.0;
            double minStep            = 0.01;
            uint   numberOfIterations = 200;
            double relaxationFactor   = 0.5;

            R.SetOptimizerAsRegularStepGradientDescent(maxStep,
                                                       minStep,
                                                       numberOfIterations,
                                                       relaxationFactor);
            R.SetInitialTransform(new TranslationTransform(fixedImage.GetDimension()));
            R.SetInterpolator(InterpolatorEnum.sitkLinear);

            IterationUpdate cmd = new IterationUpdate(R);

            R.AddCommand(EventEnum.sitkIterationEvent, cmd);

            Transform outTx = R.Execute(fixedImage, movingImage);

            // System.out.println("-------");
            // System.out.println(outTx.toString());
            // System.out.format("Optimizer stop condition: %s\n", R.getOptimizerStopConditionDescription());
            // System.out.format(" Iteration: %d\n", R.getOptimizerIteration());
            // System.out.format(" Metric value: %f\n", R.getMetricValue());

            outTx.WriteTransform(args[2]);
        }
        static void Main(string[] args)
        {
            if ( args.Length < 3 )
            {
              Console.WriteLine("Usage: %s <fixedImageFilter> <movingImageFile> <outputTransformFile>\n", "ImageRegistrationMethod1");
             return;
            }

              ImageFileReader reader = new ImageFileReader();
              reader.SetOutputPixelType( PixelIDValueEnum.sitkFloat32 );

              reader.SetFileName(args[0]);
              Image fixedImage = reader.Execute();

              reader.SetFileName(args[1]);
              Image movingImage = reader.Execute();

              ImageRegistrationMethod R = new  ImageRegistrationMethod();
              R.SetMetricAsMeanSquares();
              double maxStep = 4.0;
              double minStep = 0.01;
              uint numberOfIterations = 200;
              double relaxationFactor = 0.5;
              R.SetOptimizerAsRegularStepGradientDescent( maxStep,
                                                  minStep,
                                                  numberOfIterations,
                                                  relaxationFactor );
              R.SetInitialTransform( new TranslationTransform( fixedImage.GetDimension() ) );
              R.SetInterpolator( InterpolatorEnum.sitkLinear );

              IterationUpdate cmd = new IterationUpdate(R);
              R.AddCommand(EventEnum.sitkIterationEvent, cmd);

              Transform outTx = R.Execute( fixedImage, movingImage );

              // System.out.println("-------");
              // System.out.println(outTx.toString());
              // System.out.format("Optimizer stop condition: %s\n", R.getOptimizerStopConditionDescription());
              // System.out.format(" Iteration: %d\n", R.getOptimizerIteration());
              // System.out.format(" Metric value: %f\n", R.getMetricValue());

              outTx.WriteTransform(args[2]);
        }