我将lire, java用于图像检索项目,我想为输入图像参考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大小和方向的大小影响。为了得到我想要的案子,我必须做什么?
幅度函数:
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;
}
最佳答案
我认为您必须使用5d私人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的两个矩阵。
关于java - 二维图像中的Gabor小波,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21546770/