# ootb_sky_reconstruction: Out-of-the-box sky reconstruction In rcaiman: CAnopy IMage ANalysis

 ootb_sky_reconstruction R Documentation

## Out-of-the-box sky reconstruction

### Description

Build an above canopy image from a single below canopy image.

### Usage

ootb_sky_reconstruction(r, z, a, bin, filling_source = NULL)


### 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. bin SpatRaster. This should be a preliminary binarization of r useful for masking pixels that are very likely to be pure sky pixels. filling_source SpatRaster. An actual or reconstructed above-canopy image to complement the sky pixels detected through the gaps of r. If an incomplete above-canopy image is available, non-sky pixels should be turned NA or they will be considered as sky pixels erroneously. A photograph taken immediately after or before taking r under the open sky with the same equipment and configuration is a very good option but not recommended under fleeting clouds. The orientation relative to the North must be the same as for r. If it is set to NULL (default), only sky pixels from r will be used as input.

### Details

This function is a hard-coded version of a pipeline that uses these main functions fit_cie_sky_model and interpolate_sky_points. The code can be easily inspected by calling ootb_sky_reconstruction–no parenthesis. Advanced users could use that code as a template.

This pipeline is based on \insertCiteLang2010;textualrcaiman. The main differences between the original method by \insertCiteLang2010;textualrcaiman and the one implemented here are:

• it is fully automatic,

• the residuals of the CIE sky model (residuals=model-data) are interpolated instead of the sky digital numbers (the data), and

• the final sky reconstruction is obtained by subtracting the interpolated residuals to the CIE sky model instead of by calculating a weighted average parameterized by the user.

The recommended input for this function is data pre-processed with the HSP software package \insertCiteLang2013rcaiman. Please, refer to write_sky_points for additional details about HSP and refer to fit_cie_sky_model and interpolate_sky_points to know why the HSP pre-processing is convenient.

Providing a filling source triggers an alternative pipeline in which the sky is fully reconstructed with interpolate_sky_points after a dense sampling (1 \times 1 degree cells), which is supported by the fact that sky digital numbers will be available for almost every pixel, either from r gaps or from the filling source–an exception is a filling source with plenty of NA values, which should not be provided.

### References

\insertAllCited

Other Sky Reconstruction Functions: cie_sky_model_raster(), fit_cie_sky_model(), fit_coneshaped_model(), fit_trend_surface(), fix_reconstructed_sky(), interpolate_sky_points()

### Examples

## Not run:
#JPEG file
z <- zenith_image(ncol(caim), lens("Nikon_FCE9"))
a <- azimuth_image(z)
r <- gbc(caim\$Blue)
bin <- ootb_obia(caim %>% normalize(), z, a)
bin <- bin & mask_hs(z, 0, 85)
sky <- ootb_sky_reconstruction(r, z, a, bin)
sky <- normalize(sky, 0, 1, TRUE)
plot(sky)
sky <- ootb_sky_reconstruction(r, z, a, bin, sky)

ratio <- r/sky
plot(ratio)
hist(ratio)
ratio <- normalize(ratio, 0, 1, TRUE)
g <- sky_grid_segmentation(z, a, 10)
plot(defuzzify(ratio, g))

#preprocessed with HSP
path <- system.file("external/DSCN6342.pgm", package = "rcaiman")
z <- zenith_image(ncol(r), lens())
a <- azimuth_image(z)
bin <- find_sky_pixels(r, z, a)
sky <- ootb_sky_reconstruction(r, z, a, bin)
bin <- apply_thr(r/sky, 0.5)
sky <- ootb_sky_reconstruction(r, z, a, bin, sky)
ratio <- r/sky
ratio[is.na(ratio)] <- 0
ratio <- normalize(ratio, 0, 1, force_range = TRUE)
plot(ratio)
g <- sky_grid_segmentation(z, a, 10)
plot(defuzzify(ratio, g))

## End(Not run)


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