[ Main ] [ News] [ Download ] [ Screenshots ] [ FAQ ] [ Tutorial ] [ Documentation ] [ Forum ] [ Chat ] [ Links ]

cimg_library::cimg Namespace Reference

Namespace that encompasses low-level functions and variables of the CImg Library. More...


Functions

void info ()
 Print informations about CImg environement variables.
unsigned int & exception_mode ()
 Get/set the current CImg exception mode.
template<typename tfunc, typename tp, typename tf>
void marching_cubes (const tfunc &func, const float isovalue, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const float resx, const float resy, const float resz, CImgList< tp > &points, CImgList< tf > &primitives, const bool invert_faces)
 Polygonize an implicit function.
template<typename tfunc, typename tp, typename tf>
void marching_squares (const tfunc &func, const float isovalue, const float x0, const float y0, const float x1, const float y1, const float resx, const float resy, CImgList< tp > &points, CImgList< tf > &primitives)
 Polygonize an implicit 2D function by the marching squares algorithm.
void warn (const char *format,...)
 Display a warning message.
void system (const char *command, const char *module_name=0)
template<typename T>
void swap (T &a, T &b)
 Exchange values of variables a and b.
template<typename T1, typename T2>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2)
 Exchange values of variables (a1,a2) and (b1,b2).
template<typename T1, typename T2, typename T3>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3)
 Exchange values of variables (a1,a2,a3) and (b1,b2,b3).
template<typename T1, typename T2, typename T3, typename T4>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3, T4 &a4, T4 &b4)
 Exchange values of variables (a1,a2,...,a4) and (b1,b2,...,b4).
template<typename T1, typename T2, typename T3, typename T4, typename T5>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3, T4 &a4, T4 &b4, T5 &a5, T5 &b5)
 Exchange values of variables (a1,a2,...,a5) and (b1,b2,...,b5).
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3, T4 &a4, T4 &b4, T5 &a5, T5 &b5, T6 &a6, T6 &b6)
 Exchange values of variables (a1,a2,...,a6) and (b1,b2,...,b6).
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3, T4 &a4, T4 &b4, T5 &a5, T5 &b5, T6 &a6, T6 &b6, T7 &a7, T7 &b7)
 Exchange values of variables (a1,a2,...,a7) and (b1,b2,...,b7).
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
void swap (T1 &a1, T1 &b1, T2 &a2, T2 &b2, T3 &a3, T3 &b3, T4 &a4, T4 &b4, T5 &a5, T5 &b5, T6 &a6, T6 &b6, T7 &a7, T7 &b7, T8 &a8, T8 &b8)
 Exchange values of variables (a1,a2,...,a8) and (b1,b2,...,b8).
bool endianness ()
 Return the current endianness of the CPU.
template<typename T>
void invert_endianness (T *const buffer, const unsigned int size)
 Invert endianness of a memory buffer.
template<typename T>
T & invert_endianness (T &a)
 Invert endianness of a single variable.
unsigned long time ()
 Get the value of a system timer with a millisecond precision.
void sleep (const unsigned int milliseconds)
 Sleep for a certain numbers of milliseconds.
unsigned int wait (const unsigned int milliseconds)
 Wait for a certain number of milliseconds since the last call.
template<typename T>
const T rol (const T a, const unsigned int n=1)
 Return a left bitwise-rotated number.
template<typename T>
const T ror (const T a, const unsigned int n=1)
 Return a right bitwise-rotated number.
template<typename T>
abs (const T a)
 Return the absolute value of a number.
template<typename T>
sqr (const T val)
 Return the square of a number.
int xln (const int x)
 Return 1 + log_10(x).
template<typename t1, typename t2>
cimg::superset< t1, t2 >::type min (const t1 &a, const t2 &b)
 Return the minimum value between two numbers.
