ComfyUI Extension
ComfyUI-Mosaic-Mask
ComfyUI-Mosaic-Mask is an automatic tool designed to detect and mask mosaic areas in input images.
okgo4/ComfyUI-Mosaic-Mask
Nodes1
On cloudLocal install
CategoryMosaic Masking
Stars10
Updated6 days ago
Nodes (1)
Readme
ComfyUI-Mosaic-Mask
ComfyUI-Mosaic-Mask detects regular mosaic grids in images and returns the detected areas as a ComfyUI mask.

Features
- Detects mosaic-like grid patterns with OpenCV template matching.
- Supports image batches.
- Returns a standard
0.0to1.0ComfyUIMASK. - Keeps the largest disconnected regions and optionally expands them.
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/okgo4/ComfyUI-Mosaic-Mask.git
python -m pip install -r ComfyUI-Mosaic-Mask/requirements.txt
Restart ComfyUI after installation.
Usage
Load example.json or add MosaicMask from the Mosaic Masking category.
top_n: maximum number of disconnected regions to keep, ordered by area.kernel_size: dilation kernel size. Use0or1for no expansion.threshold: template matching threshold. Higher values reduce false positives but may miss mosaics.min_grid_size/max_grid_size: bundled template range to search. The default is 10 through 20; lower the minimum to detect finer grids.
The node includes grid templates from size 5 through 20. It works best with axis-aligned, regular square mosaics. Rotated grids, perspective distortion, unsupported scales, and naturally repetitive textures may produce missed detections or false positives.
A smoothing node may still be added for softer mask edges, but it is no longer required to normalize the output.
Thanks
Special thanks to the mosaic_detector project.