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 = nullptr );
This function returns outputPolyline.
// Function prototype.
polyline_resampler_2d(input_polyline: Union[idt.NDArrayFloat, None],
                      spacing: float = 1,
                      interpolation_type: Union[Literal["LINEAR"],Literal["CUBIC"],Literal["CATMULL_ROM"],PolylineResampler2d.InterpolationType] = PolylineResampler2d.InterpolationType.LINEAR,
                      output_polyline: Union[idt.NDArrayFloat, None] = None) -> Union[idt.NDArrayFloat, None]
This function returns outputPolyline.
// Function prototype.
public static IOLink.ArrayXd
PolylineResampler2d( IOLink.ArrayXd inputPolyline,
                     double spacing = 1,
                     PolylineResampler2d.InterpolationType interpolationType = ImageDev.PolylineResampler2d.InterpolationType.LINEAR,
                     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.
Value Description
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
Parameter Name Description Type Supported Values Default Value
input
input_polyline
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
interpolation_type
The interpolation mode.
This parameter defines the method used to calculate the polyline interpolated points.
Value Description
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
output_polyline
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
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.
Value Description
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();
polyline_2d_1 = np.zeros(0, dtype=np.double)
polyline_2d_1 = imagedev.read_array_xd(imagedev_data.get_object_path("polyline2d_1.arrayxd"), polyline_2d_1)

polyline_resampler_2d_algo = imagedev.PolylineResampler2d()
polyline_resampler_2d_algo.input_polyline = polyline_2d_1
polyline_resampler_2d_algo.spacing = 1
polyline_resampler_2d_algo.interpolation_type = imagedev.PolylineResampler2d.LINEAR
polyline_resampler_2d_algo.execute()

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

PolylineResampler2d polylineResampler2dAlgo = new PolylineResampler2d
{
    inputPolyline = polyline2d_1,
    spacing = 1,
    interpolationType = PolylineResampler2d.InterpolationType.LINEAR
};
polylineResampler2dAlgo.Execute();

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

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();
polyline_2d_1 = np.zeros(0, dtype=np.double)
polyline_2d_1 = imagedev.read_array_xd(imagedev_data.get_object_path("polyline2d_1.arrayxd"), polyline_2d_1)

result = imagedev.polyline_resampler_2d(polyline_2d_1, 1, imagedev.PolylineResampler2d.LINEAR)

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

IOLink.ArrayXd result = Processing.PolylineResampler2d( polyline2d_1, 1, PolylineResampler2d.InterpolationType.LINEAR );

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



© 2026 Thermo Fisher Scientific Inc. All rights reserved.