[Courses][gimp] Lesson 6: Erasing Unwanted Objects from Images

Akkana Peck akkana at shallowsky.com
Sat Mar 5 07:14:23 EST 2005


One of the best uses for an image editing program is to erase
things you wish weren't in the picture.  Maybe you have a great
photo of your sweetie except there's a telephone pole growing out of
his head; maybe that outhouse in the background really takes away from
your nice scenery photo.  For whatever reason, learning to remove
stuff from images is a fun and important gimpish skill.

Removing objects undetectably can be very difficult.  I'll touch
on several techniques you can use for simple removals.  For difficult
projects involving complicated backgrounds, it will usually take a
combination of several tools, plus lots of patience.

Let's start with this hummingbird image:
http://shallowsky.com/images/gimpcourse/lesson6/hummer-orig.jpg

Isn't that branch annoying?  The one going straight through her head?
And that other branch that's blocking our view of her?
Let's explore some techniques for removing them.

SMUDGE

An easy tool to start with is the Smudge tool.  It looks like a hand
with a pointing finger.  Smudge does exactly what the name implies: it
behaves as though you were smudging or smearing the image with your
finger.  Select it in the toolbox, and look at the tool options.

Notice that the smudge tool has a Brush associated with it.  The brush
you choose makes a big difference.  Most of the time, you'll probably
want a fairly large brush, with a fuzzy edge, not a sharp edge.
But for very small images, you may want to use a small brush, or
even one with sharp edges.  I'm going to choose "Circle Fuzzy (15)",
the third-from-largest fuzzy circle.

