Skip to content

getRectSubPix

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

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

ARGUMENTSimage, patchSize, center, patch
FUNCTIONgetRectSubPix
RETURN TYPEvoid
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Retrieves a pixel rectangle from an image with sub-pixel accuracy.

The function getRectSubPix extracts pixels from src:

patch(x, y) = src(x +  \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y +  \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)

where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. Also the image should be a single channel or three channel image. While the center of the rectangle must be inside the image, parts of the rectangle may be outside.

See: warpAffine, warpPerspective

getRectSubPix(image: Mat, patchSize: Size, center: Point2f, patch: Mat, patchType: number): void;
2 available overloads
getRectSubPix(image: Mat, patchSize: Size, center: Point2f, patch: Mat): void;
getRectSubPix(image: Mat, patchSize: Size, center: Point2f, patch: Mat, patchType: number): void;
image

Source image.

patchSize

Size of the extracted patch.

center

Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.

patch

Output destination, filled by the native operation. Extracted patch that has the size patchSize and the same number of channels as src .

patchType

Depth of the extracted pixels. By default, they have the same depth as src .

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.