Ejemplo n.º 1
0
 /*
  * Converts histogram onscreen horizontal pixel amounts to image values.
  */
 private double pixelToValue(final int pixel) {
   synchronized (_synchObject) {
     final double[] minMaxView = _histogramDataGroup.getMinMaxView();
     final double min = minMaxView[0];
     return min + pixelToValueRelative(pixel);
   }
 }
Ejemplo n.º 2
0
 /*
  * Converts image value to histogram onscreen horizontal pixel.
  */
 private int valueToPixel(final double value) {
   synchronized (_synchObject) {
     final double[] minMaxView = _histogramDataGroup.getMinMaxView();
     final double min = minMaxView[0];
     final double max = minMaxView[1];
     final int pixel = (int) (PaletteFix.getSize() * (value - min) / (max - min));
     return pixel;
   }
 }
Ejemplo n.º 3
0
 private double pixelToValueRelative(final int pixel) {
   synchronized (_synchObject) {
     final double[] minMaxView = _histogramDataGroup.getMinMaxView();
     final double min = minMaxView[0];
     final double max = minMaxView[1];
     final double valuePerPixel = (max - min) / PaletteFix.getSize();
     return pixel * valuePerPixel;
   }
 }
Ejemplo n.º 4
0
  /**
   * This method should be called whenever a new set of histogram values is to be displayed (i.e.
   * when a different image gets focus).
   *
   * @param histogramData
   */
  public void setHistogramData(final HistogramDataGroup histogramData) {
    double[] minMaxView;
    double[] minMaxLUT;
    synchronized (_synchObject) {
      _histogramDataGroup = histogramData;
      _histogramDataGroup.setListener(new HistogramDataListener());
      minMaxView = _histogramDataGroup.getMinMaxView();
      minMaxLUT = _histogramDataGroup.getMinMaxLUT();
    }

    //		IJ.log("----");
    //		IJ.log("setHistogramData");
    //		IJ.log("view " + minMaxView[0] + " "  + minMaxView[1] + " lut " + minMaxLUT[0] + " " +
    // minMaxLUT[1]);
    //		IJ.log("----");

    if (null != _frame) {
      if (_frame.isVisible()) {
        _frame.setVisible(true);
      }
      _frame.setTitle(histogramData.getTitle());

      _histogramPanel.setStatistics(histogramData.getStatistics(WIDTH));

      final boolean autoRange = histogramData.getAutoRange();
      if (autoRange) {
        // turn cursors off
        _histogramPanel.setCursors(null, null);
      } else {
        // set cursors to edges
        _histogramPanel.setCursors(INSET, INSET + WIDTH - 1);
      }
      _uiPanel.setAutoRange(autoRange);
      _uiPanel.setExcludePixels(histogramData.getExcludePixels());
      _uiPanel.setCombineChannels(histogramData.getCombineChannels());
      _uiPanel.setDisplayChannels(histogramData.getDisplayChannels());
      _uiPanel.enableChannels(histogramData.hasChannels());
      _uiPanel.setMinMaxLUT(minMaxLUT[0], minMaxLUT[1]);

      _colorBarPanel.setMinMax(minMaxView[0], minMaxView[1], minMaxLUT[0], minMaxLUT[1]);
    }
  }
Ejemplo n.º 5
0
  /*
   * Updates histogram and color bar during the fit.
   */
  private void changed(
      final double minView, final double maxView, final double minLUT, final double maxLUT) {
    synchronized (_synchObject) {
      // TODO ARG added this 9/27 to change hDG internal minMaxViews
      _histogramDataGroup.setMinMaxView(minView, maxView);
      _histogramPanel.setStatistics(_histogramDataGroup.getStatistics(WIDTH));
      _colorBarPanel.setMinMax(minView, maxView, minLUT, maxLUT);
      // TODO changed is currently called from two places:
      // i) the HistogramData listener will call it periodically during the
      // fit.
      // ii) if the user types in a new LUT range this gets called.
      // iii) in the future more UI interactions will wind up here
      //
      // TODO if the user drags a new LUT range this doesn't get called!

      // IJ.log("changed min/maxView " + minView + " " + maxView +
      // " min/maxLUT " + minLUT + " " + maxLUT);

      _histogramDataGroup.redisplay();
    }
  }
Ejemplo n.º 6
0
  // TODO TIDY THIS UP do we need "reset cursor positions"
  private void zoomToLUT() {
    final double minMaxLUT[] = _histogramDataGroup.getMinMaxLUT();
    final double minLUT = minMaxLUT[0];
    final double maxLUT = minMaxLUT[1];

    // zoom to fit current min/max LUT settings
    final double minView = minLUT;
    final double maxView = maxLUT;

    changed(minView, maxView, minLUT, maxLUT);

    // reset cursor positions
    _histogramPanel.resetCursors();
  }