Iron Suite for .NET
10 .NETライブラリ。1つの完全なドキュメントスイート。
機械学習ソフトウェアを使用した画像からのテキスト抽出
機械学習を使用してキャプチャまたはスキャンされた文書からテキストを抽出することは、コンピュータビジョンと自然言語処理の交差点にある急成長している分野です。 この技術は、高度な機械学習、物体認識アルゴリズム、高度なグラフィックスソフトウェア、ディープウェブとダークウェブ、およびニューラルネットワークアーキテクチャを活用して、画像やスキャンされた紙文書からテキスト情報を正確に識別し抽出します。 光学文字認識(OCR)や深層学習といったさまざまな機械学習技術を用いることで、自動化され効率的な視覚シーンテキスト検出から、編集可能で検索可能な構造化データ、及び物体検出へと変換を可能にします。
この進化する環境の中で、研究者や実務者は、印刷文書のデジタル化、コンテンツのインデックス付け、翻訳、アクセシビリティ向上などのアプリケーションにおいて重要な要素となる、画像やスキャンされた文書からのテキスト検出と抽出の精度、速度、汎用性を向上させるために不断の努力を続けています。
この記事では、強力な機械学習アルゴリズムとテキスト関連機能を搭載したOCRライブラリであるIronOCRを使用して、画像からテキストを抽出する方法について説明します。 テキスト抽出、またはキーワード抽出は、機械学習に基づいて非構造化データや会社の中央データベースから関連性のあるまたは基本的な単語やフレーズを自動的にスキャンして抽出します。
機械学習を使用して画像からテキストを抽出する方法
- 画像からテキストを抽出するためのC#ライブラリをダウンロードします。
- シーンテキスト認識のためにOcrInputオブジェクトをインスタンス化して特定の画像を読み込みます。
- ocrTesseract.Readメソッドを使用して画像からデータを抽出します。
- Console.WriteLineメソッドを使用して、抽出されたテキストをコンソールに出力します。
- CropRectangleオブジェクトを使用して画像の領域でOCRを実行します。
IronOCR - 光学文字認識(OCR)ライブラリ
IronOCRは、画像やドキュメントからのテキスト抽出技術の最前線に立った著名かつ高度な光学文字認識(OCR)ソフトウェアです。 Iron Softwareによって開発されたこの強力なOCRエンジンは、スキャンされた画像、PDF、またはテキストの写真を編集可能で検索可能なデジタルコンテンツに正確かつ効率的に変換するように設計されています。 機械学習アルゴリズムとニューラルネットワークを巧みに活用することで、IronOCRはデータ抽出、コンテンツインデックス作成、および正確なテキスト認識を必要とする自動化プロセスを含むさまざまなアプリケーションのための堅牢なソリューションを提供します。
複数の言語や多様なフォントに対応できる能力は、さまざまなソフトウェアやアプリケーションにおける効率的なテキスト認識アルゴリズム抽出機能を求める開発者や企業にとって、多用途なツールとなります。 IronOCRを使用すると、テキスト抽出アルゴリズムによって非構造化データを完全にスキャンされたページへ変換する一般的なテキスト認識手法で、テキストを自動的にスキャンできます。
IronOCRのインストール
IronOCRはNuGetパッケージマネージャーを使用してインストールが可能です。 以下はIronOCRをインストールする手順です:
-
まず、新しいC# Visual Studioプロジェクトを作成するか、既存のプロジェクトを開きます。

-
プロジェクトが作成されたら、上部のメニューでツールに移動してNuGetパッケージマネージャーを選択し、ソリューションのNuGetパッケージマネージャーを選択します。

-
新しいウィンドウが画面に表示されます。 [参照]タブに移動し、検索バーにIronOCRと入力します。
-
IronOCRパッケージのリストが表示されます。 最新のものを選択し、インストールをクリックします。

