Setting a Point Cloud's Color Components in FME

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2022.0

Introduction

This article demonstrates how to set and work with a point cloud’s colour components. We will go through how to apply colours from a raster, as well as how to apply other manipulations to point cloud colour values, such as highlighting features of interest. The next articles in this series demonstrate how to set other components, such as intensity and classification.

point cloud color.png
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, which can include 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 colour 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 colour 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 colourize 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’ colour 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.

0 - Source data.png
Source data. Left: LAS point cloud. Centre: 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 colourize the point cloud.

1. Open the starting workspace in FME Workbench
Download the tutorial attachments, and open PointCloudColorization_Start.fmwt to follow along. The workspace has three readers to get us started with the source data: a LAS point cloud, Esri Shapefile, and MrSID orthophoto.

1 - Start workspace.PNG

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.

2 - Clipper.PNG

This transformer clips the road network so it looks like this:

2 - clipper 1 output.PNG

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.

3 - Bufferer.PNG

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:

3 - bufferer output.PNG

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”.

4 - Clipper.PNG

This gives us a raster to work with that contains only the road corridors:

4 - clipper 2 output.PNG

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.

5 - RasterExpressionEvaluator workspace.PNG

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


5 - RasterExpressionEvaluator.PNG

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.

6 - RasterMosaicker workspace.PNG

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 will ensure that the coloured pixels will be chosen over the black ones (coloured values are higher than 0,0,0).

Also set “Merge Palettes” to “No”, and “Accumulation Mode” to “Merge Incoming Attributes”.

6 - RasterMosaicker parameters.PNG

The mosaicked raster looks like this:

6 - rastermosaicker output.PNG

7. Add a PointCloudOnRasterComponentSetter
Time for the main event. Add a PointCloudOnRasterComponentSetter transformer to colourize the point cloud with the prepared raster.
 

Tip: 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.

7 - PCORCS.PNG

Open the transformer parameters, and set the following:

  • Components to Set: Color
  • Extract Raster Nodata: Yes
  • Default Values Overwrite Data: Yes
  • Interpolation Type: Bicubic


7 - PCORCS parameters.PNG

This transformer will colourize the point cloud so it looks like this:

7 - pcorcs output.PNG

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.

8 - PCCTC.PNG

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


8 - PCCTC parameters.PNG

9. Add an Inspector
Add an Inspector to the previous transformer's “Output” port, which will route the resulting point cloud to Visual Preview so we can inspect it. The final workspace looks like this:

9 - Inspector.PNG


10. Run the workspace and inspect the output
Run the workspace, and view the point cloud with highlighted road corridors.

The images below show how the point cloud looks with regular orthophoto colouring (left) and how it looks after we have highlighted the road corridors (right).

output.png

The final workspace can also be seen 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 are supportive of the Ohio Enterprise.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.