protected void extractGist(IMAGE image) { MBFImage mbfimage; if (image instanceof FImage) { mbfimage = new MBFImage((FImage) image); } else if (image instanceof MBFImage) { mbfimage = (MBFImage) image; } else { throw new UnsupportedOperationException("Image type " + image.getClass() + " is not currently supported. Please file a bug report."); } final MBFImage o = prefilter(mbfimage.normalise()); this.response = gistGabor(o); }
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; }
@Override public void analyseImage(IMAGE image) { if (fixedSize) { final double sc = Math.max((double) imageWidth / (double) image.getWidth(), (double) imageHeight / (double) image.getHeight()); final IMAGE resized = image.process(new ResizeProcessor((float) sc)); final IMAGE roi = resized.extractCenter(imageWidth, imageHeight); extractGist(roi); } else { if (gaborFilters == null || gaborFilters[0].width != image.getWidth() || gaborFilters[0].height != image.getHeight()) { gaborFilters = GaborFilters.createGaborJets(image.getWidth() + 2 * this.boundaryExtension, image.getHeight() + 2 * this.boundaryExtension, orientationsPerScale); } extractGist(image.clone()); // clone to stop side effects from // normalisation further down } }
final int blocksPerFilter = computeNumberOfSamplingBlocks(); final int nFeaturesPerBand = gaborFilters.length * blocksPerFilter; final int nBands = this.response.values.length / nFeaturesPerBand;
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; }
@Override public void analyseImage(IMAGE image) { if (fixedSize) { final double sc = Math.max((double) imageWidth / (double) image.getWidth(), (double) imageHeight / (double) image.getHeight()); final IMAGE resized = image.process(new ResizeProcessor((float) sc)); final IMAGE roi = resized.extractCenter(imageWidth, imageHeight); extractGist(roi); } else { if (gaborFilters == null || gaborFilters[0].width != image.getWidth() || gaborFilters[0].height != image.getHeight()) { gaborFilters = GaborFilters.createGaborJets(image.getWidth() + 2 * this.boundaryExtension, image.getHeight() + 2 * this.boundaryExtension, orientationsPerScale); } extractGist(image.clone()); // clone to stop side effects from // normalisation further down } }
final int blocksPerFilter = computeNumberOfSamplingBlocks(); final int nFeaturesPerBand = gaborFilters.length * blocksPerFilter; final int nBands = this.response.values.length / nFeaturesPerBand;
protected void extractGist(IMAGE image) { MBFImage mbfimage; if (image instanceof FImage) { mbfimage = new MBFImage((FImage) image); } else if (image instanceof MBFImage) { mbfimage = (MBFImage) image; } else { throw new UnsupportedOperationException("Image type " + image.getClass() + " is not currently supported. Please file a bug report."); } final MBFImage o = prefilter(mbfimage.normalise()); this.response = gistGabor(o); }