| MIL 10 Reference
| Customize Help
| Save Settings

MimStat



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

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
Calculate a variety of statistics on the source image.
Syntax
void MimStat(
MIL_ID SrcImageBufId, //in
MIL_ID StatResultImId, //in
MIL_INT64 StatType, //in
MIL_INT64 Condition, //in
MIL_DOUBLE CondLow, //in
MIL_DOUBLE CondHigh //in
)
Description

This function calculates a variety of statistics for the pixels that satisfy the specified condition in the source image. Results are stored in the specified statistic result buffer.

You can retrieve statistical results using MimGetResult1d() or MimGetResult().

If pixel values in your image represent angles instead of intensities, you can also choose to have MIL treat the pixels as unit vectors, where the angular value of a pixel is considered to be the angle of a vector with a length of one. Treating the pixels as unit vectors allows MIL to calculate directional statistics, which take into account the wrap-around characteristic of angles (so that, for example, the mean of 0 and 360 is either 0 or 360, not 180). For example, instead of selecting to calculate the average value of the hue component of pixels in HSL color images, you should select to calculate their angular mean (M_ANGULAR_DATA_MEAN), since hue is expressed as an angular value. In this case, the angles are treated as unit vectors and added using vector addition before being divided by the number of pixels.

The angles are considered to have been scaled to the type of image buffer. For unsigned buffers, the minimum pixel value is considered as an angle of 0, and one plus the maximum possible pixel intensity value is considered as an angle of 360. For example, an 8-bit buffer would have 0° mapped to a value of 0, while 360° would be mapped to a value of 256 (since the maximum pixel value is 255). For signed buffers, the minimum pixel value is considered as an angle of -180° while one plus the maximum pixel value is considered as an angle of 180°. Floating point buffers have intensity values anywhere between 0 and 1, and these values are linearly mapped between 0° and 360°.

You can limit this function's results to a region of the source image buffer using a region of interest (ROI) set using MbufSetRegion().

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 if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
SrcImageBufId

Specifies the identifier of the source image for the operation. This parameter must be given a 1-band image buffer identifier.

This image buffer can have an 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).

StatResultImId

Specifies the identifier of the destination result buffer for the operation.

This parameter must be given the identifier of an image processing result buffer, allocated using MimAllocResult() function with M_STAT_LIST as the result type.

StatType

Specifies the type of statistic to compute.

You can set the StatType parameter to one or more of the following values.

function map For specifying the type of statistic to compute
CollapseValue Description
Collapse M_MAX

Specifies the maximum pixel value that respects the setting of the Condition parameter.

Collapse M_MAX_ABS

Specifies the maximum absolute pixel value that respects the setting of the Condition parameter.

Collapse M_MEAN

Specifies the mean value of the pixels that respect the setting of the Condition parameter.

Collapse M_MIN

Specifies the minimum pixel value that respects the setting of the Condition parameter.

Collapse M_MIN_ABS

Specifies the minimum absolute pixel value that respects the setting of the Condition parameter.

Collapse M_NUMBER +

Specifies the number of pixels that respect the setting of the Condition parameter.

Collapse M_STANDARD_DEVIATION

Specifies the standard deviation of the pixels values that respect the setting of the Condition parameter. Note that MIL calculates the standard deviation using the following formula:

(summarize)
Collapse M_SUM

Specifies the sum of the pixel values that respect the setting of the Condition parameter.

Collapse M_SUM_ABS

Specifies the sum of the absolute pixel values that respect the setting of the Condition parameter.

Collapse M_SUM_OF_SQUARES

Specifies the sum of the squared pixel values that respect the setting of the Condition parameter.

Combination constants that can be used alone or as combination constants for M_NUMBER.

You can use one or more of the following values in combination with each other or with the above-mentioned value, to set which angular statistics to compute.

To calculate these statistics, the pixel values in your image should represent angles since these statistics will treat the pixels as unit vectors.

Note that the result of the addition of the angular data using vector addition is known as the vector sum.

function map For computing angular statistics
CollapseValue Description
Collapse M_ANGULAR_DATA_COHERENCE

Calculates the coherence of the angular data. The coherence represents the directional trend of all the angular data in the image and is a measure of how coherent or parallel the unit vectors are with respect to each other. The coherence is calculated as the ratio between the length (norm) of the vector sum and its maximum possible length (which corresponds to the number of pixels being considered, since each pixel is presumed to have a length of one). Numerically, this quantity lies between 0 and 1, where 0 represents absolutely no coherence (unit vectors pointing in random directions) and 1 is total coherence (unit vectors pointing in same direction).

(summarize)
Collapse M_ANGULAR_DATA_MEAN

