Results 1 to 3 of 3

Thread: Use convert for jpeg to tiff suitable for tesseract

  1. #1
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,438
    Distro
    Lubuntu 16.04 Xenial Xerus

    Question Use convert for jpeg to tiff suitable for tesseract

    I often need to use OCR (optical character recognition) to get new text onto the computer.

    When I use tesseract, I get terrible results, unless I use GIMP to set the image to 1-bit monochrome (and save as TIFF).

    (See "Preparing images for Tesseract" at the bottom of the Community OCR page.)

    As I often get these files, I'd like to automate the conversion, rather than have to fire up GIMP and manually do it every time.

    I tried using convert, but the command gives an error when I try to convert it to monochrome:
    Code:
    $ convert newtext.jpg -flatten -monochrome newtext.tif
    convert: BitsPerSample 1 not allowed for JPEG. `JPEGSetupEncode'.
    If I use convert without the -monochrome option, then tesseract puts out garbage.

    Any ideas?

  2. #2
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Use convert for jpeg to tiff suitable for tesseract

    I tried the jpg to tif conversion with the monochrome option and got the same result as you did. I was able to convert from jpg to png with the monochrome option and then to convert the png image to tif. I checked the resulting tif image and it was 1-bit and loaded fine in my image viewer. It's a bit of a kludge, but if nothing else works, you may want to give it a try.

  3. #3
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,438
    Distro
    Lubuntu 16.04 Xenial Xerus

    Re: Use convert for jpeg to tiff suitable for tesseract

    kaibob, that works a treat. As you say, a bit of a kludge, but hey, it works.

    Thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •