Swap color of text and background for part of an image

asked 2019-07-10 08:15:23 -0500

ubutar gravatar image

I have an image where text, specifically, table headers are "white text on black", while the rest of document is "black on white". The thing is, these headers may appear in different places not known beforehand.

Such conversion is needed due to poor OCR results for such headers - results are mess - thus some quality loss after processing with openCV is not a problem.

Is there a way to unify background with open CV based on text color, or that's ideologically impossible without knowing location to invert colors or preceding OCR? (which works terrible in this case!)

image description

edit retag flag offensive close merge delete

Comments

I'd say it is ideologically possible. Try detecting black rectangles and negating them. Perhaps this would be helpful: https://answers.opencv.org/question/9...

Witek gravatar imageWitek ( 2019-07-13 16:46:36 -0500 )edit