Processing math: 100%
ImageDev

MomentsOfInertia2d

Computes the elements of the covariance matrix of a two-dimensional grayscale image.

Access to parameter description

For an introduction: This algorithm computes the variance-covariance matrix of the input image. It outputs an object containing the M2x, M2y and Mxy elements of this matrix. This object also contains the first order moments M1x and M1y, and orientation of the largest eigenvector of the covariance matrix.

For this measurement the image calibration is ignored. The coordinates used to calculate the moments are expressed in pixels.

See also

Function Syntax

This function returns outputMeasurement.
// Function prototype
MomentsOfInertia2dMsr::Ptr momentsOfInertia2d( std::shared_ptr< iolink::ImageView > inputImage, MomentsOfInertia2dMsr::Ptr outputMeasurement = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label or Grayscale nullptr
output
outputMeasurement
The output measurement result. MomentsOfInertia2dMsr nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

MomentsOfInertia2d momentsOfInertia2dAlgo;
momentsOfInertia2dAlgo.setInputImage( polystyrene );
momentsOfInertia2dAlgo.execute();

std::cout << "barycenterX: " << momentsOfInertia2dAlgo.outputMeasurement()->barycenterX( 0 ) ;

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = momentsOfInertia2d( polystyrene );

std::cout << "barycenterX: " << result->barycenterX( 0 ) ;