Beispiel #1
0
 /**
  * Adds a new double parameter to be altered for the model being tuned.
  *
  * @param param the model parameter
  * @param initialSearchValues the values to try for the specified parameter
  */
 public void addParameter(DoubleParameter param, double... initialSearchValues) {
   if (param == null) throw new IllegalArgumentException("null not allowed for parameter");
   searchParams.add(param);
   DoubleList dl = new DoubleList(initialSearchValues.length);
   for (double d : initialSearchValues) dl.add(d);
   Arrays.sort(dl.getBackingArray()); // convience, only really needed if param is warm
   if (param.isWarmParameter() && !param.preferredLowToHigh())
     Collections.reverse(dl); // put it in the prefered order
   if (param.isWarmParameter()) // put it at the front!
   searchValues.add(0, dl);
   else searchValues.add(dl);
 }
Beispiel #2
0
 /**
  * Sets the parameters according to the given array
  *
  * @param setTo the index corresponds to the parameters, and the value which parameter value to
  *     use.
  */
 private void setParameters(int[] setTo) {
   for (int i = 0; i < setTo.length; i++) {
     Parameter param = searchParams.get(i);
     if (param instanceof DoubleParameter)
       ((DoubleParameter) param).setValue(searchValues.get(i).get(setTo[i]));
     else if (param instanceof IntParameter)
       ((IntParameter) param).setValue(searchValues.get(i).get(setTo[i]).intValue());
   }
 }
Beispiel #3
0
 @Override
 public double runThresholder(ImageHandler input, InputImages images) {
   double thld1 = threshold1.getThreshold(input, images, nbCPUs, debug);
   double thld2 = threshold2.getThreshold(input, images, nbCPUs, debug);
   if (debug) ij.IJ.log("thld1:" + thld1 + " thld2:" + thld2);
   if (operation.getSelectedItem().equals(methods[0])) {
     return Math.max(thld2, thld1);
   } else if (operation.getSelectedItem().equals(methods[1])) {
     return Math.min(thld2, thld1);
   } else if (operation.getSelectedItem().equals(methods[1])) {
     double coeffd = coeff.getDoubleValue(0.5d);
     return thld1 * (1 - coeffd) + thld2 * coeffd;
   } else return thld1;
 }
  // Construct GUI for a set of parameters
  public static void makeControls(
      Container controls,
      GridBagLayout controlLayout,
      GridBagConstraints controlCon,
      Vector dpList,
      Vector optList,
      String title) {
    Container spec = new Container();
    controlLayout.setConstraints(spec, controlCon);
    controls.add(spec);

    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();

    spec.setLayout(layout);

    Iterator i = dpList.iterator();
    while (i.hasNext()) {
      DoubleParameter dp = (DoubleParameter) (i.next());

      // Make slider and text field
      JSlider val = new JSlider(JSlider.HORIZONTAL);
      JTextField tval = new JTextField(5);

      dp.register(val);
      dp.register(tval);

      // Lay out label, slider, text field
      con.fill = GridBagConstraints.NONE;
      con.weightx = 0.0;
      con.weighty = 0.0;
      con.gridwidth = 1;

      JLabel name = new JLabel(dp.name);
      layout.setConstraints(name, con);
      spec.add(name);

      con.fill = GridBagConstraints.HORIZONTAL;
      con.weightx = 0.8;
      layout.setConstraints(val, con);
      spec.add(val);

      con.weightx = 0.2;
      con.gridwidth = GridBagConstraints.REMAINDER;
      layout.setConstraints(tval, con);
      spec.add(tval);
    }

    // Label column on bottom
    con.fill = GridBagConstraints.VERTICAL;
    con.anchor = GridBagConstraints.SOUTH;
    con.weightx = 0.0;
    con.weighty = 1.0;
    con.gridwidth = GridBagConstraints.REMAINDER;
    JLabel ltitle = new JLabel(title);
    layout.setConstraints(ltitle, con);
    spec.add(ltitle);

    // Display options
    con.anchor = GridBagConstraints.WEST;
    i = optList.iterator();
    while (i.hasNext()) {
      BooleanParameter bp = (BooleanParameter) (i.next());

      JCheckBox ck = new JCheckBox(bp.name);
      bp.register(ck);

      layout.setConstraints(ck, con);
      spec.add(ck);
    }
  }
Beispiel #5
0
 public ThresholderOperation() {
   operation.setHelp("Choose operation performed on computed thresholds", true);
   coeff.setHelp(
       "returned threshold is a ponderated mean value of thld1 & thld2: thld1 * (1-coeff) + thld2*coeff",
       true);
 }