MorphologicSkeletoning
Reduce a fat mask to a one-pixel line — for measuring, tracing, and contour work
- src
- IMAGE
Some nodes are clearly built for a niche, and this is one. MorphologicSkeletoning takes a shape and strips it down to its centerline - a one-pixel-wide skeleton that traces the "spine" of the mask. Think of it as the outline of a river drawn as a single curving line down the middle, instead of the whole river shape. It's the morphological operation of thinning, and it's a genuinely hard thing to do well, which is why it's worth having instead of hacking it together.
The use cases are the computer-vision-flavored ones: you want the centerline of a road, a crack, a blood vessel, a stroke of paint, or any elongated shape so you can measure its length, trace along it, or feed it to a contour/path node. The pack's own framing is masks and collages, and this fits the "analyze my mask geometry" corner of that.
How it works
The implementation is telling: it doesn't reimplement thinning - it calls scikit-image's skeletonize (the skimage.morphology module). The image is binarized at 127, skeletonized, and scaled back to 255. That dependency is the reason this node sits in a pack whose requirements include scikit-image - most of the other nodes only need OpenCV. The output is a thin white line on black, still an IMAGE, so it plugs straight into your existing mask/contour pipelines.
The input and output
One input: src (IMAGE). One output: IMAGE. That's the whole interface - the pack assumes you've already got the shape you want thinned and don't need knobs for it.
Where it fits
In practice this node is a prep step. Skeletonize a mask, then feed the result to the pack's contour nodes (Contours, Contour To Mask, Filter Contour) to get clean paths, or use it to check whether a mask is a single connected shape vs. several blobs. It also pairs with the distance-transform and morphology utilities in this same pack if you're doing geometry analysis on masks rather than just compositing them.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes
restart, or use ComfyUI Manager → search comfyui_bmad_nodes. This is one of the nodes where the scikit-image requirement actually matters - if you cloned manually and skipped requirements, this is the node that'll throw an import error while the rest of the pack loads fine. Install the pack's requirements.txt (or let Manager do it) and you're set. No model downloads.
The one thing to know
Skeletonization is sensitive to noise in the input. A few specks on your mask turn into little star-shaped branches in the skeleton, which will confuse anything downstream that expects one clean line. Run the mask through the pack's MorphologicOperation (OPEN, then CLOSE) before skeletonizing and your skeleton will be dramatically cleaner. It's a two-node pipeline, but the first node is doing half the work.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| src | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |