Skip to content

Instantly share code, notes, and snippets.

@TellAnAx
TellAnAx / rgb2lab
Last active August 4, 2022 15:08
R function to convert from RGB to CIELAB color space. Code adapted from Python version https://gist.github.com/manojpandey/f5ece715132c572c80421febebaf66ae
# RGB to Lab conversion
# Step 1: RGB to XYZ
# http://www.easyrgb.com/index.php?X=MATH&H=02#text2
# Step 2: XYZ to Lab
# http://www.easyrgb.com/index.php?X=MATH&H=07#text7
rgb2lab <- function(inputColor, maxColorValue = 255){