fsleyes.gl.textures.colourmaptexture¶
This module provides the ColourMapTexture class, a 1D
Texture which can be used to store a RGBA colour map.
-
class
fsleyes.gl.textures.colourmaptexture.ColourMapTexture(name)[source]¶ Bases:
fsleyes.gl.textures.texture.TextureThe
ColourMapTextureclass is aTexturewhich stores a RGB or RGBA colour map.A
ColourMapTexturemaps a data range to to a colour map. The data range may be specified by thesetDisplayRange()method, and the colour map by thesetColourMap()method. Alternately, both can be specified with theset()method.In OpenGL, textures are indexed with a number between 0.0 and 1.0. So in order to map the data range to texture coordinates, an offset/scale transformation must be applied to data values. The
ColourMapTexturecalculates this transformation, and makes it available via thegetCoordinateTransform()method.The colour map itself can be specified in a number of ways:
A
numpyarray of size \(N\times 3\) or \(N\times 4\), containing RGB or RGBA colour values, with colour values in the range[0, 1].A function which accepts an array of values in the range
[0, 1], and returns an array of size \(N\times 3\) or \(N\times 4\), specifying the RGB/RGBA colours that correspond to the input values.
Some other methods are provided, for configuring the colour map:
Set the transparency of all colours in the colour map.
Invert the values in the colour map.
Set the resolution (number of colours) of this
ColourMapTexture.Gamma correction - uses
gammaas an exponent to weight the colour map towards the low or high end.Log scaling .
Set the interpolation used by this
ColourMapTexture- eitherGL_NEARESTorGL_LINEAR.Set the texture border colour.
-
__init__(name)[source]¶ Create a
ColourMapTexture.- Parameters
name – A unique name for this
ColourMapTexture.
-
setColourMap(cmap)[source]¶ Set the colour map stored by the
ColourMapTexture.- Parameters
cmap – The colour map, either a
numpyarray of size \(N\times 3\) or \(N\times 4\), specifying RGB/RGBA colours, or a function which accepts values in the range[0, 1], and generates corresponding RGB/RGBA colours.
-
setResolution(res)[source]¶ Set the resolution (number of colours) of this
ColourMapTexture. This setting is only applicable when the colour map is specified as a function (seesetColourMap()).
-
setAlpha(alpha)[source]¶ Set the transparency of all colours in the colour map. This setting is only applicable when the colour map is specified as RGB values.
-
setGamma(gamma)[source]¶ Gamma correction - uses
gammaas an exponent to weight the colour map towards the low or high end. Only applied if the colour map (seesetColourMap()) is specified as a function.
-
setLogScale(logScale)[source]¶ Log scaling . Only applied if the colour map (see
setColourMap()) is specified as a function.
-
setInterp(interp)[source]¶ Set the interpolation used by this
ColourMapTexture- eitherGL_NEARESTorGL_LINEAR.
-
setDisplayRange(drange)[source]¶ Set the data range which corresponds to the colours stored in this
ColourMapTexture. A matrix which transforms values from from this data range into texture coordinates is available via thegetCoordinateTransform()method.
-
setBorder(border)[source]¶ Set the texture border colour. If
None, the edge colours of the colour map are used as the border.
-
getCoordinateTransform()[source]¶ Returns a matrix which transforms values from from the colour map data range (see
setDisplayRange()) into texture coordinates.
-
set(**kwargs)[source]¶ Set any parameters on this
ColourMapTexture. Valid keyword arguments are:cmapSee
setColourMap().invertSee
setInvert().interpSee
setInterp().alphaSee
setAlpha().resolutionSee
setResolution().gammaSee
setGamma().logScaleSee
setLogScale().displayRangeSee
setDisplayRange().borderSee
setBorder().
-
__prepareTextureSettings()¶ Called by
__refresh(). Prepares all of the texture settings, and returns a tuple containing:An array containing the colour map data
The display range
The interpolation setting
The border colour
-
__refresh()¶ Called when any settings of this
ColourMapTextureare changed. Re-configures the texture.
-
__module__= 'fsleyes.gl.textures.colourmaptexture'¶