Nodes/ComfyUI-Wavelet-2D/Wavelet Reconstruct (IDWT)
ComfyUI Node

Wavelet Reconstruct (IDWT)

The Undo Button That Doubles as a Band-Pass Filter

By NobutakaKuroki·Created about a month ago·Updated 25 days ago· 1
Wavelet Reconstruct (IDWT)
  • HH
  • HL
  • LH
  • LL
  • signed_image
wavelethaar

Wavelet Reconstruct (IDWT) is the "R" in DWT: the inverse transform that rebuilds an image from its four wavelet subbands. The boring version of this node is a lossless round-trip - Decompose in, Reconstruct out, original back. The interesting version is that every one of its subband inputs is optional, and an unconnected input is treated as all zeros. Wire in only the detail bands and Reconstruct becomes a band-pass filter that hands you the edges on a plate. Leave out only the fine detail and you've got a smooth.

It's the natural other half of the pack's Wavelet Decompose. Decompose splits a SIGNED_IMAGE into LL/LH/HL/HH using PyWavelets; this node puts them back together with the matching inverse. It's a genuinely deterministic, model-free operation - the KB's post-processing notes keep saying "reach for a $0, millisecond operation instead of burning a diffusion pass," and this is a textbook example: classical image processing, zero AI.

How it works

Under the hood it calls pywt.idwt2 with symmetric boundary handling - the same mode Decompose uses, so the round-trip is exact. The subbands are:

  • LL - the smoothed approximation
  • LH - horizontal edges
  • HL - vertical edges
  • HH - diagonal detail

One implementation detail worth knowing: Decompose halves each subband by a display gain of 0.5 on the way out (keeps coefficients near -1..1), and Reconstruct doubles on the way back in. Those two operations are exact multiplicative inverses, so reconstruction accuracy is never affected - the gain only touches display range. The author, Dr. Nobutaka Kuroki at Kobe University, built this pack as teaching material, and this is the design choice that lets the samples survive being previewed.

The wavelet dropdown is the one input that will bite you. It defaults to haar; db4, sym4 and bior4.4 are the alternatives. It must match the wavelet you used at Decompose - mismatch the two and you get garbage out, or a shape error. There's no auto-detection.

The inputs and outputs

  • wavelet - enum, default haar. Set it to exactly what Decompose used.
  • HH, HL, LH, LL - optional SIGNED_IMAGE inputs, wired directly from a Decompose's outputs (they're ordered the same way). Missing ones become all-zero subbands; having none connected is an error.
  • Output signed_image - one SIGNED_IMAGE, fed to To Unsigned ImageSave Image, or Preview Signed Image.

Two structural rules, both grounded in how idwt2 works: all connected subbands must share the exact same shape - a mismatch is a hard error, deliberately, because silently cropping like Wavelet Layout does would corrupt the reconstruction, not just its display. And if your original had an odd height or width, the reconstruction can come back 1px larger on that axis - for any wavelet longer than haar, the subband shapes alone don't record whether the original length was odd or even.

How to install it

ComfyUI Manager, search "comfyui-wavelet-2d", install. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/NobutakaKuroki/comfyui-wavelet-2d
cd comfyui-wavelet-2d
pip install -r requirements.txt

The whole Python dependency is one line - PyWavelets. No models, no keys. The required companion is comfyui-signed-image, which defines the SIGNED_IMAGE type this node uses and provides To Unsigned Image / Preview Signed Image; it is not installed automatically. Skip it and you'll hit missing-type errors immediately. Restart ComfyUI after both.

Common issues

  • Garbage output - wavelet at Reconstruct doesn't match Decompose. Set both to haar first, experiment after.
  • "All provided subbands must have the same shape" - the four bands aren't from one Decompose at one level. They must share one exact shape; this is by design, not a bug.
  • "At least one of HH/HL/LH/LL must be provided" - you need at least one band connected; the node can't guess dimensions from nothing.
  • Output is 1px larger than the input - expected with odd dimensions and a non-haar wavelet; crop if it matters.
  • Washed-out preview - the output is SIGNED_IMAGE; render it through To Unsigned Image, not a plain 0..1 preview.
CategoryKULab/Wavelet

Inputs (5)

NameTypeDefaultDescription
waveletCOMBOhaar4 options: haar, bior4.4, db4, sym4
HHoptSIGNED_IMAGE
HLoptSIGNED_IMAGE
LHoptSIGNED_IMAGE
LLoptSIGNED_IMAGE

Outputs (1)

NameTypeDescription
signed_imageSIGNED_IMAGE