public static int[] compute(Histogram h) {

    int autoThreshold = 5000;
    double threshold = ((h.getTotals())[0]) / autoThreshold;
    int[] bins = h.getBins(0);
    int nBins = bins.length;
    int histogramMin = 0, histogramMax = 0;

    double[] pThreshold = h.getPTileThreshold(0.4);
    for (int loop = (int) pThreshold[0]; loop < nBins; loop++)
      if (bins[loop] > threshold) {
        histogramMin = loop;
        break;
      }
    for (int loop = nBins - 1; loop >= 0; loop--)
      if (bins[loop] > threshold) {
        histogramMax = loop;
        break;
      }
    if (histogramMax >= histogramMin) {
      int lowValue = (int) h.getLowValue(0);
      int min = lowValue + histogramMin;
      int max = lowValue + histogramMax;
      if (min == max) {
        min = (int) h.getLowValue(0);
        max = (int) h.getHighValue(0);
      }
      return new int[] {max - min, min + (int) ((max - min) / 2)};
    }
    return null;
  }
예제 #2
0
  private void copyStx(RasterDataNode sourceRaster, RasterDataNode targetRaster) {
    final Stx sourceStx = sourceRaster.getStx();
    final Histogram sourceHistogram = sourceStx.getHistogram();
    final Histogram targetHistogram =
        new Histogram(
            sourceStx.getHistogramBinCount(),
            sourceHistogram.getLowValue(0),
            sourceHistogram.getHighValue(0),
            1);

    System.arraycopy(
        sourceHistogram.getBins(0),
        0,
        targetHistogram.getBins(0),
        0,
        sourceStx.getHistogramBinCount());

    final Stx targetStx =
        new Stx(
            sourceStx.getMinimum(),
            sourceStx.getMaximum(),
            sourceStx.getMean(),
            sourceStx.getStandardDeviation(),
            sourceStx.getCoefficientOfVariation(),
            sourceStx.getEquivalentNumberOfLooks(),
            sourceStx.isLogHistogram(),
            sourceStx.isIntHistogram(),
            targetHistogram,
            sourceStx.getResolutionLevel());

    targetRaster.setStx(targetStx);
  }