ComfyUI Node
Mask Refine (K-Means)
A ComfyUI node in XJNodes/segs with 5 inputs and 1 output.
Mask Refine (K-Means)
- image
- mask
- refined_mask
◄n_clusters3►
◄grow_pixels50►
◄similarity_threshold0.50►
CategoryXJNodes/segs
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| n_clusters | INT | 32–10 | Number of k-means clusters to use for color segmentation. More clusters can capture more color variation but may be slower. |
| grow_pixels | INT | 500–200 | Maximum pixels to grow the mask. Use with similarity_threshold to control how far the growth extends. |
| similarity_threshold | FLOAT | 0.500–1 | Threshold for including similar clusters (0-1). Higher = more strict. Use to include clusters that are close in color to the original mask, for smoother boundaries. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| refined_mask | MASK | — |