I want to recognize the numbers in the Pic1.
I did some work on it and it returns to pic2
Here is my code:
package captchadecproj;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/*
* @author Mr__Hamid
*/
public class NewClass {
public static void main(String args[]) throws IOException {
int width = 110;
int heigth = 40;
BufferedImage image1 = new BufferedImage(width, heigth, BufferedImage.TYPE_INT_RGB);
BufferedImage num1 = new BufferedImage(width, heigth, BufferedImage.TYPE_INT_RGB);
BufferedImage image = null;
File f = null;
try {
f = new File("E:\\Desktop 2\\Captcha Project\\CaptchaDecoder\\captchaDecProj\\167.png");
image = new BufferedImage(width, heigth, BufferedImage.TYPE_INT_ARGB);
image = ImageIO.read(f);
System.out.println("Read!");
} catch (IOException e) {
System.out.println("Error" + e);
}
int[] pixel = null;
for (int y = 0; y < image.getHeight(); y++) {
for (int x = 0; x < image.getWidth(); x++) {
pixel = image.getRaster().getPixel(x, y, new int[3]);
if (pixel[0] < 30 & pixel[1] > 130 & pixel[2] < 110 & pixel[2] > 60) {
image1.setRGB(x, y, Integer.parseInt("ffffff".trim(), 16));
System.out.println(pixel[0] + " - " + pixel[1] + " - " + pixel[2] + " - " + (image.getWidth() * y + x));
} else {
image1.setRGB(x, y, 1);
System.out.println(pixel[0] + " - " + pixel[1] + " - " + pixel[2] + " - " + (image.getWidth() * y + x));
}
}
}
try {
f = new File("D:\\Original.jpg");
ImageIO.write(image, "jpg", f);
f = new File("D:\\black&White.jpg");
ImageIO.write(image1, "jpg", f);
System.out.println("Writed");
} catch (IOException e) {
System.out.println("Error" + e);
}
}
}
I have two questions:
How can I split these numbers?
How can I recognize which one is my number?
For example in the uploaded pic: 7, 1, 6