if (FALSE) {
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
# Automatic sky brightness estimation
sky <- apply_by_direction(r, z, a, m, spacing = 10, fov = c(30, 60),
method = "detect_bg_dn", parallel = TRUE)
plot(sky$dn)
plot(r / sky$dn)
# Using cone-shaped model
sky_cs <- apply_by_direction(caim, z, a, m, spacing = 15, fov = 60,
method = "fit_coneshaped_model", parallel = TRUE)
plot(sky_cs$dn)
# Using trend surface model
sky_s <- apply_by_direction(caim, z, a, m, spacing = 15, fov = 60,
method = "fit_trend_surface_np1", parallel = TRUE)
plot(sky_s$dn)
# Using a custom thresholding function
thr <- apply_by_direction(r, z, a, m, 15, fov = c(30, 40, 50),
fun = function(r, z, a, m) {
thr <- tryCatch(thr_twocorner(r[m])$tm, error = function(e) NA)
r[] <- thr
r
},
parallel = TRUE
)
plot(thr$dn)
plot(binarize_with_thr(r, thr$dn))
}
Run the code above in your browser using DataLab