Imagine++
Classes | Macros | Typedefs | Functions | Variables
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)   (s)
 Transform relative file path to absolute path. More...
 
#define stringSrcPath(s)   (s)
 Transform relative file path to absolute path. More...
 

Typedefs

typedef RGBA< byte > Imagine::AlphaColor
 RGBA<byte> alias. More...
 
typedef RGB< byte > Imagine::Color
 RGB<byte> alias. More...
 

Functions

template<typename T , int M>
Imagine::det (const FMatrix< T, M, M > &A)
 Determinant. More...
 
template<typename T , int M>
FMatrix< T, M, M > Imagine::Diagonal (const FVector< T, M > &d)
 Diagonal. More...
 
double Imagine::doubleRandom ()
 Uniform double. More...
 
double Imagine::gaussianRandom ()
 Normal law. More...
 
void Imagine::initRandom ()
 Init. More...
 
void Imagine::initRandom (unsigned int s)
 Init with seed. More...
 
int Imagine::intRandom (int a, int b)
 Uniform int. More...
 
template<typename T , int M>
FMatrix< T, M, M > Imagine::inverse (const FMatrix< T, M, M > &A)
 Inverse. More...
 
template<typename T >
bool Imagine::loadBinary (T &obj, std::string filename)
 Object loading. More...
 
template<typename T >
bool Imagine::loadText (T &obj, std::string filename)
 Object loading. More...
 
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. More...
 
template<typename T , int M, int N>
FMatrix< T, M, N > Imagine::operator* (T s, const FMatrix< T, M, N > &A)
 Scalar multiplication. More...
 
template<typename T , int M, int N>
FMatrix< T, M, N > Imagine::operator+ (T s, const FMatrix< T, M, N > &A)
 Scalar addition. More...
 
template<typename T , int M, int N>
FMatrix< T, M, N > Imagine::operator- (T s, const FMatrix< T, M, N > &A)
 Scalar substraction. More...
 
std::ostream & Imagine::operator<< (std::ostream &out, const Color &c)
 Display color as three integral values.
 
template<typename T >
FVector< double, 3 > Imagine::RGB2YUV (const RGB< T > &rgb)
 RGB to YUV. More...
 
template<typename T >
bool Imagine::saveBinary (const T &obj, std::string filename)
 Object saving. More...
 
template<typename T >
bool Imagine::saveText (const T &obj, std::string filename, int precision=-1)
 Object saving. More...
 
size_t Imagine::size_tRandom (size_t a)
 Uniform size_t. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename T , int M, int N>
FMatrix< T, N, M > Imagine::transpose (const FMatrix< T, M, N > &A)
 Transpose. More...
 
unsigned int Imagine::uintRandom (unsigned int a)
 Uniform unsigned int. More...
 
void Imagine::waitKey (const char *message="Press <enter> to continue...")
 Pause in program execution until key press. More...
 
template<typename T >
RGB< T > Imagine::YUV2RGB (const FVector< double, 3 > &yuv)
 YUV to RGB. More...
 

Variables

const AlphaColor Imagine::ABLACK =AlphaColor(0,0,0)
 Predefined color. More...
 
const AlphaColor Imagine::ABLUE =AlphaColor(0,0,255)
 Predefined color. More...
 
const AlphaColor Imagine::ACYAN =AlphaColor(0,255,255)
 Predefined color. More...
 
const AlphaColor Imagine::AGREEN =AlphaColor(0,255,0)
 Predefined color. More...
 
const AlphaColor Imagine::AMAGENTA =AlphaColor(255,0,255)
 Predefined color. More...
 
const AlphaColor Imagine::ARED =AlphaColor(255,0,0)
 Predefined color. More...
 
const AlphaColor Imagine::AWHITE =AlphaColor(255,255,255)
 Predefined color. More...
 
const AlphaColor Imagine::AYELLOW =AlphaColor(255,255,0)
 Predefined color. More...
 
const Color Imagine::BLACK =Color(0,0,0)
 Predefined color. More...
 
const Color Imagine::BLUE =Color(0,0,255)
 Predefined color. More...
 
const Color Imagine::CYAN =Color(0,255,255)
 Predefined color. More...
 
const Color Imagine::GREEN =Color(0,255,0)
 Predefined color. More...
 
const Color Imagine::MAGENTA =Color(255,0,255)
 Predefined color. More...
 
const Color Imagine::ORANGE =Color(255,128,0)
 Predefined color. More...
 
const Color Imagine::PURPLE =Color(128,0,255)
 Predefined color. More...
 
const Color Imagine::RED =Color(255,0,0)
 Predefined color. More...
 
const std::string Imagine::VERSION ="5.0.0"
 version of libraries. More...
 
const Color Imagine::WHITE =Color(255,255,255)
 Predefined color. More...
 
const Color Imagine::YELLOW =Color(255,255,0)
 Predefined color. More...
 

Detailed Description

Macro Definition Documentation

◆ srcPath

