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 (unsigned int s)
 Init with seed. More...
 
void Imagine::initRandom ()
 Init. 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

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; // ...

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
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

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

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
I=Diagonal(d); // ...

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]

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

Examples:
Common/test/test.cpp.

◆ initRandom() [1/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.

◆ initRandom() [2/2]

void Imagine::initRandom ( )
inline

Init. Uses a time-dependent seed.

initRandom(); // Init with time dependent 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]

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
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)

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

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

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]

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

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

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

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]

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

◆ 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

Examples:
Common/test/test.cpp.

◆ AYELLOW

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

Predefined color

col=YELLOW; // predefined YELLOW

◆ 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

Examples:
Common/test/test.cpp.

◆ PURPLE

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

Predefined color

col=PURPLE; // predefined PURPLE

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.