ComfyUI Extension: ComfyUI Fast Mosaic Detector
High-speed and high-accuracy mosaic detection node for ComfyUI. Supports FAST, ACCURATE, and HYBRID modes with ROI refinement.
Custom Nodes (0)
README
ComfyUI Fast Mosaic Detector
š English | š ę„ę¬čŖ
High-precision & high-speed mosaic detection node for ComfyUI, featuring three modes (FAST / ACCURATE / HYBRID) and adaptive ROI refinement.
The HYBRID mode delivers near-ACCURATE precision at a fraction of the cost (7Ć faster).
š Overview
This node detects mosaic (pixel-block censorship / block-pattern noise) from images or video frames.
It outputs:
- A binary mask (0 or 255)
- Estimated mosaic block size
The detector combines:
- B-mode (FAST) ā lightweight, CUDA batch-optimized
- D-mode (ACCURATE) ā full histogram + gradient + grid-structure analysis
- HYBRID mode ā FAST ā ROI extraction ā ACCURATE refinement
HYBRID mode typically achieves:
ā
~85ā95% of ACCURATE precision
ā
~7Ć faster than ACCURATE
ā
Robust for video sequences
Workflow Screenshot

Input Video
https://github.com/user-attachments/assets/17b95590-77cc-435e-8df1-6cf04604c46b
Output Video (Image&Mask Blend)
https://github.com/user-attachments/assets/28731ee8-8a11-4971-af86-5be63b44a870
Example Workflow
You can find the example workflow here:
š¾ FastMosaicDetectorExample.json
ā Features
FAST Mode
- ~4 sec for 840[frames]x640x480[pixels] @RTX3090 (210fps)
- May over-detect
- Best for quick estimation
ACCURATE Mode
- ~420 sec for 840[frames]x640x480[pixels] @RTX3090 (0.5fps)
- Best precision
- Full-frame exhaustive scan
HYBRID Mode (Recommended)
- ~40ā60 sec for 840[frames]x640x480[pixels] @RTX3090 (14-21fps)
- Near-accurate quality
- Smart ROI refinement
- Recommended for most use cases
ā Inputs & Parameters
Below is the detailed explanation for every parameter in the node.
š¼ Image
image: IMAGE
Accepts single images or multi-frame batches.
š ACCURATE Mode (D-mode) Parameters
ā Skin Mask (HSV-based)
| Parameter | Description |
|----------|-------------|
| hsv_skin_h_low | Minimum hue for skin detection |
| hsv_skin_h_high | Maximum hue |
| hsv_skin_s_threshold | Minimum saturation |
Helps detect mosaics primarily appearing on skin regions.
ā Gradient Detection
| Parameter | Description |
|----------|-------------|
| gradient_threshold | Threshold for edge gradient magnitude |
| ratio_threshold | Gradient ratio threshold (block pattern strength) |
| gradient_band_height | Height of sampling windows |
| gradient_band_half_width | Half-width of sampling windows |
Controls how the algorithm identifies block-like structure.
ā Histogram / Grid Structure
| Parameter | Description |
|----------|-------------|
| histogram_threshold | Required peak ratio of histogram bin |
| mosaic_length_min | Minimum block size |
| mosaic_length_max | Maximum block size |
| intersection_margin | Allowed misalignment |
š Execution Mode
mode: FAST | ACCURATE | HYBRID
- FAST ā Quick, lower precision
- ACCURATE ā Highest precision
- HYBRID ā Recommended balance
ā Backend Selection
processing_backend: AUTO | CPU | TORCH
- AUTO ā intelligently selects optimal mode
- CPU ā forces CPU
- TORCH ā forces PyTorch/CUDA
š§ System Parameters
max_workers
CPU thread count for accurate mode.
Suggested: equal to physical CPU cores.
š¦ HYBRID Mode Parameters
fast_recall_boost
Boost recall of FAST detector (0.1ā2.0).
Higher ā more ROIs but may include noise.
roi_margin_px
Expand ROIs (recommended: 24px)
refine_logic
| Option | Meaning |
|--------|---------|
| replace | Replace FAST masks with refined results |
| union | Merge masks |
| intersect | Keep only overlapping |
Default: replace
ROI-related parameters
| Parameter | Description |
|----------|-------------|
| refine_frame_stride | Interval of refinement |
| roi_merge_dilate_px | Unifies ROIs |
| roi_max_count | ROI count limit |
| min_mask_pixels | Minimum mask size |
| frame_cover_threshold | Frame considered over-detected if exceeding ratio |
š© Adaptive ROI Downscaling
Automatically downscale large ROIs to accelerate refinement.
| Parameter | Description |
|----------|-------------|
| adaptive_roi_area_ratio | Shrink ROI when > this % of frame |
| adaptive_roi_min_side | Small ROIs never downscale |
| roi_downscale_large | Downscale rate (0.4ā1.0) |
šØ Aspect Ratio Filters
| Parameter | Description |
|----------|-------------------------------------------------------|
| roi_aspect_ratio_max | Ignore overly elongated ROIs (recommended range: 3-5) |
| roi_min_short_side | Ignore too-small ROIs |
Useful for rejecting window frames, bars, non-mosaic patterns.
ā Output
maskā 0/255 binary mosaic masksizeā detected mosaic block size
Fully batch-compatible with ComfyUI's image sequences.
ā Recommended Presets
Best Practical
mode = HYBRID
roi_downscale_large = 0.75
roi_aspect_ratio_max = 3.0
fast_recall_boost = 0.9
Highest Precision
mode = ACCURATE
Fast Preview
mode = FAST
ā Notes
-
Smaller mosaics require
roi_downscale_large = 1.0 -
For anime/non-skin content ā expand HSV ranges
-
If HYBRID misses regions ā increase
fast_recall_boost -
This node is fully compatible with ComfyUI-VideoHelperSuite for loading video frames and saving processed video outputs. If you plan to use this node with video workflows, installing VideoHelperSuite is strongly recommended.
ā License
MIT
ā Author
Takahiro Yano
ComfyUI Fast Mosaic Detector