ComfyUI Node
BD Crop To Mask
Crop an image to the bounding box of its active region, add proportional padding, optionally enforce a square crop, then resize to a target resolution. Use channel='R' to center/size the crop on lips only (not teeth/tongue). Use fixed_size_px to force the same crop size across all visemes for consistent UV atlas framing — lips always appear at the same scale and center position.
BD Crop To Mask
- image
- mask
- cropped
- crop_box
- status
◄channelR►
◄threshold0.05►
◄padding_pct0.15►
◄fixed_size_px0►
◄squaretrue►
◄output_size512►
◄resize_modefit►
◄fallbackfull_image►
Category🧠BrainDead/Segmentation
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| maskopt | MASK | — | |
| channelopt | COMBO | R | Which image channel drives the bounding box detection. all — union of R/G/B (lips+teeth+tongue) R — lips only (recommended for consistent atlas framing) G — teeth only B — tongue only A — alpha/depth channel |
| thresholdopt | FLOAT | 0.050–1 | Pixel value above which a pixel counts as active. |
| padding_pctopt | FLOAT | 0.150–0.5 | Padding on each side as a fraction of the larger bbox dimension. 0.15 = 15%% per side. Used when fixed_size_px=0. |
| fixed_size_pxopt | INT | 00–4096 | When >0, force the crop to exactly this square size (in source pixels) centered on the detected channel centroid. Use the SAME value across all 7 visemes for a consistent atlas — every cell covers the same mouth region at the same scale. Tip: run once with fixed_size_px=0 to see crop sizes in the status output, then set fixed_size_px to the largest bbox+padding size. |
| squareopt | BOOLEAN | true | Enforce a square crop. Ignored when fixed_size_px>0 (already square). |
| output_sizeopt | INT | 51264–4096 | Output resolution (square). |
| resize_modeopt | COMBO | fit | fit — scale to fill output_size preserving aspect ratio, then pad edges with black. Lips keep their natural shape; horizontal visemes get top/bottom bars, vertical visemes get left/right bars. stretch — squash to exact output_size (may distort lip shape). |
| fallbackopt | COMBO | full_image | 2 options: full_image, center_crop |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cropped | IMAGE | — |
| crop_box | STRING | — |
| status | STRING | — |