欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java圖片識(shí)別高效代碼 java圖片識(shí)別高效代碼怎么用

java 實(shí)現(xiàn)圖片的文字識(shí)別

摘要圖像識(shí)別是目前很熱門的研究領(lǐng)域,涉及的知識(shí)很廣,包括信息論、模式識(shí)別、模糊數(shù)學(xué)、圖像編碼、內(nèi)容分類等等。本文僅對(duì)使用Java實(shí)現(xiàn)了一個(gè)簡(jiǎn)單的圖像文本二值處理,關(guān)于識(shí)別并未實(shí)現(xiàn)。

十載的昌圖網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營(yíng)銷型網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整昌圖建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“昌圖網(wǎng)站設(shè)計(jì)”,“昌圖網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

步驟

建立文本字符模板二值矩陣

對(duì)測(cè)試字符進(jìn)行二值矩陣化處理

代碼

/*

* @(#)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 copy 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.edu.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 copy 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.edu.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 codeimage .* @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;

}

資源來(lái)自:

JAVA識(shí)別圖片驗(yàn)證碼

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 {

//設(shè)置頁(yè)面不緩存

response.setHeader("Pragma", "No-cache");

response.setHeader("Cache-Control", "no-cache");

response.setDateHeader("Expires", 0);

// 在內(nèi)存中創(chuàng)建圖象

int width = 60, height = 20;

BufferedImage image = new BufferedImage(width, height,

BufferedImage.TYPE_INT_RGB);

// 獲取圖形上下文

Graphics g = image.getGraphics();

//生成隨機(jī)類

Random random = new Random();

// 設(shè)定背景色

g.setColor(getRandColor(200, 250));

g.fillRect(0, 0, width, height);

//設(shè)定字體

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);

// 隨機(jī)產(chǎn)生155條干擾線,使圖象中的認(rèn)證碼不易被其它程序探測(cè)到

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);

}

// 取隨機(jī)產(chǎn)生的認(rèn)證碼(4位數(shù)字)

String sRand = "";

for (int i = 0; i 4; i++) {

String rand = String.valueOf(random.nextInt(10));

sRand += rand;

// 將認(rèn)證碼顯示到圖象中

g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110),

20 + random.nextInt(110))); //調(diào)用函數(shù)出來(lái)的顏色相同,可能是因?yàn)榉N子太接近,所以只能直接生成

g.drawString(rand, 13 * i + 6, 16);

}

// 將認(rèn)證碼存入SESSION

HttpSession session = request.getSession();

session.setAttribute("rand", sRand);

// 圖象生效

g.dispose();

// 輸出圖象到頁(yè)面

ImageIO.write(image, "JPEG", response.getOutputStream());

}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

doGet(request, response);

}

//給定范圍獲得隨機(jī)顏色

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);

}

}

你試試??!

java根據(jù)ocr識(shí)別名片,誰(shuí)有java處理圖片的代碼,要效果好一點(diǎn)、識(shí)別效率高的、

云脈OCR SDK開(kāi)發(fā)者平臺(tái)上有提供名片識(shí)別API接口,支持Java、C++、C、object pascal及objective-C等多種語(yǔ)言,識(shí)別速度快,平均識(shí)別時(shí)間少于0.6秒,識(shí)別率高,字符識(shí)別率97.37%,用戶登錄后即可自主下載接口.....

通過(guò)文字搜索圖片 java代碼實(shí)現(xiàn)及說(shuō)明

import ja.io.*;

//獲取文件夾內(nèi)容

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())

{

//輸出的是完整的文件夾內(nèi)文件的路徑

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;ifiles.length;i++)

{

listFile(files[i]);

System.out.println("回車");

}

}

}

}

1 首先確定你要搜索的目錄

2 要搜索的關(guān)鍵字 如“花”

3 只搜索圖片類型 .jpg .gif .png .bmp之類的

4 在文本框里獲得搜索的關(guān)鍵字

5 取得要搜索目錄下的所有圖片類型的名字

6 用關(guān)鍵字和取得的文件名一一進(jìn)行對(duì)比

7 若有關(guān)鍵字 記錄該圖片的名字

8 若都沒(méi)關(guān)鍵字 表示無(wú)該名字的圖片

9 空白區(qū)域你可以用一個(gè)窗體來(lái)表示

10 把搜索到的圖片都顯示在這個(gè)窗體。

求一個(gè)實(shí)現(xiàn)java圖片數(shù)字識(shí)別并儲(chǔ)存在一個(gè)數(shù)組里的的代碼

//byte數(shù)組到圖片到硬盤上

public void byte2image(byte[] data,String path){

if(data.length3||path.equals("")) return;//判斷輸入的byte是否為空

try{

FileImageOutputStream imageOutput = new FileImageOutputStream(new File(path));//打開(kāi)輸入流

imageOutput.write(data, 0, data.length);//將byte寫入硬盤

imageOutput.close();

System.out.println("Make Picture success,Please find image in " + path);

} catch(Exception ex) {

System.out.println("Exception: " + ex);

ex.printStackTrace();

}

}

當(dāng)前文章:java圖片識(shí)別高效代碼 java圖片識(shí)別高效代碼怎么用
轉(zhuǎn)載來(lái)源:http://chinadenli.net/article26/hiegcg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站電子商務(wù)、網(wǎng)站排名微信公眾號(hào)、網(wǎng)站維護(hù)、網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)