Table of Contents

Method BlobFromImage

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

BlobFromImage(Mat, double, Size, Scalar, bool, bool)

Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center, subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels.

public static Mat BlobFromImage(Mat image, double scaleFactor = 1, Size size = default, Scalar mean = default, bool swapRB = true, bool crop = true)

Parameters

image Mat

input image (with 1- or 3-channels).

scaleFactor double

multiplier for @p image values.

size Size

spatial size for output image

mean Scalar

scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.

swapRB bool

flag which indicates that swap first and last channels in 3-channel image is necessary.

crop bool

flag which indicates whether image will be cropped after resize or not

Returns

Mat

4-dimansional Mat with NCHW dimensions order.

Remarks

if @p crop is true, input image is resized so one side after resize is equal to corresponing dimension in @p size and another one is equal or larger.Then, crop from the center is performed. If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.