| 22 | |
| 23 | |
| 24 | class ImageGetSetBuffer { |
| 25 | |
| 26 | public static void main(String args[]) { |
| 27 | |
| 28 | if (args.length < 1) { |
| 29 | System.out.format("Usage: ImageSetGetBuffer <input>"); |
| 30 | System.exit(-1); |
| 31 | } |
| 32 | |
| 33 | Image image = SimpleITK.readImage(args[0]); |
| 34 | |
| 35 | // The loaded image may be of any type and number of components, so convert to float, |
| 36 | // so there is a known type. |
| 37 | if (image.getNumberOfComponentsPerPixel() != 1) { |
| 38 | image = SimpleITK.cast(image, PixelIDValueEnum.sitkVectorFloat32); |
| 39 | } else { |
| 40 | image = SimpleITK.cast(image, PixelIDValueEnum.sitkFloat32); |
| 41 | } |
| 42 | |
| 43 | java.nio.FloatBuffer buffer = (java.nio.FloatBuffer)image.getBufferAsBuffer(); |
| 44 | |
| 45 | System.out.println(buffer.toString()); |
| 46 | |
| 47 | for (int i = 0; i < 10 && buffer.hasRemaining(); ++i) { |
| 48 | System.out.println(buffer.get()); |
| 49 | } |
| 50 | |
| 51 | buffer.rewind(); |
| 52 | while (buffer.hasRemaining()) { |
| 53 | buffer.put(0); |
| 54 | } |
| 55 | |
| 56 | } |
| 57 | } |
nothing calls this directly
no outgoing calls
no test coverage detected