find_sky_pixels: Find sky pixels

View source: R/find_sky_pixels.R

find_sky_pixelsR Documentation

Find sky pixels

Description

Find sky pixels automatically.

Usage

find_sky_pixels(r, z, a, sample_size_pct = 30)

Arguments

r

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

z

SpatRaster built with zenith_image().

a

SpatRaster built with azimuth_image().

sample_size_pct

Numeric vector of length one. Minimum percentage of cells to sample. The population is comprised of 1296 cells of 5 \times 5 degrees.

Details

This function assumes that:

  • there is at least one pure sky pixel at the level of cells of 30 \times 30 degrees, and

  • sky pixels have a digital number (DN) greater than canopy pixels have.

For each 30 \times 30 cell, this method computes a quantile value and uses it as a threshold to select the pure sky pixels from the given cell. As a result, a binarized image is produced in a regional binarization fashion (regional_thresholding()). This process starts with a quantile probability of 0.99. After producing the binarized image, this function uses a search grid with cells of 5 \times 5 degrees to count how many of these cells have at least one sky pixel (pixels equal to one in the binarized image). If the percentage of cells with sky pixels does not reach argument sample_size_pct, it goes back to the binarization step but decreasing the probability by 0.01 points.

If probability reach 0.9 and the sample_size_pct criterion were not yet satisfied, the sample_size_pct is decreased one percent and the process starts all over again.

Value

An object of class SpatRaster with values 0 and 1. This layer masks pixels that are very likely pure sky pixels.

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_nonnull(), masking(), optim_normalize(), percentage_of_clipped_highlights(), read_bin(), read_caim_raw(), read_caim(), write_bin(), write_caim()

Examples

## Not run: 
caim <- read_caim() %>% normalize(., 0, 20847)
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
r <- caim$Blue
r[is.na(r)] <- 0
bin <- find_sky_pixels(r, z, a)
plot(bin)

## End(Not run)

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