1. A computer-implemented method comprising: receiving an image mask, the image mask identifying a respective first opacity value for pixels in a raster image, each first opacity value ranging between a value representing foreground and a value representing background, each pixel in the image having a respective color; identifying a first boundary pixel in the image; and determining a second opacity value for the first boundary pixel using a first local color model of opacity, where the first local color model of opacity is a first function that determines the second opacity value based on the respective color of the first boundary pixel, where the first function is a weighted sum of products of color components of the respective color of the first boundary pixel, where the weights are determined by minimizing a second function, where the second function is based on the respective colors and the respective first opacity values of the pixels in the image within a local neighborhood of the first boundary pixel, and a smoothness constraint with respect to the second opacity value; wherein the determining is performed by one or more processors.