本文整理了Java中javax.media.jai.Histogram.getLowValue()
方法的一些代码示例,展示了Histogram.getLowValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.getLowValue()
方法的具体详情如下:
包路径:javax.media.jai.Histogram
类名称:Histogram
方法名:getLowValue
暂无
代码示例来源:origin: geotools/geotools
@Override
LookupTable createByteLookupTable(Map<String, Object> params) {
Utilities.ensureNonNull("params", params);
Histogram h = (Histogram) params.get(KEY_HISTOGRAM);
final byte[] cumulative = new byte[h.getNumBins(0)];
// sum of bins (we might have excluded 0 hence we cannot really optimise)
float totalBinSum = 0;
for (int i = 0; i < cumulative.length; i++) {
totalBinSum += h.getBinSize(0, i);
}
// this is the scale factor for the histogram equalization process
final float scale = (float) (h.getHighValue(0) - 1 - h.getLowValue(0)) / totalBinSum;
float sum = 0;
for (int i = 1; i < cumulative.length; i++) {
sum += h.getBinSize(0, i - 1);
cumulative[i] = (byte) ((sum * scale + h.getLowValue(0)) + .5F);
}
return generateLookupTableByte(cumulative);
}
},
代码示例来源:origin: bcdev/beam
/**
* Returns the width of the bin cells in the given histogram.
*
* @param histogram The histogram to inquire the bin cell width of.
* @return The width of the bin cells in the histogram.
*/
public static double getBinWidth(Histogram histogram) {
return (histogram.getHighValue(0) - histogram.getLowValue(0)) / histogram.getNumBins(0);
}
代码示例来源:origin: senbox-org/snap-desktop
static double getBinSize(Histogram histogram) {
return (histogram.getHighValue(0) - histogram.getLowValue(0)) / histogram.getNumBins(0);
}
代码示例来源:origin: bcdev/beam
static double getBinSize(Histogram histogram) {
return (histogram.getHighValue(0) - histogram.getLowValue(0)) / histogram.getNumBins(0);
}
代码示例来源:origin: bcdev/beam
private static void migrateOldHistogramData(Histogram oldHistogram, Histogram newHistogram) {
final double oldMin = oldHistogram.getLowValue(0);
final double oldMax = oldHistogram.getHighValue(0);
final int[] oldBins = oldHistogram.getBins(0);
final int oldNumBins = oldBins.length;
final double oldBinWidth = computeBinWidth(oldMin, oldMax, oldNumBins);
final double newMin = newHistogram.getLowValue(0);
final double newMax = newHistogram.getHighValue(0);
final int[] newBins = newHistogram.getBins(0);
final int newNumBins = newBins.length;
final double newBinWidth = computeBinWidth(newMin, newMax, newNumBins);
for (int i = 0; i < oldBins.length; i++) {
int count = oldBins[i];
if (count == 0) {
continue;
}
final double binCenterValue = oldMin + oldBinWidth * i + oldBinWidth / 2;
int newBinIndex = (int) Math.floor((binCenterValue - newMin) / newBinWidth);
if (newBinIndex >= newNumBins) {
newBinIndex = newNumBins - 1;
}
newBins[newBinIndex] += count;
}
}
代码示例来源:origin: locationtech/geowave
final javax.media.jai.Histogram histogram2) {
final int numBands = Math.min(histogram1.getNumBands(), histogram2.getNumBands());
final double[] lowValue1 = histogram1.getLowValue();
final double[] lowValue2 = histogram2.getLowValue();
final double[] lowValue = new double[numBands];
for (int b = 0; b < numBands; b++) {
代码示例来源:origin: bcdev/beam
private HistogramStxOp getHistogramOp(String vdnName, double minimum, double maximum, Band band) {
HistogramStxOp histogramStxOp = histogramMap.get(vdnName);
boolean intHistogram;
intHistogram = band.getGeophysicalImage().getSampleModel().getDataType() < DataBuffer.TYPE_FLOAT;
if (histogramStxOp == null) {
histogramStxOp = new HistogramStxOp(initialBinCount, minimum, maximum, intHistogram, false);
histogramMap.put(vdnName, histogramStxOp);
} else {
final Histogram oldHistogram = histogramStxOp.getHistogram();
final double oldMin = oldHistogram.getLowValue()[0];
final double oldMax = oldHistogram.getHighValue()[0];
if (minimum < oldMin || maximum > oldMax) {
histogramStxOp = HistogramExpanderTransmitter.createExpandedHistogramOp(oldHistogram, minimum, maximum, intHistogram, this.initialBinCount);
histogramMap.put(vdnName, histogramStxOp);
}
}
return histogramStxOp;
}
}
代码示例来源:origin: bcdev/beam
private static Histogram getBeamHistogram(RenderedOp histogramImage) {
javax.media.jai.Histogram jaiHistogram = JAIUtils.getHistogramOf(histogramImage);
int[] bins = jaiHistogram.getBins(0);
int minIndex = 0;
int maxIndex = bins.length - 1;
for (int i = 0; i < bins.length; i++) {
if (bins[i] > 0) {
minIndex = i;
break;
}
}
for (int i = bins.length - 1; i >= 0; i--) {
if (bins[i] > 0) {
maxIndex = i;
break;
}
}
double lowValue = jaiHistogram.getLowValue(0);
double highValue = jaiHistogram.getHighValue(0);
int numBins = jaiHistogram.getNumBins(0);
double binWidth = (highValue - lowValue) / numBins;
int[] croppedBins = new int[maxIndex - minIndex + 1];
System.arraycopy(bins, minIndex, croppedBins, 0, croppedBins.length);
return new Histogram(croppedBins, lowValue + minIndex * binWidth, lowValue
+ (maxIndex + 1.0) * binWidth);
}
代码示例来源:origin: bcdev/beam
static HistogramStxOp createExpandedHistogramOp(Histogram oldHistogram, double minimum, double maximum, boolean intHistogram, int initialBinCount) {
final double oldMin = oldHistogram.getLowValue()[0];
final double oldMax = oldHistogram.getHighValue()[0];
final double newMin = Math.min(oldMin, minimum);
代码示例来源:origin: senbox-org/snap-desktop
HashMap<String, Object> statistics = new HashMap<>();
Histogram histogram = getHistogram(mask);
statistics.put("minimum", histogram.getLowValue(0));
statistics.put("maximum", histogram.getHighValue(0));
statistics.put("median", histogram.getPTileThreshold(0.5)[0]);
代码示例来源:origin: bcdev/beam
HashMap<String, Number> statistics = new HashMap<>();
Histogram histogram = getHistogram(mask);
statistics.put("minimum", histogram.getLowValue(0));
statistics.put("maximum", histogram.getHighValue(0));
statistics.put("median", histogram.getPTileThreshold(0.5)[0]);
代码示例来源:origin: bcdev/beam
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.isLogHistogram(),
sourceStx.isIntHistogram(),
targetHistogram,
sourceStx.getResolutionLevel());
targetRaster.setStx(targetStx);
}
代码示例来源:origin: bcdev/beam
pb.add(1); // yPeriod
pb.add(histogram.getLowValue()); // ?
代码示例来源:origin: bcdev/beam
@Test
public void testMinMaxBinsLogHistogram() throws Exception {
StxFactory factory = new StxFactory();
factory
.withMinimum(0.1)
.withMaximum(10)
.withLogHistogram(true)
.withHistogramBins(new int[]{1, 2, 3, 6, 6, 3, 2, 1});
Stx stx = factory.create();
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(0.1, stx.getMinimum(), 1e-10);
assertEquals(10, stx.getMaximum(), 1e-10);
assertEquals(Math.pow(10.0, stx.getHistogram().getMean()[0]), stx.getMean(), 1e-3);
assertEquals(Math.pow(10.0, 0), stx.getMedian(), 1e-3);
assertEquals(-1.0, stx.getHistogram().getLowValue(0), 1e-10);
assertEquals(1.0, stx.getHistogram().getHighValue(0), 1e-10);
assertArrayEquals(new int[]{1, 2, 3, 6, 6, 3, 2, 1}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinIsMax() throws Exception {
StxFactory factory = new StxFactory();
factory
.withMinimum(0)
.withMaximum(0)
.withHistogramBins(new int[]{1000, 0, 0, 0, 0, 0, 0, 0});
Stx stx = factory.create();
assertEquals(0, stx.getMinimum(), 1e-10);
assertEquals(0, stx.getMaximum(), 1e-10);
assertEquals(0, stx.getMean(), 1e-10);
assertEquals(0, stx.getMedian(), 1e-10);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(0, stx.getHistogram().getLowValue(0), 1E-10);
assertEquals(1.0E-10, stx.getHistogram().getHighValue(0), 1E-10);
assertTrue(stx.getHistogram().getLowValue(0) < stx.getHistogram().getHighValue(0));
assertArrayEquals(new int[]{1000, 0, 0, 0, 0, 0, 0, 0}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinAndMaxAreTheSameVeryLargePositiveValue() throws Exception {
double aLargePositiveValue = Double.MAX_VALUE;
double aSlightlySmallerValue = Math.nextAfter(aLargePositiveValue, Double.NEGATIVE_INFINITY);
StxFactory factory = new StxFactory();
factory
.withMinimum(aLargePositiveValue)
.withMaximum(aLargePositiveValue)
.withHistogramBins(new int[]{1000, 0, 0, 0, 0, 0, 0, 0});
Stx stx = factory.create();
assertEquals(aLargePositiveValue, stx.getMinimum(), 1e-10);
assertEquals(aLargePositiveValue, stx.getMaximum(), 1e-10);
assertEquals(aLargePositiveValue, stx.getMean(), 1e-10);
assertEquals(aLargePositiveValue, stx.getMedian(), 1e-10);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(aSlightlySmallerValue, stx.getHistogram().getLowValue(0), 1E-10);
assertEquals(aLargePositiveValue, stx.getHistogram().getHighValue(0), 1E-10);
assertTrue(stx.getHistogram().getLowValue(0) < stx.getHistogram().getHighValue(0));
assertArrayEquals(new int[]{1000, 0, 0, 0, 0, 0, 0, 0}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinAndMaxAreTheSameVeryLargeNegativeValue() throws Exception {
double aLargeNegativeValue = -Double.MAX_VALUE;
double aSlightlyLargerValue = Math.nextUp(aLargeNegativeValue);
StxFactory factory = new StxFactory();
factory
.withMinimum(aLargeNegativeValue)
.withMaximum(aLargeNegativeValue)
.withHistogramBins(new int[]{1000, 0, 0, 0, 0, 0, 0, 0});
Stx stx = factory.create();
assertEquals(aLargeNegativeValue, stx.getMinimum(), 1e-10);
assertEquals(aLargeNegativeValue, stx.getMaximum(), 1e-10);
assertEquals(aLargeNegativeValue, stx.getMean(), 1e-10);
assertEquals(aLargeNegativeValue, stx.getMedian(), 1e-10);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(aLargeNegativeValue, stx.getHistogram().getLowValue(0), 1E-10);
assertEquals(aSlightlyLargerValue, stx.getHistogram().getHighValue(0), 1E-10);
assertTrue(stx.getHistogram().getLowValue(0) < stx.getHistogram().getHighValue(0));
assertArrayEquals(new int[]{1000, 0, 0, 0, 0, 0, 0, 0}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinMaxBins() throws Exception {
StxFactory factory = new StxFactory();
factory
.withMinimum(-1.0)
.withMaximum(1.0)
.withHistogramBins(new int[]{1, 2, 3, 6, 6, 3, 2, 1});
Stx stx = factory.create();
assertEquals(-1.0, stx.getMinimum(), 1e-10);
assertEquals(1.0, stx.getMaximum(), 1e-10);
assertEquals(-0.125, stx.getMean(), 1e-10);
assertEquals(0.0, stx.getMedian(), 1e-10);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(-1.0, stx.getHistogram().getLowValue(0), 1e-10);
assertEquals(1.0, stx.getHistogram().getHighValue(0), 1e-10);
assertArrayEquals(new int[]{1, 2, 3, 6, 6, 3, 2, 1}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinMaxBinsIntHistogram() throws Exception {
StxFactory factory = new StxFactory();
factory
.withMinimum(1)
.withMaximum(100)
.withIntHistogram(true)
.withHistogramBins(new int[]{1, 2, 3, 6, 6, 3, 2, 1});
Stx stx = factory.create();
assertEquals(1, stx.getMinimum(), 1e-10);
assertEquals(100, stx.getMaximum(), 1e-10);
assertEquals(44.75, stx.getMean(), 1e-10);
assertEquals(51.0, stx.getMedian(), 1e-10);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(1, stx.getHistogram().getLowValue(0), 1e-10);
assertEquals(101, stx.getHistogram().getHighValue(0), 1e-10);
assertArrayEquals(new int[]{1, 2, 3, 6, 6, 3, 2, 1}, stx.getHistogramBins());
}
代码示例来源:origin: bcdev/beam
@Test
public void testMinMaxBinsLogHistogramWithNegativeMinimum() throws Exception {
StxFactory factory = new StxFactory();
factory
.withMinimum(-10)
.withMaximum(+10)
.withLogHistogram(true)
.withHistogramBins(new int[]{1, 2, 3, 6, 6, 3, 2, 1});
Stx stx = factory.create();
assertEquals(-10, stx.getMinimum(), 1e-10);
assertEquals(+10, stx.getMaximum(), 1e-10);
assertEquals(0.0, stx.getMean(), 1e-3);
assertEquals(0.0, stx.getMedian(), 1e-3);
assertNotNull(stx.getHistogram());
assertEquals(1, stx.getHistogram().getNumBands());
assertEquals(8, stx.getHistogram().getNumBins()[0]);
assertEquals(-9.0, stx.getHistogram().getLowValue(0), 1e-10); // 1E-9 is the max value we handle
assertEquals(1.0, stx.getHistogram().getHighValue(0), 1e-10);
assertArrayEquals(new int[]{1, 2, 3, 6, 6, 3, 2, 1}, stx.getHistogramBins());
}
内容来源于网络,如有侵权,请联系作者删除!