A Layer Mask Project

Done using GIMP 2.10.20 on Kubuntu Linux 18.04 LTS

A good way to learn these tools is by doing a project that lets you integrate a variety of tools. Most things you do in GIMP require multiple tools to carry off, and you want to learn how to string together image modifications to get the desired results. And any time you want inspiration or new ideas, check out YouTube. For instance, Chris Parker has a channel for Parker Photographic, and he has been doing a series of tutorials on Text Effects in GIMP that I have enjoyed a great deal, and I have learned a lot from that, even though I have no present need to do any of these effects. They are still valuable to me for showing me how he uses the GIMP tools.

For this project I decided to use an outdoor image, so I went to the US Fish and Wildlife Service National Digital Library this time. All of the images I looked at were Public Domain, so I could use any of them freely, and they give the license information on the page for each photo so you can check it.

Image of license information on US Fish and Wildlife Service image.
Image of license information on US Fish and Wildlife Service image.

The image I selected was this one:

What I wanted to try was replacing the sky with something completely different. This should let me use a number of tools to get the result I want. Note that this is a *.jpg image, and thus does not have an Alpha Channel. So when I open this in GIMP, the first thing I need to do is add an Alpha Channel. Right-click on the Layer in the Layer Window, and select Add Alpha Channel.

To replace the sky there are several possible ways to do this. First of all, you could create a Layer Mask, and freehand draw black on the sky, making it transparent. That would work, but you would need to be careful about detail at the horizon. To get it right, you would need to zoom in to the image and use a small brush, and that might take a bit of time. But that is definitely doable. To use the zoom, the key to press is “Z”, and then you can use the Plus and Minus keys to zoom in or out as needed. This gets you a highly pixelated image:

Zoomed in section of image
Zoomed in section of image

Because of the anti-aliasing you have decisions to make about which pixels to erase, and it can take some time to go through this. There has to be a better way.

You could use the select tool, for instance. Given the rough horizon boundary, you would need to use the free select tool (or the Foreground Select). I would start by duplicating the layer, so that if this doesn’t work out I can just delete the duplicate and still have my original image. To duplicate the layer, go to the bottom button bar and select the button that has two over-lapping images on it. (Also note that you can hover over each button to see what it does.)

Layer button bar
Layer button bar

Clicking this button gives you a duplicate. And at this point it is a good idea to start naming your layers so you can keep track of what you are doing. To rename a layer, just double-click on the layer name and it becomes editable. I named the original image “Original”, and my duplicate “Working copy”. I added Layer Mask to the Working copy, and turned off visibility for my original. Now my layer window looks like this:

GIMP Layer Window after making changes
GIMP Layer Window after making changes

Since the last thing I did was turn off visibility, that Original layer is the active one now, as we can see because it has the white border around it. So we need to click on the Layer Mask to make it active. Then use the Selection tool. I found it useful to zoom in two notches before doing this. Remember that you are setting a series of control points around your selection to define the area, and you need to connect back to the first point. This will mean continuing the path of the selection outside of the image boundary so as to come back and make it a completed area boundary. You will know you are at the first point again when instead of the empty circles you get from control points you suddenly get a yellow solid circle. Click when you see that, and you should have a complete area created. Then it is a simple matter of making sure the foreground color is black (000000), and using the bucket fill tool. Note that if you forgot to turn off the visibility of the original image you may see it come through, and you will think you never did anything. Now I get this image:

GIMP image with sky removed using Select tool and Layer Mask.
GIMP image with sky removed using Select tool and Layer Mask.

This is not bad, but there are a couple of problems. On the right side and on the top you can see thin strips where I did not quite do my selection right. This can be fixed by going back to the Layer Mask and using the Paintbrush tool to paint over these strips with the Black color.

Another approach uses some different tools. As before, I loaded the image, added an Alpha Channel, made a Duplicate layer, but I did not add a Layer Mask to that layer. That will come in a later step. Then I selected the duplicate image (not the Layer Mask), and went to the Color menu and selected Desaturate to turn it into a black-and-white image:

Desaturated black-and-white image
Desaturated black-and-white image

Then, go to the Color menu again, and select the Curves Tool. This tool has many uses for adjusting color balance, but in this case I am using it to increase the Contrast of this black-and-white image.

GIMP Curves Tool
GIMP Curves Tool

This is a click-and-drag tool where you click the control points at the top and bottom and move them to make the change. With these settings on this photo, I got:

High-contrast image
High-contrast image

I then used my paintbrush, swapped my foreground color to White, and painted out the rest of the sky, then went back to Black to paint out the foreground.

Even higher contrast
Even higher contrast

Then one more time to the Curves tool to complete the separation:

GIMP Curves Tool second time
GIMP Curves Tool second time

And I now have this image>

Fully separated silhouette image
Fully separated silhouette image

We are getting there. But I need to switch the black and white, so I go to the Color menu again, and select Invert.

Inverted silhouette
Inverted silhouette

We are almost there. But so far I have done this all with a copy of the original image, and I need to get this onto a Layer Mask. And since I was doing all of this work on my first Duplicate copy, I need another one to apply the Layer Mask to. So I create another Duplicate, add a Layer mask to that duplicate layer, and then it is simply a copy-and-paste. Ctrl+C on the first duplicate image, then Ctrl+V on the Layer Mask. This will at first show up as a floating layer on the clipboard, but clicking the Anchor button on the bottom will get it securely in place.

Image with sky removed
Image with sky removed

I think this image has the most detail, so it is the one I prefer. And it gave us a chance to use a few more tools along the way. One thing to be careful of when you are working with multi-layer images is to know which layers are visible, and in what order. You can get really confused if you lose track of that.

Now, the final step is to add something new to the sky. First, I created a new layer, and named it Sky. And to fill it, I decided to use a radial gradient. Although some gradients have radial in the name, the fact is that most gradients can be applied as radials. To start, select the Gradient Fill tool, such as by going to Tools–>Paint Tools–>Gradient, or by using the hot key G. Then I chose Skyline as my gradient in the Gradient tab. Then for the tool property Shape I selected Radial. I then clicked on the center of my transparent Sky layer and dragged to fill the layer. With this done, I moved the layer down below the image so that it appears through the transparency, and I have this final picture:

GIMP Layer Mask Final Image
GIMP Layer Mask Final Image

I like the effect I got here, it has a kind of Science Fiction feel to it, like this is a moon orbiting a big planet in some alien system. I could go on to add some spacecraft, but this tutorial is long enough and has accomplished its purpose.

 Save as PDF