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.
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
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.
(a) |
(b) |
(c) |
(d) |
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 );
This function returns outputPolyline.
// Function prototype. polyline_resampler_2d( input_polyline, spacing = 1, interpolation_type = PolylineResampler2d.InterpolationType.LINEAR, output_polyline = 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
Class Name | PolylineResampler2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 | ||||||||
spacing |
The spacing between each vertex of the output polyline.
This spacing is expressed in world coordinates. |
Float64 | >=0 | 1 | |||||||
interpolationType |
The interpolation mode.
This parameter defines the method used to calculate the polyline interpolated points.
|
Enumeration | LINEAR | ||||||||
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() );