I am using lire, java for an image extraction project, and I want to calculate the amplitude of the gabor wavelet for each pixel of my input image ref here . The default function in the lire library returns a downsampling vector. I want the calculated amplitude of Gabor's wavelets. I am trying to create a getMagnitude function:
public double[][] getMagnitude(BufferedImage image) {
image = ImageUtils.scaleImage(image, MAX_IMG_HEIGHT);
Raster imageRaster = image.getRaster();
System.out.println(imageRaster);
int[][] grayLevel = new int[imageRaster.getWidth()][imageRaster.getHeight()];
int[] tmp = new int[3];
for (int i = 0; i < imageRaster.getWidth(); i++) {
for (int j = 0; j < imageRaster.getHeight(); j++) {
grayLevel[i][j] = imageRaster.getPixel(i, j, tmp)[0];
}
}
double[][] magnitudes = computeMagnitudes(grayLevel);
return magnitudes;
}
The gabor functions are private variables of the gabor class:
private static final double U_H = .4;
private static final double U_L = .05;
private static final int S = 1, T = 1;
private static final int M = 4, N = 5;
private static final int MAX_IMG_HEIGHT = 64;
In addition, it seems that the size of the array of finite size depends on the size of the scale and the orientation of M, N. What should I do to get the case that I want?
Cap amplitude function:
private double[][] computeMagnitudes(int[][] image) {
double[][] magnitudes = new double[M][N];
for (int i = 0; i < magnitudes.length; i++) {
for (int j = 0; j < magnitudes[0].length; j++) {
magnitudes[i][j] = 0.;
}
}
if (this.gaborWavelet == null) {
precomputeGaborWavelet(image);
}
for (int m = 0; m < M; m++) {
for (int n = 0; n < N; n++) {
for (int x = S; x < image.length; x++) {
for (int y = T; y < image[0].length; y++) {
magnitudes[m][n] += Math.sqrt(Math.pow(this.gaborWavelet[x - S][y - T][m][n][0], 2) + Math.pow(this.gaborWavelet[x - S][y - T][m][n][1], 2));
}
}
}
}
return magnitudes;
}
source
share