| Customize Help
| Save Settings

MpatDefine



Function Map
Synopsis
Add one or more models to, or delete a model from, a Pattern Matching context.
Syntax
void MpatDefine(
MIL_ID ContextPatId, //in
MIL_INT64 ModelType, //in
MIL_ID SrcImageBufId, //in
MIL_DOUBLE Param1, //in
MIL_DOUBLE Param2, //in
MIL_DOUBLE Param3, //in
MIL_DOUBLE Param4, //in
MIL_INT64 ControlFlag //in
)
Description

This function allows you to add one or more models at a time to, or delete a model from, a Pattern Matching context. When defining a search model, you are specifying the area of an image to use as a pattern to find within a target image, using MpatFind(). When a call to MpatFind() is made, all models that are part of the specified context (and that have MpatControl() with M_NUMBER set to a value greater than zero) are searched for simultaneously in the target. Note, when a model is added or deleted, the Pattern Matching context must be preprocessed again, using MpatPreprocess().

The search is performed according to the general search settings specified in the Pattern Matching context, as well as the individual model search settings (depending on the M_SEARCH_MODE value specified). Specify both the context and individual model search settings using MpatControl().

When adding a model to the context, a number is assigned to the new model. The context starts numbering the models at 0, and each subsequent model added to the Pattern Matching context is given a sequential index number, in the order that you add the models. When deleting a model, all models with a higher index shift down one.

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
ContextPatId

Specifies the Pattern Matching context to which to add, or from which to delete, the model. The Pattern Matching context must have been previously allocated on the required system using MpatAlloc().

ModelType

Specifies the type of the model to define when adding models to the context, or specifies to delete a model from the Pattern Matching context.

See the Parameter associations section for possible values that can be specified.

SrcImageBufId

Specifies the identifier of the image buffer from which to define the models, or the Pattern Matching context from which to copy a model.

Set this parameter to M_NULL if not used.

See the Parameter associations section for possible values that can be specified.

Param1

Specifies an attribute of the model to add. Its definition is dependent on the model type chosen. When not used, set this parameter to M_DEFAULT.

See the Parameter associations section for possible values that can be specified.

Param2

Specifies an attribute of the model to add. Its definition is dependent on the model type chosen. When not used, set this parameter to M_DEFAULT.

See the Parameter associations section for possible values that can be specified.

Param3

Specifies an attribute of the model to add. Its definition is dependent on the model type chosen. When not used, set this parameter to M_DEFAULT.

See the Parameter associations section for possible values that can be specified.

Param4

Specifies an attribute of the model to add. Its definition is dependent on the model type chosen. When not used, set this parameter to M_DEFAULT.

See the Parameter associations section for possible values that can be specified.

ControlFlag

Specifies the speed of the allocation or the interpolation mode to use, depending on the model type chosen. When not used, set this parameter to M_DEFAULT.

See the Parameter associations section for possible values that can be specified.

The tables below list possible values for the ModelType, SrcImageBufId, Param1, Param2, Param3, Param4, and ControlFlag parameters.

To add a model to the Pattern Matching context, the ModelType, Param1, Param2, Param3, and ControlFlag parameters can be set to the following values:

Note that any unused parameters should be set to M_DEFAULT. Note, if unused, set SrcImageBufId to M_NULL.

function map For finding models to add to specified Pattern Matching context
Click to summarizeModelType Description
SrcImageBufId
Param1
Param2
Param3
Param4
ControlFlag
Click to summarize M_AUTO_MODEL +

Defines one or more models automatically of the specified dimensions from the most-suitable distinct areas found, in the source image. If none are found, no model is allocated and an error is reported. This is useful when you want to perform whole image alignment, for which allocation of a distinct model is essential. It can take several seconds to find the best models (more for large or small images).

To be effective, the source image should be a typical target image.

You can only define an M_AUTO_MODEL that respect the following condition: (maxvalue 2 * Param3 * Param4) < 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 model must be greater or equal to 4 pixels (Param3 * Param4 >= 4).

