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
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
画像
input
Image
Required
明るい部分、特定の色成分、透明でない部分などを分けたい画像です。

Output Ports

NameTypeDescription
マスク
output
Image
白黒マスクです。白が選ばれた部分、黒が選ばれなかった部分です。

Parameters

NameTypeDefaultRangeDescription / Options
基準
source
Enum
OKLCH-L

白黒を決める基準です。明るさで分けるなら OKLCH 明度、形だけなら Alpha、色相範囲なら色域選択ノードを使います。

  • OKLCH 明度OKLCH-L
    見た目の明るさで判定します。影やハイライトなど、目で見た明暗に合わせたい時に使います。
  • OKLCH 彩度OKLCH-C
    色の鮮やかさで判定します。くすんだ色と鮮やかな色を分けたい時に使います。
  • HSV 彩度HSV-S
    HSV の鮮やかさで判定します。一般的な色相・彩度・明度の感覚で選びたい時に使います。
  • HSV 明度HSV-V
    RGB の一番明るいチャンネルを基準にします。光った色や原色の強さを見たい時に使います。
  • RGB 赤RGB-R
    赤の強さで判定します。赤みだけを抜き出したい時に使います。
  • RGB 緑RGB-G
    緑の強さで判定します。緑成分だけを抜き出したい時に使います。
  • RGB 青RGB-B
    青の強さで判定します。青成分だけを抜き出したい時に使います。
  • アルファAlpha
    透明度で判定します。不透明な形だけをマスクにしたい時に使います。
  • 輝度Luminance
    RGB から計算した明るさで判定します。OKLCH より単純な白黒変換に近い結果が欲しい時に使います。
判定方法
method
Enum
Global

生成画像など明るさが揃った素材は『画像全体で1つ』、影や照明ムラのある写真・スキャンは『周辺の明るさに追従』を使います。

  • 画像全体で1つGlobal
    全ピクセルを同じしきい値で判定します。従来と同じ結果です。
  • 周辺の明るさに追従LocalMean
    各ピクセルを周辺平均と比べます。影や照明ムラのある写真・スキャン向けです。
しきい値
threshold
Float
0.50–1 / step 0.01

上げるほど白になる範囲が狭くなり、下げるほど広く選ばれます。

周辺半径
local_radius
Int
81–128

各ピクセルの周囲を平均する距離です。まず8px前後、広い影や照明ムラには16〜32pxへ上げます。細い線が消える時は下げます。

局所バイアス
local_bias
Float
0.05-0.5–0.5 / step 0.01

周辺平均からこの値を引きます。正へ上げると反転前の白が広がります。暗い線を反転で抜く時は、上げるほど薄い線を除外します。まず0.03〜0.10が目安です。

端の扱い
boundary
Enum
Clamp

単体の写真は端を繰り返し、上下左右につなぐ素材は反対側へ回り込ませます。

  • 端を繰り返すClamp
    最外周のピクセルを外側へ繰り返します。通常の写真・スキャン向けです。
  • 反対側へ回り込むWrap
    反対側のピクセルを周辺として使い、タイル境界でも同じ判定をします。
反転
invert
Bool
false

選ばれる部分と選ばれない部分を入れ替えます。

マスクを透明度にする
alpha_from_mask
Bool
false

白黒マスク自体を透明度にも使います。黒い部分は透明、白い部分は表示されます。元画像の色は保持しません。

完全透明を無視
ignore_fully_transparent
Bool
true

完全透明な入力ピクセルは、内部のRGB値にかかわらず選択しません。

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
Threshold — PixPipeline Node Reference