Repository navigation
Replies: 2 comments
|
The most reliable fix for spreads is honestly not a Tesseract setting but splitting each spread into two pages before OCR. Tesseract's layout analysis sometimes treats the gutter as just a wide space and reads straight across, and no flag fully prevents that. MuPDF can do the split in one command: mutool poster -x 2 spreads.pdf split.pdf # each page → left half + right half
ocrmypdf split.pdf out.pdfThat also tends to improve accuracy in general, since each page is OCR'd as a normal single page. If you want to keep the spreads as-is, these are the knobs OCRmyPDF passes through to Tesseract that matter here:
Also worth checking why your direct Tesseract run behaved differently. You ran it on a JPEG, which may have been at a different resolution than what OCRmyPDF rasterizes, so try |
|
The most reliable fix is to split the spread before OCR, rather than trying to tune layout analysis to guess the gutter. Each PDF page currently contains two book pages side by side. Tesseract sometimes treats the middle gutter as just a wide word space and reads straight across. No PSM flag fully prevents that once the page is rasterized as one wide image. Split first with MuPDF (ships with PyMuPDF / mutool): This also matches why your direct-Tesseract test looked better: you ran it on a single JPEG export, likely at a different DPI / preprocessing than what OCRmyPDF rasterizes internally. If you want to keep spreads as-is, these are the knobs that matter in OCRmyPDF:
Example to try before splitting: If that still merges lines across the gutter on some pages, splitting with |
Uh oh!
There was an error while loading. Please reload this page.
I'm working with PDFs which have been scanned as spreads, so each PDF page has two facing pages of the scanned document. Usually the text in the pages is correctly split into columns, but sometimes the text is interpreted as a single line that spans both pages. I ran Tesseract directly on a JPEG of one of the pages which had this issue in OCRmyPDF, and the pages were split correctly, so I'm wondering if there's any tuning I can do to make the results from OCRmyPDF better?
All reactions