| MIL 10 Reference
| Customize Help
| Save Settings

MpatAllocAutoModel



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
Previous
Synopsis
Automatically allocate unique pattern matching models of the specified type, from a source image.
Syntax
MIL_ID MpatAllocAutoModel(
MIL_ID SystemId, //in
MIL_ID SrcImageBufId, //in
MIL_INT SizeX, //in
MIL_INT SizeY, //in
MIL_INT PosUncertaintyX, //in
MIL_INT PosUncertaintyY, //in
MIL_INT64 ModelType, //in
MIL_INT64 Mode, //in
MIL_ID *ModelIdArrayPtr //out
)
Description

This function searches for the specified number of most-suitable unique areas, of the specified dimensions, in the model's source image. From each area found, the function automatically allocates a model. If none are found, no model is allocated and an error is reported. It can take several seconds to find the best models (more for large or small images).

To be effective, the model's target image should be a typical target image. Therefore, MpatAllocAutoModel() is useful, for example, when you want to perform whole image alignment, for which allocation of a unique model is essential.

You can determine the offset of a model's origin relative to its source image, using the MpatInquire() function.

If the eventual model can appear at an angle, in most cases, it is better to allocate an M_NORMALIZED + M_CIRCULAR_OVERSCAN type of model and then use MpatSetAngle() to specify the angular range.

You can change a model's search parameter settings at any time, using the appropriate MpatSet...() function. When the model(s) is no longer required, you should release its memory, using MpatFree().

You can only define models that respect the following condition: (maxvalue 2 * SizeX * SizeY) < 2 63 where maxvalue is the maximum pixel value (typically, 255) in the target image and the model. This restriction is imposed to avoid overflows in the internal 64-bit accumulators.

The total area of the defined model must be greater or equal to 4 pixels (SizeX * SizeY >= 4).

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
SystemId INQ

Specifies the system on which to allocate the models.

This parameter should be set to one of the following values:

function map For specifying the system identifier
CollapseValue Description
Collapse M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

Collapse MIL system identifier

Specifies a valid system identifier, which you have allocated using the MsysAlloc() function.

SrcImageBufId

Specifies the identifier of the image buffer from which to extract the models. This image should be representative of the target images. This function currently supports only 8-bit unsigned grayscale images.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

SizeX INQ

Specifies the width of the required models.

SizeY INQ

Specifies the height of the required models.

PosUncertaintyX

Specifies the maximum displacement (shift) expected between the reference position of the models in the source image and their position when found in the target images in the horizontal direction. This information is used to select models that are far enough from the image borders to be present in the target images.

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

function map For specifying the maximum displacement in the X-direction
CollapseValue Description
Collapse M_DEFAULT

Selects models from anywhere in the whole width of the image. The default search region of each model is automatically set using the original position of the model, plus or minus the specified positional uncertainty.

(summarize)
Collapse Value

Sets PosUncertaintyX to the expected maximum pixel displacement in the horizontal direction. This value will select models that are far enough from the image borders to be present in the target images.

(summarize)
PosUncertaintyY

Specifies the maximum displacement (shift) expected between the reference position of the models in the source image and their position when found in the target images in the vertical direction. This information is used to select models that are far enough from the image borders to be present in the target images.

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

function map For specifying the maximum displacement in the Y-direction
CollapseValue Description
Collapse M_DEFAULT

Selects models from anywhere in the whole height of the image. The default search region of each model is automatically set using the original position of the model, plus or minus the specified positional uncertainty.

(summarize)
Collapse Value

Sets PosUncertaintyY to the expected maximum pixel displacement in the vertical direction. This value will select models that are far enough from the image borders to be present in the target images.

(summarize)
ModelType INQ

Specifies the type of the model. The parameter must be set to the following:

function map For specifying the type of model
CollapseValue Description
Collapse M_NORMALIZED +

Specifies a model used to search for the position, match score, and angle (if angular search is enabled) of a model occurrence in a target image, using MpatFindModel() and MpatFindMultipleModel().

Combination constant for any of the possible values of the ModelType parameter.

You can add the following value to the above-mentioned value to extract the model, as well as circular overscan data.

function map For the ModelType parameter
CollapseCombination value Description
Collapse M_CIRCULAR_OVERSCAN

Extracts the model, as well as circular overscan data from the source image. The overscan data is determined by rotating the area from which to extract the model, about its center. The overscan data of an M_CIRCULAR_OVERSCAN type model is used if you search for an occurrence of the model at an angle.

For this model, you cannot define "don't care" pixels (MpatSetDontCare()).

(summarize)
Mode

Specifies the speed of the allocation process. This parameter must be set to one of the values below.

function map For specifying the speed of the allocation
CollapseValue Description
Collapse M_DEFAULT

Same as M_FAST.

Collapse M_BEST +

Allocates the models with high precision.

Collapse M_FAST +

Allocates the models at high-speed.

Combination constant for any of the possible values of the Mode parameter.

You can add the following value to the above-mentioned values to set the number of models to allocate from the same image.

function map For the Mode parameter
CollapseCombination value Description
Collapse M_MULTIPLE + n

Allocates several models from the same image. Set n to the number of models to allocate.

For example, set Mode to M_BEST + M_MULTIPLE + 4 to find and allocate the four most unique models available in your image. Models can overlap within the image by half the size of the model (in X and Y).

(summarize)
ModelIdArrayPtr

Specifies the address of the array in which to write the model identifiers. The identifier is required to use a model with other pattern matching functions. Since MpatAllocAutoModel() also returns the model identifier, you can set this parameter to M_NULL when allocating a single model. If allocation fails, M_NULL is written as the identifier.

Return value
The returned value is the model identifier if the allocation is successful. If allocation fails, M_NULL is returned.
Compilation information
Header Include mil.h.
Library Use mil.lib; milpat.lib.
DLL Requires mil.dll; milpat.dll.
DEFAULT HOST UNSIGNED PROC NONE SIZE X SIZE Y DEFAULT DEFAULT NORMALIZED CIRCULAR OVERSCAN DEFAULT BEST FAST MULTIPLE n