真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java圖片識別高效代碼 java圖片識別高效代碼怎么用

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

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

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

步驟

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

對測試字符進(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;

}

資源來自:

JAVA識別圖片驗(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è)置頁面不緩存

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)證碼不易被其它程序探測到

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ù)出來的顏色相同,可能是因?yàn)榉N子太接近,所以只能直接生成

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

}

// 將認(rèn)證碼存入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);

}

//給定范圍獲得隨機(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);

}

}

你試試?。?/p>

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

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

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

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)行對比

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

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

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

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

求一個(gè)實(shí)現(xiàn)java圖片數(shù)字識別并儲存在一個(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));//打開輸入流

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

}

}


分享名稱:java圖片識別高效代碼 java圖片識別高效代碼怎么用
標(biāo)題網(wǎng)址:http://weahome.cn/article/hiegcg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部