Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try {
                if (args.Length < 1)
                {
                    Console.WriteLine("Usage: ImageIOSelection image_input_file");
                    return;
                }

                // Find out which image IOs are supported
                ImageFileReader         reader    = new ImageFileReader();
                itk.simple.VectorString image_ios = reader.GetRegisteredImageIOs();
                Console.Write("The supported image IOs are: ");
                for (int i = 0; i < image_ios.Count; i++)
                {
                    Console.Write(image_ios[i] + " ");
                }
                Console.WriteLine("\n--------------------");

                // Another option is to just print the reader and see which
                // IOs are supported
                Console.WriteLine(reader.ToString());
                Console.WriteLine("--------------------");

                // Force the use of a specific IO. If the IO doesn't support
                // reading the image type it will throw an exception.
                reader.SetImageIO("PNGImageIO");
                reader.SetFileName(args[0]);
                Image image = reader.Execute();
                Console.WriteLine("Read image: " + args[0]);
            } catch (Exception ex) {
                Console.WriteLine("Read failed: " + ex);
            }
        }
Ejemplo n.º 2
0
        static void example1(string inputImageFileName, string outputImageFileName)
        {
            ImageFileReader reader = new ImageFileReader();

            reader.SetImageIO("PNGImageIO");
            reader.SetFileName(inputImageFileName);
            Image image = reader.Execute();

            ImageFileWriter writer = new ImageFileWriter();

            writer.SetFileName(outputImageFileName);
            writer.Execute(image);
        }