v2026.4.1
All Bundles

Image

OpenCV image

Operations

AdaptiveThreshold

Applies an adaptive threshold to an array

method : public : AdaptiveThreshold(maxval:Float, adaptive_method:Int, threshold_type:Int, block_size:Int, C:Float) ~ Image

Parameters

NameTypeDescription
maxvalFloatnon-zero value assigned to pixels that satisfy the condition
adaptive_methodIntadaptive thresholding algorithm (0=MEAN_C, 1=GAUSSIAN_C)
threshold_typeIntthreshold type (must be BINARY or BINARY_INV)
block_sizeIntsize of the pixel neighborhood (must be odd and greater than 1)
CFloatconstant subtracted from the mean or weighted mean

Return

TypeDescription
Imagethresholded image

BilateralFilter

Applies bilateral filter to the image

method : public : BilateralFilter(d:Int, sigmaColor:Float, sigmaSpace:Float) ~ Image

Parameters

NameTypeDescription
dIntdiameter of each pixel neighborhood
sigmaColorFloatfilter sigma in the color space
sigmaSpaceFloatfilter sigma in the coordinate space

Return

TypeDescription
Imagefiltered image

BoundingRect

Computes the bounding rectangle for a single contour.

function : BoundingRect(contours:Int[], index:Int) ~ Rect

Parameters

NameTypeDescription
contoursIntpacked contour data from FindContours()
indexIntindex of the contour

Return

TypeDescription
Rectbounding rectangle

Bytes

Gets image bytes

method : public : Bytes() ~ Byte[]

Return

TypeDescription
Byteimage bytes

Canny

Applies Canny edge detection

method : public : Canny(threshold1:Float, threshold2:Float) ~ Image

Parameters

NameTypeDescription
threshold1Floatfirst threshold for hysteresis procedure
threshold2Floatsecond threshold for hysteresis procedure

Return

TypeDescription
Imageedge-detected image

Clone

Creates a deep copy of the image

method : public : Clone() ~ Image

Return

TypeDescription
Imagecloned image

Columns

Gets image columns

method : public : Columns() ~ Int

Return

TypeDescription
Intimage columns

ContourArea

Computes the area of a single contour.

function : ContourArea(contours:Int[], index:Int) ~ Float

Parameters

NameTypeDescription
contoursIntpacked contour data from FindContours()
indexIntindex of the contour

Return

TypeDescription
Floatarea of the contour

Convert

Convert an image to a given byte format

method : public : Convert(format:Image->Format) ~ Byte[]

Parameters

NameTypeDescription
formatImage->Formatoutput format

Return

TypeDescription
Byteconverted image bytes

Crop

Crops an image using a rectangle region of interest

method : public : Crop(rect:Rect) ~ Image

Parameters

NameTypeDescription
rectRectbounding rectangle for the crop region

Return

TypeDescription
Imagecropped image

CvtColor

Converts image color space

method : public : CvtColor(code:Int) ~ Image

Parameters

NameTypeDescription
codeIntcolor conversion code from ColorConversionCodes

Return

TypeDescription
Imageconverted image

Dilate

Dilates an image using a structuring element

method : public : Dilate(shape:Int, ksize_w:Int, ksize_h:Int) ~ Image

Parameters

NameTypeDescription
shapeIntstructuring element shape from MorphShapes
ksize_wIntkernel width
ksize_hIntkernel height

Return

TypeDescription
Imagedilated image

DrawCircle

Draws a bounding circle

method : public : DrawCircle(pt:Point, radius:Int, color:Scalar, thickness:Int, type:LineType) ~ API.OpenCV.Image

Parameters

NameTypeDescription
ptPointcircle center
radiusIntcircle radius
colorScalarbounding circle color
thicknessIntbounding circle thickness
typeLineTypebounding circle type

Return

TypeDescription
Imageupdated image

DrawContours

Draws contours on the image.

method : public : DrawContours(contours:Int[], contourIdx:Int, color:Scalar, thickness:Int) ~ Image

Parameters

NameTypeDescription
contoursIntpacked contour data from FindContours()
contourIdxIntindex of contour to draw, or -1 to draw all contours
colorScalardrawing color
thicknessIntline thickness (default 1)

Return

TypeDescription
Imageimage with contours drawn

DrawRectangle

Draws a bounding rectangle

method : public : DrawRectangle(rect:Rect, color:Scalar, thickness:Int, type:LineType) ~ API.OpenCV.Image

Parameters

NameTypeDescription
rectRectbounding rectangle
colorScalarbounding rectangle color
thicknessIntbounding rectangle thickness
typeLineTypebounding rectangle type

Return

TypeDescription
Imageupdated image

DrawText

Draws text on an image

method : public : DrawText(text:String, font:Font, color:Scalar, thickness:Int, type:LineType) ~ API.OpenCV.Image

Parameters

NameTypeDescription
textStringtext to draw
fontFonttext font
colorScalarbounding circle color
thicknessIntbounding circle thickness
typeLineTypebounding circle type

Return

TypeDescription
Imageupdated image

Erode

Erodes an image using a structuring element

method : public : Erode(shape:Int, ksize_w:Int, ksize_h:Int) ~ Image

Parameters

NameTypeDescription
shapeIntstructuring element shape from MorphShapes
ksize_wIntkernel width
ksize_hIntkernel height

Return

TypeDescription
Imageeroded image

FindContours

Finds contours in a binary image. The image should be single-channel (e.g., after CvtColor to grayscale and Threshold). Returns a packed Int[] with format: [count, size0..sizeN-1, x0,y0,x1,y1,...]. Use ContourArea() and BoundingRect() to analyze individual contours.

method : public : FindContours(mode:Int, approx:Int) ~ Int[]

Parameters

NameTypeDescription
modeIntcontour retrieval mode from RetrievalModes
approxIntcontour approximation method from ContourApproximationModes

Return

TypeDescription
Intpacked Int[] representing the detected contours

Flip

Flips an image

method : public : Flip(flipCode:Int) ~ Image

Parameters

NameTypeDescription
flipCodeInt0 for vertical, 1 for horizontal, -1 for both

Return

TypeDescription
Imageflipped image

GaussianBlur

Applies Gaussian blur to the image

method : public : GaussianBlur(ksize_w:Int, ksize_h:Int, sigmaX:Float) ~ Image

Parameters

NameTypeDescription
ksize_wIntkernel width (must be odd)
ksize_hIntkernel height (must be odd)
sigmaXFloatGaussian kernel standard deviation in X direction

Return

TypeDescription
Imageblurred image

GetRotationMatrix2D

Computes a 2D rotation matrix for an affine transformation.

function : GetRotationMatrix2D(center_x:Float, center_y:Float, angle:Float, scale:Float) ~ Float[]

Parameters

NameTypeDescription
center_xFloatx-coordinate of the rotation center
center_yFloaty-coordinate of the rotation center
angleFloatrotation angle in degrees (positive counter-clockwise)
scaleFloatisotropic scale factor

Return

TypeDescription
Float6-element Float[] representing the 2x3 rotation matrix

IsEmpty

Determines if an image is empty

method : public : IsEmpty() ~ Bool

Return

TypeDescription
Booltrue if empty, false otherwise

Load

Load image from file

function : Load(image_path:String) ~ API.OpenCV.Image

Parameters

NameTypeDescription
image_pathStringimage file path

Return

TypeDescription
Imageloaded image

Load

Load image from bytes

function : Load() ~ API.OpenCV.Image

Parameters

NameTypeDescription

Return

TypeDescription
Imageloaded image

MedianBlur

Applies median blur to the image

method : public : MedianBlur(ksize:Int) ~ Image

Parameters

NameTypeDescription
ksizeIntaperture size (must be odd and greater than 1)

Return

TypeDescription
Imageblurred image

MorphologyEx

Applies a morphological operation to an image

method : public : MorphologyEx(op:Int, shape:Int, ksize_w:Int, ksize_h:Int) ~ Image

Parameters

NameTypeDescription
opIntmorphological operation type from MorphTypes
shapeIntstructuring element shape from MorphShapes
ksize_wIntkernel width
ksize_hIntkernel height

Return

TypeDescription
Imageprocessed image

Normalize

