The C++ Template Image Processing Library. |

[Introduction]- [News]- [Download]- [Screenshots]- [Tutorial]- [Forums]- [Reference]- [SourceForge Repository ]

Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

# cimg_library::cimg Namespace Reference

The `cimg::` namespace encompasses low-level functions and variables of the CImg Library. More...

## Functions

const char * | convert_path ()
| Return the path of the ImageMagick `convert` tool.
const char * | temporary_path ()
| Return a path to store temporary files.
const bool | endian ()
| Return `false` for little endian CPUs, `true` for big endian CPUs.
void | info ()
| Display informations about CImg compilation variables, on the standart error output stderr.
long int | time ()
| Get the value of a system timer with a millisecond precision.
void | sleep (const int milliseconds)
| Sleep for a certain numbers of milliseconds.
long int | wait (const int milliseconds=20, long int reference_time=-1)
| Wait for a certain number of milliseconds since the last call of wait().
template<typename T>
const T | rol (const T &a, const unsigned int n=1)
| Bitwise rotation on the left.
template<typename T>
const T | ror (const T &a, const unsigned int n=1)
| Bitwise rotation on the right.
template<typename T>
const T | abs (const T &a)
| Return the absolute value of `a`.
template<typename T>
const T & | min (const T &a, const T &b)
| Return the minimum between `a` and `b`.
template<typename T>
const T & | min (const T &a, const T &b, const T &c)
| Return the minimum between `a`,`b` and c.
template<typename T>
const T & | min (const T &a, const T &b, const T &c, const T &d)
| Return the minimum between `a`,`b`,`c` and `d`.
template<typename T>
const T & | max (const T &a, const T &b)
| Return the maximum between `a` and `b`.
template<typename T>
const T & | max (const T &a, const T &b, const T &c)
| Return the maximum between `a`,`b` and `c`.
template<typename T>
const T & | max (const T &a, const T &b, const T &c, const T &d)
| Return the maximum between `a`,`b`,`c` and `d`.
template<typename T>
char | sign (const T &x)
| Return the sign of `x`.
double | mod (const double &x, const double &m)
| Return `x` modulo `m` (generic modulo).
template<typename T>
T | minmod (const T &a, const T &b)
| Return minmod(`a`,`b`).
double | rand ()
| Return a random variable between [0,1] (uniform distribution).
double | crand ()
| Return a random variable between [-1,1] (uniform distribution).
double | grand ()
| Return a random variable using a gaussian distribution and a variance of 1.

## Variables

const double | PI = 3.14159265358979323846
| Definition of the mathematical constant PI.

## Detailed Description

The `cimg::` namespace encompasses low-level functions and variables of the CImg Library.

Most of the functions and variables within this namespace are used by the library for low-level purposes. Nevertheless, documented variables and functions below may be used by the user in its own source code.

Warning:
  Never write `"using namespace cimg_library::cimg;"` in your source, since a lot of functions of the cimg:: namespace have the same name than standart C functions defined in the global namespace `::`.

See also:
  CImg, CImgl, CImgDisplay, CImgStats and CImgException.

## Function Documentation

const char* convert_path | ( |  | ) |

Return the path of the ImageMagick `convert` tool.

If you have installed the ImageMagick package in a standart directory, this function returns the correct path of the `convert` tool used to load and save compressed image formats. Conversely, if the `convert` executable is not auto-detected by the function, you can define the macro `cimg_convert_path` with the correct path of the `convert` executable, before including `"CImg.h"` in your program :

           #define cimg_convert_path "/users/thatsme/local/bin/convert"
           #include "CImg.h"

           int main() {
             CImg<> img("my_image.jpg");
             return 0;
           }

Note:
  `convert` is needed to read and write compressed image formats. Other formats do not need `convert`.

See also:
  temporary_path, CImg::load_convert, CImg::save_convert.

Definition at line 1255 of file CImg.h.

const char* temporary_path | ( |  | ) |

Return a path to store temporary files.

If you are running on a standart Unix or Windows system, this function should return a correct path where temporary files can be stored. If the path is not auto-detected, you need to define the macro `cimg_temporary_path`, before including `"CImg.h"` in your program :

           #define cimg_temporary_path "/users/toto/tmp"
           #include "CImg.h"

           int main() {
             CImg<> img("my_image.jpg");
             return 0;
           }

Note:
  A temporary path is necessary to load and save compressed image formats, using `convert`.

See also:
  convert_path, CImg::load_convert, CImg::save_convert.

Definition at line 1302 of file CImg.h.

void sleep | ( | const int | milliseconds | ) |

Sleep for a certain numbers of milliseconds.

This function frees the CPU ressources during the sleeping time. May be used to temporize your program properly.

See also:
  wait, time.

Definition at line 1518 of file CImg.h.

long int wait | ( | const int | milliseconds = `20`,
|  | long int | reference_time = `-1`
| ) |

Wait for a certain number of milliseconds since the last call of wait().

If the desired delay has expired, this function returns immediately else it sleeps till the correct time. May be used to temporize your program properly.

See also:
  sleep, time.

Definition at line 1534 of file CImg.h.

double mod | ( | const double & | x,
|  | const double & | m
| ) |

| Return `x` modulo `m` (generic modulo). This modulo function accepts negative and floating-points modulo numbers `m`. Definition at line 1579 of file CImg.h.

T minmod | ( | const T & | a,
|  | const T & | b
| ) |

Return minmod(`a`,`b`).

The operator minmod(`a`,`b`) is defined to be :

- minmod(`a`,`b`) = min(`a`,`b`), if (`a` * `b`)>0.
- minmod(`a`,`b`) = 0, if (`a` * `b`)<=0

Definition at line 1589 of file CImg.h.