我使用lire, java进行图像检索项目,我想计算输入图像ref here的每个像素的gabor小波幅度。 lire库中的默认函数返回一个下采样特征向量。我想要的是gabor小波的计算幅度。我正在尝试创建一个函数getMagnitude:
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;
}
gabor功能是类gabor私有变量:
private static final double U_H = .4;
private static final double U_L = .05;
private static final int S = 1, T = 1; // filter mask size
private static final int M = 4, N = 5; // scale & orientation
private static final int MAX_IMG_HEIGHT = 64;
此外,似乎最终幅度阵列的大小受M,N比例和方向的大小影响。为了得到我想要的案子,我必须做些什么?
COmpute幅度函数:
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;
}
答案 0 :(得分:1)
我认为你必须使用5d private double [] [] [] [] [] gaborWavelet,这实际上是计算图像和母小波之间的卷积。
private double[] gaborWavelet(int[][] img, int x, int y, int m, int n) {
double re = 0;
double im = 0;
for (int s = 0; s < S; s++) {
for (int t = 0; t < T; t++) {
re += img[x][y] * selfSimilarGaborWavelets[s][t][m][n][0];
im += img[x][y] * -selfSimilarGaborWavelets[s][t][m][n][1];
}
}
return new double[]{re, im};
}
你必须选择M,N,S,T,并且返回的小波包含两个矩阵用于re和im。