Files
Introduction
This article demonstrates how to set and work with a point cloud’s color components. We will go through how to apply colors from a raster, as well as how to apply other manipulations to point cloud color values, such as highlighting features of interest. The next articles in this series demonstrate how to set other components, such as intensity and classification.
The original point cloud (left), and the same one with colouring applied from an orthophoto (right).
In a point cloud, each point has associated properties called components, including red, green, blue, intensity, classification, and other values. To understand the basics of working with point clouds in FME, see Getting Started with Point Clouds and Point Clouds (IFMEPointCloud) documentation.
The key transformer for applying color to a point cloud in FME is the PointCloudOnRasterComponentSetter. Use this transformer to overlay a point cloud on a raster and set the point cloud color values based on the interpolated raster band values at each point location. For a basic example of how to use this transformer, see the “Colorizing a point cloud with an orthoimage” example in the transformer documentation. Below, we will walk through a more complex example where we colorize a point cloud and apply corrections to highlight certain geographical features.
Step-by-Step Instructions
The goal of this scenario is to colorize a point cloud and highlight a specific geographical feature by making it brighter. This requires a corresponding dataset containing the geometry of interest.
We will highlight road corridors by making those points’ color component values brighter than the rest of the point cloud. Our source data includes a point cloud in LAS format, an orthophoto in MrSID format, and an Esri Shapefile containing road geometries.
Source data. Left: LAS point cloud. Center: Shapefile road data. Right: MrSID orthophoto.
We will use the Shapefile to identify which pixels in the orthophoto are roads, and then brighten those pixels in the raster. We will then use the prepared raster with brightened roads to colorize the point cloud.
1. Open the starting workspace in FME Workbench
Download the tutorial attachments, and add three readers to a blank workspace. For the first reader, set it to ASPRS Lidar Data Exchange Format (LAS) and browse to N2365790.las. For the second reader, set it to Esri Shapefile and browse to LakeCountryRoads.shp. For the third and final reader, set it to Extensis MrSID and browse to n2365790.sid.
2. Add a Clipper
First, clip the Shapefile to the area of interest: the extents of the point cloud. Add a Clipper transformer to the canvas. Connect the LAS reader feature type to the “Clipper” port, and the Shapefile reader feature type to the “Candidate” (formerly “Clippee”) port.
This transformer clips the road network so it looks like this:
3. Add a Bufferer
Next, we will make the road corridors more visible. Add a Bufferer transformer, and connect the “Inside” port from the Clipper to its input.
Open the parameters and set the Buffer Distance to 25. Under “Area Parameters”, set “Dissolve on Attributes” to fme_feature_type.
After passing through this transformer, the data looks like this:
4. Add a second Clipper
We’re almost ready to brighten the roads. First, add a second Clipper to clip the raster to the buffered roads. Connect the “Buffered” port to “Clipper”. Connect the MrSID orthophoto reader feature type to “Candidate”.
This gives us a raster to work with that contains only the road corridors:
5. Add a RasterExpressionEvaluator
Now it’s time to brighten the roads. For this, we will use expressions to manipulate the raster bands. The PointCloudExpressionEvaluator and the RasterExpressionEvaluator are useful transformers for manipulating point cloud components and raster bands, respectively. We will use the RasterExpressionEvaluator here to make the roads brighter in the clipped raster.
Add a RasterExpressionEvaluator transformer, and connect the “Inside” output from the second Clipper to the “A” input port.
Open the parameters and create three Band Expressions as follows:
- Interpretation: Preserve, Expression: A[0]+80
- Interpretation: Preserve, Expression: A[1]+80
- Interpretation: Preserve, Expression: A[2]+80
This will brighten the raster’s RGB values by 80.
6. Add a RasterMosaicker
Now we want to merge the raster containing the brightened roads with the original one. Add a RasterMosaicker transformer. Connect both the RasterExpressionEvaluator and the MrSID reader feature type to the input port.
Open the parameters and set “Overlapping Values” to “Maximum”. This is because when the roads raster was clipped, the unwanted components were set to black (0,0,0). Setting this parameter to Maximum ensures the colored pixels are chosen over the black ones (colored values are higher than 0,0,0).
Also set “Merge Palettes” to “No”, and “Accumulation Mode” to “Merge Incoming Attributes”.
The mosaicked raster looks like this:
7. Add a PointCloudOnRasterComponentSetter
Time for the main event. Add a PointCloudOnRasterComponentSetter transformer to colorize the point cloud with the prepared raster.
When you want to add this transformer to your workspace by typing on the canvas (“Quick Add”), you don’t have to type the full name. Rather, start typing the first letter of each word, “PCORCS”. You can use this shortcut with any transformer, but it’s especially useful here because this is the longest transformer name in FME!
Connect the RasterMosaicker output to the “Raster” input, and the LAS reader to the “PointCloud” input.
Open the transformer parameters, and set the following:
- Components to Set: Color
- Extract Raster NoData: Yes
- Default Values Overwrite Data: Yes
- Interpolation Type: Bicubic
This transformer will colorize the point cloud so it looks like this:
8. Add a PointCloudComponentTypeCoercer
The final step is to make sure the point cloud’s RGB color values are all UInt8 types. Add a PointCloudComponentTypeCoercer, and connect it to the PointCloud output of the previous transformer.
Open the parameters and set the following “Components to Coerce”:
- Component: color_red, Type: UInt8, Conversion Type: Scale by data values, Rounding Type: Round
- Component: color_green, Type: UInt8, Conversion Type: Scale by data values, Rounding Type: Round
- Component: color_blue, Type: UInt8, Conversion Type: Scale by data values, Rounding Type: Round
9. Add an Inspector
Add an Inspector to the previous transformer's “Output” port to route the resulting point cloud to Visual Preview so we can inspect it. The final workspace looks like this:
10. Run the workspace and inspect the output
Run the workspace and view the point cloud with highlighted road corridors.
The images below show the point cloud with regular orthophoto coloring (left) and after we highlight the road corridors (right).
The final workspace is also shown in the attached template, PointCloudColorization_End.fmwt.
Data Attribution
The data from these exercises originates from data made available by the Ohio Geographically Referenced Information Program. The GIS Support Center maintains enterprise and site licenses for commercial data sets that support the Ohio Enterprise.