| MIL 10 Reference
| Customize Help
| Save Settings

MbufSetRegion



See also
Availability
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
Set the region of interest (ROI) of an image buffer.
Syntax
void MbufSetRegion(
MIL_ID ImageBufId, //in
MIL_ID ImageOrGraphicListId, //in
MIL_INT64 Label, //in
MIL_INT64 Operation, //in
MIL_DOUBLE Param //in
)
Description

This function sets the region of interest (ROI) of an image buffer; if supported, MIL functions will only operate on this region of the buffer. MbufSetRegion() can also be used to modify or delete the ROI.

The ROI of an image buffer can be of any shape and can be composed of several non-contiguous areas. When dealing with processing operations that respect the ROI, all pixels outside the ROI are ignored.

You can define an ROI with either an image mask or a graphics list. The ROI should be equal to or smaller than the source image buffer. When defined from an image mask, the region of interest consists of the pixels corresponding to the non-zero pixels in the image mask. When defined from the graphics contained in a graphics list, only areas corresponding to the graphics are processed. If the graphics defining the ROI are not filled, the ROI will consist of only the graphics' outline, which is one pixel thick. However, if the combination constant M_FILL_REGION is specified when calling MbufSetRegion(), the ROI will consider non-filled graphics as being filled. This is useful if you want to display the graphics list defining the region of interest, or modify it interactively,without obstructing the target image.

Note that, unlike a child buffer, an ROI does not have its own MIL identifier and cannot have results returned with respect to it.

When defining the ROI with an image mask, this raster (bitmap) information is stored in the image buffer, creating an M_RASTER ROI. When defining the ROI with a graphics list, this vectorial information and/or its corresponding raster (bitmap) version is stored in the image buffer, creating an M_VECTOR ROI, an M_RASTER ROI, or an M_VECTOR_AND_RASTER ROI, depending on how you set the Operation parameter. Some functions (for example, MblobCalculate()) expect an M_RASTER ROI, while other functions (for example, McodeRead()) expect an M_VECTOR ROI; creating an M_VECTOR_AND_RASTER ROI allows more MIL modules to use the ROI in the source image.

When an ROI is defined, the information from the specified graphics list or image mask is copied to the source image buffer. Any subsequent changes to the original graphics list or image mask will not affect the ROI. To update the ROI using a new or modified graphics list or image mask, call MbufSetRegion() again with the new information. The old ROI information is replaced with the new ROI information.

An M_VECTOR ROI or an M_VECTOR_AND_RASTER ROI can be associated with the same calibration information as the image. This ensures that whenever the relative coordinate system moves (using McalRelativeOrigin(), McalSetCoordinateSystem(), or McalFixture()), the ROI moves accordingly. To associate an ROI with calibration information, you must define the ROI with a graphics list. All graphics in the graphics list that were created in world units (using MgraControl() with M_INPUT_UNITS set to M_WORLD) will be associated with the same callibration information as the image; all other graphics in the graphics list, as well as any generated raster information, will not be calibrated. Note that defining an M_VECTOR_AND_RASTER ROI with a graphics list containing graphics created in world units will generate an error if the specified image buffer is not already calibrated.

If the calibration information associated with the image buffer changes, the raster information of an M_VECTOR_AND_RASTER ROI will be discarded, causing the ROI to become an M_VECTOR ROI. Calling MbufSetRegion() with the Operation parameter set to M_RASTERIZE and the ImageOrGraphicListId parameter set to M_NULL transforms the ROI to an M_VECTOR_AND_RASTER ROI, such that the raster data is synchronized with the vector information.

Not all functions support an image buffer with an ROI. If you pass an image buffer with an ROI to a processing or analysis function that does not use the ROI of an image buffer, an error will be generated. The functions' descriptions state whether they support the use of an ROI.

It is not possible to set an ROI in an image buffer that has one or more child buffers. However, it is possible to define an ROI directly in a child buffer. The child buffer's ROI is not accessible from the parent buffer.

You cannot set an ROI in a YUV image buffer unless its format is YUV24, and you are using all 3 bands.

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
ImageBufId

Specifies the identifier of the image buffer for which to set the ROI.

ImageOrGraphicListId

Specifies the identifier of the image buffer or graphics list that contains the data to use to set the ROI.

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

Label

Reserved for future expansion and must be set to M_DEFAULT.

Operation

Specifies the type of operation to perform.

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

Param

Reserved for future expansion and must be set to M_DEFAULT.

The table below lists possible values for the ImageOrGraphicListId and Operation parameters.

The following ImageOrGraphicListId and corresponding Operation parameter settings are used to perform operations on ROIs related to the specified buffer.

function map For specifying the operations to perform when setting or removing the ROI
CollapseImageOrGraphicListId Description
Operation
Collapse M_NULL

