Systems and methods for encoding and decoding document images are
disclosed. Document images are segmented into multiple layers according
to a mask. The multiple layers are non-binary. The respective layers can
then be processed and compressed separately in order to achieve better
compression of the document image overall. A mask is generated from a
document image. The mask is generated so as to reduce an estimate of
compression for the combined size of the mask and multiple layers of the
document image. The mask is then employed to segment the document image
into the multiple layers. The mask determines or allocates pixels of the
document image into respective layers. The mask and the multiple layers
are processed and encoded separately so as to improve compression of the
document image overall and to improve the speed of so doing. The multiple
layers are non-binary images and can, for example, comprise a foreground
image and a background image.