Finding the location of blobs in an image can sometimes be more useful than finding their shape or size. For example, if a robotic arm needs to pick up several items regardless of their type, it can use their location in an acquired image to determine their actual physical position.
You can also use the blob location to determine if a blob touches any side of the image border. If there are any such blobs, you might want to adjust the camera's field of view so that all items are completely represented in the image, or you might want to exclude these blobs.
You can determine the blob's points of contact with the blob's bounding box aligned with the pixel coordinate system. To do so, enable the M_BOX, M_CONTACT_POINTS, and M_CENTER_OF_GRAVITY groups of features for calculation using MblobControl(). Use MblobGetResult() with the constants below to retrieve the corresponding point of contact after calculation.
Note that for the blob in the image below, there are at least two possible ways to determine each of its contact points. This is because there is only one point of contact on each side of the blob's border. For example:
Legend 

A1 
A2 

B1 
B2 

C1 
C2 

D1 
D2 

E1 
(M_X_MIN_AT_Y_MIN, M_BOX_Y_MIN) OR 
E2 

F1 
F2 

G 
In contrast, if there are multiple points of contact on one side of the blob border, each point of contact will be named differently, as shown in the image below.
The center of gravity can be calculated in binary or grayscale mode. To calculate the latter, you must provide MblobCalculate() with a grayscale image.
Besides points established from a blob's bounding box aligned with the pixel coordinate system, you can establish points from the minimumarea or the minimumperimeter bounding box of the blob. To calculate the bounding box that has the least area, use the M_MIN_AREA_BOX group of features; whereas to calculate the bounding box that has the smallest perimeter, use the M_MIN_PERIMETER_BOX group of features. These groups of features are enabled for calculation using MblobControl(). Use MblobGetResult() with the following constants to retrieve them after calculation:
Area Box Legend 
Perimeter Box Legend 

A1 
(M_MIN_AREA_BOX_Xn, M_MIN_AREA_BOX_Yn) ^{1} 
A2 

B1 
B2 
(M_MIN_PERIMETER_BOX_CENTER_X, M_MIN_PERIMETER_BOX_CENTER_Y) 

C1 
C2 

D1 
D2 

E1 
E2 
^{1} n stands for an integer from 1 to 4.
Note that the width of the box is always the longer of the two sides. The angle of the minimumarea or minimumperimeter bounding box is always measured from the Xaxis to the side from which the width of the minimumarea or minimumperimeter box is measured.
When working with calibrated images, you can retrieve the abovementioned points with respect to the relative coordinate system, by calling MblobControl() with M_RESULT_OUTPUT_UNITS set to M_WORLD. However, in this case, the abovementioned points are calculated in the pixel coordinate system and then the coordinates of these points are converted to the relative coordinate system.
To calculate the blob's bounding box and contact points in the relative coordinate system, you must enable the calculation of the M_WORLD_BOX group of features using MblobControl(); then, use MblobGetResult() with the following constants to retrieve them after calculation:
Legend 

A1 
A2 

B1 
B2 

C1 
C2 

D1 
D2 
You can obtain the coordinates of pixels bordering blobs or delimiting holes in blobs, in a counterclockwise or clockwise direction, respectively. These pixels are referred to as chained pixels. To calculate these pixels, enable the M_CHAINS group of features for calculation using MblobControl().
You can use the chained pixel coordinates to create a chain code. A chain code is a directional code that records an object's boundary as a discrete set of vectors, where each vector points to the next pixel in the chain.
Chained pixels always form a closed chain. This implies that the starting pixel in the chain is also the closing one. If your blob has regions which are 1 pixel wide, these pixels are chained twice, once in the forward direction and then in the opposite direction.
In the diagram below, the thick lines illustrate pixels that are chained twice. The diagram also illustrates chained pixels of a blob in an 8 and 4connected lattice, where the solid lines illustrate chained pixels in an 8connected lattice, and the dotted lines illustrate how chained pixels deviate in a 4connected lattice. Also, note that the blob's outermost chain is identified as index 1. Chains that delimit holes in blobs are identified by subsequent indices.
The M_CHAINS feature group enables five separate chain features for calculation. This allows you to retrieve the following feature results using MblobGetResult():
M_TOTAL_NUMBER_OF_CHAINED_PIXELS, which retrieves the total number of chained pixels.
M_NUMBER_OF_CHAINED_PIXELS, which retrieves the total number of chained pixels for each blob or a specified blob.
M_CHAIN_INDEX, which assigns an index to each chained pixel, for every chain within a blob.
M_CHAIN_X and M_CHAIN_Y, which retrieves the X and Ycoordinates of all chained pixels within a blob respectively.
When retrieving results for chain features, get the results for the number of chained pixels, in total or in a particular blob first (M_TOTAL_NUMBER_OF_CHAINED_PIXELS or M_NUMBER_OF_CHAINED_PIXELS respectively). This allows you to allocate an array that is large enough for the other chain results.
For the blob shown above, you would get the following results:
Chain index 
ChainX 
ChainY 
1 
4 
2 
1 
4 
3 
1 
4 
4 
1 
4 
5 
... 
... 
... 
2 
5 
5 
2 
6 
5 
2 
7 
5 
2 
8 
5 
As mentioned, blobs with holes have multiple chains.
To determine the chain to which a pixel coordinate (M_CHAIN_X and M_CHAIN_Y) belongs, use MblobGetResult() with M_CHAIN_INDEX.