5.5. Threshold
| 5. Color Tools |

### 5.5. Threshold

The Threshold tool transforms the current layer or the selection into a black and white image, where white pixels represent the pixels of the image whose Value is in the threshold range, and black pixels represent pixels with Value out of the threshold range.

You can use it to enhance a black and white image (a scanned text for example) or to create selection masks.

| Note
As this tool creates a black and white image, the anti-aliasing of the original image disappears. If this poses a problem, rather use the Levels tool.

#### 5.5.1. Activating the Tool

There are different possibilities to activate the tool:

- You can access this tool from the image menu through Tools → Color Tools → Threshold,,

- or through Colors → Threshold,

- or by clicking on the icon in Toolbox if this tool has been installed in it. You can do that through the Tool dialog.

#### 5.5.2. Options

Figure 13.133. Threshold tool options

Presets

  You can save the color settings of your image by clicking the Add settings to favourites button

  The button opens a menu:

  Figure 13.134. Preset Menu

  which lets you Import Settings from File or Export Settings to File, and gives you access to the Manage Save Settings dialog:

  Figure 13.135. Manage saved Settings Dialog

Threshold range

  The Threshold tool provides a visual graph, a histogram, of the intensity value of the active layer or selection. You can set the threshold range either using the input boxes or clicking button 1 and dragging on the graph. It allows you to select a part of the image with some intensity from a background with another intensity. Pixels inside the range will be white, and the others will be black. Adjust the range to get the selection you want in white on black background.

Preview

  The Preview toggle allows dynamic updating of the active layer or selection while changes are made to the intensity level.

#### 5.5.3. Using Threshold and Quick Mask to create a selection mask

That's not always the case, but an element you want to extract from an image can stand out well against the background. In this case, you can use the Threshold tool to select this element as a whole. Grokking the GIMP described a method based on a channel mask, but now, using the Quick mask is easier.

1. First start decomposing you image into its RGB and HSV components by using the Decompose filter. A new grey-scaled image is created and the components are displayed as layers in the Layer Dialog. These layers come with a thumbnail but it is too small for an easy study. You can, of course, increase the size of this preview with the dialog menu (the small triangular button), but playing with the “eyes ” is more simple to display the wanted layer in the decompose image. Select the layer that isolates the element the best.

   Figure 13.136. The original image, the decompose image and its Layer Dialog

2. Call the Threshold tool from the decompose image. By moving the black cursor, fit threshold to isolate the best the element you want to extract. This will probably not be perfect: we will enhance the result with the selection mask we are going to create.

   | Warning
   Make sure you have selected the right layer when you call the Threshold tool: when it is opened, you can't change to another layer.

   Figure 13.137. The selected layer after threshold fit

   We got the best outline for our flower. There are several red objects which we must remove.

3. Make sure the image displaying the selected layer is active and copy it to the clipboard with Ctrl+C.

4. Now, make the original image active. Click on the Quick Mask button at the bottom-left corner of the image window: the image gets covered with a red (default) translucent mask. This red color does not suit well to our image with much red: go to the Channel Dialog, activate the “Quick mask” channel and change this color with the Edit Channel Attributes. Come back to the original image. Press Ctrl+V to paste the previously copied layer.

   Figure 13.138. The mask

5. Voilà. Your selection mask is ready: you can improve the selection as usually. When the selection is ready, disable the Quick mask by clicking again on its button: you will see the marching ants around the selection.

   Figure 13.139. The result

   We used the Zoom to work at a pixel level, the Lasso to remove large unwanted areas, the pencil (to get hard limits), black paint to remove selected areas, white paint to add selected areas, especially for stem.

5.4. Brightness-Contrast tool |  | 5.6. Levels