Nodes/ComfyUI-LASED-mask/LASED Swarm Edge
ComfyUI Node

LASED Swarm Edge

LASED Swarm Edge

By MushroomFleet·Created 3 months ago·Updated 3 months ago· 0
LASED Swarm Edge
  • image
  • edge_map
  • mask
seed_x0
seed_y0
tolerance40.0
ants250
steps600
color_spacergb
handboth
beta4.0
epsilon0.05
seed0
modemasking
mask_threshold0.15
sticky_threshold0.20
freeze_after0
no_decayfalse
max_side512

Canny finds every edge in the image, and then you spend ten minutes fighting it. LASED Swarm Edge does the opposite: you click one color blob, and it comes back with the single contour around that blob. It's a different animal from the usual edge detectors, and for a specific job - "I want the boundary of this one region, not the whole picture" - it's the one you'll reach for.

LASED stands for Learning Ant Swarm Edge Detection, and the name isn't marketing. A seeded swarm of Snake-style ants spawns at your click point, adopts that pixel's color as its target, and is confined to that color region. The ants drift to the region's boundary and then wall-walk along it, depositing pheromone as they go. The accumulated edge-pheromone field is your edge map. Because the swarm follows the border of a color blob rather than intensity gradients, you get exactly the contour a human means when they point at something - which is why this pack's framing calls it an alternative to Canny/HED for region-based work.

The node takes an IMAGE plus a seed_x/seed_y pair - the "click", in input-image pixels, and it has to land inside the color region you want traced. Put it on the border and the swarm has nothing to lock onto. It outputs two things: edge_map (an IMAGE) and mask (a MASK). The edge map feeds LASED Overlay for the neon preview, or a ControlNet edge/scribble-style condition; the mask is your clean binary contour, ready for inpainting, compositing, or as a ControlNet scribble hint.

The few knobs that actually matter:

  • tolerance - the most important one. Colour tolerance for what counts as "the same region". Lower = tighter. If you're in lab color space, distances run smaller, so try 10–25 there.
  • color_space - rgb (default), weighted, or lab. lab traces one continuous boundary where RGB fragments under uneven lighting. If your blob looks clean but the contour comes out broken, try lab.
  • mode - classic or masking (default). Classic just thresholds the edge field at mask_threshold; the field evaporates by design, so the mask reflects the run's final state. Masking is the smarter Stage 2 pipeline: it latches any cell whose edge pheromone crosses sticky_threshold × the field maximum at deposit time, latched cells never decay, and when the run freezes a cleanup pass closes 1–2px gaps and drops stray-ant speckle. For anything you want to export, keep masking.
  • ants / steps - density and duration. More of both means denser, more complete contours, at a runtime cost.
  • max_side - the simulation runs downsampled to at most 512px on the longest side (0 = full resolution) and outputs are resampled back. Big images get noticeably slower; leave it unless you need pixel-perfect detail.

One more: seed. All randomness is seeded, so the same seed + params gives you identical output every time - batch item i runs with seed + i. That ties into the classic ComfyUI seed trap: check the widget's control_after_generate isn't left on randomize if you're trying to reproduce a run.

Install

Nothing exotic here. Through ComfyUI Manager, search for ComfyUI-LASED-mask, or:

cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/ComfyUI-LASED-mask

then restart ComfyUI. The nodes appear under the LASED category. There are no model downloads, and the only real dependency is numpy, which every ComfyUI install already ships. scipy is used when present for faster diffusion and component labelling, and the code falls back to pure numpy without it - you generally don't need to pip-install anything. Every node ships a drop-in example in workflows/; lased_smoke.json wires Swarm Edge → Overlay → save.

Where people get burned

  • Seed point outside the region. The swarm has no target colour to adopt, so you get noise instead of a contour. Click inside the blob.
  • Fragmented contour in uneven light. rgb splits one logical region into several. Switch color_space to lab.
  • Masking drops a contour you wanted. The cleanup keeps the dominant contour(s) and despeckles away the rest. If your target is a small or faint edge, lower sticky_threshold so more cells latch, or drop to classic and tune mask_threshold yourself.

One honest caveat: this pack is new and quiet - as of writing there's essentially no community war-story lore to lean on, so the README and a working example workflow are your friends. But the core is deliberately simple and deterministic, so it behaves predictably.

CategoryLASED

Inputs (17)

NameTypeDefaultDescription
imageIMAGE
seed_xINT00–16384Spawn point x in input-image pixels (the 'click').
seed_yINT00–16384
toleranceFLOAT40.01–250Colour tolerance (tau). Lower = tighter region. Lab distances run smaller; try 10-25 there.
antsINT2501–5000
stepsINT6001–20000Simulation ticks. More steps = cleaner, more complete contours.
color_spaceCOMBOrgb3 options: rgb, weighted, lab
handCOMBObothWall-following handedness; 'both' splits the swarm into clockwise and counter-clockwise cohorts.
betaFLOAT4.00.1–12Softmax temperature. Higher = greedier edge following.
epsilonFLOAT0.050–0.5Random-move floor; prevents the swarm freezing.
seedINT00–18446744073709550000
modeCOMBOmaskingclassic: MASK = thresholded edge pheromone. masking (Stage 2): MASK = sticky-latched, gap-closed, despeckled contour.
mask_thresholdFLOAT0.150.01–0.95classic mode only: threshold on the normalised edge map for the MASK output.
sticky_thresholdFLOAT0.200.05–0.6masking mode: latch a cell when its edge pheromone crosses this fraction of the field maximum.
freeze_afterINT00–20000masking mode: freeze (and clean) the mask after this many ticks. 0 = run all steps, then freeze.
no_decayBOOLEANfalsemasking mode: stop edge-pheromone evaporation entirely.
max_sideINT5120–4096Downsample the longest side to this for simulation (0 = full resolution). Outputs are resampled back.

Outputs (2)

NameTypeDescription
edge_mapIMAGE
maskMASK