MblobReconstruct()函数

Synopsis

Reconstruct blobs in an image buffer.

Format

void MblobReconstruct(SrcImageBufId, SeedImageBufId, DestImageBufId, Operation, ProcMode)

MIL_ID SrcImageBufId; Source image buffer identifier
MIL_ID SeedImageBufId; Seed image buffer identifier
MIL_ID DestImageBufId; Destination image buffer identifier
long Operation; Type of operation to perform
long ProcMode; Operation mode

Description

This function copies (or reconstructs) blobs or blob holes from the source to the destination buffer, according to the type of operation specified. All non-zero pixels in the source buffer are considered to be part of a blob.

The SrcImageBufId parameter specifies the identifier of the source image buffer.

The SeedImageBufId parameter specifies the identifier of the image buffer to use as a seed image. A seed image is needed to perform an M_RECONSTRUCT_FROM_SEED type of operation. For any other operation type, set this parameter to M_NULL.

The DestImageBufId specifies the identifier of the destination (processed blobs) image buffer.

The Operation parameter specifies the type of operation to perform. This parameter can be set to one of the following values.

Operation Description
M_RECONSTRUCT_FROM_SEED All blobs in the source buffer that have at least one corresponding non-zero seed pixel in the seed buffer are copied to the destination buffer.
M_ERASE_BORDER_BLOBS All blobs that do not touch the borders of the source image are copied to the destination image buffer.
Note, this operation is similar to a “border kill”.
M_FILL_HOLES All blobs in the source buffer are copied to the destination buffer and those blobs with holes are filled. A hole must reside completely within the source buffer in order to be considered a hole (that is, it cannot touch any borders).
M_EXTRACT_HOLES All holes within the blobs of the source buffer are copied to the destination buffer with their pixel values set to the maximum possible value of that buffer. For example if the destination buffer is an 8-bit buffer, the pixel values of the holes are set to 0xff. A hole must reside completely within the source buffer in order to be considered a hole (that is, it cannot touch any borders).

The ProcMode parameter specifies the processing mode to use. This parameter can be set to one of the following values:

M_BINARY
(M_DEFAULT)
The pixel values of blobs copied to the destination buffer will be set to the maximum value of that buffer (for example, 0xff for an 8-bit buffer).
M_GRAYSCALE The pixel values of blobs copied to the destination buffer will be set to the corresponding pixel value in the source buffer.

Note, in general, the M_BINARY processing mode is faster.

M_FOREGROUND_ZERO can be added to the processing mode to specify that pixels of blobs consist of zero values and the background of non-zero values; that is, the inverse of the usual blob pixel value definition.

When an M_RECONSTRUCT_FROM_SEED operation is specified, only source image blobs that contain a pixel corresponding to a seed pixel are processed and copied to the destination image. If you know in advance that every source image blob has a corresponding seed pixel, you can accelerate the process by adding an M_SEED_PIXELS_ALL_IN_BLOBS flag to ProcMode. This condition often exists when the seed image is an eroded (see MimErode) version of the source image.

Note

This function is optimized for packed binary buffers.

See also

MimErode