VS Normalize White Plate
'white' is never white, and difference matting can't forgive it
- image
- bottle_mask
- image
- report
Ask an image model for a bottle on a white background and you'll get something around 0.94 grey with a soft gradient and a faint shadow - which looks fine to your eye and is completely unusable to a difference matte. The matte works by subtracting one plate from another, so if the "white" background isn't exactly 1.0, every background pixel comes back as a sliver of semi-transparent grey. VS Normalize White Plate fixes that: measure the backdrop, divide it out, force everything outside the bottle to a hard 1.0.
The mechanism
It samples the far background - pixels that survive being outside a dilation of your bottle mask by sample_margin_px - takes the per-channel median (not the mean, which is the right choice, since the median ignores the cap's specular or a stray highlight), clamps it to a floor of 0.5 so a black-ish plate can't blow the division up, and divides the whole image by it. Then it sets every pixel where the mask is at or below outside_threshold to exactly 1.0.
That last step matters more than the division. A divided gradient backdrop still has tiny variations; the flat-1.0 override guarantees the true background is a constant, which is what a matte needs to see as "no alpha here". The report tells you what it measured:
{ "measured_background_rgb": [0.9371, 0.9368, 0.9302] }
A neutral-ish reading near 0.93 is normal. A strong colour cast is informative - that's the model tinting your backdrop, and you get to decide whether dividing it out is enough or whether the image needs a re-roll.
The inputs
image is the generated white plate; bottle_mask is the aligned silhouette from VS Align To Reference. outside_threshold (default 0.02) is the mask value below which a pixel counts as background and gets forced to 1.0 - leave it low unless your mask has soft edges you want to preserve as partial. sample_margin_px (default 24) is how far outside the bottle you have to be before the node will sample. Give it more margin than you think: the bottle's own shadow and the soft contact shading near the base are not background, and sampling them would drag the measured white down.
Outputs are image and report. The image goes on to VS Difference Matte as the white plate.
Install
ComfyUI Manager → VS Glass Matte. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/andrewclass1/comfyui-vs-glassmatte
# restart ComfyUI
Nothing to pip install - this pack is deliberately torch-and-numpy-only, dependencies = [] in pyproject.toml. No model files.
Where people get burned
There's one hard error in this node and it's explicit: ValueError("No background pixels to sample; lower sample_margin_px.") - raised when the far region has fewer than 100 pixels. That happens when the bottle fills the frame, or when you've left sample_margin_px high on a tight 9:16 crop. The error message tells you the fix; take it.
The subtler problem is a plate that's already clipped. If the model gave you a pure-white backdrop with a hard studio look, there's no gradient to remove and nothing to complain about - but if it gave you a blown-out backdrop at 1.0 while the bottle's edges sit at 0.98, the matte will find a thin bright rim where there shouldn't be one. The tell is a white fringe on the silhouette in VS Composite Over on the red background. When you see that, the issue is generated edge quality, not this node; regenerate with the bottle masked in (the pack's label-lock stage) rather than trying to clip your way out.
Also worth knowing: forcing outside pixels to 1.0 happens at outside_threshold, so a bottle mask with soft, feathered edges gets its outer ring flattened to white. For the plate pipeline that's exactly what you want. Just don't reuse the normalised plate anywhere you needed a soft mask.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| bottle_mask | MASK | — | |
| outside_threshold | FLOAT | 0.0200–0.5 | — |
| sample_margin_px | INT | 240–512 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| report | STRING | — |