導航:首頁 > 文字圖片 > 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識別圖片文字相關的資料

熱點內容
下載卡通小女孩圖片牆紙 瀏覽:94
圖片特效怎麼弄 瀏覽:497
從1到33數字高清圖片 瀏覽:186
剪輯視頻如何給圖片標注文字 瀏覽:958
衣服的畫法圖片大全兒童 瀏覽:531
結婚穿衣服圖片大全男生 瀏覽:184
黑白簡約文字圖片 瀏覽:80
手帕圖片大全如何存放 瀏覽:238
和尚漢堡圖片大全可愛 瀏覽:86
word圖片怎麼畫滑輪連線 瀏覽:851
word文字右邊加圖片怎麼操作 瀏覽:117
如何用恢復大師找到丟失的圖片 瀏覽:581
高清圖片男生帥氣海邊 瀏覽:272
word文檔插入圖片調整透明度 瀏覽:328
小說頭像女生圖片真人霸氣 瀏覽:540
六一如何發孩子圖片幽默 瀏覽:290
廠長動漫圖片 瀏覽:869
成年男生賣萌圖片 瀏覽:846
鵝蛋畫卡通圖片大全可愛 瀏覽:577
穿堂風衣服圖片 瀏覽:194