ImageDev

PolylineResampler3d

Transforms an input 3D polyline into a new polygonal chain with line segments of constant length.

Access to parameter description

The new polyline vertices can be computed with a linear, a cubic, or a cubic with Paul Breeuwsma coefficients (Catmull-Rom spline) interpolation.
The target segment length is defined by the spacing parameter.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
<b> (d) </b>
(d)
Figure 1. Polyline resampling: (a) input polyline with irregular segment lengths, (b) resampling with a small spacing,@Br (c) resampling with a large spacing, (d) large spacing polyline overlaying the input polyline

See also

Function Syntax

This function returns outputPolyline.
// Function prototype
std::shared_ptr<iolink::ArrayXd> polylineResampler3d( std::shared_ptr<iolink::ArrayXd> inputPolyline, double spacing, PolylineResampler3d::InterpolationType interpolationType, std::shared_ptr<iolink::ArrayXd> outputPolyline = NULL );
This function returns outputPolyline.
// Function prototype.
polyline_resampler_3d( input_polyline,
                       spacing = 1,
                       interpolation_type = PolylineResampler3d.InterpolationType.LINEAR,
                       output_polyline = None )
This function returns outputPolyline.
// Function prototype.
public static IOLink.ArrayXd
PolylineResampler3d( IOLink.ArrayXd inputPolyline,
                     double spacing = 1,
                     PolylineResampler3d.InterpolationType interpolationType = ImageDev.PolylineResampler3d.InterpolationType.LINEAR,
                     IOLink.ArrayXd outputPolyline = null );

Class Syntax

Parameters

Class Name PolylineResampler3d

Parameter Name Description Type Supported Values Default Value
input
inputPolyline
The input ArrayXd to resample.
The indexation needs to be {coordinate, index}, where coordinate is the axis index (0 for X, 1 for Y and 2 for Z) and index is a label identifying the vertex.
ArrayXd nullptr
input
spacing
The spacing between each vertex of the output polyline.
This spacing is expressed in world coordinates.
Float64 >=0 1
input
interpolationType
The interpolation mode.
This parameter defines the method used to calculate the polyline interpolated points.
LINEAR The vertices are linearly interpolated.
CUBIC The vertices are computed with a cubic interpolation.
CATMULL_ROM The vertices are computed with a cubic interpolation using Paul Breeuwsma coefficients.
Enumeration LINEAR
output
outputPolyline
The output resampled polyline.
The indexation of the generated arrayXd is {coordinate, index}, where coordinate is the axis index (0 for X, 1 for Y and 2 for Z) and index is a label identifying the vertex.
ArrayXd nullptr

Object Examples

std::shared_ptr< iolink::ArrayXd> polyline3d_1( new iolink::ArrayXd( { 0 } ) );
readArrayXd( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "polyline3d_1.arrayxd", polyline3d_1);

PolylineResampler3d polylineResampler3dAlgo;
polylineResampler3dAlgo.setInputPolyline( polyline3d_1 );
polylineResampler3dAlgo.setSpacing( 1 );
polylineResampler3dAlgo.setInterpolationType( PolylineResampler3d::InterpolationType::LINEAR );
polylineResampler3dAlgo.execute();

std::cout << "outputPolyline:" << polylineResampler3dAlgo.outputPolyline()->shape();
polyline_3d_1 = np.zeros(0, dtype=np.double)
polyline_3d_1 = imagedev.read_array_xd(imagedev_data.get_object_path("polyline3d_1.arrayxd"), polyline_3d_1)

polyline_resampler_3d_algo = imagedev.PolylineResampler3d()
polyline_resampler_3d_algo.input_polyline = polyline_3d_1
polyline_resampler_3d_algo.spacing = 1
polyline_resampler_3d_algo.interpolation_type = imagedev.PolylineResampler3d.LINEAR
polyline_resampler_3d_algo.execute()

print( "output_polyline:", str( polyline_resampler_3d_algo.output_polyline ) )
IOLink.ArrayXd polyline3d_1 = new IOLink.ArrayXd(new IOLink.VectorXu64( 0 ) ) ;
polyline3d_1 = Data.ReadArrayXd( @"Data/objects/polyline3d_1.arrayxd", polyline3d_1 );

PolylineResampler3d polylineResampler3dAlgo = new PolylineResampler3d
{
    inputPolyline = polyline3d_1,
    spacing = 1,
    interpolationType = PolylineResampler3d.InterpolationType.LINEAR
};
polylineResampler3dAlgo.Execute();

Console.WriteLine( "outputPolyline:" + polylineResampler3dAlgo.outputPolyline.ToString() );

Function Examples

std::shared_ptr< iolink::ArrayXd> polyline3d_1( new iolink::ArrayXd( { 0 } ) );
readArrayXd( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "polyline3d_1.arrayxd", polyline3d_1);

auto result = polylineResampler3d( polyline3d_1, 1, PolylineResampler3d::InterpolationType::LINEAR );

std::cout << "outputPolyline:" << result->shape();
polyline_3d_1 = np.zeros(0, dtype=np.double)
polyline_3d_1 = imagedev.read_array_xd(imagedev_data.get_object_path("polyline3d_1.arrayxd"), polyline_3d_1)

result = imagedev.polyline_resampler_3d( polyline_3d_1, 1, imagedev.PolylineResampler3d.LINEAR )

print( "output_polyline:", str( result ) )
IOLink.ArrayXd polyline3d_1 = new IOLink.ArrayXd(new IOLink.VectorXu64( 0 ) ) ;
polyline3d_1 = Data.ReadArrayXd( @"Data/objects/polyline3d_1.arrayxd", polyline3d_1 );

IOLink.ArrayXd result = Processing.PolylineResampler3d( polyline3d_1, 1, PolylineResampler3d.InterpolationType.LINEAR );

Console.WriteLine( "outputPolyline:" + result.ToString() );