Alters or deletes ROI information from the image buffer.

(summarize)
Collapse M_DEFAULT

Same as M_RASTERIZE.

Collapse M_DELETE

Removes ROI information from the image buffer.

Collapse M_RASTERIZE

Changes an M_VECTOR ROI to an M_VECTOR_AND_RASTER ROI. Generates an image mask from the existing vectorial information, and stores this raster (bitmap) information in the same image buffer without altering the existing vectorial information. When generating the mask, pixels corresponding to areas defined by the vectorial information are set to a non-zero value, and all other image mask pixels are set to a zero value. If a shape is not filled, only the pixels corresponding to its contour will be set to a non-zero value.

MIL functions will only operate on source image pixels corresponding to either non-zero value pixels of the image mask or areas defined by the graphics of the graphics list, depending on whether the MIL function requires raster or vectorial information.

Note that this operation has no effect on an M_RASTER or M_VECTOR_AND_RASTER ROI.

(summarize)
Collapse GraphicsListId

Specifies the identifier of a graphics list, which identifies the ROI.

(summarize)
Collapse M_DEFAULT

Same as M_RASTERIZE.

Collapse M_NO_RASTERIZE +

Creates an M_VECTOR ROI. Copies the content of the graphics list and stores this vectorial information in the specified image buffer.

Only the areas defined by the graphics of the graphics list are processed by MIL functions. If a shape is not filled, only the pixels corresponding to its contour will be processed by MIL functions. However, if the combination constant M_FILL_REGION is specified, the ROI will consider non-filled graphics as being filled.

(summarize)
Collapse M_RASTERIZE +

Creates an M_VECTOR_AND_RASTER ROI. Generates an image mask from the graphics list, and stores this raster (bitmap) information in the same buffer as the vectorial infromation. When generating the mask, pixels corresponding to areas defined by the graphics list are set to a non-zero value, and all other mask pixels are set to a zero value. If a shape is not filled, only the pixels corresponding to its contour will be set to a non-zero value. However, if the combination constant M_FILL_REGION is specified, the pixels inside a shape's contour will also be assigned a non-zero value.

MIL functions will only operate on source image pixels corresponding to either non-zero value pixels of the image mask or areas defined by the graphics of the graphics list, depending on whether the MIL function requires the raster or vectorial information.

(summarize)
Collapse M_RASTERIZE_AND_DISCARD_LIST +

Creates an M_RASTER ROI. Generates an image mask from the specified graphics list, and stores this raster (bitmap) information in the specified image buffer. When generating the mask, pixels corresponding to areas defined by the graphics list are set to a non-zero value, and all other mask pixels are set to a zero value. If a shape is not filled, only the pixels corresponding to its contour will be set to a non-zero value. However, if the combination constant M_FILL_REGION is specified, the pixels inside a shape's contour will also be assigned a non-zero value.

MIL functions will only operate on source image pixels corresponding to non-zero value pixels of the image mask. Note that the vectorial information from the graphics list is not stored in the image buffer.

(summarize)
Collapse ImageMaskId

Specifies the identifier of the image buffer to use as an image mask, which identifies the ROI. The image mask must be the same size as the source image buffer.

(summarize)
Collapse M_DEFAULT

Same as M_RASTERIZE.

Collapse M_RASTERIZE

Creates an M_RASTER ROI. Copies the content of the image mask and stores this raster information in the specified image buffer. MIL functions will only operate on source image pixels corresponding to non-zero value pixels of the image mask.

(summarize)
Combination constant for M_NO_RASTERIZE (when ImageOrGraphicListId=GraphicsListId and Operation=M_NO_RASTERIZE); M_RASTERIZE (when ImageOrGraphicListId=GraphicsListId and Operation=M_RASTERIZE); M_RASTERIZE_AND_DISCARD_LIST (when ImageOrGraphicListId=GraphicsListId and Operation=M_RASTERIZE_AND_DISCARD_LIST).

You can add the following value to the above-mentioned values to set whether to interpret the graphics in the graphics list as being filled.

function map For interpreting the elements in the graphics list as being filled
CollapseCombination value Description
Collapse M_FILL_REGION

Specifies that the graphics in the graphics list are interpreted as if they are filled when defining the region of interest. If one or many graphics of the graphics list are already filled (for example, a rectangle created with MgraRectFill()), M_FILL_REGION has no effect on the already filled graphics.

(summarize)
Compilation information
Header Include mil.h.
Library Use mil.lib.
DLL Requires mil.dll.
NULL DEFAULT DELETE RASTERIZE DEFAULT NO RASTERIZE RASTERIZE RASTERIZE AND DISCARD LIST PROC DEFAULT RASTERIZE FILL REGION