title: Detecting bold (and italic) text in an image
body: <p>I want to detect stretches of bold (and perhaps italic) text in images of pages--think TIFFs, or image PDFs.  I need pointers to any open source software that does that.</p>
  <p>Here's a picture of a dictionary entry (from a Tzeltal--Spanish dictionary) illustrating such text:</p>
  <p><a href="https://i.stack.imgur.com/6YJIl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YJIl.png" alt="enter image description here" /></a></p>
  <p>First line has bold, then italics, then &quot;normal&quot;; second has a couple words in bold, then a couple in normal font.  The formatting represents implicit structure: bold is for headwords, italics is for part of speech, and normal is for most other things.  Without knowing what's bold/ italic/ normal, it's impossible to parse these entries into structured text (like XML).</p>
  <p>When our dictionary parsing project was active several years ago, we were using Tesseract version 3 to OCR the images, with the hocr output to give us positional information on the page (crucial to e.g. separating out different entries in the dictionary).  The hocr output also included tags 'strong' for bold and 'em' for italics.  While the 'em' tagging was reasonably accurate, the 'strong' tagging was almost random.  And now version 4 of Tesseract <a href="https://stackoverflow.com/questions/44571656/">doesn't even try</a> (<a href="https://github.com/tesseract-ocr/tesseract/issues/684" rel="nofollow noreferrer">see also</a>).  You can still tell tesseract to use the old engine, but as I say, that seems to be completely inaccurate, at least on the text we fed it.</p>
  <p>It doesn't seem like distinguishing bold vs. normal text should be hard; I can stand far away from my monitor and pick out the bold and non-bold stretches even though I can't read the words at that distance.  (I suppose telling whether an entire text was bold or non-bold would be harder, but distinguishing them when both appear seems easy--for humans.)</p>
  <p>I am told that ABBYY FineReader outputs information on font style, but for various reasons that won't work for our application.</p>
  <p>If there were a non-OCR way of distinguishing bold vs. non-bold text that would put bounding boxes around the bold text, we could probably match those stretches up with the bounding boxes for characters/ words that Tesseract outputs (allowing for a few pixels difference).  I know there was <a href="https://ieeexplore.ieee.org/document/711217" rel="nofollow noreferrer">research on this decades ago</a> (also <a href="https://link.springer.com/article/10.1007/PL00013557" rel="nofollow noreferrer">here</a>), but is there any open source software that actually does it?</p>