If you’ve used Mistika (or any other software) for compositing images with an alpha channel, you’ve probably had challenges with premultiplied or matted colors. Mistikas Comp3D layers have a parameter labeled Attributes Premultiply* which let’s you work as if the image was never premultiplied as all. This works well for with basic premultiplied/black matted images, but what if it’s matted against another color or even a background image? Let’s have a look at how to get around this and even use white-matted PSD’s directly in Mistika.
* The parameter labeled premultiply should rather be labeled premultiplied, as setting it to yes implies that it’s already been multiplied by the alpha and that Mistika should not do it again when compositing. Correct me if wrong.
Digital compositing takes a foreground (f), an alpha channel (a) and a background (b) to create a composite (c). This must be done for each color channel (r, g, b):
c = α f + (1 − α) b
What we want is basically to extract the original foreground from a matted/composited file. It’s basic algebra, and when isolating f, we get something like this:
( c – (1 – a) b ) / a = f
When using this in a new composite, we can save a lot of computing power by not dividing by alpha, but instead enable the premultiplied parameter in the Comp3D layer:
premultiplied f = c – (1 – a) b
The easiest stack is for white matted images like psd files. Since the background is always 1 we don’t need to multiply the inverted alpha at all:
- Channels: RGB = RGB – inv A
If the background is not 0 (black, premultiplied) or 1 (white), we need a bigger stack:
- Channels: RGB = RGB1 -RGB2
- Foreground w/alpha
- Channels: RGB = RGB * A2
- Foreground w/alpha
This requires both inputs to be the same resolution, so if you have a files in different size than your working resolution, you can’t just use a solid in that color as background. You can however use the following trick to create a solid with the same resolution as your image:
- Create a Solid effect and set/eyedrop the matte color
- Duplicate your image and put a Channels effect on it, and set Red, Green and Blue Operation to Out=1
- Copy the Red, Green and Blue color parameters from the solid into the Scale paramaters of Red, Green and Blue
You now have a solid with the same dimensions as your input!
Take a look at the video on top of the page, and make sure you have a look at these stacks. Enjoy.