IM Plugin API reference

Plugin for processing images

simIM.abs
simIM.absdiff
simIM.absdiffK
simIM.add
simIM.addK
simIM.addWeighted
simIM.arrowedLine
simIM.bitwiseAnd
simIM.bitwiseAndK
simIM.bitwiseNot
simIM.bitwiseOr
simIM.bitwiseOrK
simIM.bitwiseXor
simIM.bitwiseXorK
simIM.cart2polar
simIM.circle
simIM.clipLine
simIM.closeVideoCapture
simIM.compare
simIM.compareK
simIM.convert
simIM.copy
simIM.create
simIM.createFromData
simIM.dataURL
simIM.destroy
simIM.distanceTransform
simIM.divide
simIM.divideK
simIM.ellipse
simIM.encode
simIM.exp
simIM.fillConvexPoly
simIM.fillPoly
simIM.flip
simIM.get
simIM.gray2rgb
simIM.hls2rgb
simIM.hsv2rgb
simIM.line
simIM.log
simIM.magnitude
simIM.merge
simIM.mixChannels
simIM.multiply
simIM.openVideoCapture
simIM.phase
simIM.polar2cart
simIM.polylines
simIM.pow
simIM.read
simIM.readFromVideoCapture
simIM.readFromVisionSensor
simIM.rectangle
simIM.reduce
simIM.repeat
simIM.resize
simIM.rgb2gray
simIM.rgb2hls
simIM.rgb2hsv
simIM.scaleAdd
simIM.set
simIM.size
simIM.split
simIM.sqrt
simIM.subtract
simIM.subtractK
simIM.text
simIM.textSize
simIM.write
simIM.writeToVisionSensor

simIM.abs

