Imagine++
Common Library

Classes

class  Imagine::Array< T >
 Array of variable size. More...
 
class  Imagine::Coords< dim >
 Coordinates. More...
 
class  Imagine::CoordsIterator< dim >
 Iterator on Coordinates. More...
 
class  Imagine::FArray< T, S >
 Array of fixed size. More...
 
class  Imagine::FMatrix< T, M, N >
 Matrix of fixed dimension. More...
 
class  Imagine::FVector< T, dim >
 Vector of fixed size. More...
 
class  Imagine::MultiArray< T, dim >
 nD array of variable size. More...
 
class  Imagine::RGB< T >
 RED GREEN BLUE color. More...
 
class  Imagine::RGBA< T >
 RED GREEN BLUE Alpha color. More...
 
class  Imagine::Timer
 Timers. More...
 

Macros

#define srcPath(s)
 Transform relative file path to absolute path.
 
#define stringSrcPath(s)
 

Typedefs

typedef RGBA< octetImagine::AlphaColor
 RGBA<byte> alias.
 
typedef unsigned char Imagine::byte
 
typedef RGB< octetImagine::Color
 RGB<octet> alias.
 
typedef unsigned char Imagine::octet
 0 to 255 integer type.
 

Functions

const Color Imagine::BLACK (0, 0, 0)
 Predefined color.
 
const Color Imagine::BLUE (0, 0, 255)
 Predefined color.
 
const Color Imagine::CYAN (0, 255, 255)
 Predefined color.
 
template<typename T, int M>
Imagine::det (const FMatrix< T, M, M > &A)
 Determinant.
 
template<typename T, int M>
FMatrix< T, M, M > Imagine::Diagonal (const FVector< T, M > &d)
 Diagonal.
 
double Imagine::doubleRandom ()
 Uniform double.
 
double Imagine::gaussianRandom ()
 Normal law.
 
const Color Imagine::GREEN (0, 255, 0)
 Predefined color.
 
void Imagine::initRandom ()
 Init.
 
void Imagine::initRandom (unsigned int s)
 Init with seed.
 
int Imagine::intRandom (int a, int b)
 Uniform int.
 
template<typename T, int M>
FMatrix< T, M, M > Imagine::inverse (const FMatrix< T, M, M > &A)
 Inverse.
 
template<typename T>
bool Imagine::loadBinary (T &obj, std::string filename)
 Object loading.
 
template<typename T>
bool Imagine::loadText (T &obj, std::string filename)
 Object loading.
 
const Color Imagine::MAGENTA (255, 0, 255)
 Predefined color.
 
template<typename T, int M, int N, int O>
FMatrix< T, M, O > Imagine::multt (const FMatrix< T, M, N > &A, const FMatrix< T, O, N > &B)
 Product.
 
template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator* (T s, const FMatrix< T, M, N > &A)
 Scalar multiplication.
 
template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator+ (T s, const FMatrix< T, M, N > &A)
 Scalar addition.
 
template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator- (T s, const FMatrix< T, M, N > &A)
 Scalar substraction.
 
std::ostream & Imagine::operator<< (std::ostream &out, const Color &c)
 Display color as three integral values.
 
const Color Imagine::ORANGE (255, 128, 0)
 Predefined color.
 
const Color Imagine::PURPLE (128, 0, 255)
 Predefined color.
 
const Color Imagine::RED (255, 0, 0)
 Predefined color.
 
template<typename T>
FVector< double, 3 > Imagine::RGB2YUV (const RGB< T > &rgb)
 RGB to YUV.
 
template<typename T>
bool Imagine::saveBinary (const T &obj, std::string filename)
 Object saving.
 
template<typename T>
bool Imagine::saveText (const T &obj, std::string filename, int precision=-1)
 Object saving.
 
size_t Imagine::size_tRandom (size_t a)
 Uniform size_t.
 
template<typename T, int M, int N, int O>
FMatrix< T, N, O > Imagine::tmult (const FMatrix< T, M, N > &A, const FMatrix< T, M, O > &B)
 Product.
 
template<typename T, int M, int N>
FVector< T, N > Imagine::tmult (const FMatrix< T, M, N > &A, const FVector< T, M > &v)
 Product with vector.
 
template<typename T, int M, int N, int O>
FMatrix< T, N, O > Imagine::tmultt (const FMatrix< T, M, N > &A, const FMatrix< T, O, M > &B)
 Product.
 
