extract_sky_points: Extract sky points

View source: R/extract_sky_points.R

extract_sky_pointsR Documentation

Extract sky points

Description

Extract sky points for model fitting.

Usage

extract_sky_points(r, bin, g, dist_to_plant = 3, min_raster_dist = 3)

Arguments

r

SpatRaster. A normalized greyscale image. Typically, the blue channel extracted from a canopy photograph. Please see read_caim and normalize.

bin

SpatRaster. This should be a preliminary binarization of r useful for masking pixels that are very likely to be pure sky pixels.

g

SpatRaster built with sky_grid_segmentation or chessboard.

dist_to_plant, min_raster_dist

Numeric vector of length one or NULL.

Details

This function will automatically sample sky pixels from the sky regions delimited by bin. The density and distribution of the sampling points is controlled by the arguments g, dist_to_plant, and min_raster_dist.

As the first step, sky pixels from r are evaluated to find, for each cell of g, the pixel with maximum digital value (local maximum). The argument dist_to_plant allows users to establish a buffer zone for bin, meaning a size reduction of original sky regions.

The final step filters these local maximum values by calculating distances between points on the raster space. It discards new points that have a distance from existing points minor than min_raster_dist. Cell labels determine the order in which the points are evaluated.

To skip a given filtering step, use code NULL as argument input. For instance, to provide min_raster_dist = NULL will return points omitting raster distance calculation, which means a faster output in comparison with using min_raster_dist = 1.

Value

An object of the class data.frame with two columns named col and row.

See Also

fit_cie_sky_model

Other Tool Functions: colorfulness(), defuzzify(), extract_dn(), extract_feature(), extract_rl(), masking(), read_bin(), read_caim(), write_bin(), write_caim()

Examples

## Not run: 
caim <- read_caim() %>% normalize()
z <- zenith_image(ncol(caim), lens("Nikon_FCE9"))
a <- azimuth_image(z)
bin <- ootb_obia(caim, z, a)
g <- sky_grid_segmentation(z, a, 10)
r <- gbc(caim$Blue*255)
sky_points <- extract_sky_points(r, bin, g)
cells <- cellFromRowCol(z, sky_points$row, sky_points$col)
hist(r[cells][,1])
xy <- xyFromCell(z, cells)
plot(r)
plot(vect(xy), add = TRUE, col = 2)

## End(Not run)

rcaiman documentation built on Sept. 20, 2022, 1:05 a.m.