読み取りのための画像の向きを修正する方法
画像処理の文脈で画像の向きを修正することは、特定の目的(例えば文字認識)において画像が正しく整列されるように調整を加えることを意味します。 IronOCR は、画像の回転、傾き補正、スケーリングを含む、画像の向きの修正をサポートします。
これらの技術は、画像内のテキストを正確に認識するために不可欠です。これにより、テキストが正しく向き、整列され、抽出に適したサイズに調整されます。
IronOCRを始めましょう
今日から無料トライアルでIronOCRをあなたのプロジェクトで使い始めましょう。
How to Fix Image Orientation for Reading
- Download a C# library to fix image orientation
- Import the PDF document and images for reading
- Apply desired orientation correction, such as rotation, deskew, and scale
- Export the corrected image for viewing
- Utilize the
Read
method for OCR processing
画像の回転例
画像の回転は、特定の角度でその向きを変更することです(例えば、時計回りまたは反時計回りに90度)画像内のテキストやコンテンツが正しい向きで適切に配置されていることを保証します。
Rotate
メソッドに度数の値を渡して回転を実行します。 正の角度値は画像を時計回りに回転させ、負の角度値は画像を反時計回りに回転させます。
:path=/static-assets/ocr/content-code-examples/how-to/image-orientation-correction-rotate-image.cs
using IronOcr;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Add image
using var imageInput = new OcrImageInput("paragraph_skewed.png");
// Rotate the image 180 degrees clockwise
imageInput.Rotate(180);
// Export the modified image
imageInput.SaveAsImages("rotate");
Imports IronOcr
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Add image
Private imageInput = New OcrImageInput("paragraph_skewed.png")
' Rotate the image 180 degrees clockwise
imageInput.Rotate(180)
' Export the modified image
imageInput.SaveAsImages("rotate")
利便性のために、SaveAsImages
メソッドを使用して修正された画像をエクスポートできます。 以下は、回転前と回転後の画像の比較です。

前

後
## 画像の傾き補正の例 Deskewingは、わずかに傾いたり歪んだりしている画像をまっすぐに調整するプロセスです。 それは傾きやずれを修正し、テキストやコンテンツが水平に整列するようにします。 画像にデスクューを適用するには、`Deskew`メソッドを使用してください。 このメソッドは、修正する最大傾斜角度を指定する整数値を受け入れます。 高い値に設定すると、修正の機会が増えるかもしれませんが、処理が遅くなり、逆さまのページを含むエラーのリスクが高まる可能性があります。 ```cs :path=/static-assets/ocr/content-code-examples/how-to/image-orientation-correction-deskew-image.cs ```

Before

After
## 画像スケール例 スケーリングとは、画像を特定の寸法またはアスペクト比にリサイズすることを指します。 これは、より一貫性のあるテキスト認識のために画像サイズを標準化するのに役立ちます。 画像にスケーリングを適用するには、`Scale`メソッドを使用します。 `Scale`メソッドはパーセンテージの値を取り、100%は無効果を意味します。 2番目のパラメーターは**ScaleCropArea**で、関連するクロップ領域も比例してスケーリングするかどうかを決定します。(「true」として推奨). ```cs :path=/static-assets/ocr/content-code-examples/how-to/image-orientation-correction-scale-image.cs ``` ### サイズ比較

