Menu Close

Automatic isolation, or instant white background

This is really an important thing – an ability to remove the background without any efforts on your side. Isn't it great? You just press the button and that's it, it works on its own. Is that even possible?

Almost all my life I thought it wasn't. As a head of the retouching department in a big online-store, I sometimes got proposals from other companies that offered something they called “automatic isolation” and they also promised an unprecedented speed and quality increase if we implemented this thing. But the samples they provided were no good at all. The so-called “automatic isolation” was either based on the Hensel Freemask technology or chroma key plug-ins, and the objects didn't look as good as what you get with the good old Magic Wand plus isolating action technique. Severely damaged edges, green spill everywhere – this is not the kind of imagery I find acceptable. My own experiments on creating an auto-isolating mechanism were fruitless at that time.

But in 2018, when the course you're studying was half-complete, I managed to invent a script-based technique that allows you to isolate images automatically. So if you ask me now, if this is possible, I would no longer say “No”.

As a matter of fact, it is possible if the conditions are right. There are actually several ways how to remove background automatically. In the next few years the whole problem will be likely to solved by neural networks because as I am writing this, the machines are learning. They keep learning and they will eventually learn to distinguish between objects and backgrounds. There are already some AI-based algorithms, like the new Photoshop Select Subject feature. If you have at least CC 2018, you can find it in the Select menu, right where the Focus Area and the Color Range commands can be found. There's nothing I want to say about it, as the whole algorithm is a bit raw and fails to select subjects properly most of the time. It is also very slow. But this kind of technology will only be developing with time, so in a few years, I expect the isolation problem to be completely solved.

There are other ways to automatically select objects in your images. One of them is the aforementioned Hensel Freemask system, which is based on physical photography equipment (you have to buy it first). The reason why I'm not telling you about it is that it's hardly applicable in catalogue photography despite all the ads. It requires you to use a tripod, which messes up the photography process. All the angles are different sometimes you have to shoot up front, sometimes from above – can't really be that flexible with a tripod. It is a working technology indeed, but it doubles the number of images (one being the normal image, the other one being a half-complete mask of the same object), and you still have to tweak the mask a bit.

There are quite a lot of plug-ins and programs that claim to isolate backgrounds automatically. I only used such a plugin once, and it was intended to remove chroma key backgrounds. It didn't do any miracles, and in the end, it turned out to be quite useless, but I admit than useful programs might exist. I just didn't have to buy anything as I usually could do what I wanted with Photoshop basic algorithms.

By the way. What we did with chroma key just a while ago was automatic isolation, too. But as you're not probably going to deal with chroma key (hopefully), let's see how we can remove backgrounds from regular online store images, like objects on a consistent white or light grey background. Or models. Or anything else.

A bit of theory

Before we start, I want you to concentrate on what exactly has to be done to automatically remove a background. The background has to be selected. Removing is easy, you just fill it with white or any other color. So the problem is actually selecting the background. There are basically two algorithms that do it: edge-based or color based. We can't use color as there's no such color that doesn't exist in product images, which means the algorithm will be eating our objects. And there are no automatic edge-based algorithms in Photoshop (I'm unsure if the Select Subject is edge-based).

The most logical way to do it is to use some kind of tool that detects edges, like the Magic Wand. You click it and it selects everything until it finds an edge because edges are contrasted with the background, and when it finds an edge it stops. As this is the final section of the Isolation chapter, you already know your way around images. You know that when you have an edge modification action, all you need to do is just click a few times on the background with the Magic Wand, the rest is done by the action.

But can the whole thing be done by means of an action? Can it click on the background? Yes, it can. Well, not an action perhaps, because when you record Magic Wand clicks, they get tied to coordinates and when you retouch images of the different size it just won't work. You have to go to the Preferences and switch from pixel to percent to be able to record Magic Wand clicks correctly, but why bother? It surely can be done in a script, as you just use the corners of the image to get relative coordinates, and you can tell the Magic Wand: “Go and click in the upper left corner!”, or even “Click on the lower middle edge of the image”. Every image has corners and a center and it means I can use the same script on any image, no matter what size it has in pixels. And what's even better, a script can make the Magic Wand click in the corners of a selection, not just the image itself. You can't do that with an action, that's for sure. So I took my time to script this.

