Main Content

smoothBoundaries

Smooth lane boundaries

Since R2024a

Description

example

laneBoundariesUpdated = smoothBoundaries(laneBoundaries) smooths the lane boundaries in the laneBoundarySegment, or laneBoundaryGroup object laneBoundaries.

example

laneBoundariesUpdated = smoothBoundaries(laneBoundaries,Name=Value) specifies options using one or more name-value arguments. For example, SmoothingFactor=1 applies the maximum smoothing to the lane boundary points.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Load lane boundary segment data into the workspace.

data = load("laneBoundarySegmentData.mat","lbsegment");

Display the loaded lane boundary segment object.

lbsegment = data.lbsegment
lbsegment = 
  laneBoundarySegment with properties:

       BoundaryIDs: [4×1 string]
    BoundaryPoints: {4×1 cell}
      BoundaryInfo: []
     NumBoundaries: 4
         NumPoints: 128
      GeoReference: []

Plot the lane boundaries in the loaded lane boundary segment object.

plot(lbsegment)

Smooth the lane boundaries in the lane boundary segment object.

lbsegment = smoothBoundaries(lbsegment);

Plot the smoothed lane boundary points.

plot(lbsegment)

Load lane boundary segment data into the workspace.

data = load("laneBoundarySegmentData.mat","lbsegment");

Display the lane boundary segment object.

lbsegment = data.lbsegment
lbsegment = 
  laneBoundarySegment with properties:

       BoundaryIDs: [4×1 string]
    BoundaryPoints: {4×1 cell}
      BoundaryInfo: []
     NumBoundaries: 4
         NumPoints: 128
      GeoReference: []

Plot the lane boundaries in the loaded lane boundary segment object.

plot(lbsegment)

Specify a smoothing factor, and smooth the lane boundary with ID 4.

lbsegment = smoothBoundaries(lbsegment,BoundaryID ="4",SmoothingFactor=0.2);

Plot the lane boundary points, including the smoothed lane boundary.

plot(lbsegment)

Load lane boundary group data into the workspace.

data = load("laneBoundaryGroupData.mat","lbGroup");

Display the loaded lane boundary group object.

lbGroup = data.lbGroup
lbGroup = 
  laneBoundaryGroup with properties:

      BoundarySegments: [2×1 laneBoundarySegment]
    SegmentConnections: {[1 2]  [4×2 string]}
        BoundaryGroups: [1×5 struct]
          GeoReference: []

Plot the lane boundaries in the loaded lane boundary group object.

plot(lbGroup)

Smooth the lane boundaries in the loaded lane boundary group object.

lbGroup = smoothBoundaries(lbGroup);

Plot the smoothed lane boundary points.

plot(lbGroup)

Input Arguments

collapse all

Lane boundaries, specified as a laneBoundarySegment, or laneBoundaryGroup object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: smoothBoundaries(laneBoundaries,SmoothingFactor=1) applies the maximum smoothing to the input lane boundary points laneBoundaries.

Level of smoothing, specified as a real scalar in the range [0, 1]. The specified value scales the heuristic window length to adjust the level of smoothing. Values closer to 0 produce shorter moving window lengths, resulting in less smoothing. Values closer to 1 produce longer moving window lengths, resulting in more smoothing. For more information on smoothing, see the smoothdata function.

Data Types: single | double

Savitzky-Golay degree, specified as a positive integer. This value specifies the degree of the polynomial in the Savitzky-Golay filter that fits the data within each window. For more information, see the smoothdata function.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

IDs of the lane boundaries to smooth, specified as an N-by-1 string array. N is the number of lane boundaries. The input argument laneBoundaries must contain the specified lane boundary IDs. By default, the smoothBoundaries function smooths all lane boundaries in the laneBoundaries argument.

Note

Each lane boundary ID value must be unique.

Data Types: string

Output Arguments

collapse all

Updated lane boundaries, returned as a laneBoundarySegment, or laneBoundaryGroup object.

The returned laneBoundariesUpdated argument contains the smoothed versions of the lane boundaries in the input laneBoundaries argument. The laneBoundariesUpdated argument matches the object type of the laneBoundaries argument.

Version History

Introduced in R2024a