Thursday, March 25, 2010

How to selectively change colour of an object in GIMP?

A very useful skill in Photo manipulation is the ability to selectively alter an area. If you can selectively colour an area you can use the same technique to apply a whole range of effects to very precise aspects of your pictures.

Here we are going to use the Path tool to create a very precise selection and then use this to demonstrate how we can change particular aspects of an image using these selections.

In this particular instance we will be changing the colour of an object, but the selection of precise objects is a very important skill to have when you are editing pictures; and the better you get at it the better you will be able to change photographs in more elaborate projects.

Here we are going to colour the hydrant and leave the chains the original colour, using the Path and Layer Mask tools.

Step 1 Duplicate the background layer and rename it ‘Hydrant’ or something similar. Now, zoom in very close to the image, I’m going in to about 200% here, and select the Path tool (press ‘B’) and click somewhere along the edge of the object you want to select, here it is the fire hydrant. Then, click another point a little way further along the edge of the object, a straight line will join the two points, however it is very rare that a straight line will follow the edge of an object perfectly so we must curve the line slightly and make sure it hugs the object closely. There are several ways to do this, so here’s a quick run through how to do this:

selective colouring with GimpThe first way to curve a line with the path tool is to hold the left mouse button down when you click the next point and drag it around. Two boxes attached to the point by dotted lines will move, with the front one following your mouse; the box between the new point and your previous one determines the shape of the curve and the front one will determine the apex of the next one, but concentrate on getting the previous line right before worrying about the next one. Once you have the curve following the edge properly you can click the front box of the newest point again to drag it to the place you want your next bend independently of the other box. You can edit both boxes individually like this at any point by holding control while you click one of them.

selective colouring with GimpAnother way is to click a previous point and drag it around, this will move the line around maintaining the same apex as before but warping the line according to where you move it. This method is far less accurate but can be useful if your line is just a little off the edge of the object but doesn’t need too much adjustment.



selective colouring with GimpA third common method to adjust a path is to grip the line in the middle by clicking and holding the left mouse button and then moving the mouse. This will move the line whilst keeping the two corresponding points as they were, allowing you to drag the bend as you like to fit a new shape. The boxes responsible for that line will be shown again, so you can re-adjust these if you like to customise the line further.



selective colouring with GimpStep 2 Draw all the way around the hydrant, ignoring the chains at this time, so follow the edge of the hydrant itself and imagine where it would be behind the places where the chains cross in front of it.

If at any point you click to add a point and no line appears, hold control and click the point you want it to be joined to whilst the new point is active.

Draw a path all the way around the hydrant sticking as close as possible to the edge of the object, and when you come to the point where you are back to the first point you drew, hold control and click it to close off your path.

Step 3 Now your path is complete, open Select>From Path and you should have a selection that fits the hydrant perfectly. If you lose your selection at any point, don’t worry; the path will have automatically been stored in the Paths pane, and all you have to do to get it back is to right click the path and choose ‘Path to Selection’ once again.

selective colouring with GimpPress Ctrl and ‘I’ to invert your selection then press the delete key to remove the surrounding part of the layer so you are left with just the hydrant. Invert the selection once again and equip the Paintbrush tool and select a large brush and a colour of your choice. Fill the selected area and you should have something that looks like a complete fiasco.

Step 4 In the Layers pane, just above the list of all the layers in your image, there should be a drop-down menu currently displaying the value ‘Normal’. Click the arrow in this menu and a long list of choices will appear, each of these is a Layer mode that governs how Gimp will display this layer over the top of layers beneath it.

Each mode has its advantages and disadvantages and is suited to different tasks, so have a look at all of them by all means, but here we are trying to colour an object so the usual choices would be the hue, colour, multiply or overlay options, or sometimes soft light.

selective colouring with GimpThe overlay and multiply options only really work for colouring greyscale images however, so it’s a choice between hue and colour. Pick whichever you prefer the look of really, it’s a matter of taste at this point, and select that before pressing ctrl, shift and ‘A’ to deselect your hydrant.

selective colouring with GimpStep 5 Finally, to reveal the red of the chains and the rings connecting them to the hydrant, we will use the Layer Mask tool. In the Layers pane right-click on the layer you have coloured blue and select ‘Add Layer Mask’, stick with the default settings and choose a small, soft-edged Paintbrush.

Then put black at the front of your colour choices by pressing ‘D’ and paint the areas of the layer you want to make transparent.

Change the brush size on the fly by pressing the left and right square brackets to more accurately paint the chains and press ‘X’ to swap between white and black as your foreground colour to paint over any areas you make transparent that you do not want hiding.

selective colouring with GimpStep 6 Right click the Layer Mask in the Layers pane and select ‘Apply Layer Mask’ to flatten it to the layer and make the changes permanent, the right click the blue layer and select ‘Flatten Image’ to make the image into one single layer. Your picture is now ready for exporting as a Jpeg.