Skip to content

pyrDown

Image processingfunctionOpenCV 5.0.0
import { pyrDown } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

imgproc_misc

example: samples/cpp/tutorial_code/ImgProc/Pyramids/Pyramids.cpp An example using pyrDown and pyrUp functions Blurs an image and downsamples it.

By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied:

\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}

The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel:

\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1  \\ 4 & 16 & 24 & 16 & 4  \\ 6 & 24 & 36 & 24 & 6  \\ 4 & 16 & 24 & 16 & 4  \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}

Then, it downsamples the image by rejecting even rows and columns.

pyrDown(src: Mat, dst: Mat, dstsize: Size, borderType: number): void;
3 available overloads
pyrDown(src: Mat, dst: Mat): void;
pyrDown(src: Mat, dst: Mat, dstsize: Size): void;
pyrDown(src: Mat, dst: Mat, dstsize: Size, borderType: number): void;
src

input image.

dst

Output destination, filled by the native operation. output image; it has the specified size and the same type as src.

dstsize

size of the output image.

borderType

Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported)

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.