Skip to content

gapi_resize

gapifunctionOpenCV 5.0.0
import { gapi_resize } from '@banou/opencv-wasm'

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

ARGUMENTSsrc, dsize, fx, fy
FUNCTIONgapi_resize
RETURN TYPEGMat
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

gapi_colorconvert

Resizes an image.

The function resizes the image src down to or up to the specified size.

Output image size will have the size dsize (when dsize is non-zero) or the size computed from src.size(), fx, and fy; the depth of output is the same as of src.

If you want to resize src so that it fits the pre-created dst, you may call the function as follows:

    // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
    resize(src, dst, dst.size(), 0, 0, interpolation);

If you want to decimate the image by factor of 2 in each direction, you can call the function this way:

    // specify fx and fy and let the function compute the destination image size.
    resize(src, dst, Size(), 0.5, 0.5, interpolation);

To shrink an image, it will generally look best with cv::INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with cv::INTER_CUBIC (slow) or cv::INTER_LINEAR (faster but still looks OK).

Note: Function textual ID is "org.opencv.imgproc.transform.resize"

See: warpAffine, warpPerspective, remap, resizeP

gapi_resize(src: GMat, dsize: Size, fx: number, fy: number, interpolation: number): GMat;
4 available overloads
gapi_resize(src: GMat, dsize: Size): GMat;
gapi_resize(src: GMat, dsize: Size, fx: number): GMat;
gapi_resize(src: GMat, dsize: Size, fx: number, fy: number): GMat;
gapi_resize(src: GMat, dsize: Size, fx: number, fy: number, interpolation: number): GMat;
src

input image.

dsize

output image size; if it equals zero, it is computed as:

\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}

Either dsize or both fx and fy must be non-zero.

fx

scale factor along the horizontal axis; when it equals 0, it is computed as

\texttt{(double)dsize.width/src.cols}
fy

scale factor along the vertical axis; when it equals 0, it is computed as

\texttt{(double)dsize.height/src.rows}
interpolation

interpolation method, see cv::InterpolationFlags

Returns

The GMat result. Release returned native handles with using or delete(), including handles nested in results.

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.