segmentation {lidaRtRee}R Documentation

Image segmentation by seed-based watershed algorithm

Description

performs a seed-based watershed segmentation (wrapper for watershed)

Usage

segmentation(maxi, dem_nl)

Arguments

maxi

cimg or SpatRaster object. image with seed points (e.g. from maxima_detection or maxima_selection)

dem_nl

cimg or SpatRaster object. image for seed propagation (typically initial image used for maxima detection).

Value

A cimg object or SpatRaster object with segments id

See Also

maxima_detection, maxima_selection, seg_adjust

Examples

data(chm_chablais3)
chm_chablais3 <- terra::rast(chm_chablais3)

# median filter
chm_chablais3 <- dem_filtering(chm_chablais3,
  nl_filter = "Median", nl_size = 3,
  sigma = 0
)$non_linear_image

# maxima detection
maxi <- maxima_detection(chm_chablais3)

# maxima selection
selected_maxi <- maxima_selection(maxi, chm_chablais3, dm = 1, dprop = 0.1)

# segmentation
seg_maxi <- segmentation(maxi, chm_chablais3)
seg_selected_maxi <- segmentation(selected_maxi, chm_chablais3)

# plot original image
terra::plot(chm_chablais3, main = "Median filter")

# plot segmented image
# replace segment with id 0 (not a tree) with NA
seg_maxi[seg_maxi == 0] <- NA
terra::plot(seg_maxi %% 8, main = "Segments, no maxima selection", 
col = rainbow(8))
seg_selected_maxi [seg_selected_maxi == 0] <- NA
terra::plot(seg_selected_maxi %% 8, main = "Segments, maxima selection", 
col = rainbow(8))

[Package lidaRtRee version 4.0.5 Index]