1. A method for encoding a text image, comprising: determining, by a computer having one or more processors, a background color of an image; dividing, by the computer, the image into text pixels and background pixels, each of the background pixels comprising the background color; determining, by the computer, a text color based on colors of the text pixels; determining, by the computer, a text attribute comprising a luminance profile describing a contour of luminance of a set of the text pixels; generating, by the computer, a binary text mask based on position and luminance of each of the text pixels and the luminance profile; and generating, by the computer, an encoded image comprising the background color, the text color, the binary text mask, and the text attribute.