JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
Collaboration diagram for Tool Functions to Build Lookup-Tables for Palettes:

Classes

struct  JKQTPColorPaletteSingleColorLinSegment
 for building palettes from linear segments of single colors using JKQTPBuildColorPaletteLUTLinSegmentsSorted() and JKQTPBuildColorPaletteLUTLinSegments() More...
 
class  JKQTPPaletteList
 for building palettes from list of colors and position values, using JKQTPBuildColorPaletteLUTLinInterpolateSorted(), ... More...
 

Functions

QRgb jkqtp_qRgbOpaque (QRgb col)
 version of qRgb() that does not require to add the alpha part
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT (const QMap< double, QRgb > &items, int lut_size=JKQTPImageTools::LUTSIZE)
 like JKQTPBuildColorPaletteLUTSorted(), but accepts a QMap<double,QRgb> as parameter instead of QList<QPair<double,QRgb>>
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT (const std::function< float(float)> &rFunc, const std::function< float(float)> &gFunc, const std::function< float(float)> &bFunc, const std::function< float(float)> &aFunc, int lut_size=JKQTPImageTools::LUTSIZE, float vMin=0.0, float vMax=1.0)
 Builds a LUT by evaluating the quadruple RGBA = ( rFunc(v) , gFunc(v) , bFunc(v) ) for v in the range vMin ... vMax at lut_size equally distributed locations.
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT (const std::function< float(float)> &rFunc, const std::function< float(float)> &gFunc, const std::function< float(float)> &bFunc, int lut_size=JKQTPImageTools::LUTSIZE, float vMin=0.0, float vMax=1.0)
 Builds a LUT by evaluating the triple RGB = ( rFunc(v) , gFunc(v) , bFunc(v) ) for v in the range vMin ... vMax at lut_size equally distributed locations.
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT (const std::function< QRgb(float)> &palFunc, int lut_size=JKQTPImageTools::LUTSIZE, float vMin=0.0, float vMax=1.0)
 Builds a LUT by evaluating palFunc(v) for v in the range vMin ... vMax at lut_size equally distributed locations.
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT (JKQTPPaletteList items, int lut_size=JKQTPImageTools::LUTSIZE)
 like JKQTPBuildColorPaletteLUTSorted(), but sorts items before processing it!
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTBySubsampling (const JKQTPImageTools::LUTType &items, int lut_size=JKQTPImageTools::NDEFAULTSTEPS)
 takes an existing JKQTPImageTools::LUTType and subsamples lut_size elements from it
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTColorsOnlySteps (JKQTPPaletteList items)
 takes the QRgb-values in items and builds a stepped palette from them, ignoring the double-values. the palette will have items.size() entries.
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolate (const QMap< double, QRgb > &items, int lut_size=JKQTPImageTools::LUTSIZE)
 like JKQTPBuildColorPaletteLUTLinInterpolateSorted(), but accepts a QMap<double,QRgb> as parameter instead of QList<QPair<double,QRgb>>
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolate (JKQTPPaletteList items, int lut_size=JKQTPImageTools::LUTSIZE)
 like JKQTPBuildColorPaletteLUTLinInterpolateSorted(), but sorts items before processing it!
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolateSorted (const JKQTPPaletteList &items, int lut_size=JKQTPImageTools::LUTSIZE)
 build a linearly interpolated palette (as a look-up table) with lut_size entries by linearly interpolating between the nodes in items . NOTE: items is assumed to be sorted by the first component of the QPair<double,QRgb> entries!
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinSegments (QList< JKQTPColorPaletteSingleColorLinSegment > itemsR, QList< JKQTPColorPaletteSingleColorLinSegment > itemsG, QList< JKQTPColorPaletteSingleColorLinSegment > itemsB, int lut_size=JKQTPImageTools::LUTSIZE)
 like JKQTPBuildColorPaletteLUTLinSegmentsSorted(), but sorts itemsR, itemB, itemsG before processing them!
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinSegmentsSorted (const QList< JKQTPColorPaletteSingleColorLinSegment > &itemsR, const QList< JKQTPColorPaletteSingleColorLinSegment > &itemsG, const QList< JKQTPColorPaletteSingleColorLinSegment > &itemsB, int lut_size=JKQTPImageTools::LUTSIZE)
 build an interpolated palette with lut_size entries from the linear segments defined for the color channels R, G and B in itemsR, itemG and itemB respectively NOTE: The entries in itemsR, itemsG, itemsB are assumed to be sorted by the position entry.
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTSorted (const JKQTPPaletteList &items, int lut_size=JKQTPImageTools::LUTSIZE)
 build a palette (as a look-up table) with lut_size entries that step between the nodes provided in items. NOTE: items is assumed to be sorted by the first component of the QPair<double,QRgb> entries!
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPCreateGreensCubeHelixLUT (float start, float rotation, float gamma=1.0, int lutsize=JKQTPImageTools::LUTSIZE, float lambda_min=0.0, float lambda_max=1.0, float saturation_min=1.2, float saturation_max=1.2)
 create color palettes/LUTs by using Green's CubeHelix method
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPModifyLUT (JKQTPImageTools::LUTType lut, std::function< QRgb(int, QRgb)> f)
 modify each element of a given lut with a given functor that receives the color and an index
 
JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPModifyLUT (JKQTPImageTools::LUTType lut, std::function< QRgb(QRgb)> f)
 modify each element of a given lut with a given functor that receives the color
 

Detailed Description

Function Documentation

◆ jkqtp_qRgbOpaque()

QRgb jkqtp_qRgbOpaque ( QRgb  col)
inline

version of qRgb() that does not require to add the alpha part

◆ JKQTPBuildColorPaletteLUT() [1/5]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT ( const QMap< double, QRgb > &  items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

like JKQTPBuildColorPaletteLUTSorted(), but accepts a QMap<double,QRgb> as parameter instead of QList<QPair<double,QRgb>>

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are stepped between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUT(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPBuildColorPaletteLUT() [2/5]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT ( const std::function< float(float)> &  rFunc,
const std::function< float(float)> &  gFunc,
const std::function< float(float)> &  bFunc,
const std::function< float(float)> &  aFunc,
int  lut_size = JKQTPImageTools::LUTSIZE,
float  vMin = 0.0,
float  vMax = 1.0 
)

Builds a LUT by evaluating the quadruple RGBA = ( rFunc(v) , gFunc(v) , bFunc(v) ) for v in the range vMin ... vMax at lut_size equally distributed locations.

Note
Each function should return a value between 0 and 1. If the values are larger, the are clipped to this range!

◆ JKQTPBuildColorPaletteLUT() [3/5]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT ( const std::function< float(float)> &  rFunc,
const std::function< float(float)> &  gFunc,
const std::function< float(float)> &  bFunc,
int  lut_size = JKQTPImageTools::LUTSIZE,
float  vMin = 0.0,
float  vMax = 1.0 
)

Builds a LUT by evaluating the triple RGB = ( rFunc(v) , gFunc(v) , bFunc(v) ) for v in the range vMin ... vMax at lut_size equally distributed locations.

Note
Each function should return a value between 0 and 1. If the values are larger, the are clipped to this range!

◆ JKQTPBuildColorPaletteLUT() [4/5]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT ( const std::function< QRgb(float)> &  palFunc,
int  lut_size = JKQTPImageTools::LUTSIZE,
float  vMin = 0.0,
float  vMax = 1.0 
)

Builds a LUT by evaluating palFunc(v) for v in the range vMin ... vMax at lut_size equally distributed locations.

◆ JKQTPBuildColorPaletteLUT() [5/5]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUT ( JKQTPPaletteList  items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

like JKQTPBuildColorPaletteLUTSorted(), but sorts items before processing it!

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are stepped between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUT(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPBuildColorPaletteLUTBySubsampling()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTBySubsampling ( const JKQTPImageTools::LUTType items,
int  lut_size = JKQTPImageTools::NDEFAULTSTEPS 
)

takes an existing JKQTPImageTools::LUTType and subsamples lut_size elements from it

◆ JKQTPBuildColorPaletteLUTColorsOnlySteps()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTColorsOnlySteps ( JKQTPPaletteList  items)

takes the QRgb-values in items and builds a stepped palette from them, ignoring the double-values. the palette will have items.size() entries.

Note
items wird zunächst nach dem double sortiert

◆ JKQTPBuildColorPaletteLUTLinInterpolate() [1/2]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolate ( const QMap< double, QRgb > &  items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

like JKQTPBuildColorPaletteLUTLinInterpolateSorted(), but accepts a QMap<double,QRgb> as parameter instead of QList<QPair<double,QRgb>>

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are interpolated between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUTLinInterpolate(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPBuildColorPaletteLUTLinInterpolate() [2/2]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolate ( JKQTPPaletteList  items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

like JKQTPBuildColorPaletteLUTLinInterpolateSorted(), but sorts items before processing it!

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are interpolated between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUTLinInterpolate(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPBuildColorPaletteLUTLinInterpolateSorted()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinInterpolateSorted ( const JKQTPPaletteList items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

build a linearly interpolated palette (as a look-up table) with lut_size entries by linearly interpolating between the nodes in items . NOTE: items is assumed to be sorted by the first component of the QPair<double,QRgb> entries!

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are interpolated between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUTLinInterpolate(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPBuildColorPaletteLUTLinSegments()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinSegments ( QList< JKQTPColorPaletteSingleColorLinSegment itemsR,
QList< JKQTPColorPaletteSingleColorLinSegment itemsG,
QList< JKQTPColorPaletteSingleColorLinSegment itemsB,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

like JKQTPBuildColorPaletteLUTLinSegmentsSorted(), but sorts itemsR, itemB, itemsG before processing them!

This is used to build a table of linear segments as a QList<JKQTPColorPaletteSingleColorLinSegment> :

  i    position    colval1            colval2
 ~~~  ~~~~~~~~~~  ~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
  0       0.0           0 (IGNORED)        0
  1       0.5         100                100
  2       0.8         255                255
  3       1.0         255                255 (IGNORED)

This will build a graph:

   colval
     ^
     |
250  -                                        #**********#
     |                                     ***
200  -                                  ***
     |                               ***
150  -                             **
     |                           **
100  -                     *****#
     |                 ****
 50  -            *****
     |       *****
  0  - #*****
     |
    ---|----|----|----|----|----|----|----|----|----|----|--> position
      0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1.0

You can also build graphs with a jump at a certain position

  i    position    colval1            colval2
 ~~~  ~~~~~~~~~~  ~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
  0       0.0           0 (IGNORED)        0
  1       0.5         100                  0
  2       1.0         255                255 (IGNORED)

This results in:

   colval
     ^
     |
250  -                                                 **#
     |                                               **
200  -                                             **
     |                                           **
150  -                                        ***
     |                                      **
100  -                          #         **
     |                    ******        **
 50  -              ******            **
     |        ******                **
  0  - #******                   #**
     |
    ---|----|----|----|----|----|----|----|----|----|----|--> position
      0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1.0
See also
JKQTPBuildColorPaletteLUTLinSegments(), Example (JKQTPlotter): Image Plots with Custom Palettes , https://matplotlib.org/api/_as_gen/matplotlib.colors.LinearSegmentedColormap.html#matplotlib.colors.LinearSegmentedColormap

◆ JKQTPBuildColorPaletteLUTLinSegmentsSorted()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTLinSegmentsSorted ( const QList< JKQTPColorPaletteSingleColorLinSegment > &  itemsR,
const QList< JKQTPColorPaletteSingleColorLinSegment > &  itemsG,
const QList< JKQTPColorPaletteSingleColorLinSegment > &  itemsB,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

build an interpolated palette with lut_size entries from the linear segments defined for the color channels R, G and B in itemsR, itemG and itemB respectively NOTE: The entries in itemsR, itemsG, itemsB are assumed to be sorted by the position entry.

This is used to build a table of linear segments as a QList<JKQTPColorPaletteSingleColorLinSegment> :

  i    position    colval1            colval2
 ~~~  ~~~~~~~~~~  ~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
  0       0.0           0 (IGNORED)        0
  1       0.5         100                100
  2       0.8         255                255
  3       1.0         255                255 (IGNORED)

This will build a graph:

   colval
     ^
     |
250  -                                        #**********#
     |                                     ***
200  -                                  ***
     |                               ***
150  -                             **
     |                           **
100  -                     *****#
     |                 ****
 50  -            *****
     |       *****
  0  - #*****
     |
    ---|----|----|----|----|----|----|----|----|----|----|--> position
      0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1.0

You can also build graphs with a jump at a certain position

  i    position    colval1            colval2
 ~~~  ~~~~~~~~~~  ~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
  0       0.0           0 (IGNORED)        0
  1       0.5         100                  0
  2       1.0         255                255 (IGNORED)

This results in:

   colval
     ^
     |
250  -                                                 **#
     |                                               **
200  -                                             **
     |                                           **
150  -                                        ***
     |                                      **
100  -                          #         **
     |                    ******        **
 50  -              ******            **
     |        ******                **
  0  - #******                   #**
     |
    ---|----|----|----|----|----|----|----|----|----|----|--> position
      0.0  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1.0
See also
JKQTPBuildColorPaletteLUTLinSegments(), Example (JKQTPlotter): Image Plots with Custom Palettes , https://matplotlib.org/api/_as_gen/matplotlib.colors.LinearSegmentedColormap.html#matplotlib.colors.LinearSegmentedColormap

◆ JKQTPBuildColorPaletteLUTSorted()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPBuildColorPaletteLUTSorted ( const JKQTPPaletteList items,
int  lut_size = JKQTPImageTools::LUTSIZE 
)

build a palette (as a look-up table) with lut_size entries that step between the nodes provided in items. NOTE: items is assumed to be sorted by the first component of the QPair<double,QRgb> entries!

The LUT is built following these rules:

  • the final LUT has lut_size entries
  • the first color in the lut is given by items.first().second
  • the last color in the lut is given by items.last().second
  • in between the colors are stepped between the nodes in items and the color-nodes are distributed according to the first component of the QPair<double,QRgb> entries:
See also
JKQTPBuildColorPaletteLUT(), Example (JKQTPlotter): Image Plots with Custom Palettes

◆ JKQTPCreateGreensCubeHelixLUT()

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPCreateGreensCubeHelixLUT ( float  start,
float  rotation,
float  gamma = 1.0,
int  lutsize = JKQTPImageTools::LUTSIZE,
float  lambda_min = 0.0,
float  lambda_max = 1.0,
float  saturation_min = 1.2,
float  saturation_max = 1.2 
)

create color palettes/LUTs by using Green's CubeHelix method

See also
see Green, D. A. 2011. A colour scheme for the display of astronomical intensity images. Bull. Astr. Soc. India 39, 289-295. and https://articles.adsabs.harvard.edu/pdf/2011BASI...39..289G and https://jiffyclub.github.io/palettable/cubehelix/
Parameters
startstart-hue for the palette
rotationrotation paremeter for the palette
gammaoptional gamma parameter
lutsizenumber of entries in LUT
lambda_minstart value for the $ \lambda $ in Green's formula
lambda_maxend value for the $ \lambda $ in Green's formula
saturation_minstart value for the saturation in Green's formula, usually the saturation is a single value, then saturation_min == saturation_max!
saturation_maxend value for the saturation in Green's formula, usually the saturation is a single value, then saturation_min == saturation_max!
Returns
the lut generated from the provided parameters with lutsize entries

◆ JKQTPModifyLUT() [1/2]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPModifyLUT ( JKQTPImageTools::LUTType  lut,
std::function< QRgb(int, QRgb)>  f 
)

modify each element of a given lut with a given functor that receives the color and an index

◆ JKQTPModifyLUT() [2/2]

JKQTPImageTools::LUTType JKQTCOMMON_LIB_EXPORT JKQTPModifyLUT ( JKQTPImageTools::LUTType  lut,
std::function< QRgb(QRgb)>  f 
)

modify each element of a given lut with a given functor that receives the color