#define srcPath (   s)    (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". This does not work with a variable, see stringSrcPath for that.

Parameters
sFile name as a C constant string
Returns
Absolute path (a C constant string)
See also
stringSrcPath
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:51
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)    (s)

This macro prepends its argument with the absolute path of the folder containing the source file. The argument (a file name relative path) is a C++ string variable.

Parameters
sFile name as a C++ string
Returns
Absolute path as a C++ string
See also
srcPath
string name="xxx"; // String source path
cout << "File named string xxx in source path is replaced by: " << stringSrcPath(name) << endl; // ...
#define stringSrcPath(s)
Transform relative file path to absolute path.
Definition: Base.h:52
Examples
Common/test/test.cpp.

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
RED GREEN BLUE Alpha color.
Definition: Color.h:138
AlphaColor acol1(12,134,13); // same as above (255 = opaque; 0 = transparent)
// ...
Examples
Graphics/test/test.cpp.

◆ Color

alias for the most common type of color!

Color col(12,234,13); // color alias
RED GREEN BLUE color.
Definition: Color.h:26
Examples
Common/test/test.cpp, Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.

Function Documentation

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp.

◆ initRandom() [1/2]

void Imagine::initRandom ( )
inline

Init. Uses a time-dependent seed.

initRandom(); // Init with time dependent seed
void initRandom(unsigned int s)
Init with seed.
Definition: Random.h:18

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and Graphics/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp.

◆ 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)
Examples
Common/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ operator*()

template<typename T , int M, int N>
FMatrix< T, M, N > Imagine::operator* ( 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+ ( 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- ( 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

◆ 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:411
RGB< byte > Color
RGB<byte> alias.
Definition: Color.h:281
Examples
Common/test/test.cpp.

◆ 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)
Examples
Common/test/test.cpp.

◆ 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)
Examples
Common/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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
Examples
Common/test/test.cpp.

◆ waitKey()

void Imagine::waitKey ( const char *  message = "Press <enter> to continue...")
inline
Parameters
messagethe message to display: (use "") to display nothing
Examples
Common/test/test.cpp, and LinAlg/test/test.cpp.

◆ 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<byte>(yuv); // YUV to RGB

Variable Documentation

◆ ABLACK

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

Predefined color

col=BLACK; // predefined BLACK
const Color BLACK
Predefined color.
Definition: Color.h:293

◆ ABLUE

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

Predefined color

col=BLUE; // predefined BLUE
const Color BLUE
Predefined color.
Definition: Color.h:299

◆ ACYAN

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

Predefined color

col=CYAN; // predefined CYAN
const Color CYAN
Predefined color.
Definition: Color.h:323

◆ AGREEN

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

Predefined color

col=GREEN; // predefined GREEN
const Color GREEN
Predefined color.
Definition: Color.h:311

◆ AMAGENTA

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

Predefined color

col=MAGENTA; // predefined MAGENTA
const Color MAGENTA
Predefined color.
Definition: Color.h:329

◆ ARED

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

Predefined color

col=RED; // predefined RED
const Color RED
Predefined color.
Definition: Color.h:305

◆ AWHITE

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

Predefined color

col=WHITE; // predefined WHITE
const Color WHITE
Predefined color.
Definition: Color.h:287
Examples
Common/test/test.cpp.

◆ AYELLOW

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

Predefined color

col=YELLOW; // predefined YELLOW
const Color YELLOW
Predefined color.
Definition: Color.h:317

◆ BLACK

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

Predefined color

col=BLACK; // predefined BLACK
Examples
Common/test/test.cpp, Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ BLUE

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

Predefined color

col=BLUE; // predefined BLUE
Examples
Common/test/test.cpp, Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ CYAN

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

Predefined color

col=CYAN; // predefined CYAN
Examples
Common/test/test.cpp, Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ GREEN

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

Predefined color

col=GREEN; // predefined GREEN
Examples
Common/test/test.cpp, Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ MAGENTA

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

Predefined color

col=MAGENTA; // predefined MAGENTA
Examples
Common/test/test.cpp, Graphics/test/example.cpp, and Graphics/test/test.cpp.

◆ ORANGE

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

Predefined color

col=ORANGE; // predefined ORANGE
const Color ORANGE
Predefined color.
Definition: Color.h:335
Examples
Common/test/test.cpp.

◆ PURPLE

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

Predefined color

col=PURPLE; // predefined PURPLE
const Color PURPLE
Predefined color.
Definition: Color.h:341
Examples
Common/test/test.cpp.

◆ RED

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

◆ VERSION

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

String contining version of Imagine++ libraries

Examples
Common/test/test.cpp.

◆ WHITE

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

Predefined color

col=WHITE; // predefined WHITE
Examples
Common/test/test.cpp, and Graphics/test/test.cpp.

◆ YELLOW

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

Predefined color

col=YELLOW; // predefined YELLOW
Examples
Common/test/test.cpp, and Graphics/test/test.cpp.