1. A document encoding system comprising: a mask separator that receives a document image and generates a mask from the document image, the mask being generated at least in part via merging regions by pairs of the document image based at least in part upon minimization of pixel energy; and an image segmenter that segments the document image into a plurality of layers according to the mask, the plurality of layers represented in non-binary format.