Main Content

randlanet

Segment point clouds using RandLA-Net semantic segmentation network

Since R2024a

    Description

    RandLA-Net is a widely used, fast, and efficient deep learning network designed for semantic segmentation of large-scale point clouds. RandLA-Net uses random sampling to downsample large point clouds and boost speed, while also employing a local feature aggregation module to preserve significant features, making it an efficient semantic segmentation network. Create a pretrained or untrained semantic segmentation network using the randlanet object. If you have a pretrained network, you can perform transfer learning and retrain it using the trainRandlanet function. If you have an untrained network, you can train it using the trainRandlanet function. Segment objects in a point cloud using the segmentObjects function on the pretrained, retrained, or newly trained segmentation network.

    Creation

    Description

    Pretrained RandLA-Net Semantic Segmentation

    example

    segmenter = randlanet(weights) creates a pretrained RandLA-Net semantic segmentation network with the weights determined by the data set on which the network is pretrained. Specify weights as "dales" to create a pretrained RandLA-Net network trained on the Dayton Annotated Lidar Earth Scan (DALES) point cloud data set. Specify weights as "pandaset" to create a pretrained RandLA-Net network trained on the PandaSet point cloud data set.

    Custom RandLA-Net Semantic Segmentation

    segmenter = randlanet(weights,classNames) creates a RandLA-Net network, and configures it to perform segmentation using the specified set of classes classNames. The classNames argument sets the ClassNames property of the network. You can create a pretrained network to perform transfer learning for the new set of classes by specifying weights as "dales" or "pandaset". You can create an untrained network by specifying weights as "none". You must train the network using the trainRandlanet function.

    Additional Options

    segmenter = randlanet(___,Name=Value) sets the ModelName, GridStep, NumPoints, and PointProperty properties by using name-value arguments in addition to any combination of input arguments from previous syntaxes. For example, randlanet("none",classNames,ModelName="semanticSegmenter") creates a randlanet object with the model name "semanticSegmenter".

    Note

    This functionality requires Deep Learning Toolbox™ and the Lidar Toolbox™ Model for RandLA-Net Semantic Segmentation. You can download and install the Lidar Toolbox Model for RandLA-Net Semantic Segmentation from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

    Input Arguments

    expand all

    Name of the data set for a pretrained network, specified as one of these options.

    • "dales" — The randlanet function creates a pretrained RandLA-Net network trained on the DALES data set using blocked point clouds with a block size of [50 50]. This option requires the Lidar Toolbox Model for RandLA-Net Semantic Segmentation.

    • "pandaset" — The randlanet function creates a pretrained RandLA-Net network trained on the PandaSet data set. This option requires the Lidar Toolbox Model for RandLA-Net Semantic Segmentation.

    • "none" — The randlanet function creates an untrained RandLA-Net network. If you create an untrained network, you must specify the segmentation class names using the classNames input argument.

    Data Types: char | string

    Properties

    expand all

    This property is read-only.

    RandLA-Net deep learning network to use for point cloud semantic segmentation, stored as a dlnetwork (Deep Learning Toolbox) object.

    This property is read-only.

    Names of the segmentation classes for training the network, specified as a vector of strings, cell array of character vectors, or categorical vector. To set this property, you must specify the classNames input argument at object creation.

    • If you create an untrained network by specifying weights as "none", you must specify classNames to set this property and configure the randlanet object for training from scratch.

    • If you create a pretrained network by specifying weights as "dales" or "pandaset", you can set this property by specifying classNames and configure the randlanet object for transfer learning. Otherwise, the network uses the default classes for the pretrained network.

    Data Types: cell | string | categorical

    Name of the RandLA-Net semantic segmentation network, specified as a string scalar or character vector. You can set this property during or after object creation.

    • If you specify weights as "dales", the default value of ModelName is 'dales'.

    • If you specify weights as "pandaset", the default value of ModelName is 'pandaset'.

    • If you specify weights as "none", the default value of ModelName is ''.

    Data Types: char | string

    Size of the 3-D box for grid average downsampling of point cloud during preprocessing, specified as a positive scalar. Grid average downsampling divides the point cloud into a 3-D grid where each cell of the grid is a cube having sides of length GridStep. The object averages all the points present in one cell of the grid, effectively downsampling the point cloud. You can set this property during or after object creation.

    • Specifying a large value for GridStep results in a small number of points representing the entire point cloud, leading to faster processing at the cost of accuracy.

    • Specifying a small value for GridStep results in a large number of points representing the entire point cloud, leading to better segmentation accuracy at the cost of increased processing time.

    Data Types: single | double

    This property is read-only.

    Number of points input to the RandLA-Net network, specified as a positive integer greater than or equal to 1024 and divisible by 256. The object crops the point cloud after grid average downsampling to retain only NumPoints number of points, as the RandLA-Net network expects a fixed number of points as the input. You can set this property during object creation, but only if you specify class names using the classNames input argument.

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

    This property is read-only.

    Properties of points input to the RandLA-Net network specified as a string scalar, character vector, string array, or cell array of character vectors. You can configure the RandLA-Net network to use colors, intensities of the points, or both as input along with the (x, y, z) coordinate locations of the points.

    • By default, the pretrained RandLA-Net network trained on the DALES data set uses the locations of the points as input, whereas the pretrained RandLA-Net network trained on the PandaSet data set uses the locations and intensities of the points as input. You cannot change this property for pretrained networks.

    • By default, any untrained RandLA-Net network or pretrained RandLA-Net network with custom class names uses the locations of the points as input. You can additionally provide the colors or intensities of the points, or both, as input. You can set this property during object creation, but only if you specify class names using the classNames input argument.

    Example: randlanet("dales",classNames,PointProperty="intensity") creates a RandLA-Net network that uses the locations and intensities of the points as input to the network.

    Example: randlanet("none",classNames,PointProperty=["color" "intensity"]) creates a RandLA-Net network that uses the locations, colors, and intensities of the points as input to the network.

    Data Types: char | string | cell

    Object Functions

    segmentObjectsSegment point cloud using RandLA-Net semantic segmentation

    Examples

    collapse all

    Read a point cloud to segment into the workspace.

    ptCloud = pcread("PandasetLidarData.pcd");

    Visualize the point cloud.

    figure
    pcshow(ptCloud)
    title("Point Cloud")
    axis off

    Create a pretrained RandLA-Net semantic segmentation network trained on the PandaSet data set.

    segmenter = randlanet("pandaset")
    segmenter = 
      randlanet with properties:
    
             GridStep: 0.0400
              Network: [1×1 dlnetwork]
           ClassNames: [unlabelled    Vegetation    Ground    Road    RoadMarkings    SideWalk    Car    Truck    OtherVehicle    Pedestrian    RoadBarriers    Signs    Buildings]
            NumPoints: 45056
        PointProperty: {'location'  'intensity'}
            ModelName: 'pandaset'
    
    
    classNames = cellstr(segmenter.ClassNames);
    numClasses = numel(classNames);

    Segment the point cloud using the pretrained network.

    labels = segmentObjects(segmenter,ptCloud);

    Convert the labels from categorical to numeric values for ease of visualization.

    labels = single(categorical(labels,segmenter.ClassNames,cellstr(string(1:numClasses))));

    Visualize the segmentation by displaying the labels.

    figure
    ax = pcshow(ptCloud.Location,labels);
    title("Semantic Segmentation of Point Cloud")
    helperLabelColorbar(ax,classNames)

    Supporting Function

    function helperLabelColorbar(ax,classNames)
    
    numClasses = numel(classNames);
    % Colormap for the original classes.
    cmap =  [[30 30 30];   % Unlabeled
            [0 255 0];     % Vegetation
            [255 150 255]; % Ground
            [255 0 255];   % Road
            [255 0 0];     % Road Markings
            [90 30 150];   % Sidewalk
            [245 150 100]; % Car
            [250 80 100];  % Truck
            [150 60 30];   % Other Vehicle
            [255 255 0];   % Pedestrian
            [0 200 255];   % Road Barriers
            [170 100 150]; % Signs
            [30 30 255]];  % Building
     
    cmap = cmap./255;
    cmap = cmap(1:numClasses,:);
    colormap(ax,cmap);
     
    % Add colorbar to current figure.
    c = colorbar(ax);
    c.Color = "white";
     
    % Center tick labels and use class names for tick marks.
    c.Ticks = 1:1:numClasses;
    c.TickLabels = classNames;
     
    % Remove tick mark.
    c.TickLength = 0;
    
    end

    References

    [1] Hu, Qingyong, Bo Yang, Linhai Xie, Stefano Rosa, Yulan Guo, Zhihua Wang, Niki Trigoni, and Andrew Markham. “Learning Semantic Segmentation of Large-Scale Point Clouds With Random Sampling.” IEEE Transactions on Pattern Analysis and Machine Intelligence 44, no. 11 (November 2022): 8338–54. https://doi.org/10.1109/TPAMI.2021.3083288.

    Version History

    Introduced in R2024a