Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Types | Public Member Functions | List of all members
BIAS::ColourGradient< StorageType > Class Template Reference

Represents a colour gradient. More...

#include <Utils/ColourGradient.hh>

+ Inheritance diagram for BIAS::ColourGradient< StorageType >:

Public Types

enum  ColourGradientType {
  Gray, Cool, Hot, Bone,
  Jet
}
 Different types of predefined color gradients that can be generated. More...
 

Public Member Functions

void AddColour (float pos, const std::vector< StorageType > &colour)
 Adds a colour to this ColourGradient. More...
 
void AddRGBColour (float pos, const StorageType r, const StorageType g, const StorageType b)
 Convenience wrapper. More...
 
 ColourGradient ()
 Default Constructor. More...
 
 ColourGradient (std::vector< StorageType > colourLeft, std::vector< StorageType > colourRight)
 Constructor. More...
 
 ColourGradient (ColourGradientType mapType, const StorageType max=255)
 Constructor that allows to generate from a predefined color map. More...
 
void GetColour (float pos, std::vector< StorageType > &colour)
 Returns the interpolated colour at a given position. More...
 

Detailed Description

template<class StorageType>
class BIAS::ColourGradient< StorageType >

Represents a colour gradient.

The ColourGradient is a function [0,1] -> YOUR_COLOUR_SPACE.

The gradient will consist of at least two colours: one colour on the "left" side (at position 0) and one on the "right" side (at position 1). Intermediate colours can be added with AddColour().

To get a linearly interpolated colour at a certain position call GetColour().

Author
rwulff 04/2010

Definition at line 54 of file ColourGradient.hh.

Member Enumeration Documentation

template<class StorageType>
enum BIAS::ColourGradient::ColourGradientType

Different types of predefined color gradients that can be generated.

Inspired by Matlab.

Enumerator
Gray 
Cool 
Hot 
Bone 
Jet 

Definition at line 64 of file ColourGradient.hh.

Constructor & Destructor Documentation

template<class StorageType >
BIAS::ColourGradient< StorageType >::ColourGradient ( )

Default Constructor.

Initialises with gray-scale gradient from black to white, assuming 3 channels and unsigned char.

Definition at line 33 of file ColourGradient.cpp.

template<class StorageType>
BIAS::ColourGradient< StorageType >::ColourGradient ( std::vector< StorageType >  colourLeft,
std::vector< StorageType >  colourRight 
)

Constructor.

Note
Both colour vectors may not be empty and must have the same size.
Parameters
colourLeftthe colour at position 0
colourRightthe colour at position 1

Definition at line 105 of file ColourGradient.cpp.

template<class StorageType>
BIAS::ColourGradient< StorageType >::ColourGradient ( ColourGradientType  mapType,
const StorageType  max = 255 
)

Constructor that allows to generate from a predefined color map.

The color maximas are set to max e.g. blue is (0 0 max)

Member Function Documentation

template<class StorageType>
void ColourGradient::AddColour ( float  pos,
const std::vector< StorageType > &  colour 
)

Adds a colour to this ColourGradient.

If a colour already exists at the given pos, it is replaced by the new value.

Parameters
posthe position where the new colour is to be set, must be in [0,1]
colourthe new colour to set, must have the same size as the colours given to the constructor

Definition at line 127 of file ColourGradient.cpp.

template<class StorageType>
void BIAS::ColourGradient< StorageType >::AddRGBColour ( float  pos,
const StorageType  r,
const StorageType  g,
const StorageType  b 
)

Convenience wrapper.

Definition at line 213 of file ColourGradient.cpp.

template<class StorageType>
void BIAS::ColourGradient< StorageType >::GetColour ( float  pos,
std::vector< StorageType > &  colour 
)

Returns the interpolated colour at a given position.

The colour is interpolated linearly between the nearest colours that were added before.

Parameters
posthe position for which the interpolated colour should be returned, must be in [0,1]
colourthe returned interpolated colour

Definition at line 174 of file ColourGradient.cpp.


The documentation for this class was generated from the following files: