gpt4 book ai didi

java - 指纹图像二值化

转载 作者:行者123 更新时间:2023-12-01 14:11:01 26 4
gpt4 key购买 nike

我有一个指纹扫描仪应用程序,它从设备获取手指图像数据。

现在我正在尝试对图像进行二值化。

我正在使用 Otsu's algorithm将图像二值化,即像素值 0 或 255。

阈值使用相同的算法计算在 160 左右。
这是我的代码:

public static byte[][] binarizeImage(BufferedImage bfImage){
final int THRESHOLD = 160;
int height = bfImage.getHeight();
int width = bfImage.getWidth();
byte[][] image = new byte[width][height];

for(int i=0; i<width; i++){
for(int j=0; j<height; j++){
Color c = new Color(bfImage.getRGB(i,j));
int red = c.getRed();
int green = c.getGreen();
int blue = c.getBlue();
if(red<THRESHOLD && green<THRESHOLD && blue<THRESHOLD){
image[i][j] = 1;
}else{
image[i][j] = 0;
}
}
}
return image;
}

但生成的图像不是所需的输出。

enter image description here

谁能帮我解决这个问题。

最佳答案

Otsu 方法不适用于指纹图像。尝试在下面使用此过滤器:

  • Bradley 本地阈值
  • 伯恩森阈值。
  • 最大熵阈值。

  • 你会在这里找到: http://code.google.com/p/catalano-framework/

    例子:
    FastBitmap fb = new FastBitmap(bufferedImage);
    fb.toGrayscale();

    BradleyLocalThreshold b = new BradleyLocalThreshold();
    b.applyInPlace(fb);

    bufferedImage = fb.toBufferedImage();

    关于java - 指纹图像二值化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18528750/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com