And not just this. Is that all that can be done to make isolation automatic? Not yet. We can still do some other things to make the whole thing work even better. How about making some changes to the image before it gets clicked on with the Magic Wand? How about defining the object more clearly so that the clicking becomes more successful? Without it what we have is just a clicker that clicks with the Magic Wand, but if we also modify the object to be more visible against the background, we would be able to get a reliable auto isolation mechanism.

Demonstration

As I did the coding, I also didn't want the script to leave a mess in the History, so I wrote it such a way that it works as a single step. When I run the script it's the same as if I click several times with the Magic Wand around the image. Three times, to be exact – in the upper left, lower left and the lower right corners. Why three? Because it works faster than four and better than two. And if there's no background where it tries to click, if there's an edge instead, if the sampled pixel is dark, it will click until it finds a free spot. It will not click randomly, but try each corner and the middle of each image side as well. Don't forget that it doesn't click on the original image, it uses an enhanced version, that is black and white and has well-defined edges, so sometimes it might be unclear why it clicks and why it doesn't, as the user only sees the original image.

When you have several images in need of isolation opened, you can use the Batch feature to run the script on all of them and have a more or less fine selection on every image. It will save you some time and you won't have to click yourself. Combine the script with isolating action and you'll get an automatic isolation action.

And that's exactly what I did. Now let me show you how and when it works and, what's even more important – when it doesn't because there's no magic here. I could have just used some carefully selected test images and convince you that I invented a super-powerful auto isolation method. But I hate this sort of misleading advertising, so I'm trying to do the opposite: show you that despite the fact that it is truly possible to isolate an image in one click, you have to be extra careful and attentive while doing so.

Some contents or functionalities here are not available due to your cookie preferences!

This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

Most of the isolation we do for the catalogues is merely clicking around with the Magic Wand and running the edge modification action that fills the background with white. That is entirely possible as long as photographers can provide decent images. So if you work in a badly organized place where they shoot white stuff on gray and the background is always dirty, and there are huge dark shadows everywhere, don't expect any magic. If you wonder whether this would work on your images, ask yourself: “Can I isolate this with the Magic Wand and edge modification isolating action?”. If the answer is no, then no, automatic isolation won't work for you. It means that you can't automatically isolate objects that blend with the background or objects made of fur, and you also can't do it if your images are too small, as in low-res. As for the rest, keep on watching and I'll show you all we can do.

If you have an object that is contrasted with the background, and the edges of the object are smooth, you can be pretty sure the automatic isolation will work well. There are two actions in the Automatic Isolation set. The first one is called “auto_isolation” and it doesn't require you to do anything. Just run it and you'll get your object isolated in a few seconds. When it finishes its work, it runs the isolation checking script that turns the image black where it's not isolated for a second and then reverts back to the isolated state. This is necessary for the visual control of isolation so that you can immediately see if it went fine or not, if there's some trash on the background left or the object is damaged. But in this case, it's absolutely great.

What's not great is the time it took to run the action. That's because the image is huge, it's almost 5500 pixels wide, and it's not cropped. The action will do its work faster on cropped images because it will have less work to do. So it's a good idea to help it by working with cropped images, cropped as close to the object as possible. It might work up to two times faster, which is quite an improvement. If you want to save time, crop your images in Camera Raw before isolating them. When the isolation's done, all that's left is to restore the shadow, which I'll do automatically with the action we've already discussed. It's evident that the automatic isolation action is not able to get rid of dark shadows under the objects, so if you're isolating without a shadow, photographers might as well shoot images without one, or at least without dark shadows in the first place.

To be isolated automatically, the object doesn't have to be dark. It just has to be contrasted with the background. If you haven't cropped the image, you can make a rectangular selection around the object really quick, and the action will ignore the rest of the image. When it's done, restore the shadow and pat yourself on the back.

