ImageDev

PolylineResampler2d

Transforms an input 2D 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> polylineResampler2d( std::shared_ptr<iolink::ArrayXd> inputPolyline, double spacing, PolylineResampler2d::InterpolationType interpolationType, std::shared_ptr<iolink::ArrayXd> outputPolyline = NULL );

Class Syntax

Parameters

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 and 1 for Y) 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 arrayX is {coordinate, index}, where coordinate is the axis index (0 for X and 1 for Y) and index is a label identifying the vertex.
ArrayXd nullptr

Object Examples

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

PolylineResampler2d polylineResampler2dAlgo;
polylineResampler2dAlgo.setInputPolyline( polyline2d_1 );
polylineResampler2dAlgo.setSpacing( 1 );
polylineResampler2dAlgo.setInterpolationType( PolylineResampler2d::InterpolationType::LINEAR );
polylineResampler2dAlgo.execute();

std::cout << "outputPolyline:" << polylineResampler2dAlgo.outputPolyline()->shape();

Function Examples

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

auto result = polylineResampler2d( polyline2d_1, 1, PolylineResampler2d::InterpolationType::LINEAR );

std::cout << "outputPolyline:" << result->shape();