Lore

Mask-based high-frequency blend

The mask-based high-frequency blend is the step that turns the frequency-separated layers into the final image. It mixes the original image's high-frequency layer with the relit image's high-frequency layer under a mask. The result has the original subject's details everywhere except the generated parts.

Steps

  1. Take the high-frequency layers produced by Frequency separation for detail preservation (native ComfyUI) for the original and for the relit image.
  2. Feed both, plus the Segment Anything subject mask (see Subject masking and background replacement), into an image-blend-by-mask node.
  3. Merge the blended high-frequency layer on top of the relit image's low-frequency layer.

The low-frequency layer from the relit image brings the new lighting. The masked high-frequency layer restores the real product's text and texture. The background keeps its generated detail because the mask excludes it.

This is the final stage of relight-then-restore-detail-pipeline. It reuses the mask created earlier for compositing, so the segmentation does not have to be repeated.

The segmentation mask does double duty

The Segment Anything mask is used twice:

  1. It first isolates the subject for compositing onto the new background.
  2. It then decides where original high-frequency detail is used (the subject) and where generated detail is kept (everything else).

Because of the second job, the mask can be replaced to change where detail is preserved. See hand-drawn-detail-preservation-mask. If the image is upscaled, the mask must be resized too. See upscaling-placement-in-relight-workflow. For subjects that one pass cannot fully capture, see multiple-segment-anything-groups-for-complex-subjects.