The automatic isolation action is not able to click anywhere within the object, just around it. If there's no selection in the image, it clicks around image edges. If there's a selection, it clicks around the selection boundaries. But it doesn't click inside this bag's handle, that's why this area won't be isolated. To isolate the bag properly, you have to do this: Make a rectangular selection around the bag, or just Select All if the image is cropped already. Then use the Magic Wand and click it in the handle area while holding Alt to subtract it from the selection. Then run the action, and it will isolate the handle area as well.

If the item is white or light gray, but it's not blending with the background, you can still use the automatic action and isolate it with no problem at all. As you can see, this area on top of the object, which is really bright, has not been eaten away, it's still there, untouched.

Same with thin items. If an object is thin, it doesn't mean that the automatic isolation will eat it. It only happens with fur. So you can use it to isolate things like this as well.

You might wonder why there's the second action in the same set and when we're going to start using it. Well, it's about time. Sometimes automatic isolation won't be working properly. This shoe is black, but it has a white area on the sole that is really blending with the background. If you try automatic action on it, it will eat away the sole. This is exactly the time you'd want to use the other action from the pack, that is called “auto_isolation_threshold”. Unlike its fully independent neighbor, this action will give you a Threshold prompt where you have to find such a setting that the edge of the object will have no holes and tears in it. So I'll zoom in on the sole where it blends with the background for a better view, and run the action. When the Threshold window appears, I'll change the default number, which is 250, to 251, but that's not enough. Then I'll increase it again, to 252. The tear has now closed, but some weird artifacts have appeared on the background. This is not a problem. After pressing Enter, the action will finish its work and you'll get the image isolated. Now the sole looks fine.

Same as before, the automatic action eats this small transparent plastic thingie. But run the “threshold” version and set the Threshold to 252, and it will be fine. There will be more trash on the background because the action is not able to select it anymore, not when you demand it to be more careful with the edges. But the isolation is still very decent. Erase the trash and restore the shadow, and that's it.

Sometimes the fully automatic action will refuse to work for no apparent reason. This shoe is very dark and contrasted with the background, but still, the action eats the sole almost completely. This is not a mistake of some sort, this is pretty much inevitable. The action works with edges, no matter how dark or light the object is. This is exactly what lets the action isolate objects so efficiently. But this shoe has problematic edges here, where the sole blends with the shadow. I'll use the Find Edges filter to demonstrate the idea. Here, in this spot, there's no definite edge, so when the action clicks with the Magic Wand, it will select the sole as well.

So if something like this happens, just run the other action. 251 in the Threshold prompt is enough to make the isolation correct.

There's a limit to how much you can increase the Threshold settings though. There's no magic in Photoshop, only math. You can't really go higher than 253. At 254 the background will be filled with trash and artifacts and it will render the isolation useless. So if you try 253 and it doesn't do any good, the image cannot be isolated automatically. Use other methods.

The reason why the action was not able to isolate the previous image is obvious: because the edges were not definite enough. But in this case, you can still get a good result with the Threshold action set to 253. Now there's a lot of trash in the lower right corner, but removing it is much faster than tracing the boots with the Pen Tool. So it's reasonable to try the automatic approach even if the image looks as if it's not going to work.

The Threshold setting can also be decreased, and it might make your life better. Some items can hardly be isolated with the Magic Wand, like this gloves here. This edge is really fuzzy and the Magic Wand can't get through. If you try the fully automatic action, it will leave you with a dirty border around the edge. But if I run the Threshold action and start decreasing the value, you'll see that this fuzzy edge gets diminished, and at 190 it will no longer be fuzzy. It's not very smooth either, but it doesn't have to when it's made of such a hairy material. After aligning and resizing the gloves look pretty normal. But don't get carried away when decreasing the Threshold value. At 180 the action will destroy one of the gloves. You have to make sure that the object edge is not torn, or it won't work.

The same approach can be used to eliminate deep shadows around an object if the object is dark and contrasted with the background. If I use the fully automatic action, the flower will be surrounded with the shadowy pieces of background. This is not such a good result. But if I run the Threshold action and set it to, let's say 215, it will be much better. Especially after resizing and aligning.

So if your object is very contrasted with the background, you can decrease the Threshold value in the action prompt and get rid of nasty shadows or other things like that. Here, I can go as low as 190 and remove the plastic fixture completely. Just make sure you don't tear the edge. It takes some practice with the Threshold to get the hang of it, but it's not rocket science, all you have to do is test different values on different images and see the result.

The automatic isolation actions can also be used on images like this one, where the background is not really consistent. This image is just horrible, and it looks like you'd need the Pen Tool to isolate it. But I'll select the areas within the earrings manually and invert the selection, and then run the Threshold action. I'll set the Threshold to 241 and look, after restoring the shadow it looks pretty decent for something that took a few seconds. The top of the earrings was not isolated properly, so I'll have to do it manually, but the rest of the image is absolutely fine. Even if you can't get a perfect result, the automatic actions can still save you quite some time.

Open

If you use this automatic isolating action for a while, you'll find many images that cannot be isolated even with the Threshold-based action, because you can't get a closed outline before the background becomes a total mess. Sometimes it's just a little hole in the outline that ruins it all. If that's the case with your images, I've made an additional couple of actions to deal with that matter. It's basically just the Threshold-based action divided into two separate actions. See how it works:

Some contents or functionalities here are not available due to your cookie preferences!

This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

This image here is not that bad – the contrast between the object and the background seems like enough for automatic isolation. But if you run the Threshold based action you'll see that the left side of the shirt is full of holes like an old sack, even if you go as high as 253 in the Threshold prompt. And if you try and apply the changes, you get a total mess.

So let's see if the two stages approach can do you any good in this situation. I'll run the action number one and set the Threshold to 253. It leaves quite a bunch of trash on the background. But that's not the problem. The problem is this gap in the side. Now all I have to do is just grab a hard black brush or an eraser with the black Background swatch and fill the gap. It's hard to tell where it ends, but I think about halfway to the top is okay. And while I'm at it, why not switch to white and erase the mess on the background, at least the biggest pieces of trash. It would only take a few seconds as I don't need to come close to the edges. Don't worry about this weird pattern – as it's made of thin lines, the isolating action is able to handle that.

Now run the action number two and enjoy – the isolation is almost perfect except for a couple of dots. With all the manual intervention it's still much faster than using the Pen Tool for the whole process.

This shoe is not easy to isolate without using the Pen Tool as well. The object is propped with some plastic thingie and the edge is not that definite. If you run the Threshold based action it won't work too well. No matter what you put in the prompt, you get a mess. So let's try and use the separated version of the same action. I'll make a rectangular selection to get rid of the shadow and the plastic fixture and run the action number one. 250 in the prompt will do. I'll use a black brush to fill these two tiny gaps below, and I'll also erase what's left of the fixture while making sure there are no holes in the edge. Now I'll run the action number two.

What we have here is quite a decent isolation. There's no trash on the background, and all that's left to do is just restore the shadow with the History Brush. Now I'll resize and align the image so that you can see how it will look on an average online store website.

This one is really bad – the upper edge of both shoes is hardly distinguishable from the background. But we always try our best to avoid using the Pen Tool. I'll make a rectangular selection and run the action number one. After that, I'll use the black brush to fill in the gaps and holes. It doesn't have to be perfect, but it absolutely has to be fast. After that, I'll run the action number two and restore the shadow with the restoration action and a couple of History Brush strokes. It's not so bad, but the upper edge doesn't look well. Fortunately, it's easy to fix with a large and hard History Brush – just a few clicks and it's fine.

After resizing and aligning the shoes there's nothing left to do. There are probably a few dots left on the background somewhere, but even if so, getting rid of them will only take a few seconds.

One last thing. It doesn't always go so smooth with the action number two. As we're always trying to work as fast as possible, you might miss a gap or two, and it will ruin your isolation. So after I've filled all the holes with black, I'll run the action number two, but instead of nice smooth isolation, it just eats away half of the item.

Something has definitely gone wrong. But it's too tedious to go back and meticulously search around the edge looking for gaps – they can be really tiny and not easy to find. So I'll use this little trick instead: go back in history so that I'm able to do something about the image and then apply some Gaussian Blur, but the Radius should be as small as possible, like 1. It will fill all the tiny gaps without any need for manual work. Now run the action number two again and you'll get your image isolated in just a couple of seconds. The edge is all nice and smooth. Align and resize and you're finished. Better this than tracing the whole thing with the Pen Tool, right?

Open

This, of course, is not automatic isolation anymore, as the process requires quite a bit of manual labor. And if an object blends with the background too much, you might find the Pen Tool to be faster and easier than this approach. So it's not a magical way how to isolate-em-all, it's just another isolation method that might prove useful after you get the hang of it. I've run some time tests on other images and I've found out that if a user is quick and skillful with the Pen, and if the object shape is not too complex, the Pen Tool often wins in terms of time and quality. It all depends on how many gaps and holes there are in the outline of the object you're trying to isolate with the Threshold method. If there are too many, you'll find yourself tracing it with the brush, which is more awkward and slower than using the Pen. It can be two times faster with the Pen, seriously. So if you try the semi-automatic approach and see that the outline is no good at all, it might be a good idea to just undo it and work manually.

The automatic isolation pack is available in the shop. A free test version (HERE) is available as well.

Isolation is based on two things: consistency of the background and definition of the edges. If there's a clear edge between the object and the background, you can isolate it. If there's no clear edge, you have to define one by using precise isolating tools like the Pen or a Brush in the Quick Mask mode. This fact makes automatic isolation impossible, and it makes manual isolation somewhat tricky, especially if the object is not smooth, but has some fuzzy edge. Or if it's made of fur or something like that. If the background is not consistent, which happens when it's made of rough material or is just dirty, it forms small clusters of pixels that might and will be recognized as edges by all the edge-based isolation tools like the Magic Wand. So the less consistent the background, the fewer possibilities for edge-based isolation, be it automatic, semi-automatic isolation, or manual clicking with the Magic Wand. All that means that if photographers cannot provide images where objects are shot on a consistent smooth background and have clearly visible edges against the aforementioned background, the isolation process will always be a struggle, no matter how experienced the retoucher is or how advanced his methods are. We strongly depend on the photography stage here, always keep it in mind.

You can download the images for practice purposes from the gallery above. Each thumbnail is linked to the respective hi-res image, just click on the thumbnails you need to open them in a separate window. You can right-click and "Save link as…" to download images without having to open them first.

"Magical" isolation

Beware of Photoshop actions that are supposed to isolate and enhance images at the same time. Especially if their creators promise you magical results. If you ever googled, you've probably found tons of weird actions that only look great in their advertising videos. I can show you one as well. Have a look at this bunch of cookies that are all dull and gloomy. I will run an action and they will become much more attractive, and the background will become pure and white – all in a second. Seriously.

Some contents or functionalities here are not available due to your cookie preferences!

This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

See! Now, how cool was that? Just don't get all impressed as that was a cheap trick. If you get this action, you'll realize really quickly that there's nothing cool about it. It can only isolate objects on a consistent background, and all the trash's gonna stay. Objects will become significantly brighter in the process, so the trick only works with the dark stuff. White stuff will be totally destroyed. If you still want to know how it works – well that's easy. It makes a copy of the background layer and fills it with Average (Average can be found in the Blur submenu of the filter menu). Then it blends the top layer in the Divide mode, which does the whole isolating and brightening thing.

It might look great, and it's really easy to impress people this way, you can sell anything. Just tell them: your images will become spectacular, or better – you'll be retouching like a pro, and people will swarm you and make you take all their money.

The bitter truth is – there's always a catch. There's no magic. Product image editing in Photoshop is all about math and algorithms, and most of our skill is repetition based. I do pretty exciting things in this course, but they all have a scientific basis, and you have to learn a lot of boring things to be able to do at least something with all this knowledge.

And by all means, avoid automatic color correction and never mix it with isolation. This time I'm serious.

Next: Isolation quality control

Top

On this website, we use first or third-party tools that store small files (cookies) on your device. Cookies are normally used to allow the site to run properly (technical cookies), to generate navigation usage reports (statistics cookies) and to suitable advertise our services/products (profiling cookies). We can directly use technical cookies, but you have the right to choose whether or not to enable statistical and profiling cookies. Enabling these cookies, you help us to offer you a better experience. If you choose to disable cookies, you won’t be able to watch the embedded videos. Cookie policy