When working with images, we often need to
isolate an object or person, and remove the background, so we can layer it with other
images. In this video, we’re going to talk about
how to remove the background of an image in Photopea, with both a simple image that we
can use a basic technique on, and a difficult image that will require a more advanced method. You can find a link to all of the images I’m
using in the description, or just search for them on pexels.com. I’ll search for fruit, and we’ll use this
apple. We could download the image, and load it into
Photopea, but I’m just going to right click and copy it, and then switch over to Photopea,
and paste it into this project I’ve got open. I’ll use the move tool to resize it, and
get it positioned on the canvas. I’ve got the finished product here, and
this apple has a transparent background, which you can see if I switch off the background
layer. With an image like this, we can easily remove
the background with the Magic Wand tool. The Magic Wand tool lets you select pixels
with the same or similar color. Select the Magic Wand tool by pressing W twice. We can click the canvas, and it makes a selection
based on the color that we’ve clicked on. If you have contiguous checked, the Magic
Wand will select pixels that neighbor each other. If contiguous is not checked, when you make
a selection, any pixel within the color range is selected, even if it isn’t connected
to the area where you clicked. You can see some of the apple was selected
here. You’re going to want to have contiguous
checked when removing the background like this. Clicking the white area makes a selection
of the white pixels, but some of the pixels on the edge of the shadow have made it in,
as well. The Tolerance controls the range of color
selected when using the magic wand. The lower the value of tolerance, the smaller
the range of similar colors that are let through. The higher the value of tolerance, the wider
the range of colors let through. So, if we turn tolerance up, to 40, and click
the background again, more of the shadows have been added. But, there are still some areas of the background
that were not added to the selection. Your first thought might be to keep upping
the tolerance, to let a wider color range through. But, the higher you set the tolerance, the
more likely the selection you make will cut into our target, the apple. If we set the tolerance to 80, and click on
the background, most of the shadow has been included, but if you look at the top of the
apple, some areas have been selected. Some of this water drop, too. So, let’s turn the tolerance back down to
40, and make the original selection again. Now, the top of the apple looks good, it isn’t
cutting in on the top edge, or on the water drop, either. But, we need to add these areas of the background
to the selection, which you can do by holding down shift, and clicking to add an area. We can come down here, and add this area,
and other than some shadows at the bottom, this looks pretty good. Hold down Alt, and scroll the mouse wheel
to zoom in, and then hold down shift and click to add the shadow to the selection. When we do that, it cuts in a little too far,
so I’ll undo with Control Alt Z, and then turn the tolerance down, to 15. Then, I can add to the selection, and less
color range is let through. Click on all of these little areas to add
them, and let’s zoom out. Now, we’ve got two ways to get rid of the
background. You could just press the delete key, and delete
the background altogether, which is what I’ve done with this first layer. The problem with this, is that deleting the
background is destructive, it permanently deletes the background. Of course, right now, you can hit Control
Z to undo it, but once you save this project, you’ll lose the ability to bring the background
back, or make adjustments to the selection we made. So, there is a better way to get rid of the
background, that is non-destructive, which means we will still have access to the background
after we remove it. What we want to do, is create a raster mask,
that will mask out the background, leaving just the apple visible. To do that, we need to select everything on
the canvas except for the apple. We need to add the rest of the background
to the selection by shift clicking outside of the selection. Then, we need to invert the selection, so
we only have the apple selected. Invert it by going to the Select menu, and
click Inverse, or by pressing Shift Control I. Once you have only the apple selected, make
sure you have it’s layer selected in the layers panel, and click on Add Raster Mask. OK, that looks pretty good, most of the background
has been masked, but there are some areas we missed here. You can edit the mask by selecting it in the
layers panel, and use the brush tool. If we paint on the canvas with black, we can
mask out where we paint. So, let’s get rid of the rest of this shadow. If you go too far, and mask out some of the
apple, switch the color to white, and paint over it. With a raster mask, any area that is black
will be hidden, and any area that is white will be shown. Once you get the mask right, press V to switch
to the Move tool, and resize it, so it’s about the same size as the other apple. Rotate it, and put it over here. With a simple shape like an apple on a solid
background, it’s easy enough to use the magic wand tool to make a good selection,
and use a raster mask to hide the unwanted areas. But, sometimes you’ll have an image that
is a little more complex, and this method wont be good enough. This is often the case with hair, or fur. Let’s go over to pexels.com, and search
for something to work with. I’ll search for kitten. OK, this image here is a great example. The kitten’s fur would make it impossible
to use the magic wand tool to remove the background. Either you’re going to cut off the fur on
the edges, and the cut wont look natural, or your going to cut around the fur, and let
some of the background through. I’ll go ahead and copy this image, and switch
back to Photopea, and let’s start a new project. I’ll set the background to a darker color,
and paste the image to the canvas. I’ll resize it, so it fits on the canvas
better. Now, when you’ve got an image that doesn't
have a clear edge to cut from, we can use the Refine Edge tool, to make a more precise
selection. First, we want to get a base selection, of
as much of the kitten as we can, so let’s switch to the quick selection tool, by pressing
W. Then, click and drag on the kitten to select as much as possible. Try not to get any of the background, but
don’t worry if you do, just get it as close as possible. Once you’ve got a good selection, click
the Refine Edge button. The Refine Edge tool let’s you select complex
shapes, by creating a trimap, of 3 colors, black, gray, and white. You can choose between these three colors
here, and paint with them on the left canvas. The right canvas is the end result of the
process. Painting over an area on the left canvas with
black, will hide it on the right canvas. Painting with white on the left canvas, will
show the image, letting it through completely. When you make a selection, like we did of
the kitten, before clicking the refine edge button, the selected area is automatically
painted white, so that area will already be shown here. Lets use black to paint over the background
we let through. Where this is different from a raster mask
though, is when we paint the edges with gray. That’s what makes the Refine Edge tool work. By using gray to paint over the areas that
area hard to select, Photopea will deduce what should be part of the background, and
what should be part of the foreground, and automatically make the background transparent. It’s hard to see what it looks like on the
right side, with no background, so let’s switch this background to black. This background is temporary, the layer will
still be transparent when we’re done. You can see how the kitten's fur is added
to the selection, but the background is not being let through. Just paint along the edges, covering any areas
where there is fur. We can paint over these whiskers, and they
are shown on the right side. You don’t have to be too careful about making
your selection, as the background will be removed automatically. But, the more accurately you paint the gray
pixels, the sharper and clearer the final result will be. If you paint too much background area with
gray, it starts to look smudged, and isn’t as sharp as it would be if we painted the
trimap more precisely. I’ll go ahead and finished this up, and
get everything looking nice. If you spend the time refining this, we could
get it looking really good, but this will do for now. Now, we’ve got three options we can choose
from before we click OK to apply this to the image. We can choose New Layer, Raster Mask or Selection. New Layer takes what we’ve got on the right,
with no background, and creates a new layer with this image. Raster Mask creates a new raster mask using
this shape, and links it to the original layer, masking out the selection, and finally, selection
will create a new selection based on the result. We’re going to choose New Layer, and hit
OK. Once we do that, our new layer is created
with the kitten, except the background is removed. It doesn’t look as good as it could, because
I haven’t spent enough time refining the trimap, but you can see how easily you can
remove the background even from more complex images. Just for fun, let’s go to our first project,
and duplicate the apple layer into our new project, and I’ll drag it up here so it’s
in the kitten’s line of sight. Then, let’s go back to Pexels, and search
for moon landing. This one will work. I’ll copy the image, and paste it into our
project. Press V to select the move tool, and place
it over here. Then, I’ll move this layer to the bottom,
so it acts as our background. Last, let’s select the top layer, and add
a new adjustment layer, and choose solid color fill. Click here to set it’s color, to black,
and set the blending mode of this layer to color. Then, bring back the opacity a bit, to about
75 percent. All right, there you have it. That covers how to remove a background from
an image in Photopea. For a simple shape like this apple, you can
use the magic wand tool to select the background, and use shift to add to the selection until
you select everything, and then delete the background, or create a raster mask. With more complicated images like this kitten,
you can use the Refine Edge tool to create a trimap of the image, using Photopea to blend
the more difficult areas. Thanks for watching, see you next time.