From Filter Forge Wiki
We know threshold operations from various image editing software. Based on a source and a threshold, it selects which of two outputs to use. However in Filter Forge the threshold concept has been extended. This article explores some of the possibilities and uses of the Threshold component.
The component itself is fast and possess quite a few different applications. Knowing these can mean not only a faster filter but also more simple constructions and an easier filter making process.
About the Threshold Component
In the documentation on the Threshold component, you can read the basic description of the inputs and functionality of the component. Here we provide additional information.
When you connect a non grayscale input to the Source input, the source is internally desaturated using simple average, i.e. (Red + Green + Blue) / 3 (not lightness as specified in the documentation). The same is true for the Threshold and Smooth inputs. If you want a weighted average or another type of grayscale conversion, you must insert this operation in between your source and the threshold input (Source, Threshold and Smooth) you want to connect to.
The Smooth input is one of extensions FF adds to the basic threshold concept (as known from e.g. Photoshop). Based on the evaluation of Source and Threshold, Smooth allows you to mix the Low and High sources in a transition range it specifies: Smooth = 0 will keep the Low and High sources strictly seperated, Smooth = 100 will mix Low and High using the outcome of the evaluation as weight (or "Opacity"). You can read more about this in the Filter_Construction:_Clipping#Threshold_Clipping Clipping article.
Contrast and Mask Construction
The most obvious use of the Threshold component is probably high contrast-like adjustments. With grayscale sources the Threshold can perform contrast increasing adjustment similar to using the Contrast component (positive contrast adjustment). Use the following settings (default settings):
- Threshold = 50
- Low = black
- High = white
Now the Smooth input works as an inverse positive contrast input (i.e. 0 = full contrast, 100 = unchanged contrast).
The cool thing is that we can adjust the graypoint (or midpoint) of the contrast adjustment by changing the Threshold settings: The standard Contrast component always uses a fixed graypoint at 50, but this really depends in the source image material.
The graypoint of e.g. the Image Component source is the overall average intensity of the image. In other words, if we hook up the Average Color component to the Threshold input, we get a smarter image contrast adjustment construction.
The Threshold component is very useful when you want to create solid masks for blending operations later on. Typically you would set Smooth = 0 and the find threshold that gives your mask wanted shape and size.
Tone Mapping & Tinting
The Threshold component can be used for Duo Tone Mapping, Shadow Tinting and Highlight Tinting. By changing the Low input to a dark, but saturated color, we control the shadow tone, and similar by changing the High input to a bright saturated color, we control the highlight tone.
To perform tinting, we need to connect either Low or High input with the original colored Source input source (e.g. the Image component). By adjusting Smooth and Threshold we can control the tinting contrast and amount of tinting.
The Threshold component can be used to perform interpolation between two sources using a weight, similar to how the Blend component blends foreground on background via opacity.
To make the Threshold component work this way, set Threshold = 50, Smooth = 100 and use Source as opacity, Low as background and High as foreground. While it may not be obvious, there is a difference in functionality from the Blend component: no alpha blending is performed, i.e. the alpha of the High input does not have any influence on the result, and moreover the alpha is interpolated like the other channels.
This makes the "blending" operation slightly more efficient, and if the Source ("opacity") contains large areas of pure white or black, the performance difference can be quite significant, since for these areas either Low or High is used, but not both.
Threshold and Smooth can additionally be used to "preprocess" the weight or opacity source (the Source input).
Lighten / Darken with selectable output
The Low and High sources are ONLY used when Source either lower or higher than Threshold (and outside of Smooth transition range). This means that the unused Low or High source branch is completely skipped, which can be taken advantage of when optimizing filters. Filter_Construction:_Clipping covers this topic in depth.