fix_reconstructed_sky: Fix reconstructed sky

View source: R/fix_reconstructed_sky.R

fix_reconstructed_skyR Documentation

Fix reconstructed sky


Automatically edit a raster image of sky digital numbers (DNs) reconstructed with functions such as fit_coneshaped_model and fit_trend_surface.


fix_reconstructed_sky(sky, z, r, bin)

fix_predicted_sky(sky, z, r, bin)



SpatRaster. Sky DNs predicted with functions such as fit_coneshaped_model and fit_trend_surface.


SpatRaster built with zenith_image.


SpatRaster. The source of the sky DNs used to build sky (the data source).


SpatRaster. The binarization of r used to select the sky DNs for building the sky argument.


The predicted sky DNs are usually erroneous near the horizon because either they are a misleading extrapolation or are based on corrupted data (non-pure sky DNs).

The proposed automatic edition consists of (1) flattening the values below the minimum value from the data source–defined by r and bin–and (2) forcing the values toward the horizon to become gradually the median value from the data source. The latter is achieved by calculating the weighted average of the median value and the predicted sky DNs, using the ratio of z to 90 to determine the weights.


An object of class SpatRaster. The argument sky with dimensions unchanged but values edited.

See Also

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


## Not run: 
path <- system.file("external/DSCN4500.JPG", package = "rcaiman")
caim <- read_caim(path, c(1280, 960) - 745, 745 * 2, 745 * 2)
z <- zenith_image(ncol(caim), lens("Nikon_FCE9"))
a <- azimuth_image(z)
r <- gbc(caim$Blue)
g <- sky_grid_segmentation(z, a, 10)
bin <- find_sky_pixels(r, z, a)
sky_points <- extract_sky_points(r, bin, g)
sky_points <- extract_rl(r, z, a, sky_points, NULL)
model <- fit_coneshaped_model(sky_points$sky_points)
sky_cs <- model$fun(z, a)
sky_cs <- fix_reconstructed_sky(sky_cs, z, r, bin)
persp(sky_cs, theta = 90, phi = 0)

## End(Not run)

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