VBScript / Visual Basic

PhenoCapture Scripting API Reference (VBScript)

Welcome to the complete PhenoCapture Scripting API Reference. Click on any of the four class headers below to reveal its function list, and click on any function name to view its full syntax, parameter type table, return value, and VBScript code examples.


1. Region Object (ScriptRegionHelper)

The Region object (ScriptRegionHelper) provides complete control over interactive selection shapes, pixel-based binary masks, region queries, and spatial boundary measurements.

Core Display & State Methods

Region.Unselect() – Clear Active Selection

Description: Clears all active selection shapes, resets mask data, and hides the selection overlay from the workspace canvas.

Syntax: Region.Unselect()

Parameters: None

Return Value: None

VBScript Example:

' Clear any active selection area on the workspace
Region.Unselect()
Region.Show() – Display Selection Overlay

Description: Displays the selection overlay on the active workspace canvas.

Syntax: Region.Show()

Parameters: None

Return Value: None

VBScript Example:

Region.Show()
Region.Hide() – Hide Selection Overlay

Description: Hides the active selection overlay without clearing the underlying mask data.

Syntax: Region.Hide()

Parameters: None

Return Value: None

VBScript Example:

Region.Hide()
Region.Invalidate() – Refresh Canvas Display

Description: Triggers an immediate redraw of the workspace drawing board to refresh selection boundaries and marching ants.

Syntax: Region.Invalidate()

Parameters: None

Return Value: None

VBScript Example:

Region.Invalidate()

Selection Shape Query Functions

Region.IsNone() – Check If Selection Is Empty

Description: Checks if there is no active selection shape or mask on the canvas.

Syntax: result = Region.IsNone()

Parameters: None

Return Value: Boolean (True if no selection exists, otherwise False)

VBScript Example:

If Region.IsNone() Then
    App.Log "No active selection."
End If
Region.IsLine() – Check If Line Selection

Description: Checks if the active selection shape is a line measurement.

Syntax: result = Region.IsLine()

Parameters: None

Return Value: Boolean

Region.IsRectangle() – Check If Rectangle Selection

Description: Checks if the active selection shape is a rectangle.

Syntax: result = Region.IsRectangle()

Parameters: None

Return Value: Boolean

Region.IsCircle() – Check If Circle / Ellipse Selection

Description: Checks if the active selection shape is a circle or ellipse.

Syntax: result = Region.IsCircle()

Parameters: None

Return Value: Boolean

Region.IsPolygon() – Check If Polygon Selection

Description: Checks if the active selection shape is a polygon.

Syntax: result = Region.IsPolygon()

Parameters: None

Return Value: Boolean

Region.IsPath() – Check If Freehand Path Selection

Description: Checks if the active selection shape is a freehand path.

Syntax: result = Region.IsPath()

Parameters: None

Return Value: Boolean

Region.IsBitmapMask() – Check If Complex Bitmap Mask

Description: Checks if the active selection is a complex bitmap pixel mask.

Syntax: result = Region.IsBitmapMask()

Parameters: None

Return Value: Boolean

Region.GetShape() – Query Current Shape Identifier

Description: Returns the name of the current shape type as a string.

Syntax: shapeName = Region.GetShape()

Parameters: None

Return Value: String (e.g., "Rectangle", "Circle", "Polygon", "Path", "Line", "BitmapMask", "None")

VBScript Example:

App.Log "Active Shape: " & Region.GetShape()

Shape Creation & Definition Methods

Region.SetLine(x1, y1, x2, y2) – Define Line Selection

Description: Defines a linear measurement selection across specified canvas coordinates.

Syntax: Region.SetLine(x1, y1, x2, y2)

ParameterDescription
x1 (Integer)Starting X coordinate in pixels
y1 (Integer)Starting Y coordinate in pixels
x2 (Integer)Ending X coordinate in pixels
y2 (Integer)Ending Y coordinate in pixels

Return Value: None

VBScript Example:

Region.SetLine 100, 100, 400, 300
Region.SetRectangle(left, top, right, bottom) – Define Rectangle Selection

Description: Creates an active rectangular selection box defined by bounding coordinates.

Syntax: Region.SetRectangle(left, top, right, bottom)

ParameterDescription
left (Integer)Left boundary X coordinate in pixels
top (Integer)Top boundary Y coordinate in pixels
right (Integer)Right boundary X coordinate in pixels
bottom (Integer)Bottom boundary Y coordinate in pixels

