The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
spectra2rgb converts hyperspectral reflectance
signatures to sRGB hex codes and CIELAB coordinates. It bundles the CIE
1931 standard observer and D65 illuminant, so no external colour-science
package is required.
set.seed(1)
wl <- seq(400, 700, by = 10)
mat <- matrix(runif(5 * length(wl), 0.1, 0.9), nrow = 5)
colnames(mat) <- as.character(wl)
df <- as.data.frame(mat)
spectra_to_rgb_lab(df, id_col = paste0("leaf_", 1:5))
#> Sample_ID R G B hex L a b
#> 1 leaf_1 191 184 201 #BFB8C9 75.94563 5.473204 -7.532564
#> 2 leaf_2 172 199 175 #ACC7AF 77.70915 -13.652753 9.003911
#> 3 leaf_3 158 181 194 #9EB5C2 72.32000 -4.948629 -9.435452
#> 4 leaf_4 218 181 184 #DAB5B8 76.85865 14.004340 3.584069
#> 5 leaf_5 196 204 187 #C4CCBB 80.92846 -5.719798 7.240532df2 <- df
df2[2, ] <- NA
# Silent zero-fill (default):
spectra_to_rgb(df2, na_action = "zero")
#> Sample_ID R G B hex
#> 1 1 191 184 201 #BFB8C9
#> 2 2 0 0 0 #000000
#> 3 3 158 181 194 #9EB5C2
#> 4 4 218 181 184 #DAB5B8
#> 5 5 196 204 187 #C4CCBB
# Drop with warning:
suppressWarnings(spectra_to_rgb(df2, na_action = "drop"))
#> Sample_ID R G B hex
#> 1 1 191 184 201 #BFB8C9
#> 2 3 158 181 194 #9EB5C2
#> 3 4 218 181 184 #DAB5B8
#> 4 5 196 204 187 #C4CCBB
# Preserve NA:
spectra_to_rgb(df2, na_action = "keep")
#> Sample_ID R G B hex
#> 1 1 191 184 201 #BFB8C9
#> 2 2 NA NA NA <NA>
#> 3 3 158 181 194 #9EB5C2
#> 4 4 218 181 184 #DAB5B8
#> 5 5 196 204 187 #C4CCBBThese binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.