# lmf

0th

Percentile

##### Individual Tree Detection Algorithm

This function is made to be used in tree_detection. It implements an algorithm for tree detection based on a local maximum filter. The windows size can be fixed or variable and its shape can be square or circular. The internal algorithm works either with a raster or a point cloud. It is deeply inspired from Popescu & Wynne (2004) (see references).

##### Usage
lmf(ws, hmin = 2, shape = c("circular", "square"))
##### Arguments
ws

numeric or function. Length or diameter of the moving window used to the detect the local maxima in the unit of the input data (usually meters). If it is numeric a fixed window size is used. If it is a function, the function determines the size of the window at any given location on the canopy. The function should take the height of a given pixel or points as its only argument and return the desired size of the search window when centered on that pixel/point.

hmin

numeric. Minimum height of a tree. Threshold below which a pixel or a point cannot be a local maxima. Default is 2.

shape

character. Shape of the moving windows used to find the local maxima. Can be "square" or "circular".

##### References

Popescu, Sorin & Wynne, Randolph. (2004). Seeing the Trees in the Forest: Using Lidar and Multispectral Data Fusion with Local Filtering and Variable Window Size for Estimating Tree Height. Photogrammetric Engineering and Remote Sensing. 70. 589-604. 10.14358/PERS.70.5.589.

Other individual tree detection algorithms: manual

• lmf
##### Examples
# NOT RUN {
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las = readLAS(LASfile, select = "xyz", filter = "-drop_z_below 0")

# point-cloud-based
# =================

# 5x5 m fixed windows size
ttops = tree_detection(las, lmf(5))

x = plot(las)

# variable windows size
f = function(x) { x * 0.07 + 3}
ttops = tree_detection(las, lmf(f))

x = plot(las)

# raster-based
# ============

# 5x5 m fixed windows size
chm = grid_canopy(las, res = 1, p2r(0.15))
kernel = matrix(1,3,3)
chm = raster::focal(chm, w = kernel, fun = median, na.rm = TRUE)

ttops = tree_detection(chm, lmf(5))

raster::plot(chm, col = height.colors(30))

# variable windows size
f = function(x) { x * 0.07 + 3 }
ttops = tree_detection(chm, lmf(f))

raster::plot(chm, col = height.colors(30))