template<typename t1, typename t2, typename t3>
cimg::superset2< t1, t2, t3 >::type min (const t1 &a, const t2 &b, const t3 &c)
 Return the minimum value between three numbers.
template<typename t1, typename t2, typename t3, typename t4>
cimg::superset3< t1, t2, t3,
t4 >::type 
min (const t1 &a, const t2 &b, const t3 &c, const t4 &d)
 Return the minimum value between four numbers.
template<typename t1, typename t2>
cimg::superset< t1, t2 >::type max (const t1 &a, const t2 &b)
 Return the maximum value between two numbers.
template<typename t1, typename t2, typename t3>
cimg::superset2< t1, t2, t3 >::type max (const t1 &a, const t2 &b, const t3 &c)
 Return the maximum value between three numbers.
template<typename t1, typename t2, typename t3, typename t4>
cimg::superset3< t1, t2, t3,
t4 >::type 
max (const t1 &a, const t2 &b, const t3 &c, const t4 &d)
 Return the maximum value between four numbers.
template<typename T>
sign (const T x)
 Return the sign of a number.
template<typename T>
unsigned long nearest_pow2 (const T x)
 Return the nearest power of 2 higher than a given number.
template<typename T>
mod (const T &x, const T &m)
 Return the modulo of a number.
template<typename T>
minmod (const T a, const T b)
 Return the minmod of two numbers.
double rand ()
 Return a random variable between [0,1] with respect to an uniform distribution.
double crand ()
 Return a random variable between [-1,1] with respect to an uniform distribution.
double grand ()
 Return a random variable following a gaussian distribution and a standard deviation of 1.
double round (const double x, const double y, const unsigned int round_type=0)
 Return a rounded number.
char uncase (const char x)
 Remove the 'case' of an ASCII character.
void uncase (char *const string)
 Remove the 'case' of a C string.
float atof (const char *str)
 Read a float number from a C-string.
int strlen (const char *s)
 Compute the length of a C-string.
int strncmp (const char *s1, const char *s2, const int l)
 Compare the first n characters of two C-strings.
int strncasecmp (const char *s1, const char *s2, const int l)
 Compare the first n characters of two C-strings, ignoring the case.
int strcmp (const char *s1, const char *s2)
 Compare two C-strings.
int strcasecmp (const char *s1, const char *s2)
 Compare two C-strings, ignoring the case.
int strfind (const char *s, const char c)
 Find a character in a C-string.
const char * basename (const char *s)
 Compute the basename of a filename.
const char * temporary_path ()
 Return path to store temporary files.
const char * imagemagick_path ()
 Return path of the ImageMagick's convert tool.
const char * graphicsmagick_path ()
 Return path of the GraphicsMagick's gm tool.
const char * medcon_path ()
 Return path of the XMedcon tool.
const char * ffmpeg_path ()
 Return path to the 'ffmpeg' command.
const char * gzip_path ()
 Return path to the 'gzip' command.
const char * gunzip_path ()
 Return path to the 'gunzip' command.
const char * split_filename (const char *const filename, char *const body=0)
 Split a filename into two strings 'body' and 'extension'.
char * filename_number (const char *const filename, const int number, const unsigned int n, char *const string)
 Create a numbered version of a filename.
std::FILE * fopen (const char *const path, const char *const mode)
 Open a file, and check for possible errors.
int fclose (std::FILE *file)
 Close a file, and check for possible errors.
template<typename T>
int fread (T *const ptr, const unsigned int nmemb, std::FILE *stream)
 Read file data, and check for possible errors.
template<typename T>
int fwrite (const T *ptr, const unsigned int nmemb, std::FILE *stream)
 Write data to a file, and check for possible errors.
template<typename t>
int dialog (const char *title, const char *msg, const char *button1_txt, const char *button2_txt, const char *button3_txt, const char *button4_txt, const char *button5_txt, const char *button6_txt, const CImg< t > &logo, const bool centering=false)
 Display a dialog box, where a user can click standard buttons.

