コード例 #1
0
  /** Calls the algorithm. */
  protected void callAlgorithm() {

    try {
      resultImage =
          new ModelImage(imageA.getType(), imageA.getExtents(), (imageA.getImageName() + "_isn"));
      resultImage.copyFileTypeInfo(imageA);

      // Make algorithm
      isnAlgo = new PlugInAlgorithmISN(resultImage, imageA);

      // This is very important. Adding this object as a listener allows the algorithm to
      // notify this object when it has completed of failed. See algorithm performed event.
      // This is made possible by implementing AlgorithmedPerformed interface
      isnAlgo.addListener(this);

      createProgressBar(imageA.getImageName(), " ...", isnAlgo);

      // Hide dialog
      setVisible(false);

      if (isRunInSeparateThread()) {

        // Start the thread as a low priority because we wish to still have user interface work
        // fast.
        if (isnAlgo.startMethod(Thread.MIN_PRIORITY) == false) {
          MipavUtil.displayError("A thread is already running on this object");
        }
      } else {
        isnAlgo.run();
      }
    } catch (OutOfMemoryError x) {
      System.gc();
      MipavUtil.displayError("AlgorithmAbsoluteValue: unable to allocate enough memory");

      return;
    }
  }
コード例 #2
0
  /**
   * Once all the necessary variables are set, call the Gaussian Blur algorithm based on what type
   * of image this is and whether or not there is a separate destination image.
   */
  protected void callAlgorithm() {

    try {

      centerDistanceAlgo =
          new PlugInAlgorithmCenterDistance2(
              image,
              blueMin,
              redMin,
              redFraction,
              mergingDistance,
              greenMin,
              greenFraction,
              greenRegionNumber,
              twoGreenLevels,
              blueBoundaryFraction,
              blueSmooth,
              interpolationDivisor);

      // This is very important. Adding this object as a listener allows
      // the algorithm to
      // notify this object when it has completed or failed. See algorithm
      // performed event.
      // This is made possible by implementing AlgorithmedPerformed
      // interface
      centerDistanceAlgo.addListener(this);
      createProgressBar(image.getImageName(), " ...", centerDistanceAlgo);

      setVisible(false); // Hide dialog

      if (isRunInSeparateThread()) {

        // Start the thread as a low priority because we wish to still
        // have user interface work fast.
        if (centerDistanceAlgo.startMethod(Thread.MIN_PRIORITY) == false) {
          MipavUtil.displayError("A thread is already running on this object");
        }
      } else {
        centerDistanceAlgo.run();
      }
    } catch (OutOfMemoryError x) {
      MipavUtil.displayError("Center Distance: unable to allocate enough memory");

      return;
    }
  } // end callAlgorithm()