import org.itk.simple.*;
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) {
Image image = SimpleITK.readImage(inputImageFileName,
PixelIDValueEnum.sitkUnknown,
"PNGImageIO");
SimpleITK.writeImage(image, outputImageFileName);
}
static void example3() {
Euler2DTransform basic_transform = new Euler2DTransform();
double[] t = {2.0, 3.0};
VectorDouble trans = new VectorDouble(t);
basic_transform.setTranslation(trans);
SimpleITK.writeTransform(basic_transform, "euler2D.tfm");
Transform read_result = SimpleITK.readTransform("euler2D.tfm");
assert basic_transform.getClass() != read_result.getClass();
}
public static void main(String argv[]) {
if ( argv.length < 2 ) {
System.out.println("Usage: java SimpleIO <input> <output>");
return;
}
example1(argv[0], argv[1]);
example2(argv[0], argv[1]);
example3();
}
}