Nodes/ComfyUI-Image-Filters/Sharpen Filter (Latent)
ComfyUI Node

Sharpen Filter (Latent)

Sharpening before the VAE ever sees it

By spacepxl·Created 3 years ago·Updated 8 months ago· 293
Sharpen Filter (Latent)
  • latents
  • LATENT
filter_size1
factor1.00

Most sharpening happens after the fact - decode your image, then run an unsharp mask or similar on the pixels. This node does it earlier, directly on the latent, before it's ever been through the VAE decode. The README's description: "Increases local contrast between latent 'pixels' with an image sharpening filter." Same underlying idea as pixel-space sharpening (boost local contrast to make edges read as crisper), just applied to the compressed representation the diffusion model actually works in.

Why sharpen a latent instead of the final image

Sharpening in latent space produces a genuinely different result than sharpening the decoded pixels, because the VAE decoder has to reconcile whatever you did to the latent - it's not a simple filter pass, it's feeding a slightly different input into a neural decode. That can read as more "generative" texture enhancement rather than a purely mechanical edge boost, similar in spirit to how this pack's own Enhance Detail node uses a guided filter instead of the typical gaussian-blur-based sharpening most tools default to. It's a niche, experimental tool rather than a standard step in most workflows - reach for it when you specifically want to test whether pushing local contrast before decode changes the character of the output in a way pixel-space sharpening doesn't.

Inputs and outputs

  • latents (LATENT) - the latent to sharpen.
  • filter_size (1–128, default 1) - the kernel radius the sharpen filter operates over. Larger values consider a wider neighborhood when computing local contrast.
  • factor (-100 to 100, default 1) - the strength of the effect. Positive values sharpen; because the range extends into negative territory, pushing it negative flips the effect toward softening/blurring instead. Small changes near the default go a long way - this isn't a parameter that needs large values to have a visible effect, and pushing it hard toward either end of its range gets aggressive fast.

Output is a single LATENT - ready to continue through your sampling pipeline or straight to VAE decode.

Installing it

ComfyUI Manager: search "ComfyUI-Image-Filters," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/spacepxl/ComfyUI-Image-Filters

pip install -r requirements.txt (or install.bat on Windows), restart. No model downloads - pure latent-space filtering.

The pack-wide OpenCV note applies here as well: a conflicting cv2 build from a different node pack can throw import errors across this entire repo, this node included, even though the operation itself doesn't obviously need OpenCV. import_error_install.bat is the fix, reinstalling the one correct variant (opencv-contrib-python) instead of leaving you to untangle version conflicts.

Common issues

Because factor has such a wide range (-100 to 100) relative to how strong the effect is even near 1, the most common mistake is overshooting - cranking it to a large positive value expecting more detail and instead getting harsh, artifact-y output once decoded, since you're aggressively distorting the latent before the VAE ever gets a clean signal to work with. Start small and nudge up gradually rather than jumping to an extreme. And because this operates in latent space rather than on pixels, don't expect it to behave exactly like a familiar pixel-space sharpen filter - the VAE decode step means the visible result is one step removed from the raw math, so it's worth comparing directly against a plain post-decode sharpen to see which actually gets you what you want for a given image.

CategoryImage-Filters/latent

Inputs (3)

NameTypeDefaultDescription
latentsLATENT
filter_sizeINT11–128
factorFLOAT1.00-100–100

Outputs (1)

NameTypeDescription
LATENTLATENT