MpatFindOrientation()函数

Synopsis

Find the orientation of an image or of an object in an image.

Format

void MpatFindOrientation(ImageBufId, ModelId, FindResultId, ResultRange)

MIL_ID ImageBufId; Image buffer identifier
MIL_ID *ModelId; Model identifier
MIL_ID *FindResultId; The identifier of the result buffer
long ResultRange Range of possible result angles

Description

This function finds the orientation (angle, not position) of a whole image or of an M_ORIENTATION-type model.

To find a whole image’s orientation, the image must contain predominant horizontal and/or vertical edges. These edges are considered as the major axes of orientation. This function determines the angle of orientation of these axes in relation to the axes of the image frame and returns a single value, in the range of 0° to 180°, to the result buffer.

To find a specific object’s orientation, a model must be provided. This model should have been allocated with an M_ORIENTATION model type, using MpatAllocModel, and have a simple background. The result buffer is returned the angle of rotation of the target object in relation to the model, in the range of 0° to 360°, and its associated object-to-model score (100% is perfect correlation with the model). You can request that multiple possible angles be returned to the result buffer, using MpatSetNumber.

Note, this function is designed for images with smooth edges, usually obtained when grabbing an image with a camera. It will not work well on an artificially-generated image unless the lines and edges are anti-aliased. In particular, it will not work on a nearest-neighbor resampled image, such as the result of MimRotate with M_NEAREST_NEIGHBOR interpolation, unless the image is heavily smoothed.

The ImageBufId parameter specifies the identifier of the target image buffer.

The ModelId parameter specifies the identifier of the model for which to search in the specified image buffer. If no model is specified (M_NULL), whole-image orientation is done, using the dominant straight edges of the image as the major axes.

The FindResultId parameter specifies the identifier of the result buffer in which to store results. The number of matches found can be obtained, using MpatGetNumber. The match angles and scores can be obtained, using MpatGetResult.

The ResultRange parameter specifies the range in which possible result angles can occur.

In whole-image orientation searches, horizontal and/or vertical edges serve as the axes for orientation purposes. Therefore, in an image of uni-directional edges (such as parallel stripes) the angle of orientation should occur within a 180° range. In an image of bi-directional edges (such as a square electronic wafer) the angle should occur within a 90° range.

In model-orientation searches a 360° range is necessary to include all the rotational possibilities of the model.

The ResultRange parameter can be set to one of the following:

ResultRange Description
For whole-image orientation:
M_RESULT_RANGE_45 Searches and returns a value between -45° and 45°.
M_RESULT_RANGE_90 Searches and returns a value between 0° and 90°.
M_RESULT_RANGE_180 Searches and returns a value between 0°and 180°.
For model orientation:
M_RESULT_RANGE_360 Searches and returns a value between 0° and 360°.

Note

Supports only unsigned 8-bit images.

See also

MpatGetNumber, MpatGetResult, MpatSetNumber

《MpatFindOrientation()函数》上有2条评论

评论已关闭。