Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: graphic
See also: hls2rgb rgb2hls hls2rgb

Quantlet: rgb2hls
Description: converts an RGB colour vector into an HLS vector.

Usage: HLS=rgb2hls(RGB)
Input:
n/a (n x 3) array of RGB colours assigned to n objects. The values of the R (red), G (green) and B (blue) channels range from 0 to 255.
Output:
HLS (n x 3) array of HLS colours assigned to n objects. The values of the H (hue) channel range from 0 to 360. H=0 corresponds to pure red, H=120 to pure green and H=240 to pure blue. The values of the L (lightness) and S (saturation) channels range from 0 to 1.

Note:

Example:
library("xplore");
library("plot");
library("graphic");
points=colorcube();
hls2=rgb2hls(points.pcolor);
rgb2=hls2rgb(hls2);
new2=(hls2[,3].*cos((pi/180)*hls2[,1]))~hls2[,2]~(hls2[,3].*sin((pi/180)*hls2[,1]));
new2=replace(new2,NaN,0);
disp1=createdisplay(1,1);
disp2=createdisplay(1,1);
setmaskp(new2,points.pcolor,points.pstyle, 10);
show(disp1,1,1,new2);
setmaskp(rgb2,points.pcolor,points.pstyle, 10);
show(disp2,1,1,rgb2);

Result:
HLS cone and RGB cube



(C) MD*TECH Method and Data Technologies, 05.02.2006