Learn R Programming

rcaiman (version 1.2.2)

optim_normalize: Optimize normalize parameters

Description

Wrapper function for bbmle::mle2(). Optimize normalize parameters by maximizing colorfulness() and minimizing saturation.

Usage

optim_normalize(caim, bin, method = "BFGS")

Value

Numeric vector of length one. The values for using as mx argument with normalize().

Arguments

caim

SpatRaster. The return of a call to read_caim() or read_caim_raw().

bin

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

method

Optimization method to use. See optim.

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

Examples

Run this code
if (FALSE) {
caim <- read_caim()
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)

mn <- quantile(caim$Blue[m], 0.01)
mx <- quantile(caim$Blue[m], 0.99)
r <- normalize(caim$Blue, mn, mx, TRUE)

bin <- find_sky_pixels(r, z, a)
mblt <- ootb_mblt(r, z, a, bin)
plot(mblt$bin)

mx <- optim_normalize(caim, mblt$bin)
ncaim <- normalize(caim, mx = mx, force_range = TRUE)
plotRGB(ncaim*255)
plotRGB(normalize(caim)*255)
percentage_of_clipped_highlights(ncaim$Blue, m)
}

Run the code above in your browser using DataLab