Image Selector
Pick the Brightest Image Out of a Batch — and the Reddest, Greenest, or Bluest
- images
- IMAGE
The Image Selector node does exactly one thing: it looks at a batch of images, scores each one, and hands you back the single best-scoring image. It's a one-node pack called ComfyUI-HH-Image-Selector, and it's small enough that the honest first sentence is: this is a tutorial artifact, not a heavyweight tool. The README credits Chris Goringe's custom-node tutorial series, and the code reads like clean homework from that series - which is fine, because "iterate over a batch, compute a score, pick the max" is the single most useful pattern in ComfyUI to see in the wild.
Why would you reach for it? Mostly the brightest mode. If you're generating a grid of variations or sampling a video for frames, you sometimes just want the best-lit one handed to you as a single image. It's the kind of thing you'd otherwise do by manually previewing every frame and squinting. The three color modes are more of a demo - "reddest" is a fun party trick, not a production pipeline.
How it works
Under the hood it's embarrassingly simple, which is the point. Each image in the batch gets a mean of all its pixels (torch.mean over the flattened tensor). For brightest, that mean is the score. For the color modes, it computes the mean of a single channel - red, green, or blue - and divides it by the overall brightness, so a dim-but-saturated image can beat a washed-out bright one. Then it takes the index of the maximum score, slices that image out of the batch, and returns it as a batch of one.
A couple of mechanical details worth knowing. ComfyUI's image tensors are in B,H,W,C order, so the channel indexing works the way you'd hope. The "brightness" it measures is plain mean RGB, not a perceptual luminance - good enough for a tie-breaker, not a colorimeter. And it sends a message to the browser via the pack's tiny JS extension, which pops up a browser alert saying which image it picked.
The inputs that matter
There are only two, both required:
- images (
IMAGE) - your batch. Wire in anything that outputs multiple frames: a KSampler with a batch count > 1, a Load Video, a batch from a grid node. - mode (
enum) -brightest,reddest,greenest, orbluest.
One output, also IMAGE: the winner, as a single-image batch, ready to drop straight into a VAE decode or a Preview Image.
Installing it
It's the easiest possible install - no Python dependencies beyond torch (which ComfyUI already has), no model files, no requirements.txt to fight. Via ComfyUI Manager, search "ComfyUI-HH-Image-Selector". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/haohaocreates/ComfyUI-HH-Image-Selector
Restart ComfyUI. The node lives under the example category in the node menu - that trips people up, since it's not under "image" where you'd look.
Gotchas
The popup alert is the big one. Every time the node runs, your browser throws an alert dialog telling you which image it picked. In an interactive session that's almost charming; in a long batch run it's a modal wall you have to click through. If it drives you mad, delete js/image_selector.js - the node itself keeps working.
The other thing to know is what this node isn't: a general-purpose batch picker. If you need to select by filename, seed, or manually from a contact sheet, a fuller pack like rgthree or WAS's batch nodes will do more. For "give me the brightest frame out of this batch," this little node does exactly what it says, and reading its 40 lines of code is a legit way to learn how batch-wise image nodes think.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| mode | COMBO | 4 options: brightest, reddest, greenest, bluest |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |