find_sky_pixels_nonnull: Find sky pixels following the non-null criteria

View source: R/find_sky_pixels_nonnull.R

find_sky_pixels_nonnullR Documentation

Find sky pixels following the non-null criteria


Cells without sky pixels are the so-called null cells. This type of cells are mathematically intractable by models typically used to obtain canopy metrics. This function find sky pixels using increase in number of null cells as the stopping criteria.


find_sky_pixels_nonnull(r, sky, g, intercept = 0, slope = 1, w = 0.5)



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


An object of class SpatRaster produced with fit_coneshaped_model(), fit_trend_surface(), fit_cie_sky_model(), or ootb_sky_reconstruction(). It also support a numeric vector of length one. For instance, it could be a value obtained with a combination of extract_sky_points() and extract_dn(). The latter can be understood as modelling the sky with a plane.


SpatRaster built with sky_grid_segmentation() or chessboard().

intercept, slope

Numeric vector of length one. These are linear function coefficients.


Numeric vector of length one. Weighting parameter from \insertCiteDiaz2018;textualrcaiman's Equation 1. See thr_mblt()


The arguments sky, intercept, slope, and w are passed to thr_mblt() whose output is in turn passed to apply_thr() along with r. As a result, r is binarized and used along with g to compute the number of null cells. The process is repeated but increasing w in steps of 0.05 as long as the number of null cells remains constant.


An object of class SpatRaster with values 0 and 1.

See Also

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


## Not run: 
caim <- read_caim()
r <- caim$Blue %>% normalize()
caim <- normalize(caim, 0, 20847, TRUE)
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !
bin <- ootb_obia(caim, z, a, m, HSV(239, 0.85, 0.5), gamma = NULL)
g <- sky_grid_segmentation(z, a, 3)
sky_points <- extract_sky_points(r, bin, g,
                                 dist_to_plant = 5,
                                 min_raster_dist = 5)
rl <- extract_rl(r, z, a, sky_points)
model <- fit_coneshaped_model(rl$sky_points)

sky <- model$fun(z, a)
sky <- fit_trend_surface(sky, z, a, !$image

x <- predict(model$model)
y <- predict(model$model) + model$model$residuals
mblt <- coefficients(lm(x~y))

g <- sky_grid_segmentation(z, a, 10)
bin <- find_sky_pixels_nonnull(r, sky, g, mblt[1], mblt[2], w = 0.1)

## End(Not run)

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