/** * Prepare data for a input to the FFT, padding if necessary. * * @param input * input data * @param rs * desired number of rows * @param cs * desired number of columns * @param centre * if true, then the data will be prepared so that the DC * component is centred. * @return prepared data */ public static float[][] prepareData(FImage input, int rs, int cs, boolean centre) { return prepareData(input.pixels, rs, cs, centre); }
/** * Prepare data for a input to the FFT, padding if necessary. * * @param input * input data * @param rs * desired number of rows * @param cs * desired number of columns * @param centre * if true, then the data will be prepared so that the DC * component is centred. * @return prepared data */ public static float[][] prepareData(FImage input, int rs, int cs, boolean centre) { return prepareData(input.pixels, rs, cs, centre); }
final float[][][] data = new float[10][][]; for (int i = 0; i < windowSize; i++) data[i] = FourierTransform.prepareData(sequence[i], height, width, false); fft.complexForward(data);
final float[][][] data = new float[10][][]; for (int i = 0; i < windowSize; i++) data[i] = FourierTransform.prepareData(sequence[i], height, width, false); fft.complexForward(data);
private void process(FImage image) { final int cs = image.getCols(); final int rs = image.getRows(); phase = new FImage(cs, rs); magnitude = new FImage(cs, rs); final FloatFFT_2D fft = new FloatFFT_2D(rs, cs); final float[][] prepared = prepareData(image.pixels, rs, cs, centre); fft.complexForward(prepared); for (int y = 0; y < rs; y++) { for (int x = 0; x < cs; x++) { final float re = prepared[y][x * 2]; final float im = prepared[y][1 + x * 2]; phase.pixels[y][x] = (float) Math.atan2(im, re); magnitude.pixels[y][x] = (float) Math.sqrt(re * re + im * im); } } }
private void process(FImage image) { final int cs = image.getCols(); final int rs = image.getRows(); phase = new FImage(cs, rs); magnitude = new FImage(cs, rs); final FloatFFT_2D fft = new FloatFFT_2D(rs, cs); final float[][] prepared = prepareData(image.pixels, rs, cs, centre); fft.complexForward(prepared); for (int y = 0; y < rs; y++) { for (int x = 0; x < cs; x++) { final float re = prepared[y][x * 2]; final float im = prepared[y][1 + x * 2]; phase.pixels[y][x] = (float) Math.atan2(im, re); magnitude.pixels[y][x] = (float) Math.sqrt(re * re + im * im); } } }
@Override public void analyseImage(FImage in) { responses = new FImage[filters.length]; final FImage image = in.padding(paddingX, paddingY); final int cols = image.getCols(); final int rows = image.getRows(); if (fft == null || preparedFilters == null || preparedFilters[0].length != rows || preparedFilters[0][0].length != 2 * cols) { fft = new FloatFFT_2D(rows, cols); preparedFilters = new float[filters.length][][]; tmpImage = new float[rows][cols * 2]; for (int i = 0; i < preparedFilters.length; i++) { final float[][] preparedKernel = FourierTransform.prepareData(filters[i].kernel, rows, cols, false); fft.complexForward(preparedKernel); preparedFilters[i] = preparedKernel; } } final float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); for (int i = 0; i < preparedFilters.length; i++) { responses[i] = convolve(cols, rows, preparedImage, preparedFilters[i]); responses[i] = responses[i].extractROI(2 * paddingX, 2 * paddingY, responses[i].width - 2 * paddingX, responses[i].height - 2 * paddingY); } }
@Override public void analyseImage(FImage in) { responses = new FImage[filters.length]; final FImage image = in.padding(paddingX, paddingY); final int cols = image.getCols(); final int rows = image.getRows(); if (fft == null || preparedFilters == null || preparedFilters[0].length != rows || preparedFilters[0][0].length != 2 * cols) { fft = new FloatFFT_2D(rows, cols); preparedFilters = new float[filters.length][][]; tmpImage = new float[rows][cols * 2]; for (int i = 0; i < preparedFilters.length; i++) { final float[][] preparedKernel = FourierTransform.prepareData(filters[i].kernel, rows, cols, false); fft.complexForward(preparedKernel); preparedFilters[i] = preparedKernel; } } final float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); for (int i = 0; i < preparedFilters.length; i++) { responses[i] = convolve(cols, rows, preparedImage, preparedFilters[i]); responses[i] = responses[i].extractROI(2 * paddingX, 2 * paddingY, responses[i].width - 2 * paddingX, responses[i].height - 2 * paddingY); } }
float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); float[][] preparedKernel = FourierTransform.prepareData(template.pixels, rows, cols, false); fft.complexForward(preparedKernel);
float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); float[][] preparedKernel = FourierTransform.prepareData(template.pixels, rows, cols, false); fft.complexForward(preparedKernel);
private void process(FImage image) { final int cs = image.getCols(); final int rs = image.getRows(); real = new FImage(cs, rs); imaginary = new FImage(cs, rs); final FloatFFT_2D fft = new FloatFFT_2D(rs, cs); final float[][] prepared = FourierTransform.prepareData(image.pixels, rs, cs, centre); fft.complexForward(prepared); for (int y = 0; y < rs; y++) { for (int x = 0; x < cs; x++) { real.pixels[y][x] = prepared[y][x * 2]; imaginary.pixels[y][x] = prepared[y][1 + x * 2]; } } }
final float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); final float[][] preparedKernel = FourierTransform.prepareData(kernel, rows, cols, false); fft.complexForward(preparedKernel);
private void process(FImage image) { final int cs = image.getCols(); final int rs = image.getRows(); real = new FImage(cs, rs); imaginary = new FImage(cs, rs); final FloatFFT_2D fft = new FloatFFT_2D(rs, cs); final float[][] prepared = FourierTransform.prepareData(image.pixels, rs, cs, centre); fft.complexForward(prepared); for (int y = 0; y < rs; y++) { for (int x = 0; x < cs; x++) { real.pixels[y][x] = prepared[y][x * 2]; imaginary.pixels[y][x] = prepared[y][1 + x * 2]; } } }
final float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, false); fft.complexForward(preparedImage); final float[][] preparedKernel = FourierTransform.prepareData(kernel, rows, cols, false); fft.complexForward(preparedKernel);
final float[][] preparedImage = FourierTransform.prepareData(image.pixels, rows, cols, centered); fft.complexForward(preparedImage);
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; }
FourierTransform.prepareData(image.pixels, rows, cols, centered); fft.complexForward(preparedImage);
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; }
final float[][] data1 = FourierTransform.prepareData(img1, h, w, false); final float[][] data2 = FourierTransform.prepareData(img2.frame, h, w, false); fft1.complexForward(data1); fft2.complexForward(data2);
final float[][] data1 = FourierTransform.prepareData(img1, h, w, false); final float[][] data2 = FourierTransform.prepareData(img2.frame, h, w, false); fft1.complexForward(data1); fft2.complexForward(data2);