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 $M_{2x}$, $M_{2y}$ and $M_{xy}$ elements of this matrix. This object also contains the first order moments $M_{1x}$ and $M_{1y}$, and orientation of the largest eigenvector of the covariance matrix.

See also

Function Syntax

This function returns the outputMeasurement output parameter.
// Function prototype.
MomentsOfInertia2dMsr::Ptr
momentsOfInertia2d( std::shared_ptr< iolink::ImageView > inputImage, MomentsOfInertia2dMsr::Ptr outputMeasurement = NULL );
This function returns the outputMeasurement output parameter.
// Function prototype.
moments_of_inertia_2d( input_image, output_measurement = None )
This function returns the outputMeasurement output parameter.
// Function prototype.
public static MomentsOfInertia2dMsr
MomentsOfInertia2d( IOLink.ImageView inputImage, MomentsOfInertia2dMsr outputMeasurement = null );

Class Syntax

Parameters

Class Name MomentsOfInertia2d

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 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

moments_of_inertia_2d_algo = imagedev.MomentsOfInertia2d()
moments_of_inertia_2d_algo.input_image = polystyrene
moments_of_inertia_2d_algo.execute()

print( "barycenterX: ", str( moments_of_inertia_2d_algo.output_measurement.barycenter_x( 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

MomentsOfInertia2d momentsOfInertia2dAlgo = new MomentsOfInertia2d
{
    inputImage = polystyrene
};
momentsOfInertia2dAlgo.Execute();

Console.WriteLine( "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 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.moments_of_inertia_2d( polystyrene )

print( "barycenterX: ", str( result.barycenter_x( 0 ) )  )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

MomentsOfInertia2dMsr result = Processing.MomentsOfInertia2d( polystyrene );

Console.WriteLine(  "barycenterX: " + result.barycenterX( 0 )  );