コード例 #1
0
 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();
 }
コード例 #2
0
 @Override
 public void configure() throws Exception {
   slope = UserUtil.queryDouble("Enter slope of correction transformatoin", slope);
   // offset = UserUtil.queryDouble("Enter offset of correction transformation", offset);
   measureHard = UserUtil.queryDouble("Measurement of hard material [HU]", measureHard);
   measureSoft = UserUtil.queryDouble("Measurement of soft material [HU]", measureSoft);
   projectionXShift = UserUtil.queryDouble("Enter projection x shift", projectionXShift);
   projectionYShift = UserUtil.queryDouble("Enter projection y shift", projectionYShift);
   lambda0 = VolumeAttenuationFactorCorrectionTool.getLambda0(measureHard, measureSoft);
   lut = Configuration.getGlobalConfiguration().getBeamHardeningLookupTable();
   ImagePlus[] images = ImageUtil.getAvailableImagePlusAsArray();
   hardMaterial =
       ImageUtil.wrapImagePlus(
           (ImagePlus)
               JOptionPane.showInputDialog(
                   null,
                   "Select projections with hard material: ",
                   "Select source",
                   JOptionPane.PLAIN_MESSAGE,
                   null,
                   images,
                   images[0]));
   configured = true;
 }
コード例 #3
0
  public OpenCLVolumeRenderer(ImagePlus image) {
    super(
        new byte[image.getWidth() * image.getHeight() * image.getStackSize() / image.getNFrames()],
        image.getWidth(),
        image.getHeight(),
        image.getStackSize() / image.getNFrames(),
        false);

    transferFunc =
        new float[] {
          0.0f, 0.0f, 0.0f, 0.0f,
          1.0f, 1.0f, 1.0f, 1.0f,
          0.0f, 0.0f, 0.0f, 0.0f,
        };

    minmax = ImageUtil.minAndMaxOfImageProcessor(image);
    minmax[1] *= 1.05;

    if (image.getNFrames() == 1) multiFrameMode = false;
    else multiFrameMode = true;

    nFrames = image.getNFrames();
    // Create the image array
    clImages = new ArrayList<CLImage3d<IntBuffer>>(image.getNFrames());
    // rewrite imagePlus container into nFrames single byte volumes
    volumes = new byte[image.getNFrames()][volumeSize[2] * volumeSize[1] * volumeSize[0]];
    for (int n = 0; n < image.getNFrames(); n++) {
      for (int k = 0; k < volumeSize[2]; k++) {
        ImageProcessor img = image.getStack().getProcessor((n * volumeSize[2]) + k + 1);
        for (int i = 0; i < image.getWidth(); i++) {
          for (int j = 0; j < image.getHeight(); j++) {
            setVoxel(volumes[n], i, j, k, img.getPixelValue(i, j));
          }
        }
      }
    }

    initialized = false;
    // System.out.println("init");
    frame.setTitle("Volume: " + image.getTitle());
  }
コード例 #4
0
ファイル: MKT_Reader.java プロジェクト: YixingHuang/CONRAD
  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();
    }
  }