Пример #1
0
  AdjustImageHelperFunction(
      JEXData imset, JEXEntry entry, TypeName[] outputNames, ParameterSet parameters) {
    // Pass the variables
    this.imset = imset;
    this.params = parameters;
    this.entry = entry;
    this.outputNames = outputNames;

    // //// Get params
    auto = Boolean.parseBoolean(params.getValueOfParameter("Automatic"));
    oldMin = Double.parseDouble(params.getValueOfParameter("Old Min"));
    oldMax = Double.parseDouble(params.getValueOfParameter("Old Max"));
    newMin = Double.parseDouble(params.getValueOfParameter("New Min"));
    newMax = Double.parseDouble(params.getValueOfParameter("New Max"));
    gamma = Double.parseDouble(params.getValueOfParameter("Gamma"));
    depth = Integer.parseInt(params.getValueOfParameter("Output Bit Depth"));

    TreeMap<DimensionMap, JEXDataSingle> map = imset.getDataMap();
    int length = map.size();

    images = new String[length];
    dimensions = new DimensionMap[length];
    int i = 0;
    TreeMap<DimensionMap, String> pathMap = ImageReader.readObjectToImagePathTable(imset);
    for (DimensionMap dim : pathMap.keySet()) {
      String path = pathMap.get(dim);
      dimensions[i] = dim;
      images[i] = path;
      i++;
    }

    // Prepare the graphics
    imagepanel = new ImagePanel(this, "Adjust image");
    displayImage(index);
    wrap = new GraphicalFunctionWrap(this, params);
    wrap.addStep(
        0,
        "Select roi",
        new String[] {"Automatic", "Old Min", "Old Max", "New Min", "New Max", "Output Bit Depth"});
    wrap.setInCentralPanel(imagepanel);
    wrap.setDisplayLoopPanel(true);
  }
Пример #2
0
  public void runStep(int index) {
    // Get the new parameters
    auto = Boolean.parseBoolean(params.getValueOfParameter("Automatic"));
    oldMin = Double.parseDouble(params.getValueOfParameter("Old Min"));
    oldMax = Double.parseDouble(params.getValueOfParameter("Old Max"));
    newMin = Double.parseDouble(params.getValueOfParameter("New Min"));
    newMax = Double.parseDouble(params.getValueOfParameter("New Max"));
    gamma = Double.parseDouble(params.getValueOfParameter("Gamma"));
    depth = Integer.parseInt(params.getValueOfParameter("Output Bit Depth"));

    // prepare the images for calculation
    ImagePlus im = new ImagePlus(images[index]);
    imagepanel.setImage(im);
    imp = (FloatProcessor) im.getProcessor().convertToFloat(); // should be
    // a float
    // processor

    adjustImage();

    imagepanel.setImage(new ImagePlus("", imp));
  }
Пример #3
0
  /** Apply the roi to all other images */
  public void finishIT() {
    auto = Boolean.parseBoolean(params.getValueOfParameter("Automatic"));
    oldMin = Double.parseDouble(params.getValueOfParameter("Old Min"));
    oldMax = Double.parseDouble(params.getValueOfParameter("Old Max"));
    newMin = Double.parseDouble(params.getValueOfParameter("New Min"));
    newMax = Double.parseDouble(params.getValueOfParameter("New Max"));
    gamma = Double.parseDouble(params.getValueOfParameter("Gamma"));
    depth = Integer.parseInt(params.getValueOfParameter("Output Bit Depth"));

    output = new JEXData(JEXData.IMAGE, outputNames[0].getName(), "Adjusted image");

    // Run the function
    // TreeMap<DimensionMap,JEXDataSingle> map = imset.getDataMap();
    TreeMap<DimensionMap, String> pathMap = ImageReader.readObjectToImagePathTable(imset);
    int count = 0;
    int total = pathMap.size();
    JEXStatics.statusBar.setProgressPercentage(0);

    TreeMap<DimensionMap, String> imMap = new TreeMap<DimensionMap, String>();
    for (DimensionMap dim : pathMap.keySet()) {
      // JEXDataSingle ds = map.get(dim);
      // String imagePath = ds.get(JEXDataSingle.FOLDERNAME) +
      // File.separator + ds.get(JEXDataSingle.FILENAME);
      String imagePath = pathMap.get(dim);
      // File imageFile = new File(imagePath);
      // String imageName = imageFile.getName();

      // get the image
      im = new ImagePlus(imagePath);
      imp = (FloatProcessor) im.getProcessor().convertToFloat(); // should
      // be a
      // float
      // processor

      // //// Begin Actual Function
      adjustImage();
      // //// End Actual Function

      // //// Save the results
      ImagePlus toSave = FunctionUtility.makeImageToSave(imp, "false", depth);
      String imPath = JEXWriter.saveImage(toSave);

      // Put into imMap
      imMap.put(dim, imPath);

      // String localDir = JEXWriter.getEntryFolder(entry);
      // String newFileName = FunctionUtility.getNextName(localDir,
      // imageName, "A");
      // String newImagePath = localDir + File.separator + newFileName;
      // FunctionUtility.imSave(imp, "false", depth, newImagePath);
      //
      // // Put into imMap
      // imMap.put(dim, localDir + File.separator + newFileName) ;

      // JEXDataSingle outputds = new DefaultJEXDataSingle();
      // outputds.put(JEXDataSingle.FOLDERNAME, localDir);
      // outputds.put(JEXDataSingle.FILENAME, newFileName);
      // output.addData(dim,outputds);

      // Increment count
      Logs.log("Finished processing " + count + " of " + total + ".", 1, this);
      count++;

      // Status bar
      int percentage = (int) (100 * ((double) count / (double) pathMap.size()));
      JEXStatics.statusBar.setProgressPercentage(percentage);
    }

    output = ImageWriter.makeImageStackFromPaths(outputNames[0].getName(), imMap);
  }