IronOCR ハウツー 画像の領域 How to Define a Specific OCR Region of an Image Curtis Chau 更新日:10月 19, 2025 Download IronOCR NuGet Download テキストの検索と置換 テキストと画像のスタンプ Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Often, you only need to extract text from a small part of an image, such as a total amount on an invoice or a specific field from a form. Scanning the full document is inefficient and can introduce errors by capturing irrelevant text. IronOCR allows you to improve precision, performance, and accuracy by specifying the exact rectangular region to scan. This guide provides a step-by-step walkthrough on how to define a specific OCR region, extract text from it, and visually verify that your coordinates are correct for your OCR tasks. Get Started with IronOCR 今日あなたのプロジェクトでIronOCRを無料トライアルで使用開始。 最初のステップ: 無料で始める How to Define a Specific OCR Region of an Image Download the C# library for defining the OCR region Instantiate the OCR engine Specify the OCR region with a rectangle Load the image with LoadImage along with the defined rectangle Access the OcrResult property to view and manipulate the extracted data Perform OCR on Specific Region To define a specific OCR region, you create a Rectangle object from the IronSoftware.Drawing namespace. This object requires four values: the x-coordinate, the y-coordinate, the width, and the height, all in pixels. The (x, y) coordinates represent the top-left corner of your desired area. When you load your image using LoadImage, you pass this Rectangle as the second parameter. IronOCR will then restrict its OCR process to only the pixels within that bounding box. ヒントTo find the coordinates for your Rectangle, you can use a simple image editor like MS Paint. Open your input image, hover your mouse over the top-left and bottom-right corners of the specified region, and note the (x, y) pixel coordinates. You can then calculate the rectangle's properties: (x1, y1, width, height), where width = x2-x1 and height = y2-y1. OCR Input We'll use a sample image with three paragraphs. Our goal is to extract only the second paragraph and ignore the rest of the text. Code :path=/static-assets/ocr/content-code-examples/how-to/ocr-region-of-an-image.cs using IronOcr; using IronSoftware.Drawing; using System; var ocrTesseract = new IronTesseract(); using var ocrInput = new OcrInput(); // Define the specific region as a Rectangle // (x, y) is the top-left corner. var ContentArea = new Rectangle(x: 215, y: 1250, width: 1335, height: 280); ocrInput.LoadImage("region-input.png", ContentArea); var ocrResult = ocrTesseract.Read(ocrInput); // Print the extracted text Console.WriteLine(ocrResult.Text); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output As you can see from the console output, only the second paragraph is processed by the OCR. Verifying the OCR region of an Image To ensure you've selected the correct coordinates for the input image, you can visualize the ContentArea you defined. A simple way to do this is to draw the rectangle on the input image and save it as a new file with StampCropRectangleAndSaveAs. This helps you debug and fine-tune the coordinates for optimal performance. Here is the output image after drawing the specified bounding box on our example input image from above. Code :path=/static-assets/ocr/content-code-examples/how-to/ocr-region-of-an-image-highlighted.cs using IronOcr; using IronSoftware.Drawing; var ocrTesseract = new IronTesseract(); using var ocrInput = new OcrInput(); // Define the specific rectangular area to scan within the image. // The coordinates are in pixels: (x, y) is the top-left corner of the rectangle. var ContentArea = new Rectangle(x: 4, y: 59, width: 365, height: 26); ocrInput.LoadImage("region-input.png", ContentArea); var ocrResult = ocrTesseract.Read(ocrInput); // Draws the rectangle from above in a blue bounding box on the image for visualization. ocrInput.StampCropRectangleAndSaveAs(ContentArea, Color.Aqua, "region-input.png"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Output The light blue rectangle confirms that we have correctly isolated the second paragraph for processing. よくある質問 画像の特定の OCR 領域を定義する必要があるのはなぜですか? 画像の特定の OCR 領域を定義すると、エラーの原因となる文書全体をスキャンするのではなく、請求書の合計金額などの関心領域に焦点を当てることで、精度と正確性を向上させるのに役立ちます。 IronOCR を使用して OCR 領域を指定するにはどうすればよいですか? IronOCRでは、必要な座標と寸法を持つ`Rectangle`オブジェクトを作成することで、OCR領域を指定できます。そして、この矩形を`LoadImage`メソッドに渡すことで、OCR処理を特定の領域に限定することができます。 OCR 領域を定義するために必要なパラメーターは何ですか? OCR領域を定義するには、`Rectangle`オブジェクトに4つのパラメータ(x座標、y座標、幅、高さ)を指定する必要があります。これらのパラメータは、領域の左上隅とサイズを決定します。 OCR に正しい座標が選択されていることを確認するにはどうすればよいですか? 正しい座標を確認するには、`StampCropRectangleAndSaveAs` を使用して入力画像に四角形を描画し、定義されたContentAreaを視覚化します。これは、座標のデバッグと微調整に役立ちます。 OCR 領域の座標を見つけるにはどのようなツールを使用できますか? OCR領域の座標を見つけるには、MSペイントなどのシンプルな画像エディタを使用できます。マウスを目的の領域の左上隅と右下隅に合わせると、ピクセル座標(x, y)が表示されます。 地域固有の OCR タスクに IronOCR を使用する利点は何ですか? IronOCR を使用すると、画像の特定の領域からテキストを効率的に抽出できるため、無関係なテキストのキャプチャを防ぐことでエラーが減り、パフォーマンスが向上します。 処理前に OCR 領域を視覚的に確認できますか? はい、入力画像上に四角形を描くことで、OCR領域を視覚的に確認できます。これにより、処理対象となる正しい領域が分離され、精度が確保されます。 IronOCR で処理できる画像の種類は何ですか? IronOCR はさまざまな画像形式を処理できるため、文書、フォーム、請求書で使用される画像の特定の領域からテキストを抽出できます。 IronOCR は指定された領域内で OCR プロセスをどのように処理しますか? IronOCR は、指定された境界ボックス内のピクセルに OCR プロセスを制限し、定義された領域内のテキストのみが抽出されるようにします。 IronOCR の OCR プロセスの出力形式は何ですか? IronOCR の OCR プロセスの出力形式は `OcrResult` プロパティを通じてアクセスでき、必要に応じて抽出されたデータを表示および操作できます。 Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 準備はいいですか? Nuget ダウンロード 5,044,537 | バージョン: 2025.11 ただ今リリースされました 試用ライセンスキーがメールで送信されました。 総ダウンロード数: 5,044,537 ライセンスを見る