r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
587 stars 132 forks source link

Question- Further interpretation of the segment_shape parameters: th1, th2, k #605

Closed cscarpon closed 2 years ago

cscarpon commented 2 years ago

Hi,

I am currently using the segment_shape() function written like this:

las <- segment_shapes(las, shp_hline(th1 = 0.5, th2 = 0.5, k = 10), "hline")

Is there a more layman's way of understanding the th and k values?

|Z1|,|Z2|,|Z3| denote the norm of the Z component of first, second and third axis of the decomposition. th1,th2,th3 denote a set of threshold values.

From my understanding, Z1 relates to the first plane or axis that the algorithm will scan on, and the "th" value will tell the algorithm how far points can deviate from that plane/axis in the units of the projection? The "k" value indicates how many pts in sequence it needs to scan to determine if there is a line?

Z2 and Z3 are just different planes from which the algorithm will scan? and th2 relates to Z2 and th3 relates to Z3?

I am trying to hammer down my methodology and just need to explain this section a bit better.

Thanks!

Jean-Romain commented 2 years ago

I think you misunderstood the method. For each point of the point cloud the algorithm looks at their k-nearest neighbors. For a given point the k selected points are either randomly distributed, aligned, planar or everything in-between. To discriminate between the cases we can apply linear algebra methods that tells use how are distributed the points. For a perfect line the points are expected to be distributes along a single axis (which is necessarily colinear with the x,y or z axis of the point cloud of course).

If the points are aligned then the third eigen value of the eigen decomposition is expected to be much bigger than the two others. This is the meaning of the equation in the doc. The eigen values do not tell us anything about the orientation of the line. But they tell us that the point are spread on a single axis. In practice alignment is not strict so there is a threshold to define what "much bigger" means. That is for line detection.

For horizontal line detection we need and additional constrains. The axis of the line must be horizontal. But eigen values do not given any information about the orientation. So we use the decomposition matrix. The line is horizontal if the orientation of main orientation of the line is not on the Z axis of the point cloud (Z component is 0). If it is not on the Z axis it is therefore on the XY plane and the line it is horizontal. In practice there is always a Z component which is never strictly 0. So we have a threshold.