1. A method for compressing an image comprising pixels, the method comprising: identifying edge pixels using gradient pixels identified in a plurality of pixels selected from the image, in a first low-pass filtered set of the plurality of pixels, and in a second low-pass filtered set of the plurality of pixels; determining an edge pixel type for each of the identified edge pixels; using at least some of the identified edge pixels to label each pixel of the plurality of pixels; using the labeled pixels to identify non-background region pixels; generating a foreground image layer comprising the non-background region pixels; generating a mask layer that identifies which pixels of the foreground image layer should be selected when generating a representation of the plurality of pixels; and compressing the mask layer differently than the foreground image layer.