extract_feature: Extract feature

View source: R/extract_feature.R

extract_featureR Documentation

Extract feature

Description

Extract features from raster images.

Usage

extract_feature(
  r,
  segmentation,
  fun = mean,
  return_raster = TRUE,
  ignore_label_0 = TRUE
)

Arguments

r

SpatRaster. Single layer raster.

segmentation

SpatRaster. The segmentation of r.

fun

A function that takes a vector as input and returns a one-length numeric or logical vector as output (e.g. mean).

return_raster

Logical vector of length one, see details.

ignore_label_0

Logical vector of length one. If this is TRUE, the segment labeled with 0 will be ignored.

Details

Given a single-layer raster, a segmentation, and a function, extract_features will return a numeric vector or a SpatRaster depending on whether the parameter return_raster is TRUE or FALSE. For the first case, each pixel of each segment will adopt the respective extracted feature value. For the second case, the return will be a vector of length equal to the total number of segments. Each value will be obtained by processing all pixels that belong to a segment with the provided function.

Value

If return_raster is set to TRUE, then an object of class SpatRaster with the same pixel dimensions than r will be returned. Otherwise, the return is a numeric vector of length equal to the number of segments found in segmentation.

See Also

Other Tool Functions: colorfulness(), correct_vignetting(), defuzzify(), extract_dn(), extract_rl(), extract_sky_points_simple(), extract_sky_points(), extract_sun_coord(), find_sky_pixels_nonnull(), find_sky_pixels(), masking(), optim_normalize(), percentage_of_clipped_highlights(), read_bin(), read_caim_raw(), read_caim(), write_bin(), write_caim()

Examples

r <- read_caim()
z <- zenith_image(ncol(r),lens())
a <- azimuth_image(z)
g <- sky_grid_segmentation(z, a, 10)
print(extract_feature(r$Blue, g, return_raster = FALSE))
# plot(extract_feature(r$Blue, g, return_raster = TRUE))

rcaiman documentation built on Nov. 15, 2023, 1:08 a.m.