template<typename T, int M, int N>
FMatrix< T, N, M > Imagine::transpose (const FMatrix< T, M, N > &A)
 Transpose.
 
unsigned int Imagine::uintRandom (unsigned int a)
 Uniform unsigned int.
 
void Imagine::waitKey (const char *message="Press <enter> to continue...")
 Pause in program execution until key press.
 
const Color Imagine::WHITE (255, 255, 255)
 Predefined color.
 
const Color Imagine::YELLOW (255, 255, 0)
 Predefined color.
 
template<typename T>
RGB< T > Imagine::YUV2RGB (const FVector< double, 3 > &yuv)
 YUV to RGB.
 

Variables

const AlphaColor Imagine::ABLACK =AlphaColor(0,0,0)
 Predefined color.
 
const AlphaColor Imagine::ABLUE =AlphaColor(0,0,255)
 Predefined color.
 
const AlphaColor Imagine::ACYAN =AlphaColor(0,255,255)
 Predefined color.
 
const AlphaColor Imagine::AGREEN =AlphaColor(0,255,0)
 Predefined color.
 
const AlphaColor Imagine::AMAGENTA =AlphaColor(255,0,255)
 Predefined color.
 
const AlphaColor Imagine::ARED =AlphaColor(255,0,0)
 Predefined color.
 
const AlphaColor Imagine::AWHITE =AlphaColor(255,255,255)
 Predefined color.
 
const AlphaColor Imagine::AYELLOW =AlphaColor(255,255,0)
 Predefined color.
 
const std::string Imagine::VERSION ="6.0.0"
 version of libraries.
 

Detailed Description

Macro Definition Documentation

◆ srcPath

#define srcPath ( s)
Value:
(s)

This macro prepends its argument with the absolute path of the folder containing the source file. The argument (a file name relative path) must be a C constant string, like "data.txt".

Parameters
sFile name as a string
Returns
Absolute path (a string)
cout << "File named xxx in source path is replaced by: " << srcPath("xxx") << endl; // C source path
#define srcPath(s)
Transform relative file path to absolute path.
Definition Base.h:43
string name="xxx"; // String source path
cout << "File named string xxx in source path is replaced by: " << srcPath(name) << endl; // ...
Examples
Common/test/test.cpp, Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

◆ stringSrcPath

#define stringSrcPath ( s)
Value:
(s)
Parameters
sFile name as a string
Deprecated
stringSrcPath is deprecated, use srcPath instead.
See also
srcPath

Typedef Documentation

◆ AlphaColor

alias for the most common type of color with alpha channel!

AlphaColor acol(12,134,13,255); // color alias with alpha channel
RGBA< octet > AlphaColor
RGBA<byte> alias.
Definition Color.h:356
AlphaColor acol1(12,134,13); // same as above (255 = opaque; 0 = transparent)
// ...

◆ byte

typedef unsigned char Imagine::byte
Deprecated
To avoid confusion with std::byte (C++17), use octet instead

◆ Color

alias for the most common type of color!

Color col(12,234,13); // color alias
RGB< octet > Color
RGB<octet> alias.
Definition Color.h:283

◆ octet

typedef unsigned char Imagine::octet

alias for 0 to 255 integers

x = (Imagine::octet)123; // octet/byte alias
unsigned char octet
0 to 255 integer type.
Definition Color.h:18

Function Documentation

◆ BLACK()

const Color Imagine::BLACK ( 0 ,
0 ,
0  )

Predefined color

col=BLACK; // predefined BLACK
const Color BLACK(0, 0, 0)
Predefined color.

◆ BLUE()

const Color Imagine::BLUE ( 0 ,
0 ,
255  )

Predefined color

col=BLUE; // predefined BLUE
const Color BLUE(0, 0, 255)
Predefined color.

◆ CYAN()

const Color Imagine::CYAN ( 0 ,
255 ,
255  )

Predefined color

col=CYAN; // predefined CYAN
const Color CYAN(0, 255, 255)
Predefined color.

◆ det()

template<typename T, int M>
T Imagine::det ( const FMatrix< T, M, M > & A)

Determinant. Available for M = N <= 3 only. For larger matrices, consider using Matrix class.

Parameters
Aargument
Returns
determinant
x=det(A11); x=det(A22); x=det(A33); // Determinant
T det(const FMatrix< T, M, M > &A)
Determinant.
Definition FMatrix.h:717

