fit_trend_surface {rcaiman} | R Documentation |
Fit a trend surface to sky digital numbers
Description
Fit a trend surface using spatial::surf.ls()
as workhorse function.
Usage
fit_trend_surface(r, z, a, bin, filling_source = NULL, np = 6)
Arguments
r |
SpatRaster. A normalized greyscale image. Typically, the
blue channel extracted from a canopy photograph. Please see |
z |
SpatRaster built with |
a |
SpatRaster built with |
bin |
SpatRaster. This should be a preliminary binarization of
|
filling_source |
SpatRaster. An actual or reconstructed
above-canopy image to complement the sky pixels detected through the gaps
of |
np |
degree of polynomial surface |
Details
This function is meant to be used after fit_coneshaped_model()
.
This method was presented in Díaz and Lencinas (2018), under
the heading Estimation of the sky DN as a previous step for our method. If
you use this function in your research, please cite that paper in addition to
this package (citation("rcaiman"
).
Value
A list with an object of class SpatRaster and of class trls
(see spatial::surf.ls()
).
Note
If an incomplete above-canopy image is available as filling source,
non-sky pixels should be turned NA
or they will be erroneously considered
as sky pixels.
References
Díaz GM, Lencinas JD (2018). “Model-based local thresholding for canopy hemispherical photography.” Canadian Journal of Forest Research, 48(10), 1204–1216. doi:10.1139/cjfr-2018-0006.
See Also
Other Sky Reconstruction Functions:
cie_sky_model_raster()
,
fit_cie_sky_model()
,
fit_coneshaped_model()
,
fix_reconstructed_sky()
,
interpolate_sky_points()
,
ootb_sky_reconstruction()
Examples
## Not run:
caim <- read_caim()
r <- caim$Blue
caim <- normalize(caim, 0, 20847, TRUE)
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
bin <- ootb_obia(caim, z, a, m, HSV(239, 0.85, 0.5), gamma = NULL)
g <- sky_grid_segmentation(z, a, 10)
sky_points <- extract_sky_points(r, bin, g, dist_to_plant = 5)
plot(bin)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)
rl <- extract_rl(r, z, a, sky_points)
model <- fit_coneshaped_model(rl$sky_points)
summary(model$model)
sky_cs <- model$fun(z, a)
persp(terra::aggregate(sky_cs, 10), theta = 90, phi = 45)
sky_s <- fit_trend_surface(r, z, a, bin, sky_cs)
persp(terra::aggregate(sky_s$image, 10), theta = 90, phi = 45)
## End(Not run)