OpenCV pyrDown_0
Downscaling with OpenCV pyrDown_0
- src
- dst
- nparray
pyrDown_0 shrinks an image to half its size - but it shrinks it properly. It's cv2.pyrDown: first blur the image with a 5×5 Gaussian kernel, then throw away every other row and column. That blur-then-sub-sample order is the whole point. It's anti-aliased downscaling, the way image pyramids have always done it, which means you don't get the jagged, shimmery stair-steps a naive nearest-neighbor resize gives you.
It's part of opencv-comfyui, the auto-generated pack wrapping ~635 standalone OpenCV functions. The author, Gerold Meisinger, shipped it to r/comfyui in April 2025 with the pack's standing warning - "ugly and complex to use. Expect dragons!" - but pyrDown_0 is on the friendly end. One input image, one output image, and the math is thirty years old and boring in the best way.
How it works and the one input that matters
The mechanism is the Gaussian pyramid: blur with a 5×5 Gaussian, subsample by 2. Output is exactly half the width and half the height of the input (rounded down). The blur is what makes it look good - without it, downsampling aliases, and fine details turn into moiré.
The inputs:
src(NPARRAY) - your image.dstsize(STRING) - here's the pack quirk: it's a compositeSize, entered as a Python literal. Enter(0, 0)to let OpenCV compute the correct half-size automatically. If you specify a size manually, it has to satisfy the pyramid size constraints (width ≤ src.width/2 + 1, roughly), and getting it wrong produces a cryptic assertion. Beginners should always use(0, 0).borderType(INT) - the border-handling enum.4(BORDER_REFLECT_101) is the OpenCV default and fine;1(BORDER_REPLICATE) also works.
The optional dst is the usual out-parameter - leave it unconnected, per the README. Output is a single nparray, half resolution.
Why you'd reach for it
Three honest use cases. First, a cheap anti-aliased downscale - if you need a small version of an image for a control-net preprocessor, a comparison strip, or a preview, pyrDown_0 is instant and looks right. Second, multiscale workflows: build a pyramid by chaining pyrDowns for coarse-to-fine alignment or matching. Third, and most ComfyUI-specific, pyramid-based blending - blend two images at multiple scales and collapse, which is how you get seamless composite boundaries. If your project is "stitch this seam invisibly," the pyramid starts here.
Install
Same as the whole pack: ComfyUI Manager → search "opencv-comfyui", or
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
restart, then pip install opencv-contrib-python. Chain IMAGE → Image2Nparray → pyrDown_0 → Nparrays2Image → IMAGE, batch size 1 only (ImageFromBatch length 1 fixes the batch error). The _1 twin is identical - generated from the second overload - so pick either.
The honest comparison
ComfyUI's built-in image scaling is fine for most jobs, and the standard resize gives you more control over method and dimensions. Where pyrDown_0 wins is exactness: it's precisely half-size, uses the canonical Gaussian kernel, and behaves exactly like the textbook pyramid step - which matters when you're chaining it with pyrUp or doing multiscale math where every stage must match OpenCV's convention. For that, there's no ambiguity. Just remember the (0, 0) literal for dstsize, and you're set.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| dstsize | STRING | — | |
| borderType | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |