package com.volcano.pub;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* 图形识别技术
* <a href="http://my.oschina.net/arthor" target="_blank" rel="nofollow">@author</a> marker
* 时间:2012-4-6
* */
public class ImageUtil {
public static void main(String[] args) throws IOException {
BufferedImage bi = (BufferedImage)ImageIO.read(new File("e://tmp//RandomPicture1174.jpg"));
//获取图像的宽度和高度
int width = bi.getWidth();
int height = bi.getHeight();
//扫描图片
for(int i=0;i<height;i++){
for(int j=0;j<width;j++){//行扫描
int dip = bi.getRGB(j, i);
//=============volcano add 20120414========start=========//
int p=dip;
int red = 0xff & (p >> 16);
int green = 0xff & (p >> 8);
int blue = 0xff & p;
// if(i == 0)
// System.out.println("i:" + i + " red:" + red + " green:"
// + green + " blue:" + blue);
if (red < 180 && green < 180 && blue < 180) {
// System.out.println(i+".....get num");
System.out.print("♦");
}
else System.out.print("0");//用0比用空格好,用以看清有多少位像素
//=============volcano add 20120414========end =========//
}
System.out.println();//换行
}
}
}