◆ Diagonal()

template<typename T, int M>
FMatrix< T, M, M > Imagine::Diagonal ( const FVector< T, M > & d)

Diagonal matrix

Parameters
ddiagonal vector
Returns
matrix
FVector<double,2> d(2.); // diagonal
Vector of fixed size.
Definition FVector.h:17
I=Diagonal(d); // ...
FMatrix< T, M, M > Diagonal(const FVector< T, M > &d)
Diagonal.
Definition FMatrix.h:743

◆ doubleRandom()

double Imagine::doubleRandom ( )
inline

Uniform double in [0;1]

Returns
random value
cout << doubleRandom() << " "; // double in [0;1]
double doubleRandom()
Uniform double.
Definition Random.h:38

◆ gaussianRandom()

double Imagine::gaussianRandom ( )
inline

Normal Gaussian

Returns
random value
cout << gaussianRandom() << endl; // double following a normal Gaussian law
double gaussianRandom()
Normal law.
Definition Random.h:87

◆ GREEN()

const Color Imagine::GREEN ( 0 ,
255 ,
0  )

Predefined color

col=GREEN; // predefined GREEN
const Color GREEN(0, 255, 0)
Predefined color.

◆ initRandom() [1/2]

void Imagine::initRandom ( )
inline

Init. Uses a time-dependent seed.

initRandom(); // Init with time dependent seed
void initRandom()
Init.
Definition Random.h:28

◆ initRandom() [2/2]

void Imagine::initRandom ( unsigned int s)
inline

Init with given seed (to obtain the same sequence)

Parameters
sseed
initRandom(0); // Init with given seed

◆ intRandom()

int Imagine::intRandom ( int a,
int b )
inline

Uniform int between to numbers a and b (included)

Parameters
a,bbounds
Returns
random value
cout << intRandom(10,20) << " "; // int in [a;b]
int intRandom(int a, int b)
Uniform int.
Definition Random.h:55

◆ inverse()

template<typename T, int M>
FMatrix< T, M, M > Imagine::inverse ( const FMatrix< T, M, M > & A)

Inverse matrix. If non invertible, ouptuts a message to cerr and returns a matrix with zeroed elements. Available for M = N <= 3 only. For larger matrices, use inverseFMatrix() in LinAlg Library.

Parameters
AFMatrix to invert
Returns
Inverse
cout << A11*inverse(A11) << endl; // 1x1 inverse
FMatrix< T, M, M > inverse(const FMatrix< T, M, M > &A)
Inverse.
Definition FMatrix.h:678
cout << A22*inverse(A22) << endl; // 2x2 inverse
cout << A33*inverse(A33) << endl; // 3x3 inverse

◆ loadBinary()

template<typename T>
bool Imagine::loadBinary ( T & obj,
std::string filename )

Loads an object from a given file in binary format (read() must be implemented)

Parameters
objobject to load
filenamefile name
Returns
false if failed
FVector<double,3> v(1/3.,2.,3.); // object to save
saveText(v,"tmp.txt",15); // save object (ASCII with given precision)
loadText(v,"tmp.txt"); // load object (ASCII)
saveBinary(v,"tmp.bin"); // save object (binary)
loadBinary(v,"tmp.bin"); // load object (binary)
bool saveText(const T &obj, std::string filename, int precision=-1)
Object saving.
Definition IO.h:67
bool loadBinary(T &obj, std::string filename)
Object loading.
Definition IO.h:47
bool saveBinary(const T &obj, std::string filename)
Object saving.
Definition IO.h:88
bool loadText(T &obj, std::string filename)
Object loading.
Definition IO.h:28

◆ loadText()

template<typename T>
bool Imagine::loadText ( T & obj,
std::string filename )

Loads an object from a given file in ASCII format (operator>>() must be implemented)

Parameters
objobject to load
filenamefile name
Returns
false if failed
FVector<double,3> v(1/3.,2.,3.); // object to save
saveText(v,"tmp.txt",15); // save object (ASCII with given precision)
loadText(v,"tmp.txt"); // load object (ASCII)
saveBinary(v,"tmp.bin"); // save object (binary)
loadBinary(v,"tmp.bin"); // load object (binary)

◆ MAGENTA()

const Color Imagine::MAGENTA ( 255 ,
0 ,
255  )

Predefined color

col=MAGENTA; // predefined MAGENTA
const Color MAGENTA(255, 0, 255)
Predefined color.