Description Calculates an absolute value of each pixel.
Lua synopsis string handle=simIM.abs(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.absdiff

Description Calculates the per-element absolute difference between two arrays.
Lua synopsis string handle=simIM.absdiff(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.absdiffK

Description Calculates the per-element absolute difference between an array and a scalar.
Lua synopsis string handle=simIM.absdiffK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.add

Description Calculates the per-element sum of two arrays.
Lua synopsis string handle=simIM.add(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.addK

Description Calculates the per-element sum of an array and a scalar.
Lua synopsis string handle=simIM.addK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.addWeighted

Description Calculates the weighted sum of two arrays, i.e. DST(i) = SRC1(i)*alpha + SRC2(i)*beta + gamma.
Lua synopsis string handle=simIM.addWeighted(string handle1, string handle2, float alpha, float beta, float gamma, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
alpha (float): alpha coefficient
beta (float): beta coefficient
gamma (float): gamma coefficient
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.arrowedLine

Description Draw a arrow segment starting from (x1,y1) and pointing to (x2,y2).
Lua synopsis simIM.arrowedLine(string handle, table[2] p1, table[2] p2, table[3] color, int thickness=1, int type=8, int shift=0, float tipLength=0.1)
Lua parameters
handle (string): handle to image
p1 (table of int, size 2): x, y coordinates of first point
p2 (table of int, size 2): x, y coordinates of second point
color (table of int, size 3): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
tipLength (float, default: 0.1): The length of the arrow tip in relation to the arrow length
Lua return values -
See also

simIM.bitwiseAnd

Description Calculates the per-element bit-wise conjunction of two arrays.
Lua synopsis string handle=simIM.bitwiseAnd(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseAndK

Description Calculates the per-element bit-wise conjunction of an array and a scalar.
Lua synopsis string handle=simIM.bitwiseAndK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseNot

Description Inverts every bit of an array.
Lua synopsis string handle=simIM.bitwiseNot(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseOr

Description Calculates the per-element bit-wise disjunction of two arrays.
Lua synopsis string handle=simIM.bitwiseOr(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseOrK

Description Calculates the per-element bit-wise disjunction of an array and a scalar.
Lua synopsis string handle=simIM.bitwiseOrK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseXor

Description Calculates the per-element bit-wise exclusive-or of two arrays.
Lua synopsis string handle=simIM.bitwiseXor(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.bitwiseXorK

Description Calculates the per-element bit-wise exclusive-or of an array and a scalar.
Lua synopsis string handle=simIM.bitwiseXorK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.cart2polar

Description Calculates magnitude and angle coordinates of 2D vectors from their x and y coordinates.
Lua synopsis string handle1, string handle2=simIM.cart2polar(string handle1, string handle2, bool angleInDegrees=false)
Lua parameters
handle1 (string): handle to first image (x)
handle2 (string): handle to second image (y)
angleInDegrees (bool, default: false): when true, the function calculates the angle in degrees, otherwise, they are measured in radians
Lua return values
handle1 (string): handle of resulting image (magnitude)
handle2 (string): handle of resulting image (angle)
See also

simIM.circle

Description Draw a circle with center (cx,cy) and radius r.
Lua synopsis simIM.circle(string handle, table[2] center, int radius, table[3] color, int thickness=1, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
center (table of int, size 2): x, y coordinates of center
radius (int): circle radius
color (table of int, size 3): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness (negative values means rect is filled)
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.clipLine

Description Clips the line against the image rectangle.
Lua synopsis bool valid, table[2] p1, table[2] p2=simIM.clipLine(string handle, table[2] p1, table[2] p2)
Lua parameters
handle (string): handle to image
p1 (table of int, size 2): x, y coordinates of first point
p2 (table of int, size 2): x, y coordinates of second point
Lua return values
valid (bool): false if the line segment is completely outside the image rectangle, otherwise true.
p1 (table of int, size 2): x, y coordinates of first point
p2 (table of int, size 2): x, y coordinates of second point
See also

simIM.closeVideoCapture

Description Close video capture device.
Lua synopsis simIM.closeVideoCapture(int deviceIndex)
Lua parameters
deviceIndex (int): device index (0 based)
Lua return values -
See also

simIM.compare

Description Performs the per-element comparison of two arrays.
Lua synopsis string handle=simIM.compare(string handle1, string handle2, int op, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
op (int): comparison operator
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.compareK

Description Performs the per-element comparison of an array and scalar value.
Lua synopsis string handle=simIM.compareK(string handle, table[] k, int op, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
op (int): comparison operator
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.convert

Description Convert the image to a different format.
Lua synopsis string handle=simIM.convert(string handle, int format, float scale=1.0, bool inPlace=false)
Lua parameters
handle (string): handle to image
format (int): target image format (see simIM.format)
scale (float, default: 1.0): scale factor
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.copy

Description Copy a (portion of) image to another image.
Lua synopsis simIM.copy(string srcHandle, table[2] srcOffset, string dstHandle, table[2] dstOffset, table[2] size)
Lua parameters
srcHandle (string): handle to source image
srcOffset (table of int, size 2): x, y offset in the source image
dstHandle (string): handle to destination image
dstOffset (table of int, size 2): x, y offset in the destination image
size (table of int, size 2): size (width, height) of the copied region
Lua return values -
See also

simIM.create

Description Create an image with given size
Lua synopsis string handle=simIM.create(int width, int height, int format=sim_im_fmt_8UC3, int initialValue=0)
Lua parameters
width (int): width
height (int): height
format (int, default: sim_im_fmt_8UC3): image format (see simIM.format)
initialValue (int, default: 0): initial value to fill matrix with
Lua return values
handle (string): handle to image
See also

simIM.createFromData

Description Create an image from given raw data
Lua synopsis string handle=simIM.createFromData(int width, int height, string data, int format=sim_im_fmt_8UC3)
Lua parameters
width (int): width
height (int): height
data (string): image data
format (int, default: sim_im_fmt_8UC3): image format (see simIM.format)
Lua return values
handle (string): handle to image
See also

simIM.dataURL

Description Encode image data according to "data" URL scheme (RFC 2397)
Lua synopsis string output=simIM.dataURL(string imgHandle, string format='BMP')
Lua parameters
imgHandle (string): Handle to the image
format (string, default: 'BMP'): Image format (BMP, JPG, or PNG)
Lua return values
output (string): Buffer with encoded data
See also

simIM.destroy

Description Destroy (i.e.: free memory) an image with given handle
Lua synopsis simIM.destroy(string handle)
Lua parameters
handle (string): handle to image
Lua return values -
See also

simIM.distanceTransform

Description Calculates the distance to the closest zero pixel for each pixel of the source image.
Lua synopsis string handle=simIM.distanceTransform(string handle, int distanceType=sim_im_dist_L2, int maskSize=sim_im_masksize_precise, bool inPlace=false)
Lua parameters
handle (string): handle to image
distanceType (int, default: sim_im_dist_L2): type of distance (see simIM.dist)
maskSize (int, default: sim_im_masksize_precise): mask size (see simIM.masksize)
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to image
See also

simIM.divide

Description Calculates the per-element division of two arrays.
Lua synopsis string handle=simIM.divide(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.divideK

Description Calculates the per-element division of a scalar by an array.
Lua synopsis string handle=simIM.divideK(table[] k, string handle, bool inPlace=false)
Lua parameters
k (table of float): scalar
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.ellipse

Description Draw an ellipse with center (cx,cy) and axes (rx,ry) points in the image.
Lua synopsis simIM.ellipse(string handle, table[2] center, table[2] radius, float angle=0.0, float startAngle=0.0, float endAngle=360.0, table[3] color={255,255,255}, int thickness=1, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
center (table of int, size 2): x, y coordinates of center
radius (table of int, size 2): radius along x and y axis
angle (float, default: 0.0): rotation in degrees
startAngle (float, default: 0.0): starting angle of the elliptic arc in degrees
endAngle (float, default: 360.0): ending angle of the elliptic arc in degrees
color (table of int, size 3, default: {255,255,255}): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness (negative values means rect is filled)
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.encode

Description Encode the image to a memory buffer.
Lua synopsis string output=simIM.encode(string handle, string format)
Lua parameters
handle (string): handle to image
format (string): image format (e.g. "PNG", "JPG", "BMP")
Lua return values
output (string): output buffer
See also

simIM.exp

Description Calculates the exponential of every array element.
Lua synopsis string handle=simIM.exp(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.fillConvexPoly

Description Fills a convex polygon.
Lua synopsis simIM.fillConvexPoly(string handle, table[] points, table[3] color, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
points (table of int): polygon vertices, i.e. {x1, y1, x2, y2, ..., xN, yN}
color (table of int, size 3): color (red, green, blue values in range 0..255)
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.fillPoly

Description Fills the area bounded by one or more polygon.
Lua synopsis simIM.fillPoly(string handle, table[] points, table[] numPoints, table[2] offset, table[3] color, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
points (table of int): contour points, i.e. {c1x1, c1y1, c1x2, c1y2, ..., c1xN1, c1yN1, c2x1, c2y1, ..., c2xN2, c2yN2, ..., cMxNM, cMyNM}
numPoints (table of int): lengths of countours, i.e. {N1, N2, ..., NM}. the sum of numPoints items must be equal to the number of x,y pairs in points.
offset (table of int, size 2): x, y offset for all points
color (table of int, size 3): color (red, green, blue values in range 0..255)
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.flip

Description Flips an image around vertical, horizontal, or both axes.
Lua synopsis string handle=simIM.flip(string handle, int op=0, bool inPlace=false)
Lua parameters
handle (string): handle to image
op (int, default: 0): a flag to specify how to flip the array (see simIM.flipOp)
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.get

Description Get pixel at specified coordinate.
Lua synopsis table[] value=simIM.get(string handle, table[2] coord)
Lua parameters
handle (string): handle to image
coord (table of int, size 2): x, y coordinates
Lua return values
value (table of float): value
See also

simIM.gray2rgb

Description Convert the specified grayscale image to RGB.
Lua synopsis string handle=simIM.gray2rgb(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.hls2rgb

Description Convert the specified HLS image to RGB.
Lua synopsis string handle=simIM.hls2rgb(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.hsv2rgb

Description Convert the specified HSV image to RGB.
Lua synopsis string handle=simIM.hsv2rgb(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.line

Description Draw a line segment between (x1,y1) and (x2,y2) points in the image.
Lua synopsis simIM.line(string handle, table[2] p1, table[2] p2, table[3] color, int thickness=1, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
p1 (table of int, size 2): x, y coordinates of first point
p2 (table of int, size 2): x, y coordinates of second point
color (table of int, size 3): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.log

Description Calculates the natural logarithm of every array element.
Lua synopsis string handle=simIM.log(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.magnitude

Description Calculates the magnitude of 2D vectors, i.e. DST(i) = sqrt(SRC1(i)^2, SRC2(i)^2).
Lua synopsis string handle=simIM.magnitude(string handle1, string handle2)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
Lua return values
handle (string): handle of resulting image
See also

simIM.merge

Description Merge many single channel images into a multichannel image.
Lua synopsis string handle=simIM.merge(table[] handles)
Lua parameters
handles (table of string): handles to individual channel images
Lua return values
handle (string): handle to merged image
See also

simIM.mixChannels

Description Mix many single channel images into many multichannel images.
Lua synopsis simIM.mixChannels(table[] inputHandles, table[] outputHandles, table[] fromTo)
Lua parameters
inputHandles (table of string): handles to input images
outputHandles (table of string): handles to output images
fromTo (table of int): array of index pairs, i.e. {src1,dst1,src2,dst2,...,srcN,dstN}. see here for details
Lua return values -
See also

simIM.multiply

Description Calculates the per-element product of two arrays.
Lua synopsis string handle=simIM.multiply(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.openVideoCapture

Description Open video capture device.
Lua synopsis simIM.openVideoCapture(int deviceIndex)
Lua parameters
deviceIndex (int): device index (0 based)
Lua return values -
See also

simIM.phase

Description Calculates the rotation angle of 2D vectors, i.e. DST(i) = atan2(SRC2(i), SRC1(i)).
Lua synopsis string handle=simIM.phase(string handle1, string handle2, bool angleInDegrees=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
angleInDegrees (bool, default: false): when true, the function calculates the angle in degrees, otherwise, they are measured in radians
Lua return values
handle (string): handle of resulting image
See also

simIM.polar2cart

Description Calculates x and y coordinates of 2D vectors from their magnitude and angle.
Lua synopsis string handle1, string handle2=simIM.polar2cart(string handle1, string handle2, bool angleInDegrees=false)
Lua parameters
handle1 (string): handle to first image (magnitude)
handle2 (string): handle to second image (angle)
angleInDegrees (bool, default: false): when true, the function calculates the angle in degrees, otherwise, they are measured in radians
Lua return values
handle1 (string): handle of resulting image (x)
handle2 (string): handle of resulting image (y)
See also

simIM.polylines

Description Draw several polygonal curves.
Lua synopsis simIM.polylines(string handle, table[] points, table[] numPoints, bool isClosed, table[3] color, int thickness=1, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
points (table of int): curve points, i.e. {c1x1, c1y1, c1x2, c1y2, ..., c1xN1, c1yN1, c2x1, c2y1, ..., c2xN2, c2yN2, ..., cMxNM, cMyNM}
numPoints (table of int): lengths of curves, i.e. {N1, N2, ..., NM}. the sum of numPoints items must be equal to the number of x,y pairs in points.
isClosed (bool): Flag indicating whether the drawn polylines are closed or not. If they are closed, the function draws a line from the last vertex of each curve to its first vertex.
color (table of int, size 3): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.pow

Description Raises every array element to a power.
Lua synopsis string handle=simIM.pow(string handle, float power, bool inPlace=false)
Lua parameters
handle (string): handle to image
power (float): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.read

Description Read an image from the specified file.
Lua synopsis string handle=simIM.read(string filename)
Lua parameters
filename (string): file name
Lua return values
handle (string): handle to image
See also

simIM.readFromVideoCapture

Description Read frame from video capture device.
Lua synopsis string handle=simIM.readFromVideoCapture(int deviceIndex, string handle="")
Lua parameters
deviceIndex (int): device index (0 based)
handle (string, default: ""): handle to existing image, or "" to create and return a new image
Lua return values
handle (string): handle to new image (or existing image if given)
See also

simIM.readFromVisionSensor

Description Read image from vision sensor.
Lua synopsis string handle=simIM.readFromVisionSensor(int sensorHandle, string handle="")
Lua parameters
sensorHandle (int): handle to vision sensor
handle (string, default: ""): handle to existing image, or "" to create and return a new image
Lua return values
handle (string): handle to new image (or existing image if given)
See also

simIM.rectangle

Description Draw a rectangle with corners (x1,y1) and (x2,y2) points in the image.
Lua synopsis simIM.rectangle(string handle, table[2] p1, table[2] p2, table[3] color, int thickness=1, int type=8, int shift=0)
Lua parameters
handle (string): handle to image
p1 (table of int, size 2): x, y coordinates of top-left corner
p2 (table of int, size 2): x, y coordinates of bottom-right corner
color (table of int, size 3): color (red, green, blue values in range 0..255)
thickness (int, default: 1): line thickness (negative values means rect is filled)
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
shift (int, default: 0): number of fractional bits in the point coordinates
Lua return values -
See also

simIM.reduce

Description Reduces a matrix to a vector.
Lua synopsis string handle=simIM.reduce(string handle, int dim, int op, bool inPlace=false)
Lua parameters
handle (string): handle to image
dim (int): dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column.
op (int): reduction operation (see simIM.reduceOp)
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.repeat

Description Fills the output array with repeated copies of the input array.
Lua synopsis string handle=simIM.repeat(string handle, int nx, int ny, bool inPlace=false)
Lua parameters
handle (string): handle to image
nx (int): how many times the src is repeated along the horizontal axis
ny (int): how many times the src is repeated along the vertical axis
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.resize

Description Resize an image and return the resized image (original image is not modified).
Lua synopsis string handle=simIM.resize(string handle, int width, int height, int interpolation=sim_im_interp_linear, bool inPlace=false)
Lua parameters
handle (string): handle to image
width (int): width of the new image
height (int): height of the new image
interpolation (int, default: sim_im_interp_linear): type of interpolation (see simIM.interp)
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to resized image
See also

simIM.rgb2gray

Description Convert the specified RGB image to gray.
Lua synopsis string handle=simIM.rgb2gray(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.rgb2hls

Description Convert the specified RGB image to HLS.
Lua synopsis string handle=simIM.rgb2hls(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.rgb2hsv

Description Convert the specified RGB image to HSV.
Lua synopsis string handle=simIM.rgb2hsv(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle to the converted image
See also

simIM.scaleAdd

Description Calculates the sum of a scaled array and another array, i.e. DST(i) = SRC1(i)*scale + SRC2(i).
Lua synopsis string handle=simIM.scaleAdd(string handle1, string handle2, float alpha, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
alpha (float): scale coefficient
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.set

Description Set pixel at specified coordinate.
Lua synopsis simIM.set(string handle, table[2] coord, table[] value)
Lua parameters
handle (string): handle to image
coord (table of int, size 2): x, y coordinates
value (table of float): value
Lua return values -
See also

simIM.size

Description Get the size of an image.
Lua synopsis table[2] size=simIM.size(string handle)
Lua parameters
handle (string): handle to image
Lua return values
size (table of int, size 2): size (width, height) of the image
See also

simIM.split

Description Split a multichannel image.
Lua synopsis table[] handles=simIM.split(string handle)
Lua parameters
handle (string): handle to image
Lua return values
handles (table of string): handles to individual channel images
See also

simIM.sqrt

Description Calculates the square root of every array element.
Lua synopsis string handle=simIM.sqrt(string handle, bool inPlace=false)
Lua parameters
handle (string): handle to image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.subtract

Description Calculates the per-element difference of two arrays.
Lua synopsis string handle=simIM.subtract(string handle1, string handle2, bool inPlace=false)
Lua parameters
handle1 (string): handle to first image
handle2 (string): handle to second image
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.subtractK

Description Calculates the per-element difference of an array and a scalar.
Lua synopsis string handle=simIM.subtractK(string handle, table[] k, bool inPlace=false)
Lua parameters
handle (string): handle to image
k (table of float): scalar
inPlace (bool, default: false): if true, the original immage will be converted in place. otherwise, the original image will not be modified and a new image is returned.
Lua return values
handle (string): handle of resulting image
See also

simIM.text

Description Drawn a text string.
Lua synopsis simIM.text(string handle, string str, table[2] pos, int fontFace=sim_im_fontface_simplex, bool italic=false, float fontScale=1.0, table[3] color={255,255,255}, int thickness=1, int type=8, bool bottomLeftOrigin=false)
Lua parameters
handle (string): handle to image
str (string): text string to be drawn
pos (table of int, size 2): x, y coordinates of the origin (bottom-left corner of the string)
fontFace (int, default: sim_im_fontface_simplex): font face (see simIM.fontFace)
italic (bool, default: false): if true text will have italic style
fontScale (float, default: 1.0): font scale
color (table of int, size 3, default: {255,255,255}): color (red, green, blue values in range 0..255)
thickness (int, default: 1): thickness used to draw a text
type (int, default: 8): type of the line (8 for 8-connected line, 4 for 4-connected line, or 16 for antialiased line)
bottomLeftOrigin (bool, default: false): When true, the image data origin is at the bottom-left corner. Otherwise, it is at the top-left corner
Lua return values -
See also

simIM.textSize

Description Calculates the width and height of a text string.
Lua synopsis int width, int height, int baseline=simIM.textSize(string str, int fontFace=sim_im_fontface_simplex, bool italic=false, float fontScale=1.0, int thickness=1)
Lua parameters
str (string): text string to be drawn
fontFace (int, default: sim_im_fontface_simplex): font face (see simIM.fontFace)
italic (bool, default: false): if true text will have italic style
fontScale (float, default: 1.0): font scale
thickness (int, default: 1): thickness used to draw a text
Lua return values
width (int): width of the text
height (int): height of the text
baseline (int): y-coordinate of the baseline relative to the bottom-most text point
See also

simIM.write

Description Write the image with given handle to a file.
Lua synopsis simIM.write(string handle, string filename)
Lua parameters
handle (string): handle to image
filename (string): file name
Lua return values -
See also

simIM.writeToVisionSensor

Description Write image to vision sensor. Make sure the vision sensor is flagged as external input.
Lua synopsis simIM.writeToVisionSensor(string handle, int sensorHandle)
Lua parameters
handle (string): handle to image
sensorHandle (int): handle to vision sensor
Lua return values -
See also



Constants

Constants used in the various functions. Refer to each constant using enumName.constantName, i.e. simUI.curve_type.xy for xy constant in simUI.curve_type enum.

simIM.format

_8UC1: 1 channel, 8 bit unsigned int
_8UC3: 3 channels, 8 bit unsigned int
_8UC4: 4 channels, 8 bit unsigned int
_32FC1: 1 channel, 32 bit float
_32FC3: 3 channels, 32 bit float
_32FC4: 4 channels, 32 bit float

simIM.interp

nearest: nearest-neighbor interpolation
linear: bilinear interpolation
area: resampling using pixel area relation (best for shrinking)
cubic: bicubic interpolation over 4x4 pixel neighborhood
lanczos4: Lanczos interpolation over 8x8 pixel neighborhood

simIM.fontFace

simplex
plain
duplex
complex
triplex
complex_small
script_simplex
script_complex

simIM.cmpOp

eq
gt
ge
lt
le
ne

simIM.reduceOp

sum: the output is the sum of all rows/columns of the matrix.
avg: the output is the mean vector of all rows/columns of the matrix.
max: the output is the maximum (column/row-wise) of all rows/columns of the matrix.
min: the output is the minimum (column/row-wise) of all rows/columns of the matrix.

simIM.flipOp

x: flip around the x-axis
y: flip around the y-axis
both: flip around both axes

simIM.dist

L1
L2
C

simIM.maskSize

_3x3
_5x5
_precise