8.54. Порог

The Threshold filter transforms the current layer or the selection into a black and white image, where white pixels represent the pixels of the image where the value for the chosen Channel is in the threshold range, and black pixels represent pixels with a value outside the threshold range.

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

[Примечание] Примечание

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

8.54.1. Activating the Filter

There are different possibilities to activate this:

8.54.2. Параметры

Рисунок 16.214. Threshold filter dialog

Threshold filter dialog

Профили

«Presets» are a common feature for several Colors commands. You can find its description in Раздел 8.1.1, «Часто встречающиеся возможности команд «Цвет»».

Канал

This allows you to select which channel(s) will be used to apply the Threshold. The default is Value, which will use all color channels, but you can also choose to use a single channel: Red, Green, Blue and Alpha (only available when the layer has an alpha channel), Luminance, or RGB.

Linear histogram , Logarithmic histogram

These two buttons to the right of the Channel selection let you choose the type of histogram shown.

Пороговый диапазон

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 minimum and maximum input boxes, or by clicking 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 are white, and the others are black. Adjust the range to get the selection you want in white on black background. The Auto button can be used to automatically adjust the threshold.

Blending Options, Предварительный просмотр, Merge filter, Сравнение до/после

These are common features described in Раздел 8.1.1, «Часто встречающиеся возможности команд «Цвет»».

8.54.3. Работа с «Порогом» и «Быстрой маской» для создания маски выделения

Sometimes 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, and then use a Quick mask.

  1. First start decomposing your image into its RGB and HSV components by using the Decompose filter. A new grayscale image is created and the components are displayed as layers in the Layers 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.

    Рисунок 16.215. The original image, the decompose image and its Layers dialog

    The original image, the decompose image and its Layers dialog
    The original image, the decompose image and its Layers dialog
    The original image, the decompose image and its Layers dialog

  2. Запустите инструмент «Порог» для разложенного изображения. Перемещая чёрный курсор, настройте порог чтобы лучше всего изолировать элемент, который нужно извлечь. Скорее всего, результат будет не идеальным: улучшим его с помощью маски выделения, которую мы собираемся создать.

    [Предупреждение] Предупреждение

    Убедитесь в том, что выбрали именно нужный слой перед вызовом «Порога»: после открытия этого инструмента изменить слой уже невозможно.

    Рисунок 16.216. Выбранный слой после подгонки порога

    Выбранный слой после подгонки порога

    Мы получили лучший возможный контур для нашего цветка. Осталось несколько красных объектов, которые нужно убрать.


  3. Убедитесь, что изображение с выбранным слоем активно, и скопируйте его в буфер обмена с помощью Ctrl+C.

  4. Now, make the original image active. Click 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 Channels 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.

    Рисунок 16.217. Маска

    Маска

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

    Рисунок 16.218. Результат

    Результат
    Результат

    We used the Zoom to work at a pixel level, Free Select 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.