◆ multt()

template<typename T, int M, int N, int O>
FMatrix< T, M, O > Imagine::multt ( const FMatrix< T, M, N > & A,
const FMatrix< T, O, N > & B )

Matrix matrix product (variant)

Parameters
Aleft operand
Bright operand
Returns
A * transpose(B)
A34=multt(A32,A42); // matrix * matrix^T
FMatrix< T, M, O > multt(const FMatrix< T, M, N > &A, const FMatrix< T, O, N > &B)
Product.
Definition FMatrix.h:630

◆ operator*()

template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator* ( T s,
const FMatrix< T, M, N > & A )

Multiplies each element by a scalar

Parameters
sThe scalar
AThe FMatrix
Returns
The result
C=2.*A; // scalar * FMatrix

◆ operator+()

template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator+ ( T s,
const FMatrix< T, M, N > & A )

Adds a scalar to each element

Parameters
sThe scalar
AThe FMatrix
Returns
The result
C=2.+A; // scalar + FMatrix

◆ operator-()

template<typename T, int M, int N>
FMatrix< T, M, N > Imagine::operator- ( T s,
const FMatrix< T, M, N > & A )

Substract each element to a scalar

Parameters
sThe scalar
AThe FMatrix
Returns
The result
C=2.-A; // scalar - FMatrix

◆ ORANGE()

const Color Imagine::ORANGE ( 255 ,
128 ,
0  )

Predefined color

col=ORANGE; // predefined ORANGE
const Color ORANGE(255, 128, 0)
Predefined color.

◆ PURPLE()

const Color Imagine::PURPLE ( 128 ,
0 ,
255  )

Predefined color

col=PURPLE; // predefined PURPLE
const Color PURPLE(128, 0, 255)
Predefined color.

◆ RED()

const Color Imagine::RED ( 255 ,
0 ,
0  )

Predefined color

col=RED; // predefined RED
const Color RED(255, 0, 0)
Predefined color.

◆ RGB2YUV()

template<typename T>
FVector< double, 3 > Imagine::RGB2YUV ( const RGB< T > & rgb)
inline

RGB to YUV

Parameters
rgbRGB color to convert
Returns
YUV as a vector of doubles
FVector<double,3> yuv=RGB2YUV(Color(12,234,123)); // RGB to YUV
FVector< double, 3 > RGB2YUV(const RGB< T > &rgb)
RGB to YUV.
Definition Color.h:413

◆ saveBinary()

template<typename T>
bool Imagine::saveBinary ( const T & obj,
std::string filename )

Saves an object from a given file in binary format (write must be implemented)

Parameters
objobject to save
filenamefile name
Returns
false if failed
FVector<double,3> v(1/3.,2.,3.); // object to save
saveText(v,"tmp.txt",15); // save object (ASCII with given precision)
loadText(v,"tmp.txt"); // load object (ASCII)
saveBinary(v,"tmp.bin"); // save object (binary)
loadBinary(v,"tmp.bin"); // load object (binary)

◆ saveText()

template<typename T>
bool Imagine::saveText ( const T & obj,
std::string filename,
int precision = -1 )

Saves an object from a given file in ASCII format (operator<<() must be implemented)

Parameters
objobject to save
filenamefile name
precisionfor ASCII output
Returns
false if failed
FVector<double,3> v(1/3.,2.,3.); // object to save
saveText(v,"tmp.txt",15); // save object (ASCII with given precision)
loadText(v,"tmp.txt"); // load object (ASCII)
saveBinary(v,"tmp.bin"); // save object (binary)
loadBinary(v,"tmp.bin"); // load object (binary)

◆ size_tRandom()

size_t Imagine::size_tRandom ( size_t a)
inline

Uniform size_t between 0 and a (included)

Parameters
abound
Returns
random value
cout << size_tRandom(15) << " "; // size_t in [0;a]
size_t size_tRandom(size_t a)
Uniform size_t.
Definition Random.h:77

◆ tmult() [1/2]

template<typename T, int M, int N, int O>
FMatrix< T, N, O > Imagine::tmult ( const FMatrix< T, M, N > & A,
const FMatrix< T, M, O > & B )

Matrix matrix product (variant)

Parameters
Aleft operand
Bright operand
Returns
transpose(A) * B
A34=tmult(A23,A24); // matrix^T * matrix
FMatrix< T, N, O > tmult(const FMatrix< T, M, N > &A, const FMatrix< T, M, O > &B)
Product.
Definition FMatrix.h:615

