fisheye_to_equidistant: Fisheye to equidistant

View source: R/fisheye_to_equidistant.R

fisheye_to_equidistantR Documentation

Fisheye to equidistant

Description

Reproject a hemispherical image from fisheye to equidistant projection (also known as polar projection) to standardize its geometry for subsequent analysis and comparison between images.

Usage

fisheye_to_equidistant(r, z, a, m, radius = NULL, k = 1, p = 1, rmax = 100)

Arguments

r

terra::SpatRaster of one or more layers (e.g., RGB channels or binary masks) in fisheye projection.

z

terra::SpatRaster generated with zenith_image().

a

terra::SpatRaster generated with azimuth_image().

m

logical terra::SpatRaster with one layer. A binary mask with TRUE for selected pixels.

radius

numeric vector of length one. Radius (in pixels) of the reprojected hemispherical image. Must be an integer value (no decimal part). If NULL (default), it is set to ncol(r) / 2.

k, p, rmax

numeric vector of length one. Parameters passed to lidR::knnidw(): number of neighbors (k), inverse distance weighting exponent (p), and maximum search radius (rmax) in units of the output resolution.

Details

Pixel values and coordinates are treated as 3D points and reprojected using Cartesian interpolation. Internally, this function uses lidR::knnidw() as interpolation engine, so arguments k, p, and rmax are passed to it without modification.

Value

terra::SpatRaster with the same number of layers as r, reprojected to equidistant projection with circular shape and radius given by 'radius

Examples

## Not run: 
path <- system.file("external/APC_0836.jpg", package = "rcaiman")
caim <- read_caim(path)
calc_diameter(c(0.801, 0.178, -0.179), 1052, 86.2)
z <- zenith_image(2216,  c(0.801, 0.178, -0.179))
a <- azimuth_image(z)
zenith_colrow <- c(1063, 771)

caim <- expand_noncircular(caim, z, zenith_colrow)
m <- !is.na(caim$Red) & select_sky_region(z, 0, 86.2)
caim[!m] <- 0
m2 <- fisheye_to_equidistant(m, z, a, !is.na(z), radius = 600)
m2 <- binarize_with_thr(m2, 0.5) #to turn it logical
caim2[!m2] <- 0

plot(caim)

## End(Not run)

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