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.

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 = nullptr );
This function returns outputMeasurement.
// Function prototype.
moments_of_inertia_2d(input_image: idt.ImageType,
                      output_measurement: Union[Any, None] = None) -> MomentsOfInertia2dMsr
This function returns outputMeasurement.
// Function prototype.
public static MomentsOfInertia2dMsr
MomentsOfInertia2d( IOLink.ImageView inputImage, MomentsOfInertia2dMsr 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
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label or Grayscale None
output
output_measurement
The output measurement result. MomentsOfInertia2dMsr None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label or Grayscale null
output
outputMeasurement
The output measurement result. MomentsOfInertia2dMsr null

Object Examples

auto 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

auto 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 )  );