Isolation
November 05, 2009You probably experience this on a regular basis: a client sends you an illustration or a logo they’d like to use in a project, but it’s a low-res bitmap or a flat image file with a background texture. Or both, if you’re really lucky. Sure, you can try and ask for a vector version, but more often than not what they originally sent was the best copy they had on hand.
I seem to have made something of a hobby out of trying to coax useful results out of this type of file. Over the years I’ve stumbled across far better ways of doing it than manually clipping the background with the the magic wand or various selection tools.
For the next time you’re handed a less-than-ideal source image, here are a few of my tricks for isolating the part of the file I want to work with in Photoshop.
I’ll use this Firefox promo image as an example. Yeah, I know I can find a vector version of this particular logo online, but it makes for a fairly good demo thanks to the complexity of the background.
Let’s start with the text. A single, flat colour ends up being fairly easy to extract. The first step is using the Hue/Saturation sliders [Ctrl / Cmd + U] to drop the saturation all the way down to a value of -100:
Then trim away the surrounding pixels to focus on the area you want:
Next use the levels sliders [Ctrl / Cmd + L] to increase the contrast on either side so that the background is black and the text is white. The trick is doing it in a way that doesn’t completely kill the anti-aliasing between the text and the background, while at the same time making sure the foreground/background colours are pure black and white. You don’t want stray pixels on either side, otherwise nasty things will happen later on when you try using your results. If you just can’t find a balance, use the brush tool to fill in the strays manually.
The best results come from images where the text is clearly a different shade than the background behind it. In this case it is, so I’m able to get a reasonably high-contrast result:
At this point you have two choices. If you don’t need the ability to change the colour of the text or apply layer effects, you can stop now and set the layer’s blending mode to Screen or invert it (Ctrl / Cmd + I) and set the mode to Multiply. With the either of those blend modes you should be able to place this high-contrast layer over top of a background and it’ll be treated as isolated text. The key being placing it on top of non-transparent background; if there are no pixels beneath for the layer to blend with, you won’t be able to save it out the same way it renders in Photoshop.
For that extra control you need to take it further. By holding down Ctrl / Cmd and clicking on the image’s layer in the Layers palette you can select just the outline; copy that to the clipboard, open the Channels palette, create a new Channel, and then paste the clipboard into that channel. If you’ve done it right it should look something like this:
Figure: Ctrl/Cmd + clicking on the channel produces selection marching ants in the preview. You can’t see the animation, but they’re there.
The same way you selected the outline of the image in the Layers palette, you can Ctrl / Cmd + click in the Channels palette and the selection will change to just the border between the background and foreground. If you switch back to the Layers palette and create a new Solid Color fill layer:
The text now sits on an isolated layer that allows you to easily change the colour, apply layer effects, etc.
The icon is more complicated. We’ve got a strong orange foreground, but the globe and the background share some tones so extracting is going to be trickier. This is a fairly common scenario in the wild, but the good news is that it’s still doable in most cases.
Let’s be a little more selective about what we’re trying extract this time. Start by focusing on the orange fox for now, we’ll come back for the globe. The Select > Color Range tool allows you to click an area and select all colours similar to that selection point, and the Fuzziness slider controls how loosely or tightly the selection matches that colour. Selecting the blue area instead of the orange produces a much higher-contrast outline of the orange area:
Once you hit okay you’re left with marching ants. The selection isn’t useful yet, so back to the Channels palette we go. Create a new alpha channel and fill the selection with white:
Now you can just pull up the Levels palette and, with the same high-contrast result in mind as the previous text example, adjust the levels until the fox is pure black and the background is as pure white as you can make it:
If you hit Ctrl / Cmd + click on the channel then head back to the Layers palette and select the original, you can click the Add Layer Mask button in the bottom of the palette and have the selection mask the image to just the orange areas we’ve managed to extract:
If you end up with too many fringe pixels from the background, you can hit Ctrl / Cmd + select the mask again, and use the Select > Modify > Contract tool to decrease the selection 1px on all sides. Invert this smaller selection with Ctrl / Cmd + Shift + I, then select and fill with black the layer mask to apply it. This will eat up a one pixel outline around the object, which should take care of the fringe without tossing out too much image data. Though it does depend on the size of the source image.
We now want to add the globe back in, so duplicate the layer and remove the mask to show the original image again. Manually trace the outline of the globe with the circular marquee tool, select the masked layer and fill that selection with white within the mask. And there we go, an isolated version of the Firefox icon that you can manipulate as you please:
Extraction this way seems like a lot of work, but once you get the hang of it you’ll find it’s fairly quick work to go from a source image to something usable.
For relatively simple jobs like the text, the process is straightforward and can be done in a couple of seconds. For more complicated extraction as in the case of the icon, creative alpha masking combined with a bit of manual tweaking will usually get the job done.
(And I don’t have to remind you to always use this for good and never for evil, do I?)
Thanks for the great tips Dave.
I often find the Extract tool is useful for this stuff. This is no longer installed by default in CS4, but is an optional plugin.
It has the ability to extract foreground shapes from a background with the correct colour and alpha channel right to the edges. This solves the problem of coloured fringe pixels that you suggest cutting off by contracting the edges of the mask.
It can take some learning, but the Adobe docs do a pretty good job of explaining it: http://help.adobe.com/en_US/Photoshop/11.0/WSCAC4D084-6AB1-483a-B264-6336B4888649.html
The Extract tool is partially replaced by the Background Eraser tool in CS4, but I think the full plugin does a better job. However, it doesn’t always work perfectly, so your alpha channel solution is sometimes better.
Good stuff. To me, the first step is to always run it through http://vectormagic.com and see how good/bad the output is. VectorMagic is a project originated at Stanford and it blows away every other raster-to-vector technology I’ve ever seen (especially what it built into Adobe products).
The Firefox logo is a tough customer because of the complexity – as you mention – but a lot of other logos come out of VectorMagic almost as if they were originals.
These are some useful tips, using channels to change isolated colors or backgrounds is a good way of getting clean results, but they all always at some point need to involve the marquee tool, in my opinion never use the magic wand tool its rubbish just get stuck in with the marquee zoom in nice and close that way you can be more hap hazard with your lines allowing to to get the job done faster.
Don’t forget to check brandsoftheworld.com to see if a vector is there. I know it’s not always but worth a check.
I often find myself using the pen tool for extracting a selection for this kind of work (aside from text/fonts.)
The background eraser tool says hello.
Often over-looked, but bloody effective with the correct settings.
if you’re comfortable and quick with it, the pen tool is a great way to handle this as well. (especially if you’re the ‘do it manually’ type)
Wow. If you had just written this 4 years ago, you could’ve saved me hours of wasted time removing extraneous background detail from logos and other image.
When I create my latest idea, Time Machine Bookmarks, I’ll be sure to add this link for my previous self to look at in 2002.
Useful technique! So many times I’ve just been told to “use the logo from our old site because we don’t have the original”. I’ve always ended up either re-drawing it, or using the pen tool, will give this a go next time.
I’m very impressed about the technique you describe. I never understood how you can isolate perfectly a logo from a background (always a problem with a coloured background and a white background website).
Thanks, I will try this.
Can’t remember how many times i had this specific problem. I’d always prefer struggling with photoshop instead of trying to talk the client into finding a better sample or using the pen tool to get something vectoral.
Anyway, i’ll be using this technique and this time, i’ll know what i’m doing :D Thanks!
if you’re comfortable and quick with it, the pen tool is a great way to handle this as well. (especially if you’re the ‘do it manually’ type