本文整理了Java中javax.media.jai.Histogram.getBins()
方法的一些代码示例,展示了Histogram.getBins()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Histogram.getBins()
方法的具体详情如下:
包路径:javax.media.jai.Histogram
类名称:Histogram
方法名:getBins
暂无
代码示例来源:origin: bcdev/beam
private static void migrateOldHistogramData(Histogram oldHistogram, Histogram newHistogram, int startOffset, int binRatio) {
final int[] oldBins = oldHistogram.getBins(0);
final int[] newBins = newHistogram.getBins(0);
final int newMaxIndex = newBins.length - 1;
for (int i = 0; i < oldBins.length; i++) {
int newBinsIndex = (startOffset + i) / binRatio;
if (newBinsIndex > newMaxIndex) {
newBinsIndex = newMaxIndex;
}
newBins[newBinsIndex] += oldBins[i];
}
}
代码示例来源:origin: bcdev/beam
/**
* @return The histogram bins (sample counts).
*/
public int[] getHistogramBins() {
return histogram.getBins(0);
}
代码示例来源:origin: bcdev/beam
static Histogram createHistogram(double minimum, double maximum, boolean logHistogram, boolean intHistogram, int[] bins) {
final Histogram histogram = createHistogram(bins.length, minimum, maximum, logHistogram, intHistogram);
System.arraycopy(bins, 0, histogram.getBins(0), 0, bins.length);
return histogram;
}
代码示例来源:origin: org.imajine/org-imajine-image-plugin-jai
/*******************************************************************************
*
* @inheritDoc
*
*******************************************************************************/
public int[] getFrequencies (int band)
{
validateBand(band);
ensureDataComputed();
return delegate.getBins(band);
}
代码示例来源:origin: org.imajine.image/org-imajine-image-plugin-jai
/*******************************************************************************
*
* @inheritDoc
*
*******************************************************************************/
@Override
public int[] getFrequencies (int band)
{
validateBand(band);
ensureDataComputed();
return delegate.getBins(band);
}
代码示例来源:origin: geosolutions-it/jai-ext
private void setHistogram(Histogram histogram)
{
this.histogram = histogram;
if(histogram != null) {
// Calculate the components dimensions.
width = histogram.getNumBins(0) * binWidth;
// Get the histogram data.
counts = histogram.getBins(0);
// Get the max and min counts.
maxCount = Integer.MIN_VALUE;
for (int c = 0; c < counts.length; c++)
{
maxCount = Math.max(maxCount, counts[c]);
}
}
repaint();
}
代码示例来源:origin: it.geosolutions.jaiext.utilities/jt-utilities
private void setHistogram(Histogram histogram)
{
this.histogram = histogram;
if(histogram != null) {
// Calculate the components dimensions.
width = histogram.getNumBins(0) * binWidth;
// Get the histogram data.
counts = histogram.getBins(0);
// Get the max and min counts.
maxCount = Integer.MIN_VALUE;
for (int c = 0; c < counts.length; c++)
{
maxCount = Math.max(maxCount, counts[c]);
}
}
repaint();
}
代码示例来源:origin: bcdev/beam
private static Histogram createHistogram(Stx[] stxs) {
Histogram histogram = new Histogram(stxs[0].getHistogramBinCount(), 0, 256, stxs.length);
for (int i = 0; i < stxs.length; i++) {
System.arraycopy(stxs[i].getHistogramBins(), 0, histogram.getBins(i), 0, stxs[0].getHistogramBinCount());
}
return histogram;
}
代码示例来源:origin: locationtech/geowave
highValue[b] = Math.max(highValue1[b], highValue2[b]);
final int[][] bins1 = histogram1.getBins();
final int[][] bins2 = histogram2.getBins();
final int[] numBins = new int[numBands];
for (int b = 0; b < numBands; b++) {
final int[] bins = histogram.getBins(b);
for (int i = 0; i < bins.length; i++) {
bins[i] = bins1[b][i] + bins2[b][i];
代码示例来源: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: 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 double computeMedian(Histogram histogram, long sampleCount) {
boolean isEven = sampleCount % 2 == 0;
double halfSampleCount = sampleCount / 2.0;
final int bandIndex = 0;
int[] bins = histogram.getBins(bandIndex);
long currentSampleCount = 0;
int lastConsideredBinIndex = 0;
for (int i = 0, binsLength = bins.length; i < binsLength; i++) {
currentSampleCount += bins[i];
if (currentSampleCount > halfSampleCount) {
if (isEven) {
double binValue = getMeanOfBin(histogram, bandIndex, i);
double lastBinValue = getMeanOfBin(histogram, bandIndex, lastConsideredBinIndex);
return (lastBinValue + binValue) / 2;
} else {
final double binLowValue = histogram.getBinLowValue(bandIndex, i);
final double binMaxValue = histogram.getBinLowValue(bandIndex, i + 1);
final double previousSampleCount = currentSampleCount - bins[i];
double weight = (halfSampleCount - previousSampleCount) / (currentSampleCount - previousSampleCount);
return binLowValue * (1 - weight) + binMaxValue * weight;
}
}
if (bins[i] > 0) {
lastConsideredBinIndex = i;
}
}
return Double.NaN;
}
代码示例来源:origin: senbox-org/snap-desktop
int[] bins = histogram.getBins(0);
for (int j = 0; j < bins.length; j++) {
histogramSeries.add(histogram.getBinLowValue(0, j),
代码示例来源:origin: bcdev/beam
int[] bins = histogram.getBins(0);
for (int j = 0; j < bins.length; j++) {
histogramSeries.add(histogram.getBinLowValue(0, j),
代码示例来源:origin: bcdev/beam
this.sampleCount = StxFactory.computeSum(histogram.getBins(0));
this.minimum = minimum;
this.maximum = maximum;
代码示例来源: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
final int[] bins = histogram.getBins(0);
final double lowValue = histogram.getLowValue(0);
final double highValue = histogram.getHighValue(0);
代码示例来源:origin: bcdev/beam
@Test
public void testPercentiles() throws Exception {
int[] samples = new int[]{0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9};
Arrays.sort(samples);
double p0 = samples[0];
double p25 = samples[samples.length / 4 - 1];
double p50 = samples[samples.length / 2 - 1];
double p75 = samples[3 * samples.length / 4 - 1];
double p100 = samples[samples.length - 1];
int[] bins = new int[10];
for (int sample : samples) {
bins[sample]++;
}
Histogram histogram = new Histogram(new int[]{10}, new double[]{0.0}, new double[]{10.0});
System.arraycopy(bins, 0, histogram.getBins(0), 0, 10);
assertEquals(p0, histogram.getPTileThreshold(0.00001)[0], 1E-10);
assertEquals(p50, histogram.getPTileThreshold(0.50)[0], 1E-10);
assertEquals(p25, histogram.getPTileThreshold(0.25)[0], 1E-10);
assertEquals(p75, histogram.getPTileThreshold(0.75)[0], 1E-10);
assertEquals(p100, histogram.getPTileThreshold(0.99999)[0], 1E-10);
}
内容来源于网络,如有侵权,请联系作者删除!