public static void main(String argv[]) { // do some simple operations System.out.println("SimpleITK says 'Hello World' from Java"); if (argv.length < 2) { System.out.println("Usage: java ImageConnection <input> <output>"); return; } ImageFileReader reader = new ImageFileReader(); reader.setFileName(argv[0]); Image img = reader.execute(); PixelContainer pixelsContainer = img.getPixelContainer(); java.math.BigInteger t = pixelsContainer.getNumberOfPixels(); int numberOfPixels = t.intValue(); int[] buffer = new int[numberOfPixels]; buffer[0] = 13; buffer[1] = 2; buffer[2] = 19; pixelsContainer.setBufferAsUnsignedInt8(buffer, numberOfPixels); }
public static void main(String argv[]) { if (argv.length < 3) { System.out.format("Usage: java %s <input> <variance> <output>", "FilterProgressReporting"); System.exit(-1); } org.itk.simple.ImageFileReader reader = new org.itk.simple.ImageFileReader(); reader.setFileName(argv[0]); Image img = reader.execute(); DiscreteGaussianImageFilter filter = new DiscreteGaussianImageFilter(); filter.setVariance(Double.valueOf(argv[1]).doubleValue()); MyCommand cmd = new MyCommand(filter); filter.addCommand(EventEnum.sitkProgressEvent, cmd); Image blurredImg = filter.execute(img); CastImageFilter caster = new CastImageFilter(); caster.setOutputPixelType(img.getPixelID()); Image castImg = caster.execute(blurredImg); ImageFileWriter writer = new ImageFileWriter(); writer.setFileName(argv[2]); writer.execute(castImg); }