Variables

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


Detailed Description

Namespace that 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 processing. Nevertheless, documented variables and functions of this namespace may be used safely in your own source code.

Warning:
Never write using namespace cimg_library::cimg; in your source code, since a lot of functions of the cimg:: namespace have prototypes similar to standard C functions that could defined in the global namespace ::.

Function Documentation

void info (  ) 

Print informations about CImg environement variables.

Printing is done on the standard error output.

unsigned int& cimg_library::cimg::exception_mode (  ) 

Get/set the current CImg exception mode.

The way error messages are handled by CImg can be changed dynamically, using this function. Possible values are :

  • 0 to hide debug messages (quiet mode, but exceptions are still thrown).
  • 1 to display debug messages on standard error (stderr).
  • 2 to display debug messages in modal windows (default behavior).
  • 3 to do as 1 + add extra warnings (may slow down the code !).
  • 4 to do as 2 + add extra warnings (may slow down the code !).

void cimg_library::cimg::warn ( const char *  format,
  ... 
)

Display a warning message.

Parameters:
format is a C-string describing the format of the message, as in std::printf().

void cimg_library::cimg::system ( const char *  command,
const char *  module_name = 0 
)

Note:
This function is similar to std::system() and is here because using the std:: version on Windows may open undesired consoles.

bool cimg_library::cimg::endianness (  ) 

Return the current endianness of the CPU.

Returns:
false for "Little Endian", true for "Big Endian".

void cimg_library::cimg::sleep ( const unsigned int  milliseconds  ) 

Sleep for a certain numbers of milliseconds.

This function frees the CPU ressources during the sleeping time. It may be used to temporize your program properly, without wasting CPU time.

unsigned int cimg_library::cimg::wait ( const unsigned int  milliseconds  ) 

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

This function is equivalent to sleep() but the waiting time is computed with regard to the last call of wait(). It may be used to temporize your program properly.

T cimg_library::cimg::abs ( const T  a  ) 

Return the absolute value of a number.

Note:
This function is different from std::abs() or std::fabs() because it is able to consider a variable of any type, without cast needed.

T cimg_library::cimg::mod ( const T &  x,
const T &  m 
)

Return the modulo of a number.

Note:
This modulo function accepts negative and floating-points modulo numbers, as well as variable of any type.

T cimg_library::cimg::minmod ( const T  a,
const T  b 
)

Return the minmod of two numbers.

minmod(a,b) is defined to be :

  • minmod(a,b) = min(a,b), if a and b have the same sign.
  • minmod(a,b) = 0, if a and b have different signs.

double cimg_library::cimg::round ( const double  x,
const double  y,
const unsigned int  round_type = 0 
)

Return a rounded number.

Parameters:
x is the number to be rounded.
y is the rounding precision.
round_type defines the type of rounding (0=nearest, 1=backward, 2=forward).

void cimg_library::cimg::uncase ( char *const   string  ) 

Remove the 'case' of a C string.

Acts in-place.

float cimg_library::cimg::atof ( const char *  str  ) 

Read a float number from a C-string.

Note:
This function is quite similar to std::atof(), but that it allows the retrieval of fractions as in "1/2".

int cimg_library::cimg::strlen ( const char *  s  ) 

Compute the length of a C-string.

Note:
This function is similar to std::strlen() and is here because some old compilers do not define the std:: version.

int cimg_library::cimg::strncmp ( const char *  s1,
const char *  s2,
const int  l 
)

Compare the first n characters of two C-strings.

Note:
This function is similar to std::strncmp() and is here because some old compilers do not define the std:: version.

int cimg_library::cimg::strncasecmp ( const char *  s1,
const char *  s2,
const int  l 
)

Compare the first n characters of two C-strings, ignoring the case.

Note:
This function is similar to std::strncasecmp() and is here because some old compilers do not define the std:: version.

int cimg_library::cimg::strcmp ( const char *  s1,
const char *  s2 
)