Return Value: None

VBScript Example:

Region.SetRectangle 50, 50, 250, 200
Region.SetCircle(left, top, right, bottom) – Define Circle Selection

Description: Creates an active circular or elliptical selection bounded by the specified rectangle.

Syntax: Region.SetCircle(left, top, right, bottom)

ParameterDescription
left (Integer)Left boundary X coordinate in pixels
top (Integer)Top boundary Y coordinate in pixels
right (Integer)Right boundary X coordinate in pixels
bottom (Integer)Bottom boundary Y coordinate in pixels

Return Value: None

Region.SetPolygon(coords) – Define Closed Polygon Selection

Description: Defines a multi-point closed polygon selection area using an array of sequential X, Y coordinate pairs.

Syntax: Region.SetPolygon(coords)

ParameterDescription
coords (Array)Flat array of sequential integers (x1, y1, x2, y2, x3, y3, ...)

Return Value: None

Boundary Coordinate Query Functions

Region.GetBoundaryLeft() – Left Boundary X

Description: Returns the minimum X coordinate (Left boundary) of the active selection area.

Syntax: xLeft = Region.GetBoundaryLeft()

Parameters: None

Return Value: Integer

Region.GetBoundaryTop() – Top Boundary Y

Description: Returns the minimum Y coordinate (Top boundary) of the active selection area.

Syntax: yTop = Region.GetBoundaryTop()

Parameters: None

Return Value: Integer

Region.GetBoundaryRight() – Right Boundary X

Description: Returns the maximum X coordinate (Right boundary) of the active selection area.

Syntax: xRight = Region.GetBoundaryRight()

Parameters: None

Return Value: Integer

Region.GetBoundaryBottom() – Bottom Boundary Y

Description: Returns the maximum Y coordinate (Bottom boundary) of the active selection area.

Syntax: yBottom = Region.GetBoundaryBottom()

Parameters: None

Return Value: Integer

2. Action Object (ScriptActionHelper)

The Action object (ScriptActionHelper) provides programmatic access to all core image processing filters, AI neural operations, color channel manipulations, workspace file operations, hardware capture triggers, and batch analysis functions in PhenoCapture.

System & Workspace Actions

Action.ActivateUndoEngine() – Enable History Tracking

Description: Activates the undo history engine on the active workspace canvas.

Syntax: Action.ActivateUndoEngine()

Parameters: None

Return Value: None

Action.DeactivateUndoEngine() – Suspend History Tracking

Description: Temporarily suspends the undo engine to avoid recording high-frequency intermediate edits into history.

Syntax: Action.DeactivateUndoEngine()

Parameters: None

Return Value: None

Action.SaveImage(sourceBitmap, destFileName, jpegQuality) – Save Bitmap to File

Description: Writes a GDI+ bitmap object directly to a specified file path on disk with custom JPEG quality settings.

Syntax: errMsg = Action.SaveImage(sourceBitmap, destFileName, jpegQuality)

ParameterDescription
sourceBitmap (Bitmap)GDI+ Bitmap object to save
destFileName (String)Full destination path on disk
jpegQuality (Integer, Optional)JPEG quality (1-100, Default: 90)

Return Value: String (Empty string on success, error message on failure)

VBScript Example:

Dim img, errStr
Set img = Action.GetImage(0)
errStr = Action.SaveImage(img, "C:\\Output\\Result.jpg", 95)

Edit & Selection Actions

Action.ExpandSelection(expandByPixels) – Dilate Selection Mask

Description: Dilates (expands) the active selection boundary by a specified pixel radius.

Syntax: success = Action.ExpandSelection(expandByPixels)

ParameterDescription
expandByPixels (Integer, Optional)Expansion radius in pixels (1-100, Default: 5)

Return Value: Boolean

Action.ShrinkSelection(shrinkByPixels) – Erode Selection Mask

Description: Erodes (shrinks) the active selection boundary by a specified pixel radius.

Syntax: success = Action.ShrinkSelection(shrinkByPixels)

ParameterDescription
shrinkByPixels (Integer, Optional)Contraction radius in pixels (1-100, Default: 5)

Return Value: Boolean

Image Transforms & Spatial Filters

Action.BoxAveraging(kernelSize) – Box Blur Filter

