| MIL 10 Reference
| Customize Help
| Save Settings

MimArith



See also
Availability
Available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Partially supported on:
Partially supported on Matrox GPU processing driver

Fully supported on:
Fully supported on Host system
Fully supported on Matrox CronosPlus
Fully supported on Matrox GigE Vision driver
Fully supported on Matrox IEEE 1394 IIDC driver
Fully supported on Matrox Iris GT
Fully supported on Matrox Morphis
Fully supported on Matrox Morphis QxT
Fully supported on Matrox Orion HD
Fully supported on Matrox Radient eCL
Fully supported on Matrox Radient eV-CXP
Fully supported on Matrox Solios eA/XA
Fully supported on Matrox Solios ecl/xcl/ev-cl
Fully supported on Matrox USB3 Vision driver (requires Update 19)
Fully supported on Matrox Vio

For any information regarding a MIL system added during a MIL Update, see the MIL system’s release note

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Perform a point-to-point arithmetic operation.
Syntax
void MimArith(
MIL_DOUBLE Src1ImageBufIdOrConst, //in
MIL_DOUBLE Src2ImageBufIdOrConst, //in
MIL_ID DstImageBufId, //in
MIL_INT64 Operation //in
)
Description

This function performs the specified point-to-point operation on two images, an image and a constant, an image, or a constant, storing results in the specified destination image buffer.

You can limit this function's results to a region of an image buffer using a region of interest (ROI) set using MbufSetRegion(). The ROI must be defined in raster format (M_RASTER or M_VECTOR_AND_RASTER). An error is generated if the ROI is only in vector format (M_VECTOR). If you specify multiple image buffers with an ROI, results are limited to the portion of the ROIs that intersect.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see which MIL system’s documentation you should use in its place and any possible differences.
Parameters
This function is not supported on the selected boards.
This function reference has not been updated for the selected MIL system. To show the content of this page, choose a second MIL system; refer to the MIL system's release note to see which MIL system’s documentation to choose and any possible differences.
Parameters
Src1ImageBufIdOrConst

Specifies the data source of the first operand. This parameter can be given an image buffer identifier or a constant. When using a constant, it will be considered to have the same type as the destination buffer. If you specify an image buffer that has an ROI associated with it, the ROI must be in raster format; otherwise, you will get an error.

Note that logical operations (for example M_AND and M_OR) cannot be performed on a floating-point buffer.

[Matrox GPU processing driver]

The source image buffer must be unsigned monochrome 8- or 16-bit, or M_BGR32 packed.

Src2ImageBufIdOrConst

Specifies the data source of the second operand. This parameter can be given an image buffer identifier or a constant. If the selected operation uses only one operand, set this parameter to M_NULL. When using a constant, it will be considered to have the same type as the destination buffer. If you specify an image buffer that has an ROI associated with it, the ROI must be in raster format; otherwise, you will get an error.

Note that logical operations (for example M_AND and M_OR) cannot be performed on a floating-point buffer.

[Matrox GPU processing driver]

The source image buffer must be unsigned monochrome 8- or 16-bit, or M_BGR32 packed.

DstImageBufId

Specifies the identifier of the destination of the results. This parameter must be given an image buffer identifier. If you specify an image buffer that has an ROI associated with it, the ROI must be in raster format; otherwise, you will get an error.

[Matrox GPU processing driver]

The destination image buffer must be unsigned monochrome 8- or 16-bit, or M_BGR32 packed.

Operation

Specifies the operation to perform. This parameter should be set in accordance to the operands.

[Matrox GPU processing driver]

Supports packed binary buffers for logical operations (for example M_AND and M_OR).

Operations using two image buffer operands are the following:

function map For specifying the type of operation
CollapseValue Description
Collapse M_ADD +

Adds the values of the first image to the corresponding values of the second image.

Collapse M_AND +

Performs a bitwise AND operation between the values of the first and second images.

Collapse M_ATAN2

Performs the two-argument arctangent function, atan2(x, y), using the first image for the X-coordinates and the second image for the Y-coordinates. This results in the counter-clockwise angle between the image's positive X-axis and each X- and Y-coordinate.

MIL establishes the resulting angle according the type of the source image buffer, and its minimum (M_MIN) and maximum (M_MIN) values. For unsigned buffers, MIL maps 0° to the minimum value of the two images, and 360° to the maximum value plus 1 (for 8-bit buffers, a maximum possible value of 256 maps to 360°). For signed buffers, MIL maps -180° to the minimum value of the two images, and +180° to the maximum value plus 1. For float buffers, MIL expects values between 0 and 1, and maps them to angles between 0° and 360°.

(summarize)
Collapse M_DIV +

Divides the values of the first image by the values of the second image.

Note that dividing a value by 0 will generate a destination pixel with an unpredictable value. This will not generate an error.

(summarize)
Collapse M_EXP

Raises the values of the first image to the power of the second image's values.

Collapse M_LOG

Takes the logarithm of the values of the second image, to the base of the values of the first image.

Collapse M_MAX

Compares the values of the first image with the values of the second image, and takes the maximum of the two.

Collapse M_MIN

Compares the values of the first image with the values of the second image, and takes the minimum of the two.

Collapse M_MULT +

Multiplies the values of the first image with the values of the second image.

Collapse M_NAND +

Performs a bitwise NAND operation between the values of the first and second images.

Collapse M_NOR +

Performs a bitwise NOR operation between the values of the first and second images.

Collapse M_OR +

Performs a bitwise OR operation between the values of the first and second images.

Collapse M_SUB +

Subtracts the values of the second image from the values of the first image (for example, image 1 - image 2).

Collapse M_SUB_ABS +

Takes the absolute value of the result of subtracting the values of the second image from the values of the first image.

Collapse M_XNOR +

Performs a bitwise exclusive NOR operation between the values of the first and second images.

Collapse M_XOR +

Performs a bitwise exclusive OR operation between the first and second images.

You can add the following value to the above-mentioned values to specify to use the logical operation rather than the bitwise operation.

function map For specifying to perform logical operations
CollapseCombination value Description
Collapse M_LOGICAL

Specifies to use the logical operation rather than the bitwise operation.

The bitwise operation performs the specified operation on each binary digit. The logical operation determines the boolean state of the image pixel or constant based on whether it is equal to 0, and then performs the specified operation on that boolean state. In the destination buffer, a result of TRUE or FALSE is represented as 1 or 0, respectively.

(summarize)

For a signed or unsigned destination buffer, the following logical operations will result in either the highest unsigned buffer value (regardless if the buffer is signed) or 0. For a floating-point buffer, the result will either be 0 or 1. Logical operations using two image buffer operands include the following.

function map For logical operations using two image buffers
CollapseValue Description
Collapse M_EQUAL

Determines if the values of the first and second images are equal.

Collapse M_GREATER

Determines if the values of the first image are greater than the second image.

Collapse M_GREATER_OR_EQUAL

Determines if the values of the first image are greater than or equal to the second image.

Collapse M_LESS

Determines if the values of the first image are less than the second image.

Collapse M_LESS_OR_EQUAL

Determines if the values of the first image are less than or equal to the second image.

Collapse M_NOT_EQUAL

Determines if the values of the first and second images are not equal.

The following are operations that use an image buffer operand and a constant. If the operation is not commutative, you must pass the constant as either the first or second operand, as can be determined from the predefined operation name.

function map For operations using one image buffer and a constant
CollapseValue Description
Collapse M_ADD_CONST +

Adds a constant to the values of an image.

Collapse M_AND_CONST +

Performs a bitwise AND operation on the image and a constant.

Collapse M_CONST_DIV +

Divides a constant by the values of an image (for example, constant / image).

Note that dividing the constant by 0 will generate a destination pixel with an unpredictable value. This will not generate an error.

(summarize)
Collapse M_CONST_EXP

Raises a constant to the power specified by the values of an image.

Collapse M_CONST_LOG

Takes the logarithm of the values of an image, to the base of a constant (for example LOG constant Image).

Collapse M_CONST_PASS

Copies the constant to each destination pixel.

Collapse M_CONST_SUB +

Subtracts the image from the constant (for example, constant - image).

Collapse M_DIV_CONST +

Divides the values of an image by a constant (for example, image / constant).

Note that dividing a value by 0 will generate an error.

(summarize)
Collapse M_EXP_CONST +

Raises the values of the image to the power specified by the constant.

Collapse M_LOG_CONST

Takes the logarithm of a constant, to the base of the values of an image (for example LOG image Constant).

Collapse M_MAX_CONST

Compares the values of one image with a constant, and takes the maximum of the two.

Collapse M_MIN_CONST

Compares the values of one image with a constant, and takes the minimum of the two.

Collapse M_MULT_CONST +

Multiplies the values of the image by the constant.

Collapse M_NAND_CONST +

Performs a bitwise NAND operation with an image and a constant.

Collapse M_NOR_CONST +

Performs a bitwise NOR operation with an image and a constant.

Collapse M_OR_CONST +

Performs a bitwise OR operation with an image and a constant.

Collapse M_SUB_CONST +

Subtracts a constant from the values of an image (for example, image - constant).

Collapse M_XNOR_CONST +

Performs a bitwise exclusive NOR operation with an image and a constant.

Collapse M_XOR_CONST +

Performs a bitwise exclusive OR operation with an image and a constant.

Combination constant for M_CONST_DIV; M_DIV; M_DIV_CONST.

You can add the following value to the above-mentioned values to specify that the operation is performed in fixed point format.

function map For specifying to perform operations in fixed point format
CollapseCombination value Description
Collapse M_FIXED_POINT

Forces the operation to be performed in a fixed point format.

Operations using this attribute result in an 0.8 fixed-point format for an 8-bit destination. That is, the 8 bits comprise only the fractional portion of the value, and no integer portion. When the destination image buffer is 16-bit, operations that use the M_FIXED_POINT attribute result in an 8.8 fixed-point format (where the eight most-significant bits are the integer portion and the eight least-significant bits are the fractional portion). For a 32-bit destination, the result is in a 16.16 fixed-point format.

Note that this attribute cannot be used when using a floating-point destination buffer.

(summarize)

You can add the following value to the above-mentioned values to specify that the operation is performed in floating-point format.

function map For specifying to perform operations in floating-point format
CollapseCombination value Description
Collapse M_FLOAT_PROC

Forces the operation to be performed in floating-point format.

Note that, if the destination buffer is not a floating-point buffer, the resulting data of the operation will be truncated accordingly.

(summarize)

For a signed or unsigned destination buffer, the following logical operations will result in either the highest unsigned buffer value (regardless if the buffer is signed) or 0. For a floating-point buffer, the result will either be 0 or 1. Logical operations using one image buffer and a constant include the following.

function map For logical operations using one image buffer and a constant
CollapseValue Description
Collapse M_EQUAL_CONST

Determines if the values of an image are equal to the specified constant.

Collapse M_GREATER_CONST

Determines if the values of an image are greater than the specified constant.

Collapse M_GREATER_OR_EQUAL_CONST

Determines if the values of an image are greater than or equal to the specified constant.

Collapse M_LESS_CONST

Determines if the values of an image are less than the specified constant.

Collapse M_LESS_OR_EQUAL_CONST

Determines if the values of an image are less than or equal to the specified constant.

Collapse M_NOT_EQUAL_CONST

Determines if the values of an image are not equal to the specified constant.

Operations using only one image buffer operand are the following:

function map For operations using one image buffer
CollapseValue Description
Collapse M_ABS

Takes the absolute value of the image values.

Collapse M_CUBE +

Raises the image values to the power of 3 ( x 3 ).

Collapse M_LN +

Performs a natural logarithm on the image values.

Collapse M_LOG2 +

Performs a base-2 logarithm on the image values.

Collapse M_LOG10 +

Performs a base-10 logarithm on the image values.

Collapse M_NEG

Performs a unary negation operation (2's complement) on an image. For example, if a pixel has a binary value of 0x01000000 (corresponding to a decimal value of 64 in a signed buffer) and you perform an M_NEG operation on it, the resulting value will be 0x11000000 (corresponding to a decimal value of -64).

This operation is buffer dependent. That is, a signed buffer with a value of 64 will be converted to -64, whereas an unsigned buffer with a value of 64 will be converted to 192.

(summarize)
Collapse M_NOT +

Performs a bitwise NOT operation (1's complement) on an image. For example, if a pixel has a binary value of 0x01000000 (corresponding to a decimal value of 64 in an unsigned buffer) and you perform an M_NOT operation on it, the resulting value will be 0x10111111 (corresponding to a decimal value of 191).

This operation is buffer dependent. That is, a signed buffer with a value of 64 will be converted to -63, whereas an unsigned buffer with a value of 64 will be converted to 191.

(summarize)
Collapse M_PASS

Copies the source buffer to the destination image buffer.

Collapse M_SQUARE +

Raises the image values to the power of 2 ( x 2 ).

Collapse M_SQUARE_ROOT +

Performs a square root operation on the image values.

You can add the following value to the above-mentioned values to specify that the operation result should be saturated if necessary.

function map For specifying to saturate results that overflow or underflow
CollapseCombination value Description
Collapse M_SATURATION

Forces the operation to saturate any resulting pixel values that overflow or underflow the possible range of the destination buffer. The pixel values are clipped to fit within the buffer's range, rather than wrapped around the range.

If you do not specify M_SATURATION and there is an overflow or underflow, the resulting pixel values are either clipped (saturated) or wrapped around the buffer's range (not saturated), depending on which is faster for your hardware.

(summarize)
Compilation information
Header Include mil.h.
Library Use mil.lib; milim.lib.
DLL Requires mil.dll; milim.dll.
PROC VECTOR PROC VECTOR PROC VECTOR ADD AND ATAN2 DIV EXP LOG MAX MIN MULT NAND NOR OR SUB SUB ABS XNOR XOR LOGICAL EQUAL GREATER GREATER OR EQUAL LESS LESS OR EQUAL NOT EQUAL ADD CONST AND CONST CONST DIV CONST EXP CONST LOG CONST PASS CONST SUB DIV CONST EXP CONST LOG CONST MAX CONST MIN CONST MULT CONST NAND CONST NOR CONST OR CONST SUB CONST XNOR CONST XOR CONST FIXED POINT FLOAT PROC EQUAL CONST GREATER CONST GREATER OR EQUAL CONST LESS CONST LESS OR EQUAL CONST NOT EQUAL CONST ABS CUBE LN LOG2 LOG10 NEG NOT PASS SQUARE SQUARE ROOT SATURATION NULL