forked from dahtah/imager
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
Unlike other colorspace conversions, sRGBtoRGB and RGBtosRGB do not rescale the input or output between imager's default 0-1 range and CImg's 0-255 range; since sRGB is not linear, this results in quite inaccurate conversions. Both input and output rescalings would be required for accurate conversion.
Lines 81 to 97 in 13ec8a0
| //' @describeIn imager.colourspaces RGB to sRGB conversion | |
| //' @export | |
| // [[Rcpp::export]] | |
| NumericVector RGBtosRGB(NumericVector im) { | |
| CId img = as<CId >(im); | |
| img.RGBtosRGB(); | |
| return wrap(img); | |
| } | |
| //' @describeIn imager.colourspaces sRGB to RGB conversion | |
| //' @export | |
| // [[Rcpp::export]] | |
| NumericVector sRGBtoRGB(NumericVector im) { | |
| CId img = as<CId >(im); | |
| img.sRGBtoRGB(); | |
| return wrap(img); | |
| } |
For example, converting white in RGB to sRGB results in values well out of range:
c(1,1,1) %>% as.cimg %>% RGBtosRGB %>% str
# 'cimg' num [1, 1, 1, 1:3] 12.7 12.7 12.7