HT Multi Mask Dilate
One mask, many subjects, zero manual cropping
- image
- mask
- cropped_masks
- cropped_images
- widths
- heights
- scale_factors
- is_multi_region
- region_count
- region_indices
You've got a mask that covers several separate things - three faces in a group photo, five product shots on a sheet, a comic page with multiple panels. Standard ComfyUI mask tools treat it as one blob. HT Multi Mask Dilate, from HommageTools, splits it into its connected regions, crops each one out of the image, and hands you the whole set as aligned batches. It's the "extract every subject at once" node.
How it works
The mechanism is textbook computer vision: it labels connected components in the mask using scipy.ndimage (so if you hit an ImportError on scipy, that's the reason - more below), finds the bounding box of each component, pads it, and crops both image and mask to that box. Then it rescales each crop toward the pack's standard buckets - 512, 768, 1024 - according to the scale_mode you pick.
The inputs that matter:
- image and mask - the source pair. Both required, same dimensions.
- scale_mode -
Scale Closest(nearest bucket),Scale Up,Scale Down, orScale Max(always 1024). This decides how big each cropped region ends up, which matters a lot for downstream processing like per-face refinement. - connectivity -
4-connectedvs8-connected. 8-connected (default) treats diagonally-touching pixels as the same region, which is usually what you want for organic subjects; 4-connected splits harder and can break one subject into pieces. - padding - extra border around each crop, default 64. Leave room for faces/hands to not be clipped.
- max_regions - cap on how many regions it'll chase, default 10.
What comes out
The outputs are aligned batches, which is the nice part:
- cropped_masks and cropped_images - the crop of every region, stacked as a batch.
- widths, heights, scale_factors - per-region metadata.
- is_multi_region, region_count, region_indices - flags and indices you can feed into a conditional or a switch.
That batch layout is what makes it usable: wire cropped_images into a batch-capable sampler or upscaler and process every face at once, instead of hand-plumbing a loop. Pair it with something like the pack's HT Detection Batch Processor for the full "find, crop, process, recombine" pipeline.
Installing it
Part of HommageTools. ComfyUI Manager → search HommageTools, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ArtHommage/HommageTools.git
cd HommageTools && pip install -r requirements.txt
Then restart. Gotcha: the node imports scipy, but scipy is not in the pack's requirements.txt. If you get a ModuleNotFoundError: scipy when the pack loads, install it yourself:
pip install scipy
Where people get burned
- Empty or near-empty masks produce zero components, and the node's behavior on that path is best handled by checking
region_countbefore using the crops. - All crops get resized to the same bucket size, which can distort wildly different aspect ratios. If one region is tall and another wide,
Scale Closestis the least surprising choice. - The masks and images are resized together, so they stay aligned - that's the part that makes this safe to chain into mask-guided sampling.
For batch subject extraction it saves real hours. Just remember the scipy install.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| scale_mode | COMBO | Scale Closest | 4 options: Scale Closest, Scale Up, Scale Down, Scale Max |
| padding | INT | 640–256 | — |
| connectivity | COMBO | 8-connected | 2 options: 4-connected, 8-connected |
| max_regions | INT | 101–100 | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| cropped_masks | MASK | — |
| cropped_images | IMAGE | — |
| widths | INT | — |
| heights | INT | — |
| scale_factors | FLOAT | — |
| is_multi_region | BOOLEAN | — |
| region_count | INT | — |
| region_indices | INT | — |