Normalizes the image for neural network preprocessing. Converts the image to float, normalizes to [0,1], converts BGR to RGB, subtracts the given mean values, and divides by the given std values per channel. Returns the result as a flattened CHW tensor (Float[]).

method : public : Normalize(mean_r:Float, mean_g:Float, mean_b:Float, std_r:Float, std_g:Float, std_b:Float) ~ Float[]

Parameters

NameTypeDescription
mean_rFloatmean value for the red channel
mean_gFloatmean value for the green channel
mean_bFloatmean value for the blue channel
std_rFloatstandard deviation for the red channel
std_gFloatstandard deviation for the green channel
std_bFloatstandard deviation for the blue channel

Return

TypeDescription
Floatflattened CHW Float[] tensor suitable for ONNX inference

Resize

Resizes an image

method : public : Resize(sz:Size, fx:Float, fy:Float, interpolation:InterpolationFlags) ~ API.OpenCV.Image

Parameters

NameTypeDescription
szSizeimage size
fxFloatx-scale factor
fyFloaty-scale factor
interpolationInterpolationFlagsfilling missing pixels method

Return

TypeDescription
Imageupdated image

Resize

Resizes an image

method : public : Resize(fx:Float, fy:Float, interpolation:InterpolationFlags) ~ API.OpenCV.Image

Parameters

NameTypeDescription
fxFloatx-scale factor
fyFloaty-scale factor
interpolationInterpolationFlagsfilling missing pixels method

Return

TypeDescription
Imageupdated image

Resize

Resizes an image

method : public : Resize(f:Float, ) ~ API.OpenCV.Image

Parameters

NameTypeDescription
fFloatscale factor

Return

TypeDescription
Imageupdated image

Rows

Gets image rows

method : public : Rows() ~ Int

Return

TypeDescription
Intimage rows

Save

Saves an image to file

method : public : Save(path:String) ~ Bool

Parameters

NameTypeDescription
pathStringoutput file path

Return

TypeDescription
Booltrue if saved successfully, false otherwise

Show

Shows an image

method : public : Show(title:String) ~ Nil

Parameters

NameTypeDescription
titleStringdialog title

Show

Shows an image

method : public : Show(title:String, scale:Float) ~ Nil

Parameters

NameTypeDescription
titleStringdialog title
scaleFloatscaling percentage

Show

Shows an image

method : public : Show(title:String, scale:Float, ) ~ Nil

Parameters

NameTypeDescription
titleStringdialog title
scaleFloatscaling percentage

Size

Gets image size

method : public : Size() ~ Int

Return

TypeDescription
Intimage size

Sobel

Applies Sobel edge detection

method : public : Sobel(ddepth:Int, dx:Int, dy:Int) ~ Image

Parameters

NameTypeDescription
ddepthIntdesired depth of the destination image (use -1 for same as source)
dxIntorder of the derivative x
dyIntorder of the derivative y

Return

TypeDescription
Imageedge-detected image

Threshold

Applies a fixed-level threshold to each array element

method : public : Threshold(thresh:Float, maxval:Float, type:Int) ~ Image

Parameters

NameTypeDescription
threshFloatthreshold value
maxvalFloatmaximum value to use with BINARY and BINARY_INV threshold types
typeIntthreshold type from ThresholdTypes

Return

TypeDescription
Imagethresholded image

Type

Gets image type

method : public : Type() ~ Int

Return

TypeDescription
Intimage type

WarpAffine

Applies an affine transformation to the image using a 2x3 matrix.

method : public : WarpAffine(matrix:Float[], width:Int, height:Int) ~ Image

Parameters

NameTypeDescription
matrixFloat6-element Float[] representing the 2x3 affine matrix (row-major)
widthIntoutput image width
heightIntoutput image height

Return

TypeDescription
Imagetransformed image

WarpPerspective

Applies a perspective transformation to the image using a 3x3 matrix.

method : public : WarpPerspective(matrix:Float[], width:Int, height:Int) ~ Image

Parameters

NameTypeDescription
matrixFloat9-element Float[] representing the 3x3 perspective matrix (row-major)
widthIntoutput image width
heightIntoutput image height

Return

TypeDescription
Imagetransformed image