Calculates the dominant direction of the unit vectors. This angle is a representation of the mean (or average) angle of all the angular data.

Note that to obtain more representative results, the mean angle should be analyzed in context with the coherence. For example, if your image has a coherence of 0.1 and a mean angle of 65°, the mean angle is not very meaningful because the unit vectors are pointing in random, incoherent directions. However, if your image has a coherence of 0.9 and a mean angle of 65°, this indicates that the unit vectors are more or less pointing in the same direction and their average value is around 65°.

(summarize)
Collapse M_ORIENTATION_DATA_MEAN

Calculates the dominant orientation of the unit vectors. The orientation of a unit vector is its inclination, without its direction; if two unit vectors have opposite directions (for example, an angle of 0° and 180°), they have the same orientation (0°). Calculating the dominant orientation using unit vectors with opposite directions (0° and 180°) would result in the magnitude of their vector sum being double the original value (2) and a dominant orientation of 0°. Whereas, calculating the dominant orientation using two unit vectors that are separated by 90° (for example, an angle of 0° and 90°) would result in the magnitude of their vector sum being 0, effectively canceling each other out (no dominant orientation), and an invalid orientation angle.

(summarize)

To compute all of the different statistics listed in the For specifying the type of statistic to compute table, set StatType to the following:

function map For computing the statistics
CollapseValue Description
Collapse M_ALL

Specifies that all statistics mentioned in the For specifying the type of statistic to compute table are to be computed.

Condition

Specifies the condition for the statistical computation.

If no condition is required, set the Condition parameter to the value below.

function map For specifying the condition for the statistical computation
CollapseValue Description
Collapse M_NULL

Specifies that no condition is set. Set CondLow and CondHigh parameters to M_NULL.

(summarize)

For conditions that use two limits, set the Condition parameter to one of the values below.

function map For conditions that use two limits
CollapseValue Description
Collapse M_IN_RANGE

Specifies that pixels with values between CondLow and CondHigh, inclusive, will be used for statistical calculations.

Collapse M_OUT_RANGE

Specifies that pixels with values less than CondLow, or greater than CondHigh, will be used for statistical calculations.

For conditions that use one limit, set the Condition parameter to one of the values below.

function map For conditions that use one limit
CollapseValue Description
Collapse M_EQUAL

Specifies that only pixels with values equal to CondLow will be used for statistical calculations.

Collapse M_GREATER

Specifies that only pixels with values greater than CondLow will be used for statistical calculations.

Collapse M_GREATER_OR_EQUAL

Specifies that only pixels with values greater than or equal to CondLow will be used for statistical calculations.

Collapse M_LESS

Specifies that only pixels with values less than CondLow will be used for statistical calculations.

Collapse M_LESS_OR_EQUAL

Specifies that only pixels with values less than or equal to CondLow will be used for statistical calculations.

Collapse M_MASK

Specifies that only pixels corresponding to the non-zero pixels in the mask buffer will be used for statistical calculations. Specify the mask using the CondLow parameter.

(summarize)
Collapse M_NOT_EQUAL

Specifies that only pixels with values not equal to CondLow will be used for statistical calculations.

CondLow

Specifies the lower limit of the selected condition.

This parameter must be set to one of the following:

function map For the lower limit
CollapseValue Description
Collapse M_NULL

Specifies that no lower limit is required. This setting should only be used when the Condition parameter is also set to M_NULL.

(summarize)
Collapse MIL image buffer identifier

Specifies a 1-band image buffer used as the mask. The buffer must be of the same size as the source image. This setting can only be used when the Condition parameter is set to M_MASK.

(summarize)
Collapse Value

Specifies the lower limit.

CondHigh

Specifies the upper limit of the selected condition.

This parameter must be set to one of the following values.

function map For the upper limit
CollapseValue Description
Collapse M_NULL

Specifies that no upper limit is required. This setting should be used for all conditions, except M_IN_RANGE and M_OUT_RANGE.

(summarize)
Collapse Value

Specifies the upper limit.

Compilation information
Header Include mil.h.
Library Use mil.lib; milim.lib.
DLL Requires mil.dll; milim.dll.
PROC VECTOR MAX MAX ABS MEAN MIN MIN ABS NUMBER STANDARD DEVIATION SUM SUM ABS SUM OF SQUARES ANGULAR DATA COHERENCE ANGULAR DATA MEAN ORIENTATION DATA MEAN ALL NULL IN RANGE OUT RANGE EQUAL GREATER GREATER OR EQUAL LESS LESS OR EQUAL MASK NOT EQUAL NULL PROC NULL NULL IN RANGE OUT RANGE MASK