private void computeCells(WindowedHistogramExtractor binnedData, Rectangle region) { final int cellWidth = (int) (region.width / numCellsX); final int cellHeight = (int) (region.height / numCellsY); for (int j = 0, y = (int) region.y; j < numCellsY; j++, y += cellHeight) { for (int i = 0, x = (int) region.x; i < numCellsX; i++, x += cellWidth) { binnedData.computeHistogram(x, y, cellWidth, cellHeight, cells[j][i]); cells[j][i].normaliseL2(); } } } }
private void computeCells(WindowedHistogramExtractor binnedData, Rectangle region) { final int cellWidth = (int) (region.width / numCellsX); final int cellHeight = (int) (region.height / numCellsY); for (int j = 0, y = (int) region.y; j < numCellsY; j++, y += cellHeight) { for (int i = 0, x = (int) region.x; i < numCellsX; i++, x += cellWidth) { binnedData.computeHistogram(x, y, cellWidth, cellHeight, cells[j][i]); cells[j][i].normaliseL2(); } } } }
private Histogram[][] computeCells(WindowedHistogramExtractor binnedData, Rectangle region) { final int numCellsX = (int) ((region.width + cellWidth / 2) / cellWidth); final int numCellsY = (int) ((region.height + cellHeight / 2) / cellHeight); final Histogram[][] cells = new Histogram[numCellsY][numCellsX]; for (int j = 0, y = (int) region.y; j < numCellsY; j++, y += cellHeight) { for (int i = 0, x = (int) region.x; i < numCellsX; i++, x += cellWidth) { cells[j][i] = binnedData.computeHistogram(x, y, cellWidth, cellHeight); cells[j][i].normaliseL2(); } } return cells; } }
private Histogram[][] computeCells(WindowedHistogramExtractor binnedData, Rectangle region) { final int numCellsX = (int) ((region.width + cellWidth / 2) / cellWidth); final int numCellsY = (int) ((region.height + cellHeight / 2) / cellHeight); final Histogram[][] cells = new Histogram[numCellsY][numCellsX]; for (int j = 0, y = (int) region.y; j < numCellsY; j++, y += cellHeight) { for (int i = 0, x = (int) region.x; i < numCellsX; i++, x += cellWidth) { cells[j][i] = binnedData.computeHistogram(x, y, cellWidth, cellHeight); cells[j][i].normaliseL2(); } } return cells; } }
@Override public Histogram extract(WindowedHistogramExtractor binnedData, Rectangle region, Histogram output) { final float dx = region.width / numBlocksX; final float dy = region.height / numBlocksY; final int blockSize = binnedData.getNumBins(); if (output == null || output.values.length != blockSize * numBlocksX * numBlocksY) output = new Histogram(blockSize * numBlocksX * numBlocksY); final RectangleSampler rs = new RectangleSampler(region, dx, dy, dx, dy); int block = 0; final Histogram tmp = new Histogram(blockSize); for (final Rectangle r : rs) { binnedData.computeHistogram(r, tmp); tmp.normaliseL2(); System.arraycopy(tmp.values, 0, output.values, blockSize * block, blockSize); block++; } return output; } }
@Override public Histogram extract(WindowedHistogramExtractor binnedData, Rectangle region, Histogram output) { final float dx = region.width / numBlocksX; final float dy = region.height / numBlocksY; final int blockSize = binnedData.getNumBins(); if (output == null || output.values.length != blockSize * numBlocksX * numBlocksY) output = new Histogram(blockSize * numBlocksX * numBlocksY); final RectangleSampler rs = new RectangleSampler(region, dx, dy, dx, dy); int block = 0; final Histogram tmp = new Histogram(blockSize); for (final Rectangle r : rs) { binnedData.computeHistogram(r, tmp); tmp.normaliseL2(); System.arraycopy(tmp.values, 0, output.values, blockSize * block, blockSize); block++; } return output; } }