简体   繁体   English

二维图像中的Gabor小波

[英]Gabor wavelets in 2d image

I use lire, java for image retrieval project and I want to calculate the amplitude of gabor wavelet for every pixel of my input image ref here . 我将lire,java用于图像检索项目,并且我想在此处为输入图像ref的每个像素计算gabor小波的幅度。 The default function in lire library return a downsampled feature vector. lire库中的默认函数返回降采样的特征向量。 What I want the computed amplitude of the gabor wavelets. 我想要gabor小波的计算振幅。 I am trying to create a function getMagnitude: 我正在尝试创建一个功能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;
}

The gabor features are class gabor private variables: 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;

Moreover, it seems that the size of the final magnitude array is affected from the size of M, N scale and orientation. 此外,似乎最终量级数组的大小受M,N大小和方向的大小影响。 What I ve got to do in order to get the case I want? 为了得到我想要的案子,我必须做什么?

COmpute magnitude 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;
}

I think that you ve got to use 5d private double[][][][][] gaborWavelet which is actually calculate the convolution between the image and mother wavelets. 我认为您必须使用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};
}

You have to choose M, N , S, T and the returned wavelets contains two matrices for re and im. 您必须选择M,N,S,T,并且返回的小波包含用于re和im的两个矩阵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM