ootb_fit_cie_sky_model: Out-of-the-box fit CIE sky model

View source: R/ootb_fit_cie_sky_model.R

ootb_fit_cie_sky_modelR Documentation

Out-of-the-box fit CIE sky model

Description

This function is a hard-coded version of a pipeline that uses these main functions extract_sun_coord(), extract_sky_points(), sor_filter(), extract_rel_radiance(), fit_cie_sky_model(), and validate_cie_sky_model().

Usage

ootb_fit_cie_sky_model(r, z, a, m, bin, gs, min_spherical_dist)

Arguments

r

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

z

SpatRaster built with zenith_image().

a

SpatRaster built with azimuth_image().

m

SpatRaster. A mask, check select_sky_vault_region().

bin

SpatRaster. This should be a preliminary binarization of r useful for masking pixels that are very likely pure sky pixels.

gs

An object of the class list. A list with the output of sky_grid_segmentation(), see the example.

min_spherical_dist

Numeric vector. These values will be passed to the min_dist argument of vicinity_filter().

Details

This function is part of the efforts to automate the method proposed by \insertCiteLang2010;textualrcaiman. A paper for thoroughly presenting and testing this pipeline is under preparation.

Value

A list with the following components:

  • An object of the SpatRaster) with the predicted digital number values.

  • The output produced by fit_cie_sky_model().

  • The output produced by validate_cie_sky_model().

  • The dist_to_black argument used in extract_sky_points().

  • The min_spherical_dist argument used to filter the sky points.

  • The sky_points argument used in extract_rel_radiance().

References

\insertAllCited

See Also

Other Sky Reconstruction Functions: cie_sky_image(), fit_cie_sky_model(), fit_coneshaped_model(), fit_trend_surface(), interpolate_sky_points(), ootb_interpolate_and_merge()

Examples

## Not run: 
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)

r <- caim$Blue

bin <- regional_thresholding(r, rings_segmentation(z, 30),
                             method = "thr_isodata")
g <- sky_grid_segmentation(z, a, 10)
sun_coord <- extract_sun_coord(r, z, a, bin, g)
sun_coord$zenith_azimuth

.a <- azimuth_image(z, orientation = sun_coord$zenith_azimuth[2]+90)
seg <- sectors_segmentation(.a, 180) * rings_segmentation(z, 30)
bin <- regional_thresholding(r, seg, method = "thr_isodata")

mx <- optim_normalize(caim, bin)
caim <- normalize_minmax(caim, mx = mx, force_range = TRUE)
ecaim <- enhance_caim(caim, m, polarLAB(50, 17, 293))
bin <- apply_thr(ecaim, thr_isodata(ecaim[m]))
bin <- bin & select_sky_vault_region(z, 0, 85)
plot(bin)

set.seed(7)
gs <- list(
  sky_grid_segmentation(z, a, 1.875, first_ring_different = TRUE),
  sky_grid_segmentation(z, a, 6, first_ring_different = TRUE),
  sky_grid_segmentation(z, a, 10, first_ring_different = TRUE)
)

sky <- ootb_fit_cie_sky_model(r, z, a, m, bin , gs,
                              min_spherical_dist = seq(3, 9, 3))

sky$sky
plot(sky$sky)
sky$model_validation$rmse
plot(r/sky$sky>1.15)
plot(sky$model_validation$pred, sky$model_validation$obs)
abline(0,1)

plot(bin)
points(sky$sky_points$col, nrow(caim) - sky$sky_points$row, col = 2, pch = 10)

## End(Not run)

GastonMauroDiaz/rcaiman documentation built on April 14, 2025, 9:39 a.m.