Isolationg Image Objects With Transparency Masks
by Wizaerd

Date Posted: 10/07/2001 - Before I begin, let me point out that masking images is going to vary on the image you're going to be masking, and what your end result is for. The steps outlined here are for separating a portion or an object out of an image.

Before beginning this project, I did not have any specific needs, so I pulled out the ole dusty digital camera, grabbed one of Ginger's stuffed animals and snapped off a quick shot. The digital camera we have is old, and it doesn't take very good pictures. So as an added bonus, we'll cover adjusting curves, but only to a very small (amateur) degree.

Here's the image straight from the camera. Egads, what a fright, eh?



So after selecting the image, I went to Image->Adjust->Levels, which brings up the following dialog box.



There are many people far better suited to teach you everything you'd possibly want to know about levels, but suffice it to say, there's a whole lot of blank white space in this dialog. Move the little dealiedoos (yup, that's a new technical term for you) to where they bump up against where the graph portion starts and ends. As show here:



Notice how much brighter your image is now. technical crap: The graph in the levels dialog is called the histogram, and it shows the relative number of pixels in each brightness level throughout an image. Experiment with the levels dialog to control brightness and contrast in images. I'm sure there's a real science to it, and just perhaps that'll be a great topic for another tutorial. Another step we could take is some color correcting, but that too will be saved for another tutorial on another day.



Alright, now since we want to remove the bunny from the background, we'll have to select the pixels that represent the rabbit. Once more there's a whole science to selecting image portions... color range select, magic wand, saturation select, etc... The list goes on and on, but since we're not dealing with very fine imagery such as hair or fur, there's one sure fire way to select what you want out of an image. And it's also one of Canvas's strong points. We're going to create a vector shape that represents what we want. So choose the Auto Curve tool from the toolbox:



As a matter of preference when tracing, I set my fill to none, and if it's a dark image, I use a bright stroke, such as white or yellow. The Auto Curve tools is a great tool to use because it allows you to just click to create a path, and let Canvas determine what the angle of the curve should be. Prior to having an Auto Curve tool, we had to use the Polygon and using click and drag techniques on each point, come up with a curve. Personally I found this to be a real PITA, and therefore didn't do a lot of tracing.

Alright, so click completely around the outside of the object you wish to isolate. One little thing to look out for is the Auto Curve tool is a bit touchy when trying to create a closed path. The Polygon tool's cursor changes when your directly over your starting point, and clicking on it automatically closes your path. The Auto Curve tool's cursor does not change. If you can precisely place it over the starting point and click, it should close the path out. I say should because I very rarely get a closed path. What I do is place the ending point close the the starting point, and lose the Auto Curve tool by pressing escape. This puts your new object back into bounding box mode. I then generally double click the object to put it in point editing mode, select the first and last points, right click and choose Join from the popup context sensitive menu.

Before you can use your shape as an image selection though, it must be filled. So I changed the fill mode to white and the stroke color to black, although for purposes of this demonstration I also applied a bit of a transparency to it just so you can see both of them clearly.



Selecting both the image and the newly created shape, go to Image->Path to Selection.



This will place your image in edit mode, and you should have a marching ants marquee where the vector shape once used to be. The first thing I do is open the channels dialog (Image->Show Channels) and click the right most button on the left hand side. Huh? I've shown an image with a red circle pointing out the button I mean.



This way I'll always have a copy of the original selection. The next thing I always do is contract my selection by a small amount, 3 pixels in this case and then feather it by just a bit, 2 pixels here. This gives a bit of a smoother selection instead of an abrupt masking. After doing these two operations click that right most left hand button again to save the selection. Click in the newly created channel, and while holding the mouse button down, drag the channel to the mask channel at the bottom of the dialog.







You now have a fully masked object from your image.



Does that mean we're done? Essentially, yes it does for now. But now that you have your masked object, now you can composite it into an image collage or make a whole new image. It's up to you what you do with it...