invert_gamma_correction: Gamma back correction of JPEG images

View source: R/invert_gamma_correction.R

invert_gamma_correctionR Documentation

Gamma back correction of JPEG images

Description

Approximates the inversion of the gamma encoding applied to JPEG images.

Usage

invert_gamma_correction(dn, gamma = 2.2)

Arguments

dn

numeric vector or terra::SpatRaster. Digital numbers from a JPEG file (range 0–255, as per standard 8-bit encoding).

gamma

numeric vector of length one. Exponent applied in the inverse gamma correction (typically 2.2 for sRGB).

Details

Digital cameras typically encode images using the sRGB color space, which applies a non-linear transformation—commonly referred to as gamma correction—to the sensor's linear luminance response. This function applies a power transformation to approximate the inverse of that encoding, restoring a response closer to linear.

Value

Same properties as dn, with values adjusted by inverse gamma correction and rescaled to the range [0, 1].

References

\insertAllCited

Examples

## Not run: 
path <- system.file("external/APC_0836.jpg", package = "rcaiman")
caim <- read_caim(path)
z <- zenith_image(2132,  lens("Olloclip"))
a <- azimuth_image(z)
zenith_colrow <- c(1063, 771)

caim <- expand_noncircular(caim, z, zenith_colrow)
m <- !is.na(caim$Red) & !is.na(z)
caim[!m] <- 0

bin <- binarize_with_thr(caim$Blue, thr_isodata(caim$Blue[m]))

display_caim(caim$Blue, bin)

caim <- invert_gamma_correction(caim, 2.2)

## End(Not run)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.