apply
Syntax
Description
processes the entire bres
= apply(bpc
,fcn
)blockedPointCloud
object bpc
by applying the function handle fcn
to
each block. Returns bres
, a new blocked point cloud containing the
processed data.
[___] = apply(___,
modifies aspects of block processing using name-value arguments.Name=Value
)
Examples
Downsample Point Cloud Data
Create a full file path for a LAZ file that contains aerial lidar data.
pcfile = fullfile(toolboxdir("lidar"),"lidardata", ... "las","aerialLidarData.laz");
Create a pcdownsample
function handle.
fun = @(block)pcdownsample(block.Data,random=0.1);
Create a blockedPointCloud
object using the LAZ file.
bpc = blockedPointCloud(pcfile,[50 50]);
Process each block of the aerial point cloud data using the specified pcdownsample
function handle.
pcdown = apply(bpc,fun);
Extract Normals from Point Cloud
Create a full file path for a LAZ file that contains aerial lidar data.
pcfile = fullfile(toolboxdir("lidar"),"lidardata", ... "las","aerialLidarData.laz");
Create a pcnormals
function handle.
fun = @(block)pcnormals(block.Data);
Create a blockedPointCloud
object using the LAZ file.
bpc = blockedPointCloud(pcfile,[50 50]);
Create a MAT adapter for writing the files from the block processing operation as MAT files.
matad = lidar.blocked.MATBlocks; outfile = tempname;
Perform a block processing operation on the point cloud file to extract the normals.
pcnorms = apply(bpc,fun,Adapter=matad,OutputLocation=outfile);
Input Arguments
bpc
— Blocked point cloud
blockedPointCloud
object
Blocked point cloud, specified as a blockedPointCloud
object.
bpcs
— Blocked point clouds
array of blockedPointCloud
objects
Blocked point clouds, specified as an array of blockedPointCloud
objects.
fcn
— Processing function
function handle
Processing function, specified as a function handle. For more information, see Create Function Handle. The processing function fcn
must accept a bstruct
as input. To pass additional arguments, specify
fcn
as an anonymous function. For more information, see Anonymous Functions.
bstruct
is a structure with these fields:
Field | Description |
---|---|
Data | Block of data from bpc |
BlockSize | Value of the BlockSize parameter. |
ROI | ROI of the block, specified as a six-element numeric row vector in the order [xmin xmax ymin ymax zmin zmax]. |
PointAttributes | Attributes for each point, specified as a |
PCNumber | Index into the |
The function fcn
typically returns the results for one block.
The results can be a pointCloud
object or a structure.
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: apply(bpc,fun,DisplayWaitbar=true)
displays a wait bar for
operations with long run times.
Adapter
— Adapter used for writing blocked point cloud data
adapter object
Adapter used for writing blocked point cloud data, specified as an adapter object. To specify different adapters for different outputs, use a cell array. If you specify a scalar object, the function uses the specified adapter for every output.
This table lists the adapters included with the toolbox.
Adapter | Description |
---|---|
LAS | Store blocks in a single LAS file |
InMemory | Store blocks in a variable in main memory |
LASBlocks | Stores each block as a LAS file in a folder |
MATBlocks | Stores each block as a MAT file in a folder |
If you do not specify the OutputLocation
argument, then the
default value of Adapter
is InMemory
. If
you specify OutputLocation
argument, then the default value of
Adapter
is LASBlocks
for output containing point cloud, point attributes, or a structure that contains both
point cloud and point attributes. For any other types of output, the default value of
Adapter
is MATBlocks
.
DisplayWaitbar
— Wait bar visualization
true
or 1
(default) | false
or 0
Wait bar visualization, specified as a logical 1
(true
) or 0
(false
). When
set to true
, the apply
object function displays
a wait bar operations with long run times. If you cancel the wait bar, the
apply
object function returns partial output, if
available.
Data Types: logical
OutputLocation
— Location of output folder
character vector | string scalar
Location of the output folder, specified as a string scalar or character vector.
If there is a single output, the apply
object function writes
it directly to this location.
For multiple outputs, the apply
object function creates
subfolders of the format outputN
, where N
is the
sequential number of the output. If the input is an array, the
apply
object function derives the output name of each element
from its Source
property. If the input is in-memory, the
apply
function reports an error.
If the UseParallel
property is true
,
OutputLocation
must be a valid path on the client session. Use
the AlternateFileSystemRoots
property of the input to specify the
required mapping for worker sessions. All outputs inherit this value.
UseParallel
— Use parallel processing
false
or 0
(default) | true
or 1
Use parallel processing, specified as a logical 0
(false
) or 1
(true
). The
function first determines whether to use a new or an existing parallel pool. If no
parallel pool is active, the function opens a new pool based on the default parallel
settings. All adapters specified by the Adapter
property must
support parallel processing. You must specify a valid
OutputLocation
.
This argument requires Parallel Computing Toolbox™.
Data Types: logical
Output Arguments
bres
— New blocked point cloud
blockedPointCloud
object
New blocked point cloud, returned as a blockedPointCloud
object.
Version History
Introduced in R2022a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)