java图片提取文字(java 获取图片格式)

华为云服务器特价优惠火热进行中!

2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。

合作流程:
1、点击链接注册/关联华为云账号:点击跳转
2、添加客服微信号:cloud7591,确定产品方案、价格方案、服务支持方案等;
3、客服协助购买,并拉微信技术服务群,享受一对一免费技术支持服务;
技术专家在金蝶、华为、腾讯原厂有多年工作经验,并已从事云计算服务8年,可对域名、备案、网站搭建、系统部署、AI人工智能、云资源规划等上云常见问题提供更专业靠谱的服务,对相应产品提供更优惠的报价和方案,欢迎咨询。

本篇文章给大家谈谈java图片提取文字,以及java 获取图片格式对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

微信号:cloud7591
如需了解更多,欢迎添加客服微信咨询。
复制微信号

本文目录一览:

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 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图像界面如何获取上一个页面文本框的内容?

1.如果你用的servlet的话,可以用request.getParameter("name");这样获取jsp页面中表单name="name"值的数据

2.如果用的struts2的话,必须在Action中写相应的get,set方法,

比如:jsp页面中有个name值等于“name”,那么相应的Action中要有相应的name属性的set和get方法

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

//提示:坐标依次打印在命令符窗口

//提示:坐标依次打印在命令符窗口

//提示:坐标依次打印在命令符窗口

//不就是监听鼠标事件吗?

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.border.Border;

/**

*我想建立个界面,可以加载本机中图片。

*加载后可以通过鼠标点击获得图片上任意点坐标。

*提问者: sunny929929 - 试用期 一级

*/

public class MyPicture extends JFrame implements MouseListener{

 private JLabel tipLabel;

 /**

 *main()

 */

 public static void main(String[] args){

  MyPicture frame = new MyPicture();

   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   frame.setVisible(true);

    }

/**

    *constructor

    */

    public MyPicture(){

  setSize(800, 600);//根据要求调整大小

  setLocation(100,100);

  setTitle("获得图片上任意点坐标");

        setResizable(false);

        Container con=getContentPane();

        ImageIcon bgIcon=new ImageIcon("bgpic.jpg");//注意图片的路径

  ImagePanel backpicPanel=new ImagePanel(bgIcon);

  backpicPanel.addMouseListener(this);

  con.add(backpicPanel,BorderLayout.CENTER);

  tipLabel=new JLabel("--------------------提示:坐标依次打印在屏幕上!--------------------");

  con.add(tipLabel,BorderLayout.SOUTH);

 }

/**

 *

 */

 public void mousePressed(MouseEvent e){

  int x=e.getX();

  int y=e.getY();

  String message="("+x+","+y+")";

  tipLabel.setText(message);

  System.out.println(message);

 }

 public void mouseReleased(MouseEvent e){

 }

 public void mouseEntered(MouseEvent e){

 }

 public void mouseExited(MouseEvent e){

 }

 public void mouseClicked(MouseEvent e){

 }

}

/**

 *类ImagePanel,用于添加背景图片

 */

class ImagePanel extends JPanel{

 private   Image   img;

    public  ImagePanel (ImageIcon   imageIcon){

     img=imageIcon.getImage();

    }

    public  void  paintComponent(Graphics   g){

     super.paintComponent(g);

     g.drawImage(img,0,0,this);

    }

}

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

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

java中导入一个图片,然后在图片上加上几个文字再输出保存,应该如何用代码实现?

import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.IOException;

import javax.imageio.ImageIO;

public class Test{

public static void main(String[] args){

try {

File f1 = new File("a.jpg");

BufferedImage image = ImageIO.read(f1);

Graphics g = image.getGraphics();

g.setFont(new Font("Serif",Font.BOLD,20));

g.setColor(Color.red);

g.drawString("happy new year!", 10, 20);

File f2 = new File("copy.jpg");

ImageIO.write(image, "JPEG", f2);

} catch (IOException e) {

e.printStackTrace();

}

}

}

java图片提取文字的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java 获取图片格式、java图片提取文字的信息别忘了在本站进行查找喔。

发布于 2023-04-12 17:04:01
收藏
分享
海报
31
目录

    忘记密码?

    图形验证码

    复制成功
    微信号: cloud7591
    如需了解更多,欢迎添加客服微信咨询。
    我知道了