ImageDev

InertiaMoment2d

Measures the resistance of an object, defined by a two-dimensional binary image, to changes in its motion around a given axis of rotation.

Access to parameter description

For an introduction: This algorithm computes a measurement of an object's resistance to changes in its rotational motion.
The moment of inertia of an object on a given axis describes how difficult it is to change its angular motion around this axis.

For a point mass $m$, the moment of inertia $I$ is simply $m$ times the square perpendicular distance $r$ from the axis of rotation: $$ I = mr^2 $$ On a digital image, a pixel intensity can be considered as a mass.
Then, for an object of a binary image, $m$ is a constant equal to 1. Thus, the moment of inertia is the sum of the square perpendicular distances from the axis: $$ I = \sum_r r^2 = \sum_x(x-p(x))^2 $$ where: The rotation axis is defined by a point (rotationCenterX and rotationCenterY) and an orientation (rotationAngle), which are user-defined parameters.

See also

Function Syntax

This function returns the outputMeasurement output parameter.
// Function prototype.
MeanInertiaMomentMsr::Ptr
inertiaMoment2d( std::shared_ptr< iolink::ImageView > inputBinaryImage,
                 int32_t rotationCenterX,
                 int32_t rotationCenterY,
                 double rotationAngle,
                 MeanInertiaMomentMsr::Ptr outputMeasurement = NULL );
This function returns the outputMeasurement output parameter.
// Function prototype.
inertia_moment_2d( input_binary_image,
                   rotation_center_x = 1024,
                   rotation_center_y = 1024,
                   rotation_angle = 10,
                   output_measurement = None )
This function returns the outputMeasurement output parameter.
// Function prototype.
public static MeanInertiaMomentMsr
InertiaMoment2d( IOLink.ImageView inputBinaryImage,
                 Int32 rotationCenterX = 1024,
                 Int32 rotationCenterY = 1024,
                 double rotationAngle = 10,
                 MeanInertiaMomentMsr outputMeasurement = null );

Class Syntax

Parameters

Class Name InertiaMoment2d

Parameter Name Description Type Supported Values Default Value
input
inputBinaryImage
The input binary image. Image Binary nullptr
input
rotationCenterX
The X pixel coordinate of the rotation axis. Int32 >=1 1024
input
rotationCenterY
The Y pixel coordinate of the rotation axis. Int32 >=1 1024
input
rotationAngle
The orientation of the rotation axis in degrees. A positive value means that the angle is taken from the positive X axis to the positive Y axis. Float64 Any value 10
output
outputMeasurement
The output measurement result. MeanInertiaMomentMsr nullptr

Object Examples

auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

InertiaMoment2d inertiaMoment2dAlgo;
inertiaMoment2dAlgo.setInputBinaryImage( polystyrene_sep );
inertiaMoment2dAlgo.setRotationCenterX( 1024 );
inertiaMoment2dAlgo.setRotationCenterY( 1024 );
inertiaMoment2dAlgo.setRotationAngle( 10 );
inertiaMoment2dAlgo.execute();

std::cout << "meanMoment: " << inertiaMoment2dAlgo.outputMeasurement()->meanMoment( 0 ) ;
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

inertia_moment_2d_algo = imagedev.InertiaMoment2d()
inertia_moment_2d_algo.input_binary_image = polystyrene_sep
inertia_moment_2d_algo.rotation_center_x = 1024
inertia_moment_2d_algo.rotation_center_y = 1024
inertia_moment_2d_algo.rotation_angle = 10
inertia_moment_2d_algo.execute()

print( "meanMoment: ", str( inertia_moment_2d_algo.output_measurement.mean_moment( 0 ) ) )
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

InertiaMoment2d inertiaMoment2dAlgo = new InertiaMoment2d
{
    inputBinaryImage = polystyrene_sep,
    rotationCenterX = 1024,
    rotationCenterY = 1024,
    rotationAngle = 10
};
inertiaMoment2dAlgo.Execute();

Console.WriteLine( "meanMoment: " + inertiaMoment2dAlgo.outputMeasurement.meanMoment( 0 ) );

Function Examples

auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

auto result = inertiaMoment2d( polystyrene_sep, 1024, 1024, 10 );

std::cout << "meanMoment: " << result->meanMoment( 0 ) ;
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

result = imagedev.inertia_moment_2d( polystyrene_sep, 1024, 1024, 10 )

print( "meanMoment: ", str( result.mean_moment( 0 ) )  )
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

MeanInertiaMomentMsr result = Processing.InertiaMoment2d( polystyrene_sep, 1024, 1024, 10 );

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