This is a detailed guide on one method for adding translucency to images on the wiki. Translucency is when part of the item/object is partially transparent, so simply cutting out around the item is not sufficient to remove the background. Category:Images needing translucency contains a list of all images that need this done. This requires rather advanced image editing skills and is not recommended for beginners, it is additionally suggested that one use a graphics tablet. It requires: experience editing images, basic grasp of algebra, understanding of colour theory and various colour models and a fair amount of patience, but the results are spectacular.
Understanding the theory[edit source]
Before we can start removing backgrounds from images effectively, we first need to understand the basics of how games and websites render translucency. Although there are different ways to blend two images together, the most basic and fundamental method is alpha blending, and is the only method we need to understand in this context. Alpha blending is represented as
- is the unedited image
- is the area of the image behind the model
- is the colour of the model with translucency turned off
- is the alpha value of the pixel, applied to the colour
This formula can be memorised using the mnemonic
Barrows 1 Awards For All
Memorising this equation is vital, and our goal will be to first recreate the image's background, then recreate either the alpha channel or the model's colour, so that we can then calculate the remaining elements of the image by rearranging our formula.
Rearranging the formula[edit source]
Most images fall into one of two categories. Either the foreground colours are easy to predict, or the alpha values are easy to predict. In both situations, we'll want to rearrange our formula for the remaining variable.
When our image we are working with contains a particularly complex texture, or the translucent areas may otherwise be difficult to properly estimate or recreate, it is preferable to estimate the alpha channel. Rearranging our formula therefore for gives us
When our image uses translucency whose colour can be predicted but contains varying alpha values, such as models that glow, it is preferable to estimate the colour of the translucent areas. Our rearranged formula is
but this value will be calculated for each channel separately and must therefore be handled appropriately. Our first option is to apply the calculation in greyscale so that we end up with a single result. Our second is to perform the calculations in full colour, then multiply our image by itself and add the channels together, using either the Calculations feature in Photoshop, or the Decompose / Recompose feature in GIMP. This option is more accurate, but also more involved.
Although we have no immediate need to calculate the background, it can occasionally be useful to estimate the alpha and foreground values first, then use them to calculate the background, thus allowing us to recalculate the first two more precisely. This concept won't be covered, but should the need arise, our rearranged formula would be
Blend modes[edit source]
Having rearranged our formula, we'll now need a way of calculating the remaining element within our chosen editing software. Unfortunately, there are no features that calculate these for us, so we have to use blending.
The four blend modes we'll need to remember are
where is our current layer, and is the blended result of all the layers below.
A painter's algorithm is traditionally used when calculating blending, so we can assume that the further down a layer is, the earlier it will be calculated. This means that if we had layers where is the top layer and is the bottom layer, and we were to apply a Multiply to and a Linear Dodge to , this would be the same as the calculation , since would be calculated before .
Blending our layers together will allow us to calculate the formulae we rearranged earlier, with each mode providing us access to our basic operators - addition, subtraction, multiplication, and division.
Layer setup[edit source]
So, let's have a go at converting our foreground formula into layers.
Firstly, to simplify the problem, we'll place brackets around our variables to explicitly define the order of operations. Every time we apply a blend mode to a layer or layer group, it will represent a single calculation being performed on two sets of brackets, thus we wish to structure our equation in such a way that we can easily see which operations need to be performed first.
As we can see when we look at our equation, the order we would usually take when calculating the formula is
Now that we've sorted out the order of operations we need to perform, let's have a look at the blend modes. Since layers further down are calculated first, we assume that is our bottom layer, and is our top layer.
Layer - our bottom layer - is inverted. Although we can calculate this by placing a layer filled with the value 1 - white - above the alpha channel, it would be easier just to invert our alpha channel and use it as it is. It therefore requires no blending.
Layer is a simple multiplication. As we have our inverted alpha channel on the bottom, all there is to do is place the background layer above it, and set its blending to Multiply.
Layer is just as simple. We place the original image above the background layer, then set its blending to Difference. Because Difference uses the absolute value, the order of the layers in the subtraction is irrelevant.
Layer is the division. This is a little trickier. Color Dodge will give us our division, but we first need to deal with the inversion in the denominator. As with before, it would be possible to use a white layer with the blending set to Difference to perform an inversion, but we're again working with just a single layer, so we should just invert it. When Color Dodge inverts it again, it will be the same as calculating which, of course, would resolve to . With Color Dodge placing the on top and the on the bottom, this makes it a lot easier for us since we won't have to create a layer group to apply blending to. Our inverted alpha channel now becomes our top layer, with a blending of Color Dodge.
We are left with our layer setup
|Layer description||Layer blending|
A list of layer set ups can be found in the Quick References section at the bottom of this article.
Need to write this up properly, but here's a load of pretty images and some regurgitated words
Set up[edit source]
- Create an original image layer for back up and comparison; place this on top so we can toggle between our attempt and the original image. Our goal is to have our attempt (with the estimated background layer visible) as close to the original image as possible.
- Duplicate the layer so that we may use this for the opaque areas of our image. Right now, this will be the same as our original image.
- Create two layers for the background, one using the RS Wiki's Light theme background (#fbfbfb); one using the Wiki's Dark theme background (#172136) Place these two on the bottom, and hide or display as necessary.
Step 1: Cutting out the opaque sections[edit source]
First, we'll remove all areas of the image that we know aren't opaque.
- Going around our model with the Polygonal Marquee tool or the Pen tool, we select the model itself, attempting to get the selection as accurate as possible. It's okay if we have areas of the original background showing at this point, as we'll be cleaning the edge up shortly.
- Use this selection to create a layer mask which we'll apply to the opaque layer we created when setting up.
- Using both dark and light background layers for contrast, clean up the edges of the model with the Clone Stamp tool, the Brush tool, or the Smudge tool, depending on practicality. Since we have a layer mask, it can often be easy to use the Smudge tool set to 100% to gently push the green sections out of the visible area, leaving a believable colour in its place.
Step 2: Recreating the background[edit source]
Recreating the background varies in complexity from image to image. Every time we do this, we want to ensure that it's as close as we can get it, which will reduce artefacts later on. In this example, we have a screenshot taken by a lovely person who understands the true value of a solid green background, so recreating it should be simple. We only need to focus on the parts of the image where we know or suspect translucency exists.
Step 3: Putting our theory to use[edit source]
Now that we have our background, there are multiple possibilities. What we do next will depend entirely on the image we're working with.
- We take the difference between the original image and the background to see if there's anything we can take from it. In our example here, we can see that it looks as though we have our translucent areas on a black background. This is good, but we still need to separate the two.
- Merging our layers, we use the Desaturate tool on the resulting layer to make a reasonable estimation of the alpha.
- With our alpha channel and background estimated, we now set up our layers, using the Quick References at the bottom of this guide for convenience. In this case, we'll be using the layer set up for calculating , remembering to invert our alpha channel for the calculations, and applying the appropriate blend modes to each layer.
- We now have our foreground colours.
- We make a copy of our alpha channel and invert it back, merge the layers we're using to calculate the foreground together, then finally apply the alpha channel as a mask to the resulting layer. All we need to do now is ensure that the layer order is correct and clean up the image.
Step 4: Cleaning up the image[edit source]
In all likelihood, our background won't have been perfect. In this case it was, because of the lovely solid green background, but we'll usually need to clean up whatever it was we calculated (the foreground in this case).
- This example is so uncharacteristically easy that our colours are entirely non-problematic, but we've also ended up calculating the opaque areas as well, so we're going to need to clean this up by using the Smudge tool on the translucency layer mask to push our alpha values into the model, hiding them behind the opaque layer. This technique is only required in areas where there's translucency present, everywhere else can simply be cut out.
Quick References[edit source]
Layer description Layer blending Inverted Color Dodge Difference Multiply Inverted None
Layer description Layer blending Group Color Dodge White layer Difference Difference None Difference None
Layer description Layer blending Color Dodge Difference Multiply None