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.
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 Segment Anything mask is used twice:
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.