◆ tmult() [2/2]

template<typename T, int M, int N>
FVector< T, N > Imagine::tmult ( const FMatrix< T, M, N > & A,
const FVector< T, M > & v )

Matrix vector product (variant)

Parameters
Aleft operand
vright operand
Returns
transpose(A)* v
v2=tmult(A32,v3); // matrix^T * vector

◆ tmultt()

template<typename T, int M, int N, int O>
FMatrix< T, N, O > Imagine::tmultt ( const FMatrix< T, M, N > & A,
const FMatrix< T, O, M > & B )

Matrix matrix product (variant)

Parameters
Aleft operand
Bright operand
Returns
transpose(A) * transpose(B)
A34=tmultt(A23,A42); // matrix^T * matrix^T
FMatrix< T, N, O > tmultt(const FMatrix< T, M, N > &A, const FMatrix< T, O, M > &B)
Product.
Definition FMatrix.h:645

◆ transpose()

template<typename T, int M, int N>
FMatrix< T, N, M > Imagine::transpose ( const FMatrix< T, M, N > & A)

Transposed FMatrix

Parameters
Amatrix to transpose
Returns
Transposed matrix
/*FMatrix<double,3,2> At=*/transpose(A);// transpose
FMatrix< T, N, M > transpose(const FMatrix< T, M, N > &A)
Transpose.
Definition FMatrix.h:564

◆ uintRandom()

unsigned int Imagine::uintRandom ( unsigned int a)
inline

Uniform int between 0 and a (included)

Parameters
abound
Returns
random value
cout << uintRandom(15) << " "; // unsigned int in [0;a]
unsigned int uintRandom(unsigned int a)
Uniform unsigned int.
Definition Random.h:66

◆ waitKey()

void Imagine::waitKey ( const char * message = "Press <enter> to continue...")
inline
Parameters
messagethe message to display: (use "") to display nothing

◆ WHITE()

const Color Imagine::WHITE ( 255 ,
255 ,
255  )

Predefined color

col=WHITE; // predefined WHITE
const Color WHITE(255, 255, 255)
Predefined color.

◆ YELLOW()

const Color Imagine::YELLOW ( 255 ,
255 ,
0  )

Predefined color

col=YELLOW; // predefined YELLOW
const Color YELLOW(255, 255, 0)
Predefined color.

◆ YUV2RGB()

template<typename T>
RGB< T > Imagine::YUV2RGB ( const FVector< double, 3 > & yuv)
inline

YUV to RGB

Parameters
yuvYUV vector to convert
Returns
RGB color
col=YUV2RGB<Imagine::octet>(yuv); // YUV to RGB
RGB< T > YUV2RGB(const FVector< double, 3 > &yuv)
YUV to RGB.
Definition Color.h:424

Variable Documentation

◆ ABLACK

const AlphaColor Imagine::ABLACK =AlphaColor(0,0,0)

Predefined color

col=BLACK; // predefined BLACK

◆ ABLUE

const AlphaColor Imagine::ABLUE =AlphaColor(0,0,255)

Predefined color

col=BLUE; // predefined BLUE

◆ ACYAN

const AlphaColor Imagine::ACYAN =AlphaColor(0,255,255)

Predefined color

col=CYAN; // predefined CYAN

◆ AGREEN

const AlphaColor Imagine::AGREEN =AlphaColor(0,255,0)

Predefined color

col=GREEN; // predefined GREEN

◆ AMAGENTA

const AlphaColor Imagine::AMAGENTA =AlphaColor(255,0,255)

Predefined color

col=MAGENTA; // predefined MAGENTA

◆ ARED

const AlphaColor Imagine::ARED =AlphaColor(255,0,0)

Predefined color

col=RED; // predefined RED

◆ AWHITE

const AlphaColor Imagine::AWHITE =AlphaColor(255,255,255)

Predefined color

col=WHITE; // predefined WHITE

◆ AYELLOW

const AlphaColor Imagine::AYELLOW =AlphaColor(255,255,0)

Predefined color

col=YELLOW; // predefined YELLOW

◆ VERSION

const std::string Imagine::VERSION ="6.0.0"

String contining version of Imagine++ libraries

cout << "Imagine++ version is " << VERSION << endl; // Version number
const std::string VERSION
version of libraries.
Definition Base.h:16