java识别图片
A. java 读取word 并识别图片
肯定不是少引用了包,提示你类型不对。这个getImagedataArray这个方法,返回的是int类型,怎么能用数组的方式去取值
B. java如何识别图片里的数字
这是深度学习领域了,三两句话讲不完,我就讲个方向
做个卷积神经网络训练模型
用训练好的模型做预测
用java的话你研究下deeplearn4j
C. 用java怎么读取图片
思路:使用 java.awt.Image包下的Image可以接收图片。读取则使用ImageIO对象。
代码如下:
/**
* 读取图片,首先导入以下的包
*/
import java.awt.Image;
import javax.imageio.ImageIO;
import java.io.*;
/**
* 用Image对象来接收图片
* 路径根据实际情况修改
*/
Image image = ImageIO.read(new File("c:\\1.png"));
System.out.println(image.getSource());
D. Java 可不可以做图像识别的系统
当然可以。
一、纯JAVA开发的技术可行性,即JAVA是否能够实现图像识别的各种算法。
二、如果第一点没有问题,纯JAVA与C++相比,开发效率上的差异。效率要低很多,和具体问题有关。
三、如果第一点没有问题且第二点差异不太大时,纯JAVA与C++相比,相同算法的情况下,软件运行效率的差异。运行效率的差异也很大,也是和具体的算法有关。
E. 怎么用java实现图片里面的数字识别
图片是由点组成(或者是别的方法),记录点的位置、颜色,控制点就行了。至于ocr,有难度,首先要制作文字的变化范围及整个字各部分的联系,这还是简单的。然后,图像分解就行了。额,我不会编程,稍微会点c++,所以这个回答就是假设如果我做这种程序的思路。
F. Java 图像识别 数字图像处理 从一张JPG图片中识别出若干黑色小方块
你需要关注的主要是这个类:java.awt.image.BufferedImage
可以查阅相关的API。
java图像处理技术在《java核心技术8 下卷》中有比较详细的介绍。
相关技术要求和注意事项:RGB标准、ICC配置特性、
建议如果进行像素识别的话可以选取关键点的识别方式、而且确认像素是否符合要求使用RGB的范围识别而非精确识别。
至于具体的识别操作过程,需要你详细定义开始识别的位置标准(规定的或者识别图像获取)、边界标准、大小(识别块得SIZE)、分组(给识别块确定属性)等
G. JAVA识别图片验证码
package com.he;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
public class CodeFact
extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
//设置页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 在内存中创建图象
int width = 60, height = 20;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
// 获取图形上下文
Graphics g = image.getGraphics();
//生成随机类
Random random = new Random();
// 设定背景色
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height);
//设定字体
g.setFont(new Font("Times New Roman", Font.PLAIN, 18));
//画边框
g.setColor(new Color(33,66,99));
g.drawRect(0,0,width-1,height-1);
// 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 155; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
// 取随机产生的认证码(4位数字)
String sRand = "";
for (int i = 0; i < 4; i++) {
String rand = String.valueOf(random.nextInt(10));
sRand += rand;
// 将认证码显示到图象中
g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110),
20 + random.nextInt(110))); //调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
g.drawString(rand, 13 * i + 6, 16);
}
// 将认证码存入SESSION
HttpSession session = request.getSession();
session.setAttribute("rand", sRand);
// 图象生效
g.dispose();
// 输出图象到页面
ImageIO.write(image, "JPEG", response.getOutputStream());
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//给定范围获得随机颜色
private Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255) {
fc = 255;
}
if (bc > 255) {
bc = 255;
}
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
}
你试试!!
H. java 实现图片的文字识别
摘要图像识别是目前很热门的研究领域,涉及的知识很广,包括信息论、模式识别、模糊数学、图像编码、内容分类等等。本文仅对使用Java实现了一个简单的图像文本二值处理,关于识别并未实现。
步骤
建立文本字符模板二值矩阵
对测试字符进行二值矩阵化处理
代码
/*
* @(#)StdModelRepository.java
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* You should have received a of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package cn.e.ynu.sei.recognition.util;import java.awt.Image;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import java.util.ArrayList;import java.util.List;import java.util.logging.Level;import java.util.logging.Logger;import javax.imageio.ImageIO;/** * Hold character charImgs as standard model repository.
* @author 88250
* @version 1.0.0.0, Mar 20, 2008
*/
public class StdModelRepository {
/** * hold character images
*/ List charImgs = new ArrayList();
/** * default width of a character
*/ static int width = 16 /** * default height of a character
*/ static int height = 28 /** * standard character model matrix
*/ public int[][][] stdCharMatrix = new int[27][width][height];
/** * Default constructor.
*/ public StdModelRepository() {
BufferedImage lowercase = null try {
lowercase = ImageIO.read(new File("lowercase.png"));
} catch (IOException ex) {
Logger.getLogger(StdModelRepository.class.getName()).
log(Level.SEVERE, null, ex);
}
for (int i = 0 i < 26 i++) {
charImgs.add(lowercase.getSubimage(i * width,
0,
width,
height));
}
for (int i = 0 i < charImgs.size(); i++) {
Image image = charImgs.get(i);
int[] pixels = ImageUtils.getPixels(image,
image.getWidth(null),
image.getHeight(null));
stdCharMatrix[i] = ImageUtils.getSymbolMatrix(pixels, 0).clone();
ImageUtils.displayMatrix(stdCharMatrix[i]);
}
}
}
/*
* @(#)ImageUtils.java
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
* You should have received a of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package cn.e.ynu.sei.recognition.util;import java.awt.Image;import java.awt.image.PixelGrabber;import java.util.logging.Level;import java.util.logging.Logger;/** * Mainipulation of image data.
* @author 88250
* @version 1.0.0.3, Mar 20, 2008
*/
public class ImageUtils {
/** * Return all of the pixel values of sepecified <code>image< .>* @param image the sepecified image
* @param width width of the image
* @param height height of the image
* @return */ public static int[] getPixels(Image image, int width, int height) {
int[] pixels = new int[width * height];
try {
new PixelGrabber(image, 0, 0, width, height, pixels, 0, width).grabPixels();
} catch (InterruptedException ex) {
Logger.getLogger(ImageUtils.class.getName()).
log(Level.SEVERE, null, ex);
}
return pixels;
}
资源来自:
http://blog.csdn.net/chief1985/article/details/2229572
I. 怎么用java从文件中读取图片和写入图片到文件里
楼下的答案有所欠缺,我这里有个比较完整的,也很简洁的方法,大家参考下import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import javax.imageio.ImageIO;
import java.io.*;public class image {
public static void main(String []args)throws IOException{
Image[] array = new Image[10];
Image image = ImageIO.read(new File("c:\\supermaket1.jpg"));//这里是你要读取的图像文件
array[0] = image;
ImageIO.write((RenderedImage) image, "png", new File("f:\\test.txt"));//这里是你要写入的文件,如果不存在这个文件,那么系统会自动创建它
}
J. 用Java读取一张图片,并识别图中的所有汉字,怎么解决
这个要是自己去写,估计很难,需要用到很多AI智能的算法,可以调用谷歌或者网络的识图API