如何将图像转换为文本 [英] How to Convert Image to text

查看:69
本文介绍了如何将图像转换为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请朋友帮助我找出将扫描图像转换为文本的最佳解决方案。

如下面的代码我试过但结果不合适。





Please friend..help me to find out the best solution to convert my scanned image to text.
as the below code I tried but the result is not proper.


protected void Page_Load(object sender, EventArgs e)
  {
      Image newImage = Image.FromFile(@"WebSite2/testingimagetotext.jpg");
      ImageToBase64(newImage, System.Drawing.Imaging.ImageFormat.Jpeg);
  }

  public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
  {
      using (MemoryStream ms = new MemoryStream())
      {
          // Convert Image to byte[]
          image.Save(ms, format);
          byte[] imageBytes = ms.ToArray();

          // Convert byte[] to Base64 String
          string base64String = Convert.ToBase64String(imageBytes);
          return base64String;
      }
  }

推荐答案

你还没有理解字节数组是什么意思。并不意味着文字。任何东西都可以用字节数组表示。但是转换 x到一个字节数组然后将数组转换为y通常不会产生任何有用的东西。

当你想识别图像上的文本时,你需要一个名为光学字符识别的程序。 (OCR)。有可用于此目的的图书馆。

小心选择一个适合你的文本(英语或印地语或泰米尔语?)!
You have still not understood that a "byte array" does not mean "text". Anything can be represented by a byte array. But "converting" x to a byte array and then converting the array to y does generally not result in anything useful.
When you want to recognize text on an image, you need a procedure called "Optical Character Recognition" (OCR). There are libraries available for that purpose.
Take care to select one which is appropriate for your texts (English or Hindi or Tamil?)!


你可以简单使用如:



you can simple use like:

img1.imageData = System.IO.File.ReadAllBytes(MapPath("~/Images/Webcam.jpg"));


谢谢为了你宝贵的时间....我得到了将我的图像(.jpeg)转换为文本的代码。使用OCR库。
Thanks for your valuable time ....I got the code to convert my image(.jpeg) to text .using OCR library.


这篇关于如何将图像转换为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