View source: R/read_caim_raw.R
read_caim_raw | R Documentation |
Read unprocessed sensor data from a camera RAW file and split the signal by spectral band according to the in-camera color filter array (CFA). Use this to obtain images with precise radiometry.
read_caim_raw(path, only_blue = FALSE, offset_value = NULL)
path |
character vector of length one. Path to a file with raw data (including file extension). |
only_blue |
logical vector of length one. If |
offset_value |
numeric vector of length one. Optional black level offsets to replace
|
Uses Python rawpy
through reticulate
to access sensor data and black-level metadata. Optionally extracts only the
blue/cyan band.
Numeric terra::SpatRaster:
single-layer if only_blue = TRUE
.
multi-layer if only_blue = FALSE
, with one layer per color per CFA
color (e.g., R, G, B).
Layers are named according to metadata in the raw file.
To ensure that R can access a Python installation, run the following test:
reticulate::py_eval("1+1")
If R can access Python successfully, you will see 2
in the console. If not,
you will receive instructions on how to install Python.
After passing the Python accessibility test, create a virtual environment using the following command:
reticulate::virtualenv_create()
rawpy
Install the rawpy package within the virtual environment:
reticulate::py_install("rawpy")
If you are an RStudio user who works with projects, you will need a .Renviron file in the root of each project. To create a .Renviron file, follow these steps:
Create a "New Blank File" named ".Renviron" (without an extension) in the project's root directory.
Run bellow code:
path <- file.path(reticulate::virtualenv_root(), reticulate::virtualenv_list(), "Scripts", "python.exe") paste("RETICULATE_PYTHON =", path)
Copy/paste the line from the console (the string between the quotes) into
the .Renviron file. This is an example RETICULATE_PYTHON = ~/.virtualenvs/r-reticulate/Scripts/python.exe
Do not forget to save the changes
By following these steps, users can easily set up their environment to access raw data efficiently, but it is not the only way of doing it, you might know an easier or better one.
See the help page of read_caim()
and fisheye_to_equidistant()
as a
complement to this help page. Further details about raw files can be found in
\insertCiteDiaz2024;textualrcaiman.
read_caim()
## Not run:
file_name <- tempfile(fileext = ".NEF")
download.file("https://osf.io/s49py/download", file_name, mode = "wb")
# Geometric and radiometric corrections -----------------------------------
zenith_colrow <- c(1290, 988)/2
diameter <- 756
z <- zenith_image(diameter, lens("Nikon_FCE9"))
a <- azimuth_image(z)
m <- !is.na(z)
caim <- read_caim_raw(file_name, only_blue = TRUE)
caim <- crop_caim(caim, zenith_colrow - diameter/2, diameter, diameter)
caim <- correct_vignetting(caim, z, c(0.0638, -0.101))
caim <- fisheye_to_equidistant(caim, z, a, m, radius = 300,
k = 1, p = 1, rmax = 100)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.