Lore

Subject masking and background replacement

Selecting the generated subject with Photoshop's quick selection tool and placing that selection as a mask over a different, upscaled background.

How to apply

  1. Select the entire subject with quick selection.
  2. Apply the selection as a mask on the upscaled background layer. See Prompt-based upscaling with Nano Banana Pro.
  3. Choose a background whose lighting direction and color mood already match the subject, so that elements such as the bridge position and the light line up without relighting.

Notes

This is a manual Photoshop step that complements generation. See Generate, then correct: alternating model output with Photoshop edits. Matching light and color beforehand follows the same idea as lighting-harmony-block, applied by choosing the plate instead of by writing the prompt.

Choosing a replacement background

A replacement background is easy to composite when its lighting direction and color mood already match the generated scene. In the host's example, the position of the bridge in the background could be matched as well, so the mask edge needed little fixing.

Generating or choosing a background that already agrees with the subject's light saves color-matching work afterwards; see Generating a custom background to use as a reference image.

A sharp, upscaled background pasted behind the subject still looks unrealistic until depth of field is rebuilt; see Field Blur with pins for depth of field.

Segment Anything with GroundingDINO in the relight workflow

In the ComfyUI relight workflow (Staged relight-then-restore-detail pipeline for product photography), subject masking uses a Segment Anything group driven by GroundingDINO. A text noun names the subject, for example 'bottle', 'bag' or 'microphone'. It masks the original subject, which is then merged on top of the generated background (Depth and lineart background generation) to give the blended composite that goes to IC-Light relighting (Stable Diffusion 1.5).

Apply: change the noun in the GroundingDINO node to match the subject in each new image.

The same mask is reused later as the blend mask in Mask-based high-frequency blend, so the subject is segmented once. Segmentation can miss parts of complex subjects (see Limits of the IC-Light + frequency-separation workflow).