Example #1
0
  @Override
  public boolean run(JEXEntry optionalEntry) {
    if (imageData == null || !imageData.getTypeName().getType().equals(JEXData.IMAGE)) {
      return false;
    }

    // Run the function
    TreeMap<DimensionMap, String> images = ImageReader.readObjectToImagePathTable(imageData);
    TreeMap<DimensionMap, String> outputMap = new TreeMap<DimensionMap, String>();

    int count = 0;
    int total = images.size();
    for (DimensionMap dim : images.keySet()) {

      if (this.isCanceled()) {
        return false;
      }

      String path = images.get(dim);
      // File f = new File(path);

      // get the image
      ImagePlus im = new ImagePlus(path);
      ij.process.ImageProcessor imProc = im.getProcessor();
      if (imProc == null) continue;
      FloatProcessor imp =
          (FloatProcessor) im.getProcessor().convertToFloat(); // should be a float processor

      int newWidth = (int) (imp.getWidth() * scale);
      imp.setInterpolationMethod(ImageProcessor.BILINEAR);
      imp = (FloatProcessor) imp.resize(newWidth);

      ImagePlus toSave = FunctionUtility.makeImageToSave(imp, "false", bitDepth);
      String finalPath = JEXWriter.saveImage(toSave);

      outputMap.put(dim.copy(), finalPath);
      Logs.log("Finished processing " + count + " of " + total + ".", 1, this);
      count++;

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

    // Set the outputs
    output = ImageWriter.makeImageStackFromPaths("temp", outputMap);
    output.setDataObjectInfo("Stack binned using binning function");

    // Return status
    return true;
  }
Example #2
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);
  }