Example #1
0
  /**
   * Returns a list of parameters necessary for this function to run... Every parameter is defined
   * as a line in a form that provides the ability to set how it will be displayed to the user and
   * what options are available to choose from The simplest FormLine can be written as: FormLine p =
   * new FormLine(parameterName); This will provide a text field for the user to input the value of
   * the parameter named parameterName More complex displaying options can be set by consulting the
   * FormLine API
   *
   * @return list of FormLine to create a parameter panel
   */
  @Override
  public ParameterSet requiredParameters() {
    Parameter p0 =
        new Parameter(
            "Automatic",
            "Enable visual interface",
            Parameter.DROPDOWN,
            new String[] {"true", "false"},
            0);
    Parameter p1 = new Parameter("Old Min", "Image Intensity Value", "0.0");
    Parameter p2 = new Parameter("Old Max", "Image Intensity Value", "4095.0");
    Parameter p3 = new Parameter("New Min", "Image Intensity Value", "0.0");
    Parameter p4 = new Parameter("New Max", "Image Intensity Value", "65535.0");
    Parameter p5 = new Parameter("Gamma", "0.1-5.0, value of 1 results in no change", "1.0");
    Parameter p6 =
        new Parameter(
            "Output Bit Depth",
            "Depth of the outputted image",
            Parameter.DROPDOWN,
            new String[] {"8", "16", "32"},
            1);

    // Make an array of the parameters and return it
    ParameterSet parameterArray = new ParameterSet();
    parameterArray.addParameter(p0);
    parameterArray.addParameter(p1);
    parameterArray.addParameter(p2);
    parameterArray.addParameter(p3);
    parameterArray.addParameter(p4);
    parameterArray.addParameter(p5);
    parameterArray.addParameter(p6);
    return parameterArray;
  }
Example #2
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);
  }
Example #3
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));
  }
Example #4
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);
  }