Repeat after me: Every project I complete makes me smarter.

Gimp Tutorial - Popout Photo

Date/Time Permalink: 07/15/07 08:09:58 am
Category: Graphics Tutorials

Really, this tutorial will be about masking: taking a photograph and separating a foreground subject from the background, for the purposes of doing something interesting with it.

This kind of subject may prove unsatisfying, because when you sit down to write a tutorial, you're free to pick whatever nice clean image you want as your subject. In the real world, clients come to you with fuzzy, blurry, low-res JPGs that have been saved numerous times, with a whole circus of noise in the background. So that's how these masking tutorials make it look so easy: we cheat. If you find this work to be slow, frustrating, and tedious, you're right: masking is just like that, and takes some skill to pull off.

So, for our nice, clean, no-hassle subject image, we'll use this Model-A Ford photo from Wikimedia Commons. From the featured images, yet!

How to mask a subject

1. Generally, the first step is to go Filters-> Colors-> Decompose, and in the dialog check "RGB" and "decompose to layers. You will have a new image with three layers for the channels red, green, and blue. The reason for this is that in noisy photos, the green channel will usually have the best contrast. In some cases with less co-operative pictures, you can combine the channels together in different ways to bring out better contrast.

Popout tutorial 1

2. Copy the channel into a new layer on top of your source image. We'll work with this to get our selection. You can close the channels image. You'll always want to use the magnify tool to blow up the image as much as you can. And select the scissors tool.

Popout tutorial 2

3. Generally, the process is going to be:

  1. Use scissors to find the rough outline of the subject.
  2. Use the lasso select tool in addition mode to include any parts of the subject border and in subtraction mode to cut out parts that aren't part of the subject.
  3. Copy the section from the source to a new layer.
  4. Use the eraser to shave off bits of the background from the image border.

Now, the scissors tool is an inexact, buggy way to select a subject, but we'll be able to correct its mistakes later. To use it, click a series of dots around the subject. Make your dots close together, like this:

scissors detail

The closer you make your dots, the easier time the scissors tool will have finding the border of your subject. In areas where there isn't a nice, clear border contrast, make the dots even closer. Remember that we'll take several more steps to clean this up, so it doesn't have to be exact. But the closer we get it, the less time it will take to clean up. When you've traced dots all the way around the image, click the first dot you laid down and then click inside the image to turn it into a selection.

Here, I've cut away all the not-selected parts to illustrate where we are:

Popout tutorial 3

4. What a lucky shot; with this nice, clean image with a subject that's all straight lines and well-defined curves, we've got it mostly done in one step. Magnify your image some more and start using the lasso selector to either include missing chunks in the selection in addition mode or to cut background off of the selection. Note that you have to start clicking and dragging the selector cursor outside your selection, or else it will think you want to move the selection.

Here, I have stroked the path of our initial selection in red, then drawn a blue box around the part I want to cut off, with a blue X to mark where I start with the lasso selector. Note the pink oval, which is showing the part of the selection options dialog where you change modes between replace, add, subtract, and intersect.

Popout tutorial 4

5. After you have the selection roughly where you need it, copy the original source image layer to a new layer and cut out all the parts not in the layer (Select-> Invert and Ctrl-K, for instance). In this case, I have added a white background and highlighted the next step, which is using the eraser tool to erase around the border and smooth off rough edges. The eraser is using a small fuzzy-circle head, and I'm holding down the shift key to get a straight line along this edge.

eraser detail

Other selection tricks which may work will be: setting the selection options to anti-aliasing, setting them to feather edges, and growing the selection by one pixel, all prior to copying. I have here neglected these steps to illustrate what to do when you have to wipe bits off the border of the selection. No two images will have the same steps.

We now return to the earlier finished selection I did:

Popout tutorial 5

6. Now that you (or, at least, I) have a cleaned-up model separated from the background, the actual work from here is a breeze. First in the layers dialog, let's delete the black and white layer, rename our cut-out subject's layer "Subject", and the white layer "Frame". Move the frame up between the subject and background. Have the eyeballs on for the subject and white frame. And move a horizontal guide out in the image to where you want the edge of the frame to be. Now with the white frame layer active, Select-> All and use the "Perspective Transform" tool to make that white rectangle into a trapezoid which will be the frame's shape.

Popout tutorial 6

7. Turn off the eyeball in the layers dialog next to the Subject, leaving only the Frame layer visible. Use the magic-wand selector tool to select the white trapezoid, then do Select-> Shrink and have it shrink by about 15 pixels. Hit Ctrl-K to delete the new shape inside of the frame shape. Note that you may also want to apply a Guassian Blur of about 2.0 to the frame to eliminate aliased jaggies along the slanted frame edges.

Popout tutorial 7

8. Now use the magic wand selector tool again, to click outside the white frame. With that selection active, in the layers dialog make the background visible, make it the active layer, and in the image hit Crtl-K to cut out everything outside of the frame's border.

Popout tutorial 8

9. Almost there! Make all of the layers visible, and merge them all down on top of each other. Make a new layer with foreground color set to neutral gray and move it to the bottom layer and flatten the image.

I hate to say "Voila!" with such a sloppy job, but here it is, anyway:

finished popout photo

Note that there's a lot we neglected, here. The car's shadow doesn't continue out of the frame. To get that, we would have to make a separate mask for the car's shadow. I blurred the car a bit to smooth out rough edges. I cropped the tires too close when cutting the shadow from them. But to the casual glance, this project is moderately acceptable. I would of course taken much more time had this been a professional assignment.

Of course, I did more work than was necessary for the finished effect - I could have just masked the front half of the car. But actually I masked the whole thing as a project before deciding what to do with it.

Conclusion: masking is an expert-level image hack, and takes much practice. But it is good to have, because professionally you run into it all the time: clients have an old logo they want modified and don't have the source images, or they want a subject moved to a different background, and so on.

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

suddenly the moon