private FloatFV gistGabor(MBFImage img) { final int blocksPerFilter = computeNumberOfSamplingBlocks(); final int nFeaturesPerBand = gaborFilters.length * blocksPerFilter; final int nFilters = this.gaborFilters.length; // pad the image img = img.paddingSymmetric(boundaryExtension, boundaryExtension, boundaryExtension, boundaryExtension); final int cols = img.getCols(); final int rows = img.getRows(); final FloatFFT_2D fft = new FloatFFT_2D(rows, cols); final float[][] workingSpace = new float[rows][cols * 2]; final FloatFV fv = new FloatFV(nFeaturesPerBand * img.numBands()); for (int b = 0; b < img.numBands(); b++) { final FImage band = img.bands.get(b); final float[][] preparedImage = FourierTransform.prepareData(band.pixels, rows, cols, true); fft.complexForward(preparedImage); for (int i = 0; i < nFilters; i++) { // convolve with the filter FImage ig = performConv(fft, preparedImage, workingSpace, this.gaborFilters[i], rows, cols); // remove padding ig = ig.extractROI(boundaryExtension, boundaryExtension, band.width - 2 * boundaryExtension, band.height - 2 * boundaryExtension); sampleResponses(ig, fv.values, b * nFeaturesPerBand + i * blocksPerFilter); } } return fv; }
private FloatFV gistGabor(MBFImage img) { final int blocksPerFilter = computeNumberOfSamplingBlocks(); final int nFeaturesPerBand = gaborFilters.length * blocksPerFilter; final int nFilters = this.gaborFilters.length; // pad the image img = img.paddingSymmetric(boundaryExtension, boundaryExtension, boundaryExtension, boundaryExtension); final int cols = img.getCols(); final int rows = img.getRows(); final FloatFFT_2D fft = new FloatFFT_2D(rows, cols); final float[][] workingSpace = new float[rows][cols * 2]; final FloatFV fv = new FloatFV(nFeaturesPerBand * img.numBands()); for (int b = 0; b < img.numBands(); b++) { final FImage band = img.bands.get(b); final float[][] preparedImage = FourierTransform.prepareData(band.pixels, rows, cols, true); fft.complexForward(preparedImage); for (int i = 0; i < nFilters; i++) { // convolve with the filter FImage ig = performConv(fft, preparedImage, workingSpace, this.gaborFilters[i], rows, cols); // remove padding ig = ig.extractROI(boundaryExtension, boundaryExtension, band.width - 2 * boundaryExtension, band.height - 2 * boundaryExtension); sampleResponses(ig, fv.values, b * nFeaturesPerBand + i * blocksPerFilter); } } return fv; }