Description: Applies a spatial box averaging smoothing filter across a specified matrix size (3, 5, 7, 9, 11, 13, 15).

Syntax: success = Action.BoxAveraging(kernelSize)

ParameterDescription
kernelSize (Integer, Optional)Odd matrix dimension: 3, 5, 7, 9, 11, 13, 15 (Default: 3)

Return Value: Boolean

Action.Resize(unit, maintainAspect, basedOn, width, height, interpolation) – Rescale Image

Description: Rescales canvas pixel dimensions with control over aspect ratio lock and interpolation algorithms.

Syntax: success = Action.Resize(unit, maintainAspect, basedOn, width, height, interpolation)

ParameterDescription
resizeUnitType (Integer, Optional)0: Pixels (Default), 1: Percent
maintainAspectRatio (Boolean, Optional)Lock aspect ratio (Default: True)
baseDimensionType (Integer, Optional)0: Based on Width (Default), 1: Based on Height
targetWidth (Integer, Optional)Target width in pixels or percentage (Default: 800)
targetHeight (Integer, Optional)Target height in pixels or percentage (Default: 600)
interpolationAlgorithmType (Integer, Optional)0: NearestNeighbor, 1: Bilinear, 2: Bicubic, 3: HQ Bilinear, 4: HQ Bicubic (Default)

Return Value: Boolean

3. ImgProc Object (ScriptImgProcHelper)

The ImgProc object (ScriptImgProcHelper) provides high-performance, direct parallel pixel-processing routines and mathematical core routines for image operations.

Core Parallel Processing & Pixel Buffer Methods

ImgProc.ImageTo_SrcPixels(SourceImage, MaskImage, isRaiseEventStarted) – Load Image Pixels

Description: Loads raw bitmap and mask pixel byte arrays into internal core memory buffers for high-speed parallel algorithm execution.

Syntax: ImgProc.ImageTo_SrcPixels(SourceImage, MaskImage, isRaiseEventStarted)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
MaskImage (Bitmap, Optional)Region mask GDI+ Bitmap object (Default: Nothing)
isRaiseEventStarted (Boolean, Optional)Raise processing progress start event (Default: True)

Return Value: None

ImgProc.OutPixelsToImage(isRaiseEventCompleted) – Output Pixel Buffer to Bitmap

Description: Converts processed output pixel memory buffers back into a standard GDI+ Bitmap object.

Syntax: Set resultBmp = ImgProc.OutPixelsToImage(isRaiseEventCompleted)

ParameterDescription
isRaiseEventCompleted (Boolean, Optional)Raise progress completion event (Default: True)

Return Value: Bitmap

