2012-03-08 16 views
0

空白で区切られた文字を含む白黒画像があります。各文字のrect(上、下、左と右のピクセル)を検出する最も良い方法は何ですか?PIL - 文字の検出方法は?

+1

Tesseract OCRこれを行うことができます – wim

+0

完全に空白の列を探してセパレータとして使用します。 –

+0

tesseractは数式を認識できません。私は各キャラクターを別々に認識することでこれをしたいと思っています。 – arts777

答えて

1

PILは、作物の読み込み/保存、基本的な変換などを行うことができますが、OCRの基本である「コンピュータサイエンス」フィルタは完全に欠けています(Leptonicaライブラリ、 Tesseractによって使用される)。 Tesseractが必要なものを認識できない場合は、コメントに記載されているように、自分のOCRソフトウェアを読んでから本当に難しい作業をしてください。

もしあなたが必要とするのは、各文字の境界矩形です。それは、一桁の簡単さです.PILでも実行可能かもしれませんが、Python-leptonicaバインディングではもっと簡単です。 leptonica.functions.pixFindRectangleCompsを使用する - 関数のheklpは次のとおりです。

PIXはleptonicaライブラリ画像オブジェクトであり、そして「boxa」は、矩形オブジェクトのリストである
pixFindRectangleComps(*args) 
      ('PIX', '*pixs')  
    ('l_int32', 'dist')  
    ('l_int32', 'minw')  
    ('l_int32', 'minh')  
     pixFindRectangleComps() 

      Input: pixs (1 bpp) 
        dist (max distance allowed between bounding box and nearest 
         foreground pixel within it) 
        minw, minh (minimum size in each direction as a requirement 
           for a conforming rectangle) 
      Return: boxa (of components that conform), or null on error 

     Notes: 
      (1) This applies the function pixConformsToRectangle() to 
       each 8-c.c. in pixs, and returns a boxa containing the 
       regions of all components that are conforming. 
      (2) Conforming components must satisfy both the size constraint 
       given by @minsize and the slop in conforming to a rectangle 
       determined by @dist. 
(END) 

私はLeptonicaのPythonバインディングを開始していました。現在、http://code.google.com/p/pylepthonica/wiki/Homeから入手できます。これらのバインディングにはあまり愛されていませんが、動作するはずですleptica 1.67(これは+/- 2歳です)

関連する問題