ComfyUI Node

Select Focus Point

Pick the pixel that stays sharp, then let depth do the rest

By EricRollei·Created 8 months ago·Updated 4 months ago· 19
Select Focus Point
  • image
  • mask
  • focus_point
  • preview
x_percent50.0
y_percent50.0

In the Refocus pipeline, everything downstream wants one answer: where is the focal plane? SelectFocusPoint is the node that answers it. It produces a FOCUS_POINT - essentially an (x, y) coordinate plus image dimensions - that you hand to ComputeDefocusMap, which then blurs everything proportionally to how far it sits from that point in depth. Focus on the subject's face and the background melts; focus on the background car and the subject goes soft. One coordinate, two completely different photographs.

Two ways to pick the point

The boring way: leave the mask disconnected and drag the two sliders. x_percent and y_percent take 0–100 percentages of the image width and height (50/50 = dead center). Fine for quick tests.

The fun way: connect a mask and the node computes the weighted centroid of that mask - its center of mass - and that becomes the focus point. The mask always wins over the sliders when it's present and non-empty, so this is the setup you want for anything interactive.

Where does a mask come from? The README's recommended chain is Impact Pack's SAM Detector or MaskPainter: click or paint the thing you want in focus, it produces a mask, this node finds its center. That's a genuinely nice workflow - click on a face, get a portrait-depth-of-field version. The preview output shows you exactly where it landed, with a red crosshair overlaid on the image, so you're never guessing.

Inputs and outputs

  • image (required) - the photo you're refocusing.
  • mask (optional) - from SAM, MaskPainter, or any mask source. Centroid becomes the focus point.
  • x_percent / y_percent (optional, 50 each) - ignored if a non-empty mask is connected.

Outputs: focus_point (FOCUS_POINT → ComputeDefocusMap) and preview (IMAGE → any preview node, so you can see the crosshair).

Gotchas

  • An empty or all-black mask silently falls back to the percentage sliders. The node prints a warning to the console, but the graph won't error - so if your focus point keeps jumping back to center, your mask is empty. Check it with a mask preview.
  • The focus point is clamped to image bounds, so off-by-one slider values won't crash anything.
  • Remember this is a plane, not a region. Everything at the same depth as your point stays sharp, not just the object you clicked. That's correct behavior for the defocus math - it's how real cameras work.

Install

It's part of the Refocus pack: ComfyUI Manager → search "Refocus - Generative Refocusing", or git clone https://github.com/EricRollei/comfyui-refocus into ComfyUI/custom_nodes/ and restart. This node itself is pure tensor math - no extra dependencies, no models. The heavy lifting (depth estimation, the FLUX pipeline) happens in the nodes it feeds, so you can even use SelectFocusPoint to play with the defocus map before you've committed to the 23GB FLUX download.

CategoryRefocus/Defocus

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
maskoptMASKOptional mask from SAM/MaskPainter - centroid becomes focus point
x_percentoptFLOAT50.00–100X coordinate as percentage of image width (ignored if mask provided)
y_percentoptFLOAT50.00–100Y coordinate as percentage of image height (ignored if mask provided)

Outputs (2)

NameTypeDescription
focus_pointFOCUS_POINT
previewIMAGE