0

我一直在研究手指图像处理,我目前想做标准化。

我在Griuale Biometric 网站上研究了这个链接。

归一化的思想在于改变每个像素的强度,以便将整个图像的均值和方差更改为一些预定义的值。

任何人都可以建议我任何可以帮助我的Java示例代码或算法。

编辑:

我正在考虑图像像素MEANVARIANCE考虑图像标准化:

这是我的代码:

public class NormalizeHistMeanVariance {
private static BufferedImage original, normalize;

public static void main(String[] args) throws IOException {
    final int N = 256; // Number of graylevels
    final int M = 250; // Max value in histogram for displaying purposes
    int nrows, ncols, size, in_img[][], out_img[][];
    int i, j, max, maxgray;
    double hist[] = new double[N], norm, mean, var, tmp;

    String f1 = "E:/single.jpg";
    String f2 = "E:/normImg";
    File original_f = new File(f1);
    original = ImageIO.read(original_f);

    Histogram histogram = new Histogram(original);
    in_img = histogram.getPixels(original);

    nrows = in_img.length;
    ncols = in_img[0].length;
    size = in_img.length * in_img[0].length;

    // Compute average gray and histogram
    for (i = 0; i < N; i++)
        hist[i] = 0;
    mean = 0;
    for (i = 0; i < nrows; i++) {
        for (j = 0; j < ncols; j++) {
            hist[in_img[i][j]]++;
            mean += in_img[i][j];
        }
    }
    mean /= size;
    System.out.println("Mean graylevel = " + mean);

    // Compute variance
    var = 0;
    for (i = 0; i < nrows; i++) {
        for (j = 0; j < ncols; j++) {
            tmp = in_img[i][j] - mean;
            var += tmp * tmp;
        }
    }
    var = Math.sqrt(var / (size));
    System.out.println("Variance = " + var);

    max = maxgray = 0;
    for (i = 0; i < N; i++) {
        if (max < hist[i]) {
            max = (int) hist[i];
            maxgray = i;
        }
    }
    System.out.println("Max count " + max + " (graylevel = " + maxgray
            + " )");

    // Normalize to M for better display effect
    norm = (double) M / maxgray;
    System.out.println("Norm = " + norm);

    out_img = new int[nrows][ncols];
    for (int x = 0; x < in_img.length; x++) {
        for (int y = 0; y < in_img[0].length; y++) {
            out_img[x][y] = (int) (in_img[x][y] * norm);
        }
    }
    normalize = ImageUtils.CreateImagefromIntArray(out_img);

    writeImage(f2);
}

private static void writeImage(String output) throws IOException {
    File file = new File(output + ".jpg");
    ImageIO.write(normalize, "jpg", file);
}
}

我想要的是正常化后的平滑图像,就像这个链接一样。但我没有得到想要的结果。有人可以帮我吗?

4

3 回答 3

1

我可以帮助您实现本文使用 Zernike Moments 进行指纹识别中使用的图像归一化

尝试使用Catalano 框架,在下一个版本(1.2)中,我将在框架中编写图像规范化代码。

如果你想做这篇文章,Zernike Moments 也和 Hu Moments 一样准备好了。

于 2013-09-02T19:15:37.463 回答
1

这是一个进行图像规范化的 Java 项目,包括代码: http: //www.developer.com/java/other/article.php/3441391/Processing-Image-Pixels-Using-Java-Controlling-Contrast-and-Brightness .htm

处理图像时,使用的术语是(均方根)对比度和亮度,而不是方差和平均值。(请务必指定您使用的对比度定义类型。)

此页面中的信息似乎暗示它与直方图均衡有关。 http://answers.opencv.org/question/6364/fingerprint-matching-in-mobile-devices-android/

维基百科信息:http ://en.wikipedia.org/wiki/Histogram_equalization#Implementationhint

于 2013-09-02T16:44:32.790 回答
1

因此,您不需要使用直方图来执行此过滤器。

// Parameters to ImageNormalization
float mean = 160;
float variance = 150;

int width = fastBitmap.getWidth();
int height = fastBitmap.getHeight();

float globalMean = Mean(fastBitmap);
float globalVariance = Variance(fastBitmap, globalMean);

for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {

        int g = fastBitmap.getGray(i, j);
        float common = (float)Math.sqrt((variance * (float)Math.pow(g - globalMean, 2)) / globalVariance);
        int n = 0;
        if (g > globalMean){
            n = (int)(mean + common);
        }
        else{
            n = (int)(mean - common);
        }

        n = n > 255 ? 255 : n;
        n = n < 0 ? 0 : n;

        fastBitmap.setGray(i, j, n);
    }
}

private float Mean(FastBitmap fb){
    int height = fb.getHeight();
    int width = fb.getWidth();

    float mean = 0;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            mean += fastBitmap.getGray(i, j);
        }
    }
    return mean / (width * height);
}

private float Variance(FastBitmap fb, float mean){
    int height = fb.getHeight();
    int width = fb.getWidth();

    float sum = 0;
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            sum += Math.pow(fastBitmap.getGray(i, j) - mean, 2);
        }
    }
    return sum / (float)((width * height) - 1);
}
于 2013-09-11T22:43:13.667 回答