Table Of Contents

Previous topic

psychopy.tools - miscellaneous tools

Next topic

psychopy.tools.coordinatetools

This Page

Quick links

psychopy.tools.colorspacetools

Functions and classes related to color space conversion

dkl2rgb(dkl[, conversionMatrix]) Convert from DKL color space (Derrington, Krauskopf & Lennie) to RGB.
dklCart2rgb(LUM, LM, S[, conversionMatrix]) Like dkl2rgb except that it uses cartesian coords (LM,S,LUM) rather than spherical coords for DKL (elev, azim, contr).
rgb2dklCart(picture[, conversionMatrix]) Convert an RGB image into Cartesian DKL space.
hsv2rgb(hsv_Nx3) Convert from HSV color space to RGB gun values.
lms2rgb(lms_Nx3[, conversionMatrix]) Convert from cone space (Long, Medium, Short) to RGB.
rgb2lms(rgb_Nx3[, conversionMatrix]) Convert from RGB to cone space (LMS).
dkl2rgb(dkl[, conversionMatrix]) Convert from DKL color space (Derrington, Krauskopf & Lennie) to RGB.

Function details

psychopy.tools.colorspacetools.dkl2rgb(dkl, conversionMatrix=None)

Convert from DKL color space (Derrington, Krauskopf & Lennie) to RGB.

Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that this will not be an accurate representation of the color space unless you supply a conversion matrix).

usage:

rgb(Nx3) = dkl2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
rgb(NxNx3) = dkl2rgb(dkl_NxNx3(el,az,radius), conversionMatrix)
psychopy.tools.colorspacetools.dklCart2rgb(LUM, LM, S, conversionMatrix=None)

Like dkl2rgb except that it uses cartesian coords (LM,S,LUM) rather than spherical coords for DKL (elev, azim, contr).

NB: this may return rgb values >1 or <-1

psychopy.tools.colorspacetools.rgb2dklCart(picture, conversionMatrix=None)

Convert an RGB image into Cartesian DKL space.

psychopy.tools.colorspacetools.hsv2rgb(hsv_Nx3)

Convert from HSV color space to RGB gun values.

usage:

rgb_Nx3 = hsv2rgb(hsv_Nx3)

Note that in some uses of HSV space the Hue component is given in radians or cycles (range 0:1]). In this version H is given in degrees (0:360).

Also note that the RGB output ranges -1:1, in keeping with other PsychoPy functions.

psychopy.tools.colorspacetools.lms2rgb(lms_Nx3, conversionMatrix=None)

Convert from cone space (Long, Medium, Short) to RGB.

Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that you will not get an accurate representation of the color space unless you supply a conversion matrix)

usage:

rgb_Nx3 = lms2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
psychopy.tools.colorspacetools.rgb2lms(rgb_Nx3, conversionMatrix=None)

Convert from RGB to cone space (LMS).

Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that you will not get an accurate representation of the color space unless you supply a conversion matrix)

usage:

lms_Nx3 = rgb2lms(rgb_Nx3(el,az,radius), conversionMatrix)
psychopy.tools.colorspacetools.dkl2rgb(dkl, conversionMatrix=None)

Convert from DKL color space (Derrington, Krauskopf & Lennie) to RGB.

Requires a conversion matrix, which will be generated from generic Sony Trinitron phosphors if not supplied (note that this will not be an accurate representation of the color space unless you supply a conversion matrix).

usage:

rgb(Nx3) = dkl2rgb(dkl_Nx3(el,az,radius), conversionMatrix)
rgb(NxNx3) = dkl2rgb(dkl_NxNx3(el,az,radius), conversionMatrix)