Nodes/pixel-sorting/Pixel Sort Analyze
ComfyUI Node

Pixel Sort Analyze

The node that stops you guessing your threshold

By rockerBOO·Created 7 months ago·Updated 7 months ago· 2
Pixel Sort Analyze
  • image
  • bright_subtle
  • bright_moderate
  • dark_subtle
  • dark_moderate

The single most common reason a pixel-sorted image looks like garbage is a bad threshold. The ASDF defaults this pack inherits (127 for bright, 223 for dark) were tuned for a 2010 Processing sketch, not your photo, and they sort way too much of most images. Pixel Sort Analyze exists to fix that: feed it the image you're about to sort and it reads the actual brightness distribution and hands back four suggested threshold values as INT outputs. It doesn't sort anything itself - it's a measurement node, the pixel-sorting equivalent of an upscaler's "analyze" button.

It lives at image/analysis in the same rockerBOO/pixel-sorting pack as the main Pixel Sort Effect node, so it costs you nothing extra. Install once, get both.

How it works

Under the hood it runs the pack's analyze() function on your image: it walks every pixel, computes lightness and pixel-value statistics (mean, median, the 25/50/75 percentiles), then maps those percentiles into suggested thresholds. Because it's a per-image measurement, the same "bright" sort on a dark moody shot and a bright daylight scene gets two very different, sensible thresholds instead of one wrong constant.

The four outputs map to percentiles of your image's brightness distribution:

  • bright_subtle - the 75th percentile: sorts only the brightest quarter of pixels
  • bright_moderate - the median: sorts the brighter half
  • dark_subtle - the 25th percentile: sorts only the darkest quarter
  • dark_moderate - the median again, for dark-mode sorting

"Subtle" is nearly always the right place to start. The whole point is that you shouldn't be dialing thresholds blind - the README's own advice is to analyze first, start subtle, then nudge up if you want more chaos.

Wiring it up

Its only input is an image, and it analyzes the first frame of the batch. This is where it earns its keep: the outputs are plain INT sockets, so you drag wires from bright_subtle straight into the bright_value input on a PixelSorting node and the threshold is correct for your image, no guesswork. Swap the source image and the suggestion updates automatically.

Load Image → PixelSortAnalyze
                 │
                 └── bright_subtle → PixelSorting (interval=bright, sorting=hue)
                                        └── → Preview

One thing to note: it only exposes bright and dark suggestions, not the white/black/threshold modes' thresholds, even though the underlying analyzer computes more. So it's the companion for the two interval modes you'll actually use 95% of the time. If you're a random or edges person, this node is just a sanity check that your thresholds aren't insane - and honestly, you'll mostly skip it.

Installing it

Same as the parent pack:

cd ComfyUI/custom_nodes/
git clone https://github.com/rockerBOO/pixel-sorting.git
cd pixel-sorting
pip install -e .
# restart ComfyUI

Or search "Pixel Sorting" in ComfyUI Manager. Dependencies are trivial - just pillow, which ComfyUI already ships - so there's no model download and no heavy install step. If the node doesn't show up, the usual suspects apply: restart ComfyUI completely, and check the console for an import error, because this pack loads its code from its own src/ folder and a partial clone or missing edit of the tree will break it.

Categoryimage/analysis

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (4)

NameTypeDescription
bright_subtleINT
bright_moderateINT
dark_subtleINT
dark_moderateINT