-
インターネット環境に応じて数秒かかります。その後、C#プロジェクトでIronOCRを使用できるようになります。
画像から編集可能で検索可能なデータへのテキスト検出
IronOCRを使用すると、画像処理技術と機械学習を利用して簡単にテキストを抽出できます。 このセクションでは、IronOCRを使用して画像からテキストを抽出する方法について説明します。
using IronOcr;
using System;
// Create a new instance of the IronTesseract class
var ocrTesseract = new IronTesseract();
// Specify the image path and perform OCR on the image
using (var ocrInput = new OcrInput(@"images\image.png"))
{
var ocrResult = ocrTesseract.Read(ocrInput);
// Print the extracted text to the console
Console.WriteLine(ocrResult.Text);
}Imports IronOcr
Imports System
' Create a new instance of the IronTesseract class
Dim ocrTesseract As New IronTesseract()
' Specify the image path and perform OCR on the image
Using ocrInput As New OcrInput("images\image.png")
Dim ocrResult = ocrTesseract.Read(ocrInput)
' Print the extracted text to the console
Console.WriteLine(ocrResult.Text)
End UsingImports IronOcr
Imports System
' Create a new instance of the IronTesseract class
Dim ocrTesseract As New IronTesseract()
' Specify the image path and perform OCR on the image
Using ocrInput As New OcrInput("images\image.png")
Dim ocrResult = ocrTesseract.Read(ocrInput)
' Print the extracted text to the console
Console.WriteLine(ocrResult.Text)
End UsingこのC#コードは、光学文字認識(OCR)用のライブラリであるIronOCRの使用法を示しています。 ステップバイステップの説明は次のとおりです:
-
ライブラリのインポート:
using IronOcr; using System;using IronOcr; using System;Imports IronOcr Imports SystemImports IronOcr Imports Systemコードはまず、OCR機能を提供するIronOCRと、一般的な機能のためのSystem名前空間を含む、必要なライブラリをインポートします。
-
IronTesseractの初期化と画像のロード:
var ocrTesseract = new IronTesseract();var ocrTesseract = new IronTesseract();Dim ocrTesseract As New IronTesseract()Dim ocrTesseract As New IronTesseract()この行は、IronOCRによって提供されるOCRエンジンであるIronTesseractのインスタンスを作成します。
using (var ocrInput = new OcrInput(@"images\image.png"))using (var ocrInput = new OcrInput(@"images\image.png"))Using ocrInput As New OcrInput("images\image.png")Using ocrInput As New OcrInput("images\image.png")OcrInputオブジェクトは、処理する画像へのパスで初期化されます。 この場合、画像ファイルは「images」ディレクトリ内の「image.png」です。
-
OCRの実行とテキストの抽出:
var ocrResult = ocrTesseract.Read(ocrInput);var ocrResult = ocrTesseract.Read(ocrInput);Dim ocrResult = ocrTesseract.Read(ocrInput)Dim ocrResult = ocrTesseract.Read(ocrInput)この行は、OcrInputオブジェクトを渡して、IronTesseractインスタンスのReadメソッドを呼び出します。 このメソッドは、提供された画像に対してOCRを実行し、テキストを抽出します。
-
抽出されたテキストの表示:
Console.WriteLine(ocrResult.Text);Console.WriteLine(ocrResult.Text);Console.WriteLine(ocrResult.Text)Console.WriteLine(ocrResult.Text)最後に、抽出されたテキストはConsole.WriteLineを使用してコンソールに出力され、画像から取得されたOCR結果が表示されます。
このコードスニペットは、指定された画像のテキスト認識にIronOCRを使用し、抽出されたテキストをコンソールに出力します。
入力画像

出力

画像の指定された領域でOCRを実行する
IronOCRを使用して、画像の特定の領域に対してOCRを実行することもできます。 以下はコード例です。
using IronOcr;
using IronSoftware.Drawing;
using System;
// Create a new instance of the IronTesseract class
var ocrTesseract = new IronTesseract();
// Specify the region on the image to be processed
using (var ocrInput = new OcrInput())
{
var ContentArea = new CropRectangle(x: 20, y: 20, width: 400, height: 50);
// Add the image with the defined content area
ocrInput.AddImage("r3.png", ContentArea);
// Perform OCR on the specified region and extract text
var ocrResult = ocrTesseract.Read(ocrInput);
// Print the extracted text to the console
Console.WriteLine(ocrResult.Text);
}using IronOcr;
using IronSoftware.Drawing;
using System;
// Create a new instance of the IronTesseract class
var ocrTesseract = new IronTesseract();
// Specify the region on the image to be processed
using (var ocrInput = new OcrInput())
{
var ContentArea = new CropRectangle(x: 20, y: 20, width: 400, height: 50);
// Add the image with the defined content area
ocrInput.AddImage("r3.png", ContentArea);
// Perform OCR on the specified region and extract text
var ocrResult = ocrTesseract.Read(ocrInput);
// Print the extracted text to the console
Console.WriteLine(ocrResult.Text);
}Imports IronOcr
Imports IronSoftware.Drawing
Imports System
' Create a new instance of the IronTesseract class
Dim ocrTesseract As New IronTesseract()
' Specify the region on the image to be processed
Using ocrInput As New OcrInput()
Dim ContentArea As New CropRectangle(x:=20, y:=20, width:=400, height:=50)
' Add the image with the defined content area
ocrInput.AddImage("r3.png", ContentArea)
' Perform OCR on the specified region and extract text
Dim ocrResult = ocrTesseract.Read(ocrInput)
' Print the extracted text to the console
Console.WriteLine(ocrResult.Text)
End UsingImports IronOcr
Imports IronSoftware.Drawing
Imports System
' Create a new instance of the IronTesseract class
Dim ocrTesseract As New IronTesseract()
' Specify the region on the image to be processed
Using ocrInput As New OcrInput()
Dim ContentArea As New CropRectangle(x:=20, y:=20, width:=400, height:=50)
' Add the image with the defined content area
ocrInput.AddImage("r3.png", ContentArea)
' Perform OCR on the specified region and extract text
Dim ocrResult = ocrTesseract.Read(ocrInput)
' Print the extracted text to the console
Console.WriteLine(ocrResult.Text)
End UsingこのC#コードは、光学文字認識(OCR)にIronOCRライブラリを利用しています。 まず、IronOCRとSystemを含む必要なライブラリをインポートします。 次に、OCRエンジンであるIronTesseractのインスタンスを作成します。 コードはCropRectangleを使用して画像内の処理対象となるContentAreaを設定し、定義した領域に絞り込みます。 この指定された領域内の画像(「r3.png」)がOCR処理のために追加されます。 OCRエンジンは指定されたコンテンツ領域を読み取ってテキストを抽出し、結果のテキストはConsole.WriteLineを使用してコンソールに出力されます。
出力

結論
画像からのテキスト抽出は、機械学習を通じて、特にIronOCRのような光学文字認識(OCR)ライブラリを利用することで、コンピュータビジョンと自然言語処理の交差点での変革的な一歩を意味します。 OCR技術と深層学習の手法はいずれも、視覚的なテキストを編集可能で検索可能なデータへ効率的に変換するうえで極めて重要な役割を果たし、文書のデジタル化、コンテンツのインデックス作成、アクセシビリティの向上といった重要な目的に役立っています。
IronOCRは、著名なOCRライブラリとして、この融合の可能性を実証し、スキャンした画像やPDFを複数の言語とフォントスタイルでデジタル編集可能なコンテンツに正確に変換することに優れています。 C#などのプログラミング言語にシームレスに統合できるため実装が容易であり、多くのアプリケーションや分野において画像からのテキスト抽出がもたらす変革的な効果をさらに高めます。
IronOCRと関連するすべての機能についてもっと知るには、このリンクこちらを訪問してください。 画像からテキストを抽出する完全なチュートリアルは、次のリンクでご覧いただけます。 IronOCRのライセンスはこのリンクから購入できます。