Example #1
0
  private void updateHistogramGraph(double min, double max) {
    xAxis.clear();
    currentMaxMin.max = max;
    currentMaxMin.min = min;
    histogramFunc.setMinMax(min, max);
    histogramFunc.setIgnoreOutliers(true);
    // sanity check if there is actually a histogram live
    List<? extends Dataset> newHistogram = histogramFunc.value(data);
    Dataset histogram = newHistogram.get(0);
    if (histograms != null && histograms.size() > 1) {
      histograms.set(histograms.size() - 1, histogram);
    } else {
      histograms = new ArrayList<Dataset>();
      histograms.add(histogram);
    }

    // Some logging to check on the histograms size
    logger.debug("number of histograms stored is {}", histograms.size());
    if (histograms.size() > 10) {
      logger.warn(
          "Number of stored histograms is over expected levels, now at {}", histograms.size());
    }

    xAxis.setValues(
        DatasetUtils.linSpace(min, max, Math.max(1, histogram.getSize() + 1), Dataset.FLOAT64));
    histogramPlotter.setXAxisValues(xAxis, 1);
    generateHistogramUpdate();
    updateChannelGraphs();
    histogramPlotter.refresh(true);
  }
Example #2
0
  private void autoRangeHistogram() {
    histogramPlotter.clearZoomHistory();
    double[] m;
    if (autoContrast && data.getRank() == 2) {
      try {
        final int[] shape = data.getShape();
        if (shape[0] > 512 && shape[1] > 512) {
          int yReduce = (int) Math.ceil(shape[0] / 512.0);
          int xReduce = (int) Math.ceil(shape[1] / 512.0);
          Downsample sample = new Downsample(DownsampleMode.MAXIMUM, xReduce, yReduce);
          m =
              Stats.quantile(
                  (Dataset) sample.value(data).get(0),
                  getPreferenceAutoContrastLo(),
                  getPreferenceAutoContrastHi());
        } else
          m = Stats.quantile(data, getPreferenceAutoContrastLo(), getPreferenceAutoContrastHi());
      } catch (Exception e) {
        m = new double[] {data.min().doubleValue(), data.max().doubleValue()};
      }
    } else {
      m = new double[] {data.min().doubleValue(), data.max().doubleValue()};
    }

    if (Double.compare(m[1], m[0]) <= 0)
      m[1] = m[0] + PreferenceConstants.MINIMUM_CONTRAST_DELTA / 100.0;

    currentMaxMin.max = m[1];
    currentMaxMin.min = m[0];
  }
Example #3
0
  public void createInitialHistogram() {
    if (!hasData()) return;

    MaxMin oldMM = currentMaxMin;
    currentMaxMin = (MaxMin) cachedMaxMin.get(data.hashCode());
    if (currentMaxMin == null) {
      currentMaxMin = new MaxMin();
      cachedMaxMin.put(data.hashCode(), currentMaxMin);
    }
    if (lockRange && oldMM != null) {
      currentMaxMin.max = oldMM.max;
      currentMaxMin.min = oldMM.min;
    } else {
      if (autoContrast || Double.isNaN(currentMaxMin.max) || Double.isNaN(currentMaxMin.min))
        autoRangeHistogram();
    }

    if (latestHistrogramUIUpdater == null || !latestHistrogramUIUpdater.inqueue) {
      latestHistrogramUIUpdater = new HistrogramUIUpdater();
      parent.getDisplay().asyncExec(latestHistrogramUIUpdater);
    }
  }
 public static void main(String args[]) {
   MaxMin maxMin = new MaxMin();
   maxMin.maximumMinimum();
 }