View source: R/rgb.calibrate.R
rgb.calibrate | R Documentation |
Calibration of existing color sampled data
rgb.calibrate(
sampled.array,
imagedir,
image.names,
calib.file,
color.standard.values = NULL,
px.radius = 2,
flip.y.values = F
)
sampled.array |
Previously sampled data from the rgb.measure function. |
imagedir |
directory of images to measure for calibration. Only images with landmarks will be processed. The landmark file names are assumed to exactly match the image names. |
image.names |
A vector of image names to look for in imagedir. |
color.standard.values |
a matrix of known values for collected color standard points. Should be N_points x 3 |
px.radius |
The size of the circular neighborhood (in pixels) to sample color around each triangulated point. |
flip.y.values |
should the calbration points be flipped to match the images? |
The function will return $sampled.color– an N_points x 3 (RGB) x N_observations array of sampled color values. A tri.surf.points class object will also be returned as $delaunay. Finally, a calibrated array of color values will be returned under $calibrated
#load landmarks and covariate data
guppy.lms <- tps2array(system.file("extdata", "original_lms.TPS", package = "Colormesh"))
specimen.factors <- read.csv(system.file("extdata", "specimen_factors.csv", package = "Colormesh"), header = F)
calib.file <- tps2array(system.file("extdata", "calib_LM_coords.TPS", package = "Colormesh"))
consensus <- tps2array(system.file("extdata", "consensus_LM_coords.TPS", package = "Colormesh"))
test.image <- image_reader(paste0(path.package("Colormesh"),"/extdata/unwarped_images/"), "GPLP_unw_001.jpg")
delaunay.map <- tri.surf(consensus, point.map = c(1,8:17,2, 18:19,3,20:27,4, 28:42,5,43:52,6,53:54,7,55:62), 3, test.image)
rgb.test <- rgb.measure(imagedir = paste0(path.package("Colormesh"),"/extdata/unwarped_images/"), image.names = specimen.factors[,2], delaunay.map = delaunay.map, linearize.color.space = F)
calibration.test <- rgb.calibrate(rgb.test, imagedir = paste0(path.package("Colormesh"),"/extdata/original_images/"), image.names = specimen.factors[,1], calib.file = calib.file)
#check result####
plot(calibration.test, individual = 2, style = "comparison")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.