Centroid2d
Computes the centroid of objects in two-dimensional binary image.
Access to parameter description
For an introduction: For an object without holes, the centroid is a unique point. For an object with holes, the centroid is made of rings surrounding each hole, as shown in Figure 1. This algorithm performs successive thinnings with rotations and until convergence, using the D configuration: 0××0∙×00× followed by ×0×0∙1×0× Where × means "don't care".

Figure 1. Centroids of objects with or without holes
Note: The centroid must not be confused with a classical center of gravity, which may be outside the object as in the case of a boomerang-shaped particle. However, for quasi-convex objects the centroid is very close to the center of gravity.
See also
Access to parameter description
For an introduction: For an object without holes, the centroid is a unique point. For an object with holes, the centroid is made of rings surrounding each hole, as shown in Figure 1. This algorithm performs successive thinnings with rotations and until convergence, using the D configuration: 0××0∙×00× followed by ×0×0∙1×0× Where × means "don't care".

Figure 1. Centroids of objects with or without holes
Note: The centroid must not be confused with a classical center of gravity, which may be outside the object as in the case of a boomerang-shaped particle. However, for quasi-convex objects the centroid is very close to the center of gravity.
See also
Function Syntax
This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > centroid2d( std::shared_ptr< iolink::ImageView > inputBinaryImage, std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
![]() |
inputBinaryImage |
The binary input image. | Image | Binary | nullptr |
![]() |
outputBinaryImage |
The binary output image. Its size and type are forced to the same values as the input. | Image | nullptr |
Object Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); Centroid2d centroid2dAlgo; centroid2dAlgo.setInputBinaryImage( polystyrene_sep ); centroid2dAlgo.execute(); std::cout << "outputBinaryImage:" << centroid2dAlgo.outputBinaryImage()->toString();
Function Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); auto result = centroid2d( polystyrene_sep ); std::cout << "outputBinaryImage:" << result->toString();