π FRED Image Sharpening Blur Level
Auto-sharpen until the image stops being blurry, no manual guessing
- image
- mask_optional
- image
A normal sharpen node makes you guess an amount and hope. FRED_Image_Sharpening_Blur_Level measures first: it computes the image's actual blur level (variance of the Laplacian, the standard cheap sharpness metric), compares it against your minimum_deblur_output target on a 0β100 scale, and sharpens until it crosses the line. Target 50 by default, hit 50, stop. It's the "set a floor, not a feel" approach, and it's genuinely easier to reason about.
How it works
The pipeline is: measure blur β if already above your minimum, do nothing (a sharp image stays untouched) β if below, apply an unsharp-mask-style sharpen, re-measure, repeat until the target is reached. The blur number is normalized from the raw Laplacian variance onto your 0β100 scale, so the minimum_deblur_output slider (default 50, step 5) is directly meaningful: 0 means "never sharpen," 100 means "sharpen until it's as crisp as we can make it."
The optional mask_optional input is where this gets interesting. Pass a face mask and the blur measurement is restricted to the masked region, so the node sharpens specifically the area that's soft - a face that's slightly out of focus - without dragging the whole image through a sharpen filter and adding halos to edges that were already fine.
When you'd reach for it
- A quick global crispness bump on upscaled output that came back slightly soft. Set 50β60, wire it between your upscale and your save node.
- Region-targeted deblur with the mask, before a face detail pass - getting the face "clean enough" before the detailer resamples it.
- Batch pre-processing for a dataset, where "sharpen until not-blurry" is more consistent than eyeballing each file.
Honest limits: this is unsharp masking, not AI restoration. It sharpens edges that exist; it cannot reconstruct detail that was never there. For genuinely soft, low-detail images you want an actual upscaler or a detail pass, not a sharpen filter. And like all Laplacian-based sharpness heuristics, it can be fooled by noise - a grainy image reads as "sharp" because grain creates edge variance. That's what the mask is for.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Poukpalaova/ComfyUI-FRED-Nodes_v2.git
Restart, or "ComfyUI FRED Nodes v2" via ComfyUI Manager. It uses opencv-python and torch from the pack's standard dependencies.
Gotchas
Set the minimum too high and you'll oversharpen, trading blur for halos - 50β70 is the sane band for most generated images. If you feed it an already-crisp image, it should pass it through untouched (that's the point); if it's still sharpening, your target is above what the image measures. And remember it's one output, image - no preview, no blend control. If you want to dial the effect in, sharpen to a result you like and then mix it with the original via a lerp/composite node at low weight.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| minimum_deblur_output | FLOAT | 500β100 | β |
| mask_optionalopt | MASK | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |