Filters
Filter values by
Operation
  • 2 image buffers
  • One image and one constant
  • One constant and one image
  • Only one image
  • Only one constant
| Customize Help
| Save Settings

MimArith



Function Map
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 unless M_FLOAT_PROC or M_FIXED_POINT has been added to the operation type. 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.

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 unless M_FLOAT_PROC or M_FIXED_POINT has been added to the operation type. 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.

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.

Operation

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

Operations using two image buffer operands are the following:

function map For specifying the type of operation
Click to summarizeValue Description
Click to summarize M_ABS_SUB +

Subtracts the absolute values of the second image from the corresponding absolute values of the first image.

Click to summarize M_ADD +

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

Click to summarize M_AND +

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

Click to summarize 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 and maximum 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)
Click to summarize M_AVG +

Averages the values of the first and second images.

Click to summarize 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)
Click to summarize M_EXP +

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

Click to summarize M_LOG +

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

Click to summarize M_MAX

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

Click to summarize M_MAX_ABS +

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

Click to summarize M_MIN

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

Click to summarize M_MIN_ABS +

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

Click to summarize M_MULT +

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

Click to summarize M_NAND +

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

Click to summarize M_NOR +

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

Click to summarize M_OR +

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

Click to summarize M_SUB +

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

Click to summarize 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.

Click to summarize M_XNOR +

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

Click to summarize M_XOR +

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

Combination value for M_MAX_ABS; M_MIN_ABS.

You can add the following value to the above-mentioned values to set the destination buffer to the source value of the selected pixel instead of the pixel's value used in the comparison.

function map For specifying to save the source value
Click to summarize
Combination value
Description
Click to summarize M_SOURCE_VALUE

Specifies to write the source value of the selected pixel into the destination buffer. When corresponding pixels from the two source images are compared based on the specified operation, MimArith() writes the source value of the pixel from the selected image into the destination buffer instead of the value used during the comparison.

For example, if combined with M_MAX_ABS, after finding the maximum absolute value between the corresponding pixels in the two source images, MimArith() writes the source value of the bigger absolute value in the destination buffer.

(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
Click to summarizeValue Description
Click to summarize M_EQUAL

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

Click to summarize M_GREATER

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

Click to summarize M_GREATER_OR_EQUAL

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

Click to summarize M_LESS

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

Click to summarize M_LESS_OR_EQUAL

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

Click to summarize 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
Click to summarizeValue Description
Click to summarize M_ADD_CONST +

Adds a constant to the values of an image.

Click to summarize M_AND_CONST +

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

Click to summarize 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)
Click to summarize M_CONST_EXP +

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

Click to summarize M_CONST_LOG +

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

Click to summarize M_CONST_PASS

Copies the constant to each destination pixel.

Click to summarize M_CONST_SUB +

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

Click to summarize 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)
Click to summarize M_EXP_CONST +

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

Click to summarize M_LOG_CONST +

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

Click to summarize M_MAX_CONST

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

Click to summarize M_MIN_CONST

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

Click to summarize M_MULT_CONST +

Multiplies the values of the image by the constant.

Click to summarize M_NAND_CONST +

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

Click to summarize M_NOR_CONST +

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

Click to summarize M_OR_CONST +

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

Click to summarize M_SUB_CONST +

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

Click to summarize M_SUB_CONST_ABS +

Takes the absolute value of the subtraction of a constant value from the values of the first image.

Click to summarize M_XNOR_CONST +

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

Click to summarize M_XOR_CONST +

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

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

function map For specifying to perform operations in fixed-point or floating-point format
Click to summarize
Combination value
Description
Click to summarize 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 and it can only be used with M_CONST_DIV, M_DIV and M_DIV_CONST. In addition, this attribute cannot be used in combination with M_FLOAT_PROC.

(summarize)
Click to summarize 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. This attribute cannot be used with M_DIV. In addition, this attribute cannot be used in combination with M_FIXED_POINT.

(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
Click to summarizeValue Description
Click to summarize M_EQUAL_CONST

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

Click to summarize M_GREATER_CONST

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

Click to summarize M_GREATER_OR_EQUAL_CONST

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

Click to summarize M_LESS_CONST

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

Click to summarize M_LESS_OR_EQUAL_CONST

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

Click to summarize 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
Click to summarizeValue Description
Click to summarize M_ABS

Takes the absolute value of the image values.

Click to summarize M_CUBE +

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

Click to summarize M_INTEGRAL +

Takes the integral of the image. This computes the cumulative sum of the source image at the corresponding pixels in the destination. Each pixel in the destination buffer contains the total sum of the pixels in the rectangular sections delimited by the pixel at (0, 0) and itself, inclusively.

(summarize)
Click to summarize M_LN +

Performs a natural logarithm on the image values.

Click to summarize M_LOG2 +

Performs a base-2 logarithm on the image values.

Click to summarize M_LOG10 +

Performs a base-10 logarithm on the image values.

Click to summarize 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)
Click to summarize 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)
Click to summarize M_PASS

Copies the source buffer to the destination image buffer.

Click to summarize M_SQUARE +

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

Click to summarize 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 to use the logical operation rather than the bitwise operation.

function map For specifying to perform logical operations
Click to summarize
Combination value
Description
Click to summarize 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)

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
Click to summarize
Combination value
Description
Click to summarize 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 ABS SUB ADD AND ATAN2 AVG DIV EXP LOG MAX MAX ABS MIN MIN ABS MULT NAND NOR OR SUB SUB ABS XNOR XOR SOURCE VALUE 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 SUB CONST ABS 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 INTEGRAL LN LOG2 LOG10 NEG NOT PASS SQUARE SQUARE ROOT LOGICAL SATURATION NULL NULL NULL CONST DIV DIV DIV CONST