1. A computer-implemented method comprising: identifying a first plurality of pixels in a raster image as foreground pixels and a distinct second plurality of pixels in the raster image as background pixels, each of the foreground pixels and background pixels having a respective color value; solving for a color model of opacity, including determining coefficients of the color model of opacity using the color values of the foreground pixels and the color values of the background pixels, where the color model of opacity is a function that determines an opacity for a given pixel from a sum of products of color components of the respective color value of the given pixel, each product weighted by one of the coefficients, where the coefficients are determined so as to minimize error in a partition of the foreground and background pixels, and where the error is measured based on the foreground pixels that are in a background partition and the background pixels that are in a foreground partition; and determining an opacity value for a pixel in the raster image using the color model of opacity; wherein solving is performed by one or more processors.