1. A computer-implemented method comprising: receiving an image mask, the image mask identifying first opacity values for pixels in an image, each pixel in the image having a color; identifying a first boundary pixel based on the image mask; determining, by a computing system, a plurality of weights by minimizing an error function that is based on the colors and the first opacity values of pixels within a local neighborhood of the first boundary pixel in the image; determining, by the computing system, a second opacity value for the first boundary pixel using a weighted sum, wherein the weighted sum combines the weights with corresponding products of color components of the first boundary pixel; and updating the image mask based on the second opacity value for the first boundary pixel.