hello dear community, i have a point cloud in a .xyz format, only with coordinates. I would like to add sth. like a color or a height ramp, which depends on the height of each value and gives each point an unique RGB value.
Hi @artec186 , recently I created a workspace including a process to add gradation color to point cloud, would share my experience here.
Step 1: Slice the source point cloud by the number of color gradation (e.g. 100)
(1) PointCloudPropertyExtractor: Retrieve zmin and zmax of the source point cloud.
(2) AttributeManager, AttributeCreator or ExpressionEvaluator: Calculate the height of each slice: slice_height = (zmax - zmin)/100
(3) Cloner: Create 100 copies of the point cloud. Name copy number attribute as "index", for example.
(4) AttributeManager or AttributeCreator: Calculate lower limit ant upper limit of each slice.
lower = zmin + slice_height x index
upper = zmin + slice_heigth x (inde + 1)
(5) PointCloudFileter: Filter the point cloud by:
lower <= z && z < upper
Step 2: Create gradation color (R, G, values
(1) RGBGradationCalculator (from FME Hub): Calculate 100 color values (Format of Destination Color: Comma-Separated Decimal RGB24). The result will be stored into "_color{}" list.
(2) ListExploder: Explode the "_color{}" into individual "_color".
(3) AttributeSplitter: Split the "_color" into 3 elements (R, G, and store them into a list, named "_rgb{}" for example.
Step 3: Set color to the point cloud slices and combine them into one
(1) FeatureMerger: Add "_rgb{}" to point cloud slices, by joining by their index.
(2) PointCloudExpressionEvaluator: Set color to point cloud slices.
Component | Data Type | Expression
color_red | UInt8 | _rgb{0}
color_green | UInt8 | _rgb{1}
color_blue | UInt8 | _rgb{2}
(3) PointCloudCombiner: Combine the slices into a single point cloud.
See the attached workspace example to learn more.
Note: If size of the source point cloud be very large, it would be better to create a custom transformer which performs creating slices iteratively with the Loop functionality, in order to reduce memory usage while translation.
Hope this helps.