ComfyUI Node
Mask Sort By Position
A ComfyUI node in MultiMaskOps with 8 inputs and 2 outputs.
Mask Sort By Position
- masks
- masks
- debug_image
◄reference_point▾►
◄sort_left_to_righttrue►
◄sort_top_to_bottomtrue►
◄primary_axis_horizontaltrue►
◄flatten_before_sortfalse►
◄drop_below_thresholdfalse►
◄threshold0.50►
CategoryMultiMaskOps
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | A list of masks to sort by spatial position. | |
| reference_point | COMBO | Which point of each mask to sort by. 'centroid' = value-weighted center of the mask. 'extreme_point' = the outermost pixel along the primary sort direction (e.g. leftmost pixel when sorting left-to-right). | |
| sort_left_to_right | BOOLEAN | true | Horizontal direction. True = left to right, False = right to left. |
| sort_top_to_bottom | BOOLEAN | true | Vertical direction. True = top to bottom, False = bottom to top. |
| primary_axis_horizontal | BOOLEAN | true | Which axis sorts first. True = sort horizontally first, then vertically to break ties. False = vertical first, then horizontal. |
| flatten_before_sort | BOOLEAN | false | If enabled, each mask is binarized at 'threshold' before its sort point is computed. Only affects sorting; output masks are unchanged. |
| drop_below_threshold | BOOLEAN | false | If enabled (and not flattening), pixels below 'threshold' are ignored when computing the sort point (a thresholded ReLU). Only affects sorting; output masks are unchanged. |
| threshold | FLOAT | 0.500–1 | Cutoff used by flatten_before_sort and drop_below_threshold to decide which pixels count when computing each mask's sort point. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| masks | MASK | The input masks reordered by spatial position. |
| debug_image | IMAGE | A white image with a black dot marking each mask's sort reference point, in sorted order. For debugging. |