I have an finger print scanner application which takes finger image data from device.
Now I am trying to binarize the image.
I am Using the Otsu's algorithm to binarize the image i.e. pixel's values either 0 or 255.
Threshold is calculated around 160 using same algorithm. Here is my code:
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;
}
But the resulting image is not of the desired output.
Could anyone help me with this.