The LAStools filter module was already able to filter colors according to RGB values. However, it sometimes makes sense to filter not only for RGB, but also for hue, saturation, and brightness values. Therefore, the HSL and HSV color models are quite common.
LAStools now support these color models in filtering points.
These are the new arguments implemented in the 64-bit version of LAStools starting with version 231230:
HSV color model:
-keep_HSV
-keep_HSV_hue
-keep_HSV_saturation
-keep_HSV_value
-drop_HSV_hue
-drop_HSV_saturation
-drop_HSV_value
HSL color model:
-keep_HSL
-keep_HSL_hue
-keep_HSL_saturation
-keep_HSL_lightness
-drop_HSL_hue
-drop_HSL_saturation
-drop_HSL_lightness
The arguments expect either 2 or 6 parameters to address the upper and lower limit of a color definition.
keep_HSV [min_h] [max_h] [min_s] [max_s] [min_v] [max_v]
‘Keep’ keeps all points whose HS[L/V] value is within the upper and lower limits (inclusive).
‘Drop’ deletes all points whose HS[L/V] value is less than the lower limit or greater than the upper limit.
The parameters must be in the range from 0 to 1 or, with an additional suffix, in the range 0..100 percent or 0..360 degrees.
To activate these conversions, the letter “p” or “d” can be added.
The combination of more than one filter behaves as usual in LAStools using the argument “-filter_or” or “-filter_and”.
Calculation of color depth
To calculate a color model, it is important to know whether the existing point colorization is in 8 or 16 bits. According to the LAS definition, colors are 16-bit values, but often providers only use 8-bit color values. Therefore, a new algorithm was implemented to automatically detect the color depth of the LAS/LAZ file. At the beginning 5000 points were read, if these contain all RGB color values below 256, we assume an 8-bit color model..
Import/Export HSL and HSV values
It is also possible to import and export HSL and HSV values.
las2txt -i in.laz -parse xyz(hsl)
will export the HSL values in a range [0..1].
las2txt -i in.laz -parse xyz(HSL)
will export the HSL values in a range [0..360;0..100;0..100].
txt2las behaves the same way when importing text values.
HSV and hsv does the job for the HSV color model.
Sample
Tree
This example shows how to remove leaves with a specific color from a tree scan.
Use laslook or your favorite image processing software to determine the color values of a sample point.
Convert this RGB value to an HSV or HSL value using color software or an online color converter.
A color range could be from 0 degrees to 93 degrees:
las2las64 -i Sydney_fig_tree.laz -o tree_without_leaves.laz -drop_HSV_hue 0d 93d
The command drops all points in the HSV color range between 0 and 93 degrees.
Many thanks to geoslam/faro for this example data!
Notes
This improvement to LAStools was initiated by Alejandro Hinojosa’s blog post “Filtering by RGB value range”.