Now I'm going to try to smudge out that small branch under the bird's
bill.  The smudge tool will drag color from wherever I start, onto
where I drag.  So I'm going to drag from the bright area, onto the
branch.  Smudging only works over a short distance (the color "runs
out" after a little while); so I have to smudge repeatedly, many
times, to get rid of the branch.  I go back and forth, sometimes
dragging from below the branch upward, sometimes from above downward.

Remember, you can always zoom in to get a better view of the part of
the image where you're working.  Hitting = or + a couple of times
can help you see what you're doing.

Digression: Zooming in is useful, but if you have a small image,
sometimes it makes it hard to see how the image looks at its native
size.  Here's a nifty GIMP trick: multiple views of the same image!
Choose the first item in the View menu, New View.  This opens a new
window showing the exact same image as the original window.  Then you
can make one big and one small; do your painting and smudging on the
big window, and look at the small one to see the result of your work.

Back to smudging: you're doing lots and lots of little motions, each
one of which is an action as far as Undo is concerned.  So you probably
won't be able to Undo a whole smudging session, though you can always
undo the last few bits of it.  Be sure to save your work before you
start smudging, and if you decide smudging wasn't the right thing, you
can use "File->Revert" to go back to the image before you started.

Here's what it looks like partway in:
http://shallowsky.com/images/gimpcourse/lesson6/hummer-somesmudge.jpg
and all the way:
http://shallowsky.com/images/gimpcourse/lesson6/hummer-smudged.jpg

CLONE

The Clone tool iss similar to smudge, but more powerful.  Clone
"remembers" a source region which you choose; then, as you paint in
the image, instead of painting a fixed color, Clone will copy from
that source image.  The icon in the toolbox looks like a rubber stamp,
and the tooltip says "Paint using Patterns or Image Regions".

I'm going to go after that vertical branch that's blocking some of
our view of the hummingbird.  I can't use the smudge tool for that,
because her breast and wing have feather patterns, and smudging
will spoil that and will end up looking artificial.  But if
I can copy the feather patterns from her breast, I might be able to
use them to paint over that branch.  I'll use a slightly smaller brush
than I used with the smudge tool, Circle Fuzzy (13), because I don't
want to slop over and get white breast-feather pattern painted over
the bird's wing or head.

The clone tool has to be initialized before you can paint with it.
At first, when the clone tool is selected, when you move your mouse
into the image, the mouse cursor will show a circle-slash, meaning
"You can't paint anything yet!"  Select a source region with
ctrl-click: move the mouse where you want your source region, hold
down control, and click the left mouse button.  Do this as close as
possible to the piece you want to remove, so that the color and
pattern will be right.  But you can't get too close, or else, when you
paint with the clone tool, part of the source pattern you're painting
will be exactly the part you want to remove!

Once you've ctrl-clicked, the mouse cursor should no longer show that
circle-slash.  You're ready to paint!  Do so, in very small strokes,
just like you did with the smudge tool earlier.  You may find that
you have to paint a small area, then select a new source image
(ctrl-click again) because the color changes.  For instance, my
hummingbird is light colored where the sun is hitting her, but has a
shadowed portion down near the branch she's sitting on.  I'll need
to paint those two areas separately, with different source regions.
Here she is with the parts in front of her removed with the clone tool: 
http://shallowsky.com/images/gimpcourse/lesson6/hummer-clone.jpg

COPYING SELECTED AREAS

I could go on using Clone and Smudge to paint out the rest of the
branch, but I have a shortcut for the next step: I'm going to select
a region next to the branch that's the same shape as the branch, then
paste it on top of the branch.  If that doesn't make sense, bear with
me while I follow the steps:

First, I'll use a selection tool to select the part of the branch
still above the bird.  Regardless of which tool I use, I want the
selection "feathered", which means that the edges of the selection
will be fuzzy, not sharp.  Sharp lines in selections tend to stand out
when you paste them somewhere else.  All of the selection tools have a
"feather" option in the Tool Options dialog, where you can set how
fuzzy you want the edges to be.

I'm going to use the lasso ("free select") tool, which lets me
hand-draw the outline of the branch.  It's not critical that the
outline exactly follow the branch; the important thing is that my
selection is entirely outside the branch, and that it's in the right
place in places where the branch touches the bird or the branch above
it.  Here's a screenshot of my selection:
http://shallowsky.com/images/gimpcourse/lesson6/hummer-branchselect.jpg

Now I have the branch (and a little padding around it) selected.
But what I actually want is to copy something right next to the
branch, not the branch itself.  I can get that by moving the selection
over by approximately the width of the branch.

It would be nice if I could just click in the selection and drag it,
but that moves the contents of the selection, leaving a blank white
area behind it.  (Try it!  It's undoable.)

In gimp, alt-drag moves a selection.  That sounds straightforward --
except that in most Linux window managers, alt-drag is already claimed
as "move window".  So when you alt-drag the selection, most likely,
the whole gimp image window moves.  Not what you want!
(Try it.  If it moves the selection, then be happy! and ignore
the next paragraph.)

There are two ways around this.  First, you can configure your window
manager not to use alt-drag to move windows.  This is supposedly the
recommended approach, but I don't recommend it; it means you'll have
to do this on every window manager you ever use, and if you ever try
to show a friend how to do something, it won't work for them.
Fortunately, there's another way: alt-shift-drag also moves the
selection.  Here's where I've moved the selection:
http://shallowsky.com/images/gimpcourse/lesson6/hummer-selectmoved.jpg

Now I Copy, then Paste, as in Lesson 4.  The pasted piece shows up as
a new layer in the layers dialog, and I can Move it using the move
tool (while it's a floating selection, I can also move it just by
dragging it).  It's a bit hard to see the how well the edges match
while I'm doing this, so I temporarily turn the marching ants off with
View->Show Selection, or ctrl-T.  (Don't forget to turn them back on
again afterward.)

When I'm happy with the placement of the new layer, I need to merge it
with the base layer.  Why?  Because I have some extra cruft at the
edge of the pasted layer, plus some extra stuff next to the
hummingbird's head, which I'll need to clean up with Clone or Smudge.
Tools only work on one layer at a time, and I'm going to want to be
able to smudge or clone right across the boundary of the layer I just
pasted.

To merge the selection layer into the background layer, I go
to the Layers dialog, and instead of clicking the New Layer button
as we've done in past lessons, I click the Anchor button.
http://shallowsky.com/images/gimpcourse/lesson6/hummer-pasted.jpg

Now I Smudge to clean up the area above the hummer's head.  I'll also
use the Clone tool to get rid of the bottom part of the branch.
Here's the result!
http://shallowsky.com/images/gimpcourse/lesson6/hummer-final.jpg

I'm done!  No more annoying branches in the way.

Homework: Erase something out of an image, using whatever tools seem
most appropriate.

Next Lesson: Advanced selection, with paths; and enhancing just the
selected part of an image.


More information about the Courses mailing list