ImgProc.SuperPixelSegmentation(SourceImage, numSuperpixels, compactness, fillWithWhite, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – SLIC Segmentation

Description: Groups perceptually similar pixels into atomic superpixel clusters using parallel SLIC segmentation.

Syntax: Set resultBmp = ImgProc.SuperPixelSegmentation(SourceImage, numSuperpixels, compactness, fillWithWhite, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
numSuperpixels (Integer, Optional)Target number of superpixels (Default: 400)
compactness (Single, Optional)Compactness factor balancing color vs space (Default: 70.0)
fillWithWhite (Boolean, Optional)Fill clusters with white instead of mean color (Default: False)
MaskImage (Bitmap, Optional)Mask bitmap object (Default: Nothing)
MaskRegionBoundary (Rectangle, Optional)Bounding rectangle of mask (Default: Nothing)
IsMaskAllRegionSelected (Boolean, Optional)Process entire canvas if true (Default: True)

Return Value: Bitmap

Color Adjustments & Color Space Conversions

ImgProc.ShadowsHighlights(original, shadowAmt, highlightAmt, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – Shadow/Highlight Recovery

Description: Adjusts local contrast to recover dark shadow details and clipped highlight areas in parallel.

Syntax: Set resultBmp = ImgProc.ShadowsHighlights(original, shadowAmt, highlightAmt, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
original (Bitmap)Source GDI+ Bitmap object
shadowAmt (Single)Shadow correction strength (0.0 to 100.0%)
highlightAmt (Single)Highlight correction strength (0.0 to 100.0%)
MaskImage (Bitmap, Optional)Mask bitmap object (Default: Nothing)
MaskRegionBoundary (Rectangle, Optional)Mask region bounds (Default: Nothing)
IsMaskAllRegionSelected (Boolean, Optional)Process entire image if True (Default: True)

Return Value: Bitmap

ImgProc.MultibandColor(original, rSat, rInt, ySat, yInt, gSat, gInt, cSat, cyanInt, bSat, bInt, mSat, mInt, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – Multiband Spectrum Adjustment

Description: Adjusts saturation and intensity across 6 discrete hue bands (Red, Yellow, Green, Cyan, Blue, Magenta).

Syntax: Set resultBmp = ImgProc.MultibandColor(original, rSat, rInt, ySat, yInt, gSat, gInt, cSat, cyanInt, bSat, bInt, mSat, mInt, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
original (Bitmap)Source GDI+ Bitmap object
rSat, rInt, ySat, yInt, gSat, gInt, cSat, cyanInt, bSat, bInt, mSat, mInt (Integer)Saturation and Intensity shifts for Red, Yellow, Green, Cyan, Blue, and Magenta bands (-100 to 100)
MaskImage / MaskRegionBoundary / IsMaskAllRegionSelectedOptional region mask parameters

Return Value: Bitmap

ImgProc.CIELab(original, lShift, aShift, bShift, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – CIE L*a*b* Adjustment

Description: Adjusts perceptual Lightness (L*) and chromaticity (a*, b*) channels in CIE L*a*b* color space.

Syntax: Set resultBmp = ImgProc.CIELab(original, lShift, aShift, bShift, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
original (Bitmap)Source GDI+ Bitmap object
lShift (Integer)Lightness shift (-127 to 127)
aShift (Integer)a-axis (Green to Red) shift (-127 to 127)
bShift (Integer)b-axis (Blue to Yellow) shift (-127 to 127)
MaskImage / MaskRegionBoundary / IsMaskAllRegionSelectedOptional region mask parameters

Return Value: Bitmap

ImgProc.HueSaturationIntensity(original, hueShift, satShift, intShift, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – Parallel HSI

Description: Adjusts Hue (-180 to 180), Saturation (-100 to 100), and Intensity (-100 to 100) channels in HSI color space.

Syntax: Set resultBmp = ImgProc.HueSaturationIntensity(original, hueShift, satShift, intShift, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
original (Bitmap)Source GDI+ Bitmap object
hueShift (Integer)Hue rotation degrees (-180 to 180)
satShift (Integer)Saturation shift (-100 to 100)
intShift (Integer)Intensity shift (-100 to 100)

Return Value: Bitmap

Morphological Operations & Filtering

ImgProc.Erode(SourceImage, BoxSizeHalf, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected, IsDoGrayScaling) – Parallel Erosion

Description: Performs morphological minimum kernel erosion across binary or grayscale regions in parallel.

Syntax: Set resultBmp = ImgProc.Erode(SourceImage, BoxSizeHalf, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected, IsDoGrayScaling)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
BoxSizeHalf (Integer)Kernel half radius (1 for 3×3, 2 for 5×5, 3 for 7×7, 4 for 9×9)
IsDoGrayScaling (Boolean, Optional)Convert to grayscale before erosion (Default: True)

Return Value: Bitmap

ImgProc.Dilate(SourceImage, BoxSizeHalf, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected, IsDoGrayScaling) – Parallel Dilation

Description: Performs morphological maximum kernel dilation across binary or grayscale regions in parallel.

Syntax: Set resultBmp = ImgProc.Dilate(SourceImage, BoxSizeHalf, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected, IsDoGrayScaling)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
BoxSizeHalf (Integer)Kernel half radius (1 for 3×3, 2 for 5×5, 3 for 7×7, 4 for 9×9)
IsDoGrayScaling (Boolean, Optional)Convert to grayscale before dilation (Default: True)

Return Value: Bitmap

ImgProc.Skeletonize(SourceImage, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – Thinning Algorithm

Description: Reduces binary object structures to 1-pixel topological medial-axis skeletons.

Syntax: Set resultBmp = ImgProc.Skeletonize(SourceImage, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
SourceImage (Bitmap)Source binary GDI+ Bitmap object
MaskImage / MaskRegionBoundary / IsMaskAllRegionSelectedOptional region mask parameters

Return Value: Bitmap

ImgProc.Emboss(SourceImage, Angle, Distance, Strength, Bias, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – Directional Relief

Description: Applies 3D directional light relief texture effects using high-speed parallel convolution.

Syntax: Set resultBmp = ImgProc.Emboss(SourceImage, Angle, Distance, Strength, Bias, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
Angle (Single, Optional)Light source angle in degrees (0-360, Default: 135.0)
Distance (Integer, Optional)Relief depth distance in pixels (Default: 1)
Strength (Single, Optional)Relief strength multiplier (Default: 1.0)
Bias (Integer, Optional)Luminance background bias level (0-255, Default: 128)

Return Value: Bitmap

Mathematical Utilities & Array Operations

ImgProc.Distance(X1, Y1, X2, Y2) – Euclidean Distance

Description: Computes the 2D Euclidean distance between two spatial coordinate points.

Syntax: dist = ImgProc.Distance(X1, Y1, X2, Y2)

ParameterDescription
X1, Y1 (Double)First coordinate point
X2, Y2 (Double)Second coordinate point

Return Value: Double

VBScript Example:

Dim d
d = ImgProc.Distance(10, 20, 100, 200)
App.Log "Distance: " & d
ImgProc.Get_CoreCount() – Query Processor CPU Cores

Description: Returns the total number of physical/logical CPU cores available for parallel processing.

Syntax: cores = ImgProc.Get_CoreCount()

Parameters: None

Return Value: Integer

ImgProc.Convert_RGBImage_To_GrayByteArray(SourceImage, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected) – 2D Grayscale Array Extraction

Description: Extracts 8-bit luminance values from an RGB bitmap into a 2D byte array Byte(Width, Height).

Syntax: grayArray = ImgProc.Convert_RGBImage_To_GrayByteArray(SourceImage, MaskImage, MaskRegionBoundary, IsMaskAllRegionSelected)

ParameterDescription
SourceImage (Bitmap)Source GDI+ Bitmap object
MaskImage / MaskRegionBoundary / IsMaskAllRegionSelectedOptional region mask parameters

Return Value: Byte(,) (2D Array of bytes)

4. App & Workspace Objects (ScriptAppHelper & ScriptWorkspaceHelper)

The App and Workspace objects (ScriptAppHelper & ScriptWorkspaceHelper) control system logging, user alerts, viewport navigation, file metadata, and window layout management.

Application Logging & Message Methods

App.Log(messageStr) – Write to Output Console

Description: Appends a text string message to the PhenoCapture Script Runner output log window.

Syntax: App.Log(messageStr)

ParameterDescription
messageStr (String)Text string to print to output log

Return Value: None

VBScript Example:

App.Log "Script execution started at " & Now()
App.Alert(promptMessage) – Display Modal Message Box

Description: Displays an interactive popup alert box containing a custom text message.

Syntax: App.Alert(promptMessage)

ParameterDescription
promptMessage (String)Message text to display in popup dialog

Return Value: None

VBScript Example:

App.Alert "Processing completed successfully!"

Workspace & Viewport Control Methods

Workspace.UpdateViewport() – Refresh Viewport Display

Description: Recalculates canvas zoom ratios, scrollbars, and updates the workspace window viewport display.

Syntax: Workspace.UpdateViewport()

Parameters: None

Return Value: None

Workspace.GetImageWidth() – Query Canvas Width

Description: Returns the exact width in pixels of the active image open in the workspace.

Syntax: w = Workspace.GetImageWidth()

Parameters: None

Return Value: Integer

Workspace.GetImageHeight() – Query Canvas Height

Description: Returns the exact height in pixels of the active image open in the workspace.

Syntax: h = Workspace.GetImageHeight()

Parameters: None

Return Value: Integer

VBScript Example:

Dim w, h
w = Workspace.GetImageWidth()
h = Workspace.GetImageHeight()
App.Log "Image resolution: " & w & "x" & h
Workspace.GetTag() – Query Image Metadata Tag

Description: Reads the file path metadata string associated with the current workspace image.

Syntax: currentPath = Workspace.GetTag()

Parameters: None

Return Value: String

Workspace.SetTag(tagString) – Set Image Metadata Tag

Description: Writes the file path metadata string associated with the current workspace image.

Syntax: Workspace.SetTag("C:\\Data\\Image.png")

ParameterDescription
tagString (String)File path or metadata string to set

Return Value: None