Compare two C-strings.

Note:
This function is similar to std::strcmp() and is here because some old compilers do not define the std:: version.

int cimg_library::cimg::strcasecmp ( const char *  s1,
const char *  s2 
)

Compare two C-strings, ignoring the case.

Note:
This function is similar to std::strcasecmp() and is here because some old compilers do not define the std:: version.

const char* cimg_library::cimg::temporary_path (  ) 

Return path to store temporary files.

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

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

       int main() {
         CImg<> img("my_image.jpg");   // Read a JPEG image file (using the defined temporary path).
         return 0;
       }

A temporary path is necessary to load and save compressed image formats, when using external tool such as convert or medcon. It is not necessary if you link your code with built-in libraries (such as libpng, libjpeg, libmagick, ...)

const char* cimg_library::cimg::imagemagick_path (  ) 

Return path of the ImageMagick's convert tool.

This function is used internally in imagemagick_path, graphicsmagick_path and medcon_path on Windows platforms If you have installed the ImageMagick package in a standard directory, this function should return the correct path of the convert tool used by the CImg Library 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_imagemagick_path with the correct path of the convert executable, before including CImg.h in your program :

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

       int main() {
         CImg<> img("my_image.jpg");     // Read a JPEG image file.
         return 0;
       }

Note that non compressed image formats can be read without installing ImageMagick.

const char* cimg_library::cimg::graphicsmagick_path (  ) 

Return path of the GraphicsMagick's gm tool.

If you have installed the GraphicsMagick package in a standard directory, this function should return the correct path of the gm tool used by the CImg Library to load and save compressed image formats. Conversely, if the gm executable is not auto-detected by the function, you can define the macro cimg_graphicsmagick_path with the correct path of the gm executable, before including CImg.h in your program :

       #define cimg_graphicsmagick_path "/users/thatsme/local/bin/gm"
       #include "CImg.h"

       int main() {
         CImg<> img("my_image.jpg");     // Read a JPEG image file.
         return 0;
       }

Note that non compressed image formats can be read without installing ImageMagick.

const char* cimg_library::cimg::medcon_path (  ) 

Return path of the XMedcon tool.

If you have installed the XMedcon package in a standard directory, this function should return the correct path of the medcon tool used by the CIg Library to load DICOM image formats. Conversely, if the medcon executable is not auto-detected by the function, you can define the macro cimg_medcon_path with the correct path of the medcon executable, before including CImg.h in your program :

       #define cimg_medcon_path "/users/thatsme/local/bin/medcon"
       #include "CImg.h"

       int main() {
         CImg<> img("my_image.dcm");    // Read a DICOM image file.
         return 0;
       }

Note that medcon is only needed if you want to read DICOM image formats.

int cimg_library::cimg::dialog ( const char *  title,
const char *  msg,
const char *  button1_txt,
const char *  button2_txt,
const char *  button3_txt,
const char *  button4_txt,
const char *  button5_txt,
const char *  button6_txt,
const CImg< t > &  logo,
const bool  centering = false 
)

Display a dialog box, where a user can click standard buttons.

Up to 6 buttons can be defined in the dialog window. This function returns when a user clicked one of the button or closed the dialog window.

Parameters:
title = Title of the dialog window.
msg = Main message displayed inside the dialog window.
button1_txt = Label of the 1st button.
button2_txt = Label of the 2nd button.
button3_txt = Label of the 3rd button.
button4_txt = Label of the 4th button.
button5_txt = Label of the 5th button.
button6_txt = Label of the 6th button.
logo = Logo image displayed at the left of the main message. This parameter is optional.
centering = Tell to center the dialog window on the screen.
Returns:
The button number (from 0 to 5), or -1 if the dialog window has been closed by the user.
Note:
If a button text is set to 0, then the corresponding button (and the followings) won't appear in the dialog box. At least one button is necessary.