Studio Yotsuba
Back to Node List

Threshold

threshold

Turns an image into a black/white mask using one cutoff or a neighborhood-aware cutoff for uneven lighting.

Reviewed
Guide available

Input Ports

NameTypeDescription
Image
input
Image
Required
Image whose bright, colored, or opaque parts will be separated.

Output Ports

NameTypeDescription
Mask
output
Image
Black/white mask. White is selected, black is not selected.

Parameters

NameTypeDefaultRangeDescription / Options
Source
source
Enum
OKLCH-L—

Choose what decides white or black: brightness, alpha, chroma, or an RGB channel. Use a color-selection node for circular hue ranges.

  • OKLCH-LOKLCH-L
    Use perceived brightness. Good when you want the result to match how bright it looks.
  • OKLCH-COKLCH-C
    Use how colorful the pixel is.
  • HSV-SHSV-S
    Use HSV saturation.
  • HSV-VHSV-V
    Use HSV value.
  • RGB-RRGB-R
    Use the red channel.
  • RGB-GRGB-G
    Use the green channel.
  • RGB-BRGB-B
    Use the blue channel.
  • AlphaAlpha
    Use alpha.
  • LuminanceLuminance
    Use Rec.709 RGB luminance.
Decision Method
method
Enum
Global—

Use one cutoff for clean generated images, or follow local brightness when a photo or scan has uneven lighting.

  • One ThresholdGlobal
    Use the Threshold value for every pixel. This is the existing behavior.
  • Follow Local BrightnessLocalMean
    Compare each pixel with its neighborhood. Use this for photos or scans with shadows and lighting gradients.
Threshold
threshold
Float
0.50–1 / step 0.01

Higher values select fewer pixels. Lower values select more pixels.

Neighborhood Radius
local_radius
Int
81–128

How far to average around each pixel. Start near 8 px; raise it when the lighting changes across a larger area.

Local Bias
local_bias
Float
0.05-0.5–0.5 / step 0.01

Subtract this from the neighborhood average. Positive values broaden white before Invert; with Invert ON, raising it rejects faint dark marks. Start around 0.03 to 0.10.

Boundary
boundary
Enum
Clamp—

Repeat edge pixels for a standalone image, or wrap to the opposite side for a seamless tile.

  • Repeat EdgeClamp
    Extend the outermost pixels. Use this for ordinary photos and scans.
  • Wrap for TilesWrap
    Read across opposite edges so a tile uses the same neighborhood at its seams.
Invert
invert
Bool
false—

Swap selected and unselected areas.

Alpha From Mask
alpha_from_mask
Bool
false—

Use the mask as transparency too. Black becomes transparent, white stays visible.

Ignore Fully Transparent
ignore_fully_transparent
Bool
true—

Keep fully transparent input pixels unselected, regardless of hidden RGB values.

Overview

Converts an image into a black-and-white mask of selected and unselected areas. Use it to extract only bright, nontransparent, or strongly red areas.

Raising threshold narrows the white range; lowering it widens the range.

Usage tips

  • The shortest mask routes are noise_generate → threshold for random spots and original image → threshold(Alpha) for a silhouette.
  • The go-to destinations are mask inputs on blend_by_mask, erase_by_mask, and mask-family nodes.
  • Start with the default OKLCH-L, perceived brightness, for selecting bright areas. Switch to RGB/HSV only when extracting a specific color component. For a circular hue range that crosses red, use a color-selection node such as color_select_replace.
  • Turn alpha_from_mask ON to make the black side transparent while creating the mask, producing a transparent-background black/white mask. It does not retain the original image colors.
  • ignore_fully_transparent keeps fully transparent input pixels unselected regardless of hidden RGB. Graphs migrated from v1 retain the former false setting for compatibility.
  • For a photo or scan with uneven lighting, switch to method=LocalMean. Start with local_radius=8 and local_bias=0.05; turn invert ON when extracting dark ink.
  • Radius is the scale of lighting variation. Keep it wider than the line being extracted but narrower than the broad shadow. Lower it when lines spread; raise it toward 16–32 when a large lighting gradient remains.
  • Bias is subtracted from the neighborhood average. Raising it broadens white before inversion. With invert ON for dark ink, raising it instead rejects faint marks and keeps only stronger dark differences.
  • Use boundary=Wrap for a tile so neighborhoods cross opposite edges. Keep Clamp for an ordinary standalone photo or scan.

Common pitfalls

  • The boundary flickers or looks unstable: values near the threshold are varying. Move threshold by ±0.1 to find a stable point, or smooth the distribution with a light gaussian_blur upstream.
  • One shaded half of a photo becomes the mask: the global cutoff is reading lighting as content. Switch to LocalMean, then start near radius 8–16 and bias 0.03–0.10.
  • Thin lines disappear in LocalMean: for dark lines with inversion, lower local_bias. If the mask spreads around a line, lower local_radius slightly as well.
  • All intermediate tones disappear: this node intentionally binarizes. Use posterize or gradient_map(Steps) to retain multiple stages.
  • Black and white are reversed: simply turn invert ON; no upstream change is needed.

Examples

  • Use Alpha to make a mask where only opaque pixels are white.
  • Use OKLCH-L to extract only luminous areas.
  • Turn invert on to select only shadows or dark areas.
  • Binarize a shaded paper scan with LocalMean(radius:8, bias:0.05, invert:ON) to remove the paper shadow while retaining dark ink as a white mask.

Related nodes

  • blend_by_mask / erase_by_mask — primary destinations for the mask
  • noise_generate — source for a random mask
  • posterize — reduce to several stages instead of two
  • color_select_replace — select and replace a specific color
Back to Node List