public void reconstructOffline(ImagePlus imagePlus) throws Exception { ImagePlusDataSink sink = new ImagePlusDataSink(); configure(); init(); for (int i = 0; i < imagePlus.getStackSize(); i++) { backproject(ImageUtil.wrapImageProcessor(imagePlus.getStack().getProcessor(i + 1)), i); } waitForResult(); if (Configuration.getGlobalConfiguration().getUseHounsfieldScaling()) applyHounsfieldScaling(); int[] size = projectionVolume.getSize(); System.out.println(size[0] + " " + size[1] + " " + size[2]); for (int k = 0; k < projectionVolume.getSize()[2]; k++) { FloatProcessor fl = new FloatProcessor(projectionVolume.getSize()[0], projectionVolume.getSize()[1]); for (int j = 0; j < projectionVolume.getSize()[1]; j++) { for (int i = 0; i < projectionVolume.getSize()[0]; i++) { fl.putPixelValue(i, j, projectionVolume.getAtIndex(i, j, k)); } } sink.process(projectionVolume.getSubGrid(k), k); } sink.close(); ImagePlus revan = ImageUtil.wrapGrid3D(sink.getResult(), "Reconstruction of " + imagePlus.getTitle()); revan.setTitle(imagePlus.getTitle() + " reconstructed"); revan.show(); reset(); }
public void run(String arg) { boolean display = false; File test = new File(arg); display = !test.exists(); OpenDialog od = new OpenDialog("Open mkt file...", arg); if (od != null) { String file = od.getFileName(); if (file == null) return; String directory = od.getDirectory(); directory = directory.replace('\\', '/'); // Windows safe if (!directory.endsWith("/")) directory += "/"; arg = directory + file; } try { FileProjectionSource fileSource = new MKTProjectionSource(); fileSource.initStream(arg); ImagePlusDataSink sink = new ImagePlusDataSink(); Grid2D imp = fileSource.getNextProjection(); int i = 0; while (imp != null) { sink.process(imp, i); i++; imp = fileSource.getNextProjection(); } sink.close(); setStack(ImageUtil.wrapGrid3D(sink.getResult(), "").getStack()); setTitle(new File(arg).getName()); fileSource.close(); if (display) show(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }