Image Binarizer
The boring preprocessor that makes circle detection work
- image
- IMAGE
Image Binarizer is the quiet workhorse of the mr7thing/circle_pattern_processor pack. It does exactly one thing: convert an image to pure black and white based on a single threshold. No AI, one slider that matters. It's the node you run before the circle detector so OpenCV sees clean, high-contrast edges instead of gradients and noise.
Here's the thing about the Hough transform that Circle Pattern Processor runs: it loves clean edges and punishes clutter. A photo of pills with soft shadows will generate a pile of spurious detections. Push that same image through Image Binarizer first, and every pill becomes a crisp white disc on black - the exact input the detector wants. The author's own example workflow does precisely this: LoadImage → ImageBinarizer → CirclePatternProcessor.
How it works
The source is short and honest. It converts the input to grayscale, then applies a fixed binary threshold with OpenCV: every pixel at or above threshold becomes white, everything below becomes black. The result is returned as a 3-channel (RGB) image, so it plugs into any IMAGE slot downstream.
The one input that matters
- threshold (default 127, range 0–255) - the cutoff. Lower it and more of the image goes white; raise it and more goes black. For a clean pattern image, find the value that separates your objects from the background and leave it alone.
Output
A single IMAGE - the black-and-white result. Wire it straight into Circle Pattern Processor's image input, or use it anywhere you want a clean binary copy of a photo: mask prep, classic CV, anything that needs high contrast.
Install
You get it with the rest of the pack. In ComfyUI Manager, search "Circle Pattern Processor" and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/mr7thing/circle_pattern_processor
cd circle_pattern_processor
pip install -r requirements.txt
It's just numpy, opencv-python, and Pillow - no models to fetch. The node lives under image/pattern in the menu.
Gotchas
- The threshold is global and fixed - there's no auto-adaptive (Otsu) mode. If your image has uneven lighting, a single cutoff won't cleanly separate everything, and you'll see it in the output.
- Only the first frame of a batch is processed, and the input must be RGB.
- It returns an RGB image of white and black pixels, not a MASK tensor, so don't try to use it as a compositing mask.
It's a one-trick node, but it's the trick that makes the rest of the pack usable. If your circle detection comes back noisy, this is the first thing to put in front of it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold | FLOAT | 1270–255 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |