How to recognise white text on dark background

  • Last Post 25 January 2019
  • Topic Is Solved
Leif posted this 15 June 2017


We have a GUI which can take an image from our scanner, and extract and parse text from selected regions. Anyway, this works well for black text on a light background. It does not work at all for white text on a dark background. As luck would have it, our first potential customer has cards with white text on a dark blue background.

Is there some setting I have to adjust? We are using the C++ COM interface to the FREngine.

Order By: Standard | Newest | Votes
Anna Savinova posted this 19 June 2017

There are two possible solutions:

  • If it is known that image is inverted, you can set "IPrepareImageMode::InvertImage = VARIANT_TRUE;". FREngine will invert all images during opening.
  • You can also turn on the automatic detection of the inverted colors by setting "IPagePreprocessingParams::CorrectInvertedImage = VARIANT_TRUE;". In this case FREngine will detect that image is inverted and fix it during the Prepocessing step.


  • Liked by
  • Leif
Leif posted this 19 June 2017

Thank you. But what if the image contains some text on a dark background and some on a light background? It sounds like two passes are needed, with one passing using an inverted image.

Anna Savinova posted this 20 June 2017

No, you don't need to process the image twice. If some blocks on the image are inverted the FREngine is able to recognize them in correct way. 

If you are still facing an issue, please send the sample images to

  • Liked by
  • Leif
Leif posted this 20 June 2017

I got no benefit from the invert image flags, although this of course could be due to the images I use. By playing around I discovered that turning on photo processing mode solves our problem:

        FREngine::IPrepareImageModePtr prepareImageModePtr = engine->CreatePrepareImageMode();
        prepareImageModePtr->PhotoProcessingMode = FREngine::PhotoProcessingModeEnum::PPM_TreatAsPhoto;

We now get a good recognition of white text on a dark blue background without harming the recognition of dark text on a light background. In fact I'd say that the recognition quality is really very good indeed.

  • Liked by
  • Anna Savinova
  • Sreeju Padmanabhan
Sreeju Padmanabhan posted this 25 January 2019

Hi I am new to ABBYY .

Could you explain where we need to set this code ( turning on photo processing mode) ?
Is it possible to set it through UI.