导航:首页 > 文字图片 > java识别图片文字

java识别图片文字

发布时间:2022-01-07 03:17:06

❶ 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

❷ java有读取图片里面文字的方法吗

使用tesseract-ocr,可以识别简单的验证码,中文没尝试过

❸ 通过文字搜索图片 java代码实现及说明

import ja.io.*;
//获取文件夹内容
public class getthing
{
public static void main(String[] args) throws Exception
{
System.out.println(welstr);
listFile(new File("e:\\aa")); //想要搜索的路径
}

public static void listFile(File file) throws Exception
{

if(file.isFile())
{
//输出的是完整的文件夹内文件的路径
System.out.println("File :"+file.getAbsolutePath());
//01.jpg就是你要找的图片
if (file.getAbsolutePath().endsWith("01.jpg"))
System.out.println("有搜索的图片");
}
else
{
System.out.println("Dir :"+file.getAbsolutePath());
File[] files =file.listFiles();
for(int i=0;i<files.length;i++)
{
listFile(files[i]);
System.out.println("回车");
}
}
}
}
1 首先确定你要搜索的目录
2 要搜索的关键字 如“花”
3 只搜索图片类型 .jpg .gif .png .bmp之类的
4 在文本框里获得搜索的关键字
5 取得要搜索目录下的所有图片类型的名字
6 用关键字和取得的文件名一一进行对比
7 若有关键字 记录该图片的名字
8 若都没关键字 表示无该名字的图片
9 空白区域你可以用一个窗体来表示
10 把搜索到的图片都显示在这个窗体。

❹ java截图后怎么用tesseract 文字识别

网上传的代码示例大多是在Windows下安装Tesseract ORC后通过CMD命令操作进行图识别操作.而 Tess4j 针对Tesseract 提供了JNI支持,同时还提供了一些图片操作的工具类,提供比如图片放大,旋转,黑白处理,锐化 等用来提高识别率的操作.操作十分方便. T

❺ java 如何读取附加到图片上的文字

图片上的文字是没法读取的,以为这涉及到图像处理。非常非常复杂!因为如果你非要读取图片上的文字,不是几行代码可以搞定的,首相从matlaB开始学,了解什么是图像处理。然后再开发相应的jar包。当然,你也可以使用相关的软件工具,比如识图软件,通过读取软件的反馈也算是读取了图片上的文字

❻ 用JAVA编写一个程序识别图片上的文字;这个难题你实现了吗

这种不是个人可以处理的,也不是java的强项,去找提供ocr api的厂商吧。

❼ 怎么用java实现图片里面的数字识别

图片是由点组成(或者是别的方法),记录点的位置、颜色,控制点就行了。至于ocr,有难度,首先要制作文字的变化范围及整个字各部分的联系,这还是简单的。然后,图像分解就行了。额,我不会编程,稍微会点c++,所以这个回答就是假设如果我做这种程序的思路。

❽ 用java怎么获得一张图片上的一个文字的坐标点 求高手解答

//提示:坐标依次打印在命令符窗口
//提示:坐标依次打印在命令符窗口
//提示:坐标依次打印在命令符窗口
//不就是监听鼠标事件吗?
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.border.Border;

/**
*我想建立个界面,可以加载本机中图片。
*加载后可以通过鼠标点击获得图片上任意点坐标。
*提问者:sunny929929-试用期一级
*/
{
privateJLabeltipLabel;

/**
*main()
*/
publicstaticvoidmain(String[]args){
MyPictureframe=newMyPicture();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

/**
*constructor
*/
publicMyPicture(){
setSize(800,600);//根据要求调整大小
setLocation(100,100);
setTitle("获得图片上任意点坐标");
setResizable(false);

Containercon=getContentPane();

ImageIconbgIcon=newImageIcon("bgpic.jpg");//注意图片的路径
ImagePanelbackpicPanel=newImagePanel(bgIcon);
backpicPanel.addMouseListener(this);
con.add(backpicPanel,BorderLayout.CENTER);

tipLabel=newJLabel("--------------------提示:坐标依次打印在屏幕上!--------------------");
con.add(tipLabel,BorderLayout.SOUTH);
}

/**
*
*/
publicvoidmousePressed(MouseEvente){
intx=e.getX();
inty=e.getY();
Stringmessage="("+x+","+y+")";
tipLabel.setText(message);
System.out.println(message);

}

publicvoidmouseReleased(MouseEvente){

}

publicvoidmouseEntered(MouseEvente){

}

publicvoidmouseExited(MouseEvente){

}

publicvoidmouseClicked(MouseEvente){

}

}

/**
*类ImagePanel,用于添加背景图片
*/
classImagePanelextendsJPanel{
privateImageimg;
publicImagePanel(ImageIconimageIcon){
img=imageIcon.getImage();
}

publicvoidpaintComponent(Graphicsg){
super.paintComponent(g);
g.drawImage(img,0,0,this);
}

}

❾ 用Java读取一张图片,并识别图中的所有汉字,怎么解决

这个要是自己去写,估计很难,需要用到很多AI智能的算法,可以调用谷歌或者网络的识图API

❿ Java如何实现从一个指定图片中提取出内容!例如图片中的完整车牌!

java本身无法实现。估计要调用第三方程序。

阅读全文

与java识别图片文字相关的资料

热点内容
结婚穿衣服图片大全男生 浏览:184
黑白简约文字图片 浏览:80
手帕图片大全如何存放 浏览:238
和尚汉堡图片大全可爱 浏览:86
word图片怎么画滑轮连线 浏览:851
word文字右边加图片怎么操作 浏览:117
如何用恢复大师找到丢失的图片 浏览:581
高清图片男生帅气海边 浏览:272
word文档插入图片调整透明度 浏览:328
小说头像女生图片真人霸气 浏览:540
六一如何发孩子图片幽默 浏览:290
厂长动漫图片 浏览:869
成年男生卖萌图片 浏览:846
鹅蛋画卡通图片大全可爱 浏览:577
穿堂风衣服图片 浏览:194
衣服不加绒图片 浏览:506
手机图片如何做箭头 浏览:529
穿短袜的男生图片 浏览:628
詹姆斯湖人图片带文字的 浏览:987
lv图案的衣服图片 浏览:991