using System;
using System.Diagnostics;
namespace itk.simple.examples {
class SimpleIO {
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);
}
static void example2(string inputImageFileName, string outputImageFileName) {
sitk.WriteImage(image, outputImageFileName);
}
static void example3() {
Euler2DTransform basic_transform = new Euler2DTransform();
VectorDouble trans = new VectorDouble( new double[] {2.0, 3.0} );
basic_transform.SetTranslation(trans);
sitk.WriteTransform(basic_transform,
"euler2D.tfm");
Transform read_result =
sitk.ReadTransform(
"euler2D.tfm");
Debug.Assert( basic_transform.GetName() != read_result.GetName() );
}
static void Main(string[] args) {
try {
if (args.Length < 2) {
Console.WriteLine("Usage: SimpleIO <input> <output>");
return;
}
example1(args[0], args[1]);
example2(args[0], args[1]);
example3();
} catch (Exception ex) {
Console.WriteLine(ex);
}
}
}
}