Extracting Text From Image

本文介绍如何利用Microsoft Office Document Imaging (MODI) 库从图像中提取文本。通过添加MODI引用并使用C#代码,可以实现图像到文本的光学字符识别(OCR)过程。文中提供了一个具体的按钮点击事件示例,展示了如何创建和处理文档。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Microsoft Office Document Imaging 虚拟打印机
Extracting Text From Image
The following program shows you how to extract text from image. For this you'll have add reference (under COM tab) of "Microsoft Office Document Imaging Library". If you wouldn't find this reference then install microsoft office version 2007 and go to customize and choose Office tools and check the "Microsoft Office Document Imaging" and install it. Now after doing this go to (add reference and under COM tab) add its reference and use it.
 
//Extract button working, text is extracted from image
 private void btnExtract_Click(object sender, EventArgs e)
 {
 
   MODI.Document doc = new MODI.Document();
   doc.Create(getFileName);
   doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
   MODI.Image img = (MODI.Image)doc.Images[0];
   MODI.Layout layout = img.Layout;
  
    for (int i = 0; i < layout.Words.Count; i++)
      {
           MODI.Word word = (MODI.Word)layout.Words[i];
 
                if (extractedText.Length > 0)
                {
                   extractedText += " ";
                }
 
                extractedText += word.Text;
                richTextBox1.Text = extractedText;
      }
         
  }
 
 
 

转载于:https://www.cnblogs.com/fx2008/archive/2013/05/12/3073828.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值