(summarize)
Click to summarize SrcImageBufId

Sets the identifier of the image buffer (source image) from which to extract a distinct model. The image buffer must be a 1-band, 8-bit, unsigned processing buffer. 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.

(summarize)
Click to summarize Param1

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

(summarize)
Click to summarize M_DEFAULT

Selects models from anywhere in the whole width of the image.

Click to summarize Value >= 0

Specifies the expected maximum pixel displacement in the horizontal direction, as an integer.

Click to summarize Param2

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

(summarize)
Click to summarize M_DEFAULT

Selects models from anywhere in the whole height of the image.

Click to summarize Value >= 0

Specifies the expected maximum pixel displacement in the vertical direction, as an integer.

Click to summarize Param3

Sets the width of the model, as an integer. Note that the width of the model must be equal to or smaller than the width of your source image.

(summarize)
Click to summarize Param4

Sets the height of the model, as an integer. Note that the height of the model must be equal to or smaller than the height of your source image.

(summarize)
Click to summarize ControlFlag

Sets the speed of the process by which model(s) are defined from the model source image.

(summarize)
Click to summarize M_DEFAULT

Same as M_FAST.

Click to summarize M_BEST +

Specifies that the search should favor high precision over speed. You should typically use this setting if the model source image is small.

(summarize)
Click to summarize M_FAST +

Specifies that the search should favor speed over high precision. You should typically use this setting if your model source image is large.

(summarize)
Click to summarize M_REGULAR_MODEL +

Defines a regular model, from the specified area, in the source image. You can use this type of model when dealing with images containing a mix of models on an inconsistent background, such as an image of loose nuts and bolts lying on a metal sheet.

If the occurrence can appear at an angle, specify the angular range in which it can appear, using MpatControl() with M_SEARCH_ANGLE.... If the occurrence is expected to be found always with the same background, use the M_CIRCULAR_OVERSCAN combination constant.

You can only define an M_REGULAR_MODEL that respect the following condition: (maxvalue 2 * Param3 * Param4) < 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 model must be greater or equal to 4 pixels (Param3 * Param4 >= 4).

(summarize)
Click to summarize SrcImageBufId

Sets the identifier of the image buffer (model source image) from which to extract the model. The image buffer must be a 1-band, 8-bit, unsigned processing buffer. 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.

You can specify an image buffer (source image) that is associated to an ROI that was set using a rotated rectangle in a 2D graphics list. To add a rotated rectangle to a 2D graphics list, you can call MgraRectAngle(); to set (associate) that rectangle as the ROI of an image buffer, you can call MbufSetRegion() with M_RASTERIZE or M_NO_RASTERIZE and M_FILL_REGION. If the region is a non-rectangular shape, you will get an error. When specifying an image buffer (source image) that is associated to an ROI, you must set Param2, Param3, and Param4, to M_DEFAULT.

(summarize)
Click to summarize Param1

Specifies the X-coordinate of the top-left corner of the model (origin) in the model source image (SrcImageBufId). Note that this X-coordinate must not be outside the model source image.

(summarize)
Click to summarize M_DEFAULT

Specifies that the X-coordinate of the model origin is 0.

Click to summarize 0 <= Value <= ImageSizeX

Specifies the X-coordinate of model origin in the source image, in pixels (as an integer).

Click to summarize Param2

Specifies the Y-coordinate of the top-left corner of the model (origin) in the source image (SrcImageBufId). Note that this Y-coordinate must not be outside the model source image.

(summarize)
Click to summarize M_DEFAULT

Specifies that the Y-coordinate of the model origin is 0.

Click to summarize 0 <= Value <= ImageSizeY

Specifies the Y-coordinate of model origin in the source image, in pixels (as an integer).

Click to summarize Param3

Specifies the width of the model in the model source image. Note that the region from which the model is defined must not be outside the model source image.

(summarize)
Click to summarize M_DEFAULT

Specifies that the width of the model is the distance from the origin of the model to the edge of the image in the X-direction.

Click to summarize 1 <= Value <= ImageSizeX

Specifies the width of the model in the model source image, in pixels (as an integer).

Click to summarize Param4

Specifies the height of the model in the model source image. Note that the region from which the model is defined must not be outside the model source image.

(summarize)
Click to summarize M_DEFAULT

Specifies that the height of the model is the distance from the origin of the model to the edge of the image in the Y-direction.

Click to summarize 1 <= Value <= ImageSizeY

Specifies the height of the model in the model source image, in pixels (as an integer).

Combination value for the values listed in For finding models to add to specified Pattern Matching context.

You can add the following value to the above-mentioned values to extract the model as well as a circular area around it.

function map For extracting the circular overscan data
Click to summarizeCombination value Description
Click to summarize M_CIRCULAR_OVERSCAN

Specifies that the model is extracted from the source image with the circular overscan data. The circular overscan data is determined by rotating the model, about its center. The circular overscan data of an M_CIRCULAR_OVERSCAN type model is used if you search for an occurrence of the model at an angle.

Angular search is fastest when performed with an M_CIRCULAR_OVERSCAN model; however, M_CIRCULAR_OVERSCAN should only be used when the region around the model is consistent, for example, when searching for a chip in the image of an integrated circuit.

When preprocessing an M_CIRCULAR_OVERSCAN model for which an angular search range has been specified, a set of models is extracted from rotated versions of the M_CIRCULAR_OVERSCAN model, defining models that would appear upright if the target image were rotated. For this type of model, a larger region than the one defined is extracted from the source image so as to allow creation of models at different angles.

The model must not be extracted from a region too close to the edge of the source image. In addition, the M_CIRCULAR_OVERSCAN model should be complex enough so that if models are created from it at the required angles, they are representative of the pattern being sought.

For a model defined to include circular overscan data, you cannot define "don't care" regions (MpatMask()).

(summarize)
Combination value for M_BEST (when ModelType=M_AUTO_MODEL and ControlFlag=M_BEST); M_FAST (when ModelType=M_AUTO_MODEL and ControlFlag=M_FAST).

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 use with the auto model context
Click to summarizeCombination value Description
Click to summarize M_MULTIPLE + n

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

For example, set ControlFlag to M_BEST + M_MULTIPLE + 4 to define the four most distinct models available in your model source image. Search models can overlap within the image by half the size of the model (in X and Y).

(summarize)

When deleting a model from the specified Pattern Matching context, use the following value:

Any unused parameters should be set to M_DEFAULT. Note, if unused, set SrcImageBufId to M_NULL.

function map For deleting the specified model from the Pattern Matching context
Click to summarizeModelType Description
SrcImageBufId
Param1
Param2
Param3
Param4
ControlFlag
Click to summarize M_DELETE

Specifies to remove the specified model from the Pattern Matching context, specified using the Param1 parameter. When deleting a model, all models with a higher index shift down one.

(summarize)
Click to summarize SrcImageBufId

This parameter must be set to M_NULL.

(summarize)
Click to summarize Param1

Specifies the model to delete from within the Pattern Matching context.

(summarize)
Click to summarize M_ALL

Specifies to delete all models from the Pattern Matching context.

Click to summarize Value >= 0

Specifies the index of the model to delete.

Compilation information
Header Include mil.h.
Library Use mil.lib; milpat.lib.
DLL Requires mil.dll; milpat.dll.
UNSIGNED PROC NONE AUTO MODEL UNSIGNED PROC NONE DEFAULT DEFAULT DEFAULT BEST FAST REGULAR MODEL UNSIGNED PROC NONE DEFAULT DEFAULT DEFAULT DEFAULT CIRCULAR OVERSCAN MULTIPLE n DELETE NULL ALL M_MULTIPLE + n