The CImg Library - C++ Template Image Processing Toolkit





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

CImg< T > Struct Template Reference

Class representing an image (up to 4 dimensions wide), each pixel being of type T. More...

List of all members.

Public Types

typedef T * iterator
 Simple iterator type, to loop through each pixel value of an image instance.
typedef const T * const_iterator
 Simple const iterator type, to loop through each pixel value of a const image instance.
typedef T value_type
 Pixel value type.

Constructors / Destructor / Instance Management

 ~CImg ()
 Destructor.
 CImg ()
 Default constructor.
 CImg (const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1)
 Construct image with specified size.
 CImg (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const T value)
 Construct image with specified size and initialize pixel values.
 CImg (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const int value0, const int value1,...)
 Construct image with specified size and initialize pixel values from a sequence of integers.
 CImg (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const double value0, const double value1,...)
 Construct image with specified size and initialize pixel values from a sequence of doubles.
 CImg (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const char *const values, const bool repeat_values)
 Construct image with specified size and initialize pixel values from a value string.
template<typename t >
 CImg (const t *const values, const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1, const bool is_shared=false)
 Construct image with specified size and initialize pixel values from a memory buffer.
 CImg (const T *const values, const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1, const bool is_shared=false)
 Construct image with specified size and initialize pixel values from a memory buffer [specialization].
 CImg (const char *const filename)
 Construct image from an image file.
template<typename t >
 CImg (const CImg< t > &img)
 Copy constructor.
 CImg (const CImg< T > &img)
 Copy constructor [specialization].
template<typename t >
 CImg (const CImg< t > &img, const bool is_shared)
 Advanced copy constructor.
 CImg (const CImg< T > &img, const bool is_shared)
 Advanced copy constructor [specialization].
template<typename t >
 CImg (const CImg< t > &img, const char *const dimensions)
 Construct image with dimensions borrowed from another image.
template<typename t >
 CImg (const CImg< t > &img, const char *const dimensions, const T value)
 Construct image with dimensions borrowed from another image and initialize pixel values.
 CImg (const CImgDisplay &disp)
 Construct image from a display window.
CImg< T > & assign ()
 In-place version of the default constructor/destructor.
CImg< T > & assign (const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1)
 In-place version of a constructor.
CImg< T > & assign (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const T value)
 In-place version of a constructor.
CImg< T > & assign (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const int value0, const int value1,...)
 In-place version of a constructor.
CImg< T > & assign (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const double value0, const double value1,...)
 In-place version of a constructor.
CImg< T > & assign (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const char *const values, const bool repeat_values)
 In-place version of a constructor.
template<typename t >
CImg< T > & assign (const t *const values, const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1)
 In-place version of a constructor.
CImg< T > & assign (const T *const values, const unsigned int size_x, const unsigned int size_y=1, const unsigned int size_z=1, const unsigned int size_c=1)
 In-place version of a constructor [specialization].
template<typename t >
CImg< T > & assign (const t *const values, const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const bool is_shared)
 In-place version of a constructor.
CImg< T > & assign (const T *const values, const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c, const bool is_shared)
 In-place version of a constructor [specialization].
CImg< T > & assign (const char *const filename)
 In-place version of a constructor.
template<typename t >
CImg< T > & assign (const CImg< t > &img)
 In-place version of the default copy constructor.
template<typename t >
CImg< T > & assign (const CImg< t > &img, const bool is_shared)
 In-place version of the advanced copy constructor.
template<typename t >
CImg< T > & assign (const CImg< t > &img, const char *const dimensions)
 In-place version of a constructor.
template<typename t >
CImg< T > & assign (const CImg< t > &img, const char *const dimensions, const T value)
 In-place version of a constructor.
CImg< T > & assign (const CImgDisplay &disp)
 In-place version of a constructor.
CImg< T > & clear ()
 In-place version of the default constructor.
template<typename t >
CImg< t > & move_to (CImg< t > &img)
 Transfer content of an image instance into another one.
CImg< T > & move_to (CImg< T > &img)
 Transfer content of an image instance into another one [specialization].
template<typename t >
CImgList< t > & move_to (CImgList< t > &list, const unsigned int pos=~0U)
 Transfer content of an image instance into a new image in an image list.
CImg< T > & swap (CImg< T > &img)
 Swap fields of two image instances.
static CImg< T > & empty ()
 Get a reference to an empty image.

Overloaded Operators

T & operator() (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0)
 Access to a pixel value.
const T & operator() (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0) const
 Access to a pixel value [const version].
T & operator() (const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int c, const unsigned long wh, const unsigned long whd=0)
 Access to a pixel value.
const T & operator() (const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int c, const unsigned long wh, const unsigned long whd=0) const
 Access to a pixel value [const version].
 operator T * ()
 Implicitely cast an image into a T*.
 operator const T * () const
 Implicitely cast an image into a T* [const version].
CImg< T > & operator= (const T value)
 Assign a value to all image pixels.
CImg< T > & operator= (const char *const expression)
 Assign pixels values from a specified expression.
template<typename t >
CImg< T > & operator= (const CImg< t > &img)
 Copy an image into the current image instance.
CImg< T > & operator= (const CImg< T > &img)
 Copy an image into the current image instance [specialization].
CImg< T > & operator= (const CImgDisplay &disp)
 Copy the content of a display window to the current image instance.
template<typename t >
CImg< T > & operator+= (const t value)
 In-place addition operator.
CImg< T > & operator+= (const char *const expression)
 In-place addition operator.
template<typename t >
CImg< T > & operator+= (const CImg< t > &img)
 In-place addition operator.
CImg< T > & operator++ ()
 In-place increment operator (prefix).
CImg< T > operator++ (int)
 In-place increment operator (postfix).
CImg< T > operator+ () const
 Get a non-shared copy of the image instance.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator+ (const t value) const
 Addition operator.
CImg< Tfloat > operator+ (const char *const expression) const
 Addition operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator+ (const CImg< t > &img) const
 Addition operator.
template<typename t >
CImg< T > & operator-= (const t value)
 In-place substraction operator.
CImg< T > & operator-= (const char *const expression)
 In-place substraction operator.
template<typename t >
CImg< T > & operator-= (const CImg< t > &img)
 In-place substraction operator.
CImg< T > & operator-- ()
 In-place decrement operator (prefix).
CImg< T > operator-- (int)
 In-place decrement operator (postfix).
CImg< T > operator- () const
 Replace each pixel by its opposite value.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator- (const t value) const
 Substraction operator.
CImg< Tfloat > operator- (const char *const expression) const
 Substraction operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator- (const CImg< t > &img) const
 Substraction operator.
template<typename t >
CImg< T > & operator*= (const t value)
 In-place multiplication operator.
CImg< T > & operator*= (const char *const expression)
 In-place multiplication operator.
template<typename t >
CImg< T > & operator*= (const CImg< t > &img)
 In-place multiplication operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator* (const t value) const
 Multiplication operator.
CImg< Tfloat > operator* (const char *const expression) const
 Multiplication operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator* (const CImg< t > &img) const
 Multiplication operator.
template<typename t >
CImg< T > & operator/= (const t value)
 In-place division operator.
CImg< T > & operator/= (const char *const expression)
 In-place division operator.
template<typename t >
CImg< T > & operator/= (const CImg< t > &img)
 In-place division operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator/ (const t value) const
 Division operator.
CImg< Tfloat > operator/ (const char *const expression) const
 Division operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator/ (const CImg< t > &img) const
 Division operator.
template<typename t >
CImg< T > & operator%= (const t value)
 In-place modulo operator.
CImg< T > & operator%= (const char *const expression)
 In-place modulo operator.
template<typename t >
CImg< T > & operator%= (const CImg< t > &img)
 In-place modulo operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator% (const t value) const
 Modulo operator.
CImg< Tfloat > operator% (const char *const expression) const
 Modulo operator.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
operator% (const CImg< t > &img) const
 Modulo operator.
template<typename t >
CImg< T > & operator&= (const t value)
 In-place bitwise AND operator.
CImg< T > & operator&= (const char *const expression)
 In-place bitwise AND operator.
template<typename t >
CImg< T > & operator&= (const CImg< t > &img)
 In-place bitwise AND operator.
template<typename t >
CImg< T > operator& (const t value) const
 Bitwise AND operator.
CImg< T > operator& (const char *const expression) const
 Bitwise AND operator.
template<typename t >
CImg< T > operator& (const CImg< t > &img) const
 Bitwise AND operator.
template<typename t >
CImg< T > & operator|= (const t value)
 In-place bitwise OR operator.
CImg< T > & operator|= (const char *const expression)
 In-place bitwise OR operator.
template<typename t >
CImg< T > & operator|= (const CImg< t > &img)
 In-place bitwise OR operator.
template<typename t >
CImg< T > operator| (const t value) const
 Bitwise OR operator.
CImg< T > operator| (const char *const expression) const
 Bitwise OR operator.
template<typename t >
CImg< T > operator| (const CImg< t > &img) const
 Bitwise OR operator.
template<typename t >
CImg< T > & operator^= (const t value)
 In-place bitwise XOR operator.
CImg< T > & operator^= (const char *const expression)
 In-place bitwise XOR operator.
template<typename t >
CImg< T > & operator^= (const CImg< t > &img)
 In-place bitwise XOR operator.
template<typename t >
CImg< T > operator^ (const t value) const
 Bitwise XOR operator.
CImg< T > operator^ (const char *const expression) const
 Bitwise XOR operator.
template<typename t >
CImg< T > operator^ (const CImg< t > &img) const
 Bitwise XOR operator.
template<typename t >
CImg< T > & operator<<= (const t value)
 In-place bitwise left shift operator.
CImg< T > & operator<<= (const char *const expression)
 In-place bitwise left shift operator.
template<typename t >
CImg< T > & operator<<= (const CImg< t > &img)
 In-place bitwise left shift operator.
template<typename t >
CImg< T > operator<< (const t value) const
 Bitwise left shift operator.
CImg< T > operator<< (const char *const expression) const
 Bitwise left shift operator.
template<typename t >
CImg< T > operator<< (const CImg< t > &img) const
 Bitwise left shift operator.
template<typename t >
CImg< T > & operator>>= (const t value)
 In-place bitwise right shift operator.
CImg< T > & operator>>= (const char *const expression)
 In-place bitwise right shift operator.
template<typename t >
CImg< T > & operator>>= (const CImg< t > &img)
 In-place bitwise right shift operator.
template<typename t >
CImg< T > operator>> (const t value) const
 Bitwise right shift operator.
CImg< T > operator>> (const char *const expression) const
 Bitwise right shift operator.
template<typename t >
CImg< T > operator>> (const CImg< t > &img) const
 Bitwise right shift operator.
CImg< T > operator~ () const
 Bitwise inversion operator.
template<typename t >
bool operator== (const CImg< t > &img) const
 Test if two images have the same size and values.
template<typename t >
bool operator!= (const CImg< t > &img) const
 Test if two images have different sizes or values.
template<typename t >
CImgList< typename
cimg::superset< T, t >::type > 
operator, (const CImg< t > &img) const
 Construct an image list from two images.
template<typename t >
CImgList< typename
cimg::superset< T, t >::type > 
operator, (const CImgList< t > &list) const
 Construct an image list from image instance and an input image list.
CImgList< T > operator< (const char axis) const
 Split image along specified axis.

Instance Characteristics

int width () const
 Get the number of image columns.
int height () const
 Get the number of image rows.
int depth () const
 Get the number of image slices.
int spectrum () const
 Get the number of image channels.
unsigned int size () const
 Get the total number of pixel values.
T * data ()
 Get a pointer to the first pixel value.
const T * data () const
 Get a pointer to the first pixel value [const version].
T * data (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0)
 Get a pointer to a located pixel value.
const T * data (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int c=0) const
 Get a pointer to a located pixel value [const version].
int offset (const int x, const int y=0, const int z=0, const int c=0) const
 Get the offset to a located pixel value, with respect to the beginning of the pixel buffer.
iterator begin ()
 Get a CImg<T>::iterator pointing to the first pixel value.
const_iterator begin () const
 Get a CImg<T>::iterator pointing to the first value of the pixel buffer [const version].
iterator end ()
 Get a CImg<T>::iterator pointing next to the last pixel value.
const_iterator end () const
 Get a CImg<T>::iterator pointing next to the last pixel value [const version].
T & front ()
 Get a reference to the first pixel value.
const T & front () const
 Get a reference to the first pixel value [const version].
T & back ()
 Get a reference to the last pixel value.
const T & back () const
 Get a reference to the last pixel value [const version].
T & at (const int offset, const T out_value)
 Access to a pixel value at a specified offset, using Dirichlet boundary conditions.
at (const int offset, const T out_value) const
 Access to a pixel value at a specified offset, using Dirichlet boundary conditions [const version].
T & at (const int offset)
 Access to a pixel value at a specified offset, using Neumann boundary conditions.
at (const int offset) const
 Access to a pixel value at a specified offset, using Neumann boundary conditions [const version].
T & atX (const int x, const int y, const int z, const int c, const T out_value)
 Access to a pixel value, using Dirichlet boundary conditions for the X-coordinate.
atX (const int x, const int y, const int z, const int c, const T out_value) const
 Access to a pixel value, using Dirichlet boundary conditions for the X-coordinate [const version].
T & atX (const int x, const int y=0, const int z=0, const int c=0)
 Access to a pixel value, using Neumann boundary conditions for the X-coordinate.
atX (const int x, const int y=0, const int z=0, const int c=0) const
 Access to a pixel value, using Neumann boundary conditions for the X-coordinate [const version].
T & atXY (const int x, const int y, const int z, const int c, const T out_value)
 Access to a pixel value, using Dirichlet boundary conditions for the X and Y-coordinates.
atXY (const int x, const int y, const int z, const int c, const T out_value) const
 Access to a pixel value, using Dirichlet boundary conditions for the X and Y coordinates [const version].
T & atXY (const int x, const int y, const int z=0, const int c=0)
 Access to a pixel value, using Neumann boundary conditions for the X and Y-coordinates.
atXY (const int x, const int y, const int z=0, const int c=0) const
 Access to a pixel value, using Neumann boundary conditions for the X and Y-coordinates [const version].
T & atXYZ (const int x, const int y, const int z, const int c, const T out_value)
 Access to a pixel value, using Dirichlet boundary conditions for the X,Y and Z-coordinates.
atXYZ (const int x, const int y, const int z, const int c, const T out_value) const
 Access to a pixel value, using Dirichlet boundary conditions for the X,Y and Z-coordinates [const version].
T & atXYZ (const int x, const int y, const int z, const int c=0)
 Access to a pixel value, using Neumann boundary conditions for the X,Y and Z-coordinates.
atXYZ (const int x, const int y, const int z, const int c=0) const
 Access to a pixel value, using Neumann boundary conditions for the X,Y and Z-coordinates [const version].
T & atXYZC (const int x, const int y, const int z, const int c, const T out_value)
 Access to a pixel value, using Dirichlet boundary conditions.
atXYZC (const int x, const int y, const int z, const int c, const T out_value) const
 Access to a pixel value, using Dirichlet boundary conditions [const version].
T & atXYZC (const int x, const int y, const int z, const int c)
 Access to a pixel value, using Neumann boundary conditions.
atXYZC (const int x, const int y, const int z, const int c) const
 Access to a pixel value, using Neumann boundary conditions [const version].
Tfloat linear_atX (const float fx, const int y, const int z, const int c, const T out_value) const
 Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X-coordinate.
Tfloat linear_atX (const float fx, const int y=0, const int z=0, const int c=0) const
 Get pixel value, using linear interpolation and Neumann boundary conditions for the X-coordinate.
Tfloat linear_atXY (const float fx, const float fy, const int z, const int c, const T out_value) const
 Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X and Y-coordinates.
Tfloat linear_atXY (const float fx, const float fy, const int z=0, const int c=0) const
 Get pixel value, using linear interpolation and Neumann boundary conditions for the X and Y-coordinates.
Tfloat linear_atXYZ (const float fx, const float fy, const float fz, const int c, const T out_value) const
 Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.
Tfloat linear_atXYZ (const float fx, const float fy=0, const float fz=0, const int c=0) const
 Get pixel value, using linear interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.
Tfloat linear_atXYZC (const float fx, const float fy, const float fz, const float fc, const T out_value) const
 Get pixel value, using linear interpolation and Dirichlet boundary conditions for all X,Y,Z and C-coordinates.
Tfloat linear_atXYZC (const float fx, const float fy=0, const float fz=0, const float fc=0) const
 Get pixel value, using linear interpolation and Neumann boundary conditions for all X,Y,Z and C-coordinates.
Tfloat cubic_atX (const float fx, const int y, const int z, const int c, const T out_value) const
 Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X-coordinate.
Tfloat cubic_atX (const float fx, const int y, const int z, const int c, const T out_value, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X-coordinate.
Tfloat cubic_atX (const float fx, const int y=0, const int z=0, const int c=0) const
 Get pixel value, using cubic interpolation and Neumann boundary conditions for the X-coordinate.
Tfloat cubic_atX (const float fx, const int y, const int z, const int c, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X-coordinate.
Tfloat cubic_atXY (const float fx, const float fy, const int z, const int c, const T out_value) const
 Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X and Y-coordinates.
Tfloat cubic_atXY (const float fx, const float fy, const int z, const int c, const T out_value, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X and Y-coordinates.
Tfloat cubic_atXY (const float fx, const float fy, const int z=0, const int c=0) const
 Get pixel value, using cubic interpolation and Neumann boundary conditions for the X and Y-coordinates.
Tfloat cubic_atXY (const float fx, const float fy, const int z, const int c, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X and Y-coordinates.
Tfloat cubic_atXYZ (const float fx, const float fy, const float fz, const int c, const T out_value) const
 Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.
Tfloat cubic_atXYZ (const float fx, const float fy, const float fz, const int c, const T out_value, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.
Tfloat cubic_atXYZ (const float fx, const float fy, const float fz, const int c=0) const
 Get pixel value, using cubic interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.
Tfloat cubic_atXYZ (const float fx, const float fy, const float fz, const int c, const Tfloat min_value, const Tfloat max_value) const
 Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.
CImg< T > & set_linear_atXY (const T &value, const float fx, const float fy=0, const int z=0, const int c=0, const bool is_added=false)
 Set pixel value, using linear interpolation for the X and Y-coordinates.
CImg< T > & set_linear_atXYZ (const T &value, const float fx, const float fy=0, const float fz=0, const int c=0, const bool is_added=false)
 Set pixel value, using linear interpolation for the X,Y and Z-coordinates.
CImg< charT > value_string (const char separator=',', const unsigned int max_size=0) const
 Get a C-string containing a list of all values of the image instance.
static const char * pixel_type ()
 Get the type of image pixel values as a C string.

Instance Checking

bool is_shared () const
 Test shared state of the pixel buffer.
bool is_empty () const
 Test if image instance is empty.
bool is_sameX (const unsigned int size_x) const
 Test if image width is equal to a specified value.
template<typename t >
bool is_sameX (const CImg< t > &img) const
 Test if image width is the same as that of another image.
bool is_sameX (const CImgDisplay &disp) const
 Test if image width is the same as that of an existing display window.
bool is_sameY (const unsigned int size_y) const
 Test if image height is equal to a specified value.
template<typename t >
bool is_sameY (const CImg< t > &img) const
 Test if image height is the same as that of another image.
bool is_sameY (const CImgDisplay &disp) const
 Test if image height is the same as that of an existing display window.
bool is_sameZ (const unsigned int size_z) const
 Test if image depth is equal to a specified value.
template<typename t >
bool is_sameZ (const CImg< t > &img) const
 Test if image depth is the same as that of another image.
bool is_sameC (const unsigned int size_c) const
 Test if image spectrum is equal to a specified value.
template<typename t >
bool is_sameC (const CImg< t > &img) const
 Test if image spectrum is the same as that of another image.
bool is_sameXY (const unsigned int size_x, const unsigned int size_y) const
 Test if image width and height are equal to specified values.
template<typename t >
bool is_sameXY (const CImg< t > &img) const
 Test if image width and height are the same as that of another image.
bool is_sameXY (const CImgDisplay &disp) const
 Test if image width and height are the same as that of an existing display window.
bool is_sameXZ (const unsigned int size_x, const unsigned int size_z) const
 Test if image width and depth are equal to specified values.
template<typename t >
bool is_sameXZ (const CImg< t > &img) const
 Test if image width and depth are the same as that of another image.
bool is_sameXC (const unsigned int size_x, const unsigned int size_c) const
 Test if image width and spectrum are equal to specified values.
template<typename t >
bool is_sameXC (const CImg< t > &img) const
 Test if image width and spectrum are the same as that of another image.
bool is_sameYZ (const unsigned int size_y, const unsigned int size_z) const
 Test if image height and depth are equal to specified values.
template<typename t >
bool is_sameYZ (const CImg< t > &img) const
 Test if image height and depth are the same as that of another image.
bool is_sameYC (const unsigned int size_y, const unsigned int size_c) const
 Test if image height and spectrum are equal to specified values.
template<typename t >
bool is_sameYC (const CImg< t > &img) const
 Test if image height and spectrum are the same as that of another image.
bool is_sameZC (const unsigned int size_z, const unsigned int size_c) const
 Test if image depth and spectrum are equal to specified values.
template<typename t >
bool is_sameZC (const CImg< t > &img) const
 Test if image depth and spectrum are the same as that of another image.
bool is_sameXYZ (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z) const
 Test if image width, height and depth are equal to specified values.
template<typename t >
bool is_sameXYZ (const CImg< t > &img) const
 Test if image width, height and depth are the same as that of another image.
bool is_sameXYC (const unsigned int size_x, const unsigned int size_y, const unsigned int size_c) const
 Test if image width, height and spectrum are equal to specified values.
template<typename t >
bool is_sameXYC (const CImg< t > &img) const
 Test if image width, height and spectrum are the same as that of another image.
bool is_sameXZC (const unsigned int size_x, const unsigned int size_z, const unsigned int size_c) const
 Test if image width, depth and spectrum are equal to specified values.
template<typename t >
bool is_sameXZC (const CImg< t > &img) const
 Test if image width, depth and spectrum are the same as that of another image.
bool is_sameYZC (const unsigned int size_y, const unsigned int size_z, const unsigned int size_c) const
 Test if image height, depth and spectrum are equal to specified values.
template<typename t >
bool is_sameYZC (const CImg< t > &img) const
 Test if image height, depth and spectrum are the same as that of another image.
bool is_sameXYZC (const unsigned int size_x, const unsigned int size_y, const unsigned int size_z, const unsigned int size_c) const
 Test if image width, height, depth and spectrum are equal to specified values.
template<typename t >
bool is_sameXYZC (const CImg< t > &img) const
 Test if image width, height, depth and spectrum are the same as that of another image.
bool containsXYZC (const int x, const int y=0, const int z=0, const int c=0) const
 Test if specified coordinates are inside image bounds.
template<typename t >
bool contains (const T &pixel, t &x, t &y, t &z, t &c) const
 Test if pixel value is inside image bounds and get its X,Y,Z and C-coordinates.
template<typename t >
bool contains (const T &pixel, t &x, t &y, t &z) const
 Test if pixel value is inside image bounds and get its X,Y and Z-coordinates.
template<typename t >
bool contains (const T &pixel, t &x, t &y) const
 Test if pixel value is inside image bounds and get its X and Y-coordinates.
template<typename t >
bool contains (const T &pixel, t &x) const
 Test if pixel value is inside image bounds and get its X-coordinate.
bool contains (const T &pixel) const
 Test if pixel value is inside image bounds.
template<typename t >
bool is_overlapped (const CImg< t > &img) const
 Test if pixel buffers of instance and input images overlap.
template<typename tp , typename tc , typename to >
bool is_object3d (const CImgList< tp > &primitives, const CImgList< tc > &colors, const to &opacities, const bool is_full_check=true, char *const error_message=0) const
 Test if the set {*this,primitives,colors,opacities} defines a valid 3d object.
bool is_CImg3d (const bool is_full_check=true, char *const error_message=0) const
 Test if image instance represents a valid serialization of a 3d object.

Mathematical Functions

CImg< T > & sqr ()
 Compute the square value of each pixel value.
CImg< Tfloat > get_sqr () const
 Compute the square value of each pixel value [new-instance version].
CImg< T > & sqrt ()
 Compute the square root of each pixel value.
CImg< Tfloat > get_sqrt () const
 Compute the square root of each pixel value [new-instance version].
CImg< T > & exp ()
 Compute the exponential of each pixel value.
CImg< Tfloat > get_exp () const
 Compute the exponential of each pixel value [new-instance version].
CImg< T > & log ()
 Compute the logarithm of each pixel value.
CImg< Tfloat > get_log () const
 Compute the logarithm of each pixel value [new-instance version].
CImg< T > & log10 ()
 Compute the base-10 logarithm of each pixel value.
CImg< Tfloat > get_log10 () const
 Compute the base-10 logarithm of each pixel value [new-instance version].
CImg< T > & abs ()
 Compute the absolute value of each pixel value.
CImg< Tfloat > get_abs () const
 Compute the absolute value of each pixel value [new-instance version].
CImg< T > & sign ()
 Compute the sign of each pixel value.
CImg< Tfloat > get_sign () const
 Compute the sign of each pixel value [new-instance version].
CImg< T > & cos ()
 Compute the cosine of each pixel value.
CImg< Tfloat > get_cos () const
 Compute the cosine of each pixel value [new-instance version].
CImg< T > & sin ()
 Compute the sine of each pixel value.
CImg< Tfloat > get_sin () const
 Compute the sine of each pixel value [new-instance version].
CImg< T > & sinc ()
 Compute the sinc of each pixel value.
CImg< Tfloat > get_sinc () const
 Compute the sinc of each pixel value [new-instance version].
CImg< T > & tan ()
 Compute the tangent of each pixel value.
CImg< Tfloat > get_tan () const
 Compute the tangent of each pixel value [new-instance version].
CImg< T > & cosh ()
 Compute the hyperbolic cosine of each pixel value.
CImg< Tfloat > get_cosh () const
 Compute the hyperbolic cosine of each pixel value [new-instance version].
CImg< T > & sinh ()
 Compute the hyperbolic sine of each pixel value.
CImg< Tfloat > get_sinh () const
 Compute the hyperbolic sine of each pixel value [new-instance version].
CImg< T > & tanh ()
 Compute the hyperbolic tangent of each pixel value.
CImg< Tfloat > get_tanh () const
 Compute the hyperbolic tangent of each pixel value [new-instance version].
CImg< T > & acos ()
 Compute the arccosine of each pixel value.
CImg< Tfloat > get_acos () const
 Compute the arccosine of each pixel value [new-instance version].
CImg< T > & asin ()
 Compute the arcsine of each pixel value.
CImg< Tfloat > get_asin () const
 Compute the arcsine of each pixel value [new-instance version].
CImg< T > & atan ()
 Compute the arctangent of each pixel value.
CImg< Tfloat > get_atan () const
 Compute the arctangent of each pixel value [new-instance version].
template<typename t >
CImg< T > & atan2 (const CImg< t > &img)
 Compute the arctangent2 of each pixel value.
template<typename t >
CImg< Tfloat > get_atan2 (const CImg< t > &img) const
 Compute the arctangent2 of each pixel value [new-instance version].
template<typename t >
CImg< T > & mul (const CImg< t > &img)
 In-place pointwise multiplication.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_mul (const CImg< t > &img) const
 In-place pointwise multiplication [new-instance version].
template<typename t >
CImg< T > & div (const CImg< t > &img)
 In-place pointwise division.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_div (const CImg< t > &img) const
 In-place pointwise division [new-instance version].
CImg< T > & pow (const double p)
 Raise each pixel value to a specified power.
CImg< Tfloat > get_pow (const double p) const
 Raise each pixel value to a specified power [new-instance version].
CImg< T > & pow (const char *const expression)
 Raise each pixel value to a power, specified from an expression.
CImg< Tfloat > get_pow (const char *const expression) const
 Raise each pixel value to a power, specified from an expression [new-instance version].
template<typename t >
CImg< T > & pow (const CImg< t > &img)
 Raise each pixel value to a power, pointwisely specified from another image.
template<typename t >
CImg< Tfloat > get_pow (const CImg< t > &img) const
 Raise each pixel value to a power, pointwisely specified from another image [new-instance version].
CImg< T > & rol (const unsigned int n=1)
 Compute the bitwise left rotation of each pixel value.
CImg< T > get_rol (const unsigned int n=1) const
 Compute the bitwise left rotation of each pixel value [new-instance version].
CImg< T > & rol (const char *const expression)
 Compute the bitwise left rotation of each pixel value.
CImg< T > get_rol (const char *const expression) const
 Compute the bitwise left rotation of each pixel value [new-instance version].
template<typename t >
CImg< T > & rol (const CImg< t > &img)
 Compute the bitwise left rotation of each pixel value.
template<typename t >
CImg< T > get_rol (const CImg< t > &img) const
 Compute the bitwise left rotation of each pixel value [new-instance version].
CImg< T > & ror (const unsigned int n=1)
 Compute the bitwise right rotation of each pixel value.
CImg< T > get_ror (const unsigned int n=1) const
 Compute the bitwise right rotation of each pixel value [new-instance version].
CImg< T > & ror (const char *const expression)
 Compute the bitwise right rotation of each pixel value.
CImg< T > get_ror (const char *const expression) const
 Compute the bitwise right rotation of each pixel value [new-instance version].
template<typename t >
CImg< T > & ror (const CImg< t > &img)
 Compute the bitwise right rotation of each pixel value.
template<typename t >
CImg< T > get_ror (const CImg< t > &img) const
 Compute the bitwise right rotation of each pixel value [new-instance version].
CImg< T > & min (const T val)
 Pointwise min operator between an image and a value.
CImg< T > get_min (const T val) const
template<typename t >
CImg< T > & min (const CImg< t > &img)
 Pointwise min operator between two images.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_min (const CImg< t > &img) const
CImg< T > & min (const char *const expression)
 Pointwise min operator between an image and a string.
CImg< Tfloat > get_min (const char *const expression) const
CImg< T > & max (const T val)
 Pointwise max operator between an image and a value.
CImg< T > get_max (const T val) const
template<typename t >
CImg< T > & max (const CImg< t > &img)
 Pointwise max operator between two images.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_max (const CImg< t > &img) const
CImg< T > & max (const char *const expression)
 Pointwise max operator between an image and a string.
CImg< Tfloat > get_max (const char *const expression) const
T & min ()
 Return a reference to the minimum pixel value of the image instance.
const T & min () const
T & max ()
 Return a reference to the maximum pixel value of the image instance.
const T & max () const
template<typename t >
T & min_max (t &max_val)
 Return a reference to the minimum pixel value and return also the maximum pixel value.
template<typename t >
const T & min_max (t &max_val) const
template<typename t >
T & max_min (t &min_val)
 Return a reference to the maximum pixel value and return also the minimum pixel value.
template<typename t >
const T & max_min (t &min_val) const
kth_smallest (const unsigned int k) const
 Return the kth smallest element of the image.
median () const
 Return the median value of the image.
Tdouble sum () const
 Return the sum of all the pixel values in an image.
Tdouble mean () const
 Return the mean pixel value of the image instance.
Tdouble variance (const unsigned int variance_method=1) const
 Return the variance of the image.
template<typename t >
Tdouble variance_mean (const unsigned int variance_method, t &mean) const
 Return the variance and the mean of the image.
Tdouble variance_noise (const unsigned int variance_method=2) const
 Estimate noise variance of the image instance.
template<typename t >
Tdouble MSE (const CImg< t > &img) const
 Compute the MSE (Mean-Squared Error) between two images.
template<typename t >
Tdouble PSNR (const CImg< t > &img, const Tdouble valmax=255) const
 Compute the PSNR between two images.
double eval (const char *const expression, const double x=0, const double y=0, const double z=0, const double c=0) const
 Evaluate math expression.
CImg< T > & stats (const unsigned int variance_method=1)
 Compute a statistics vector (min,max,mean,variance,xmin,ymin,zmin,cmin,xmax,ymax,zmax,cmax).
CImg< Tdouble > get_stats (const unsigned int variance_method=1) const

Vector / Matrix Operations

Tdouble magnitude (const int magnitude_type=2) const
 Return the norm of the current vector/matrix. ntype = norm type (0=L2, 1=L1, -1=Linf).
Tdouble trace () const
 Return the trace of the image, viewed as a matrix.
Tdouble det () const
 Return the determinant of the image, viewed as a matrix.
template<typename t >
Tdouble dot (const CImg< t > &img) const
 Return the dot product of the current vector/matrix with the vector/matrix img.
CImg< T > get_vector_at (const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
 Return a new image corresponding to the vector located at (x,y,z) of the current vector-valued image.
CImg< T > get_matrix_at (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const
 Return a new image corresponding to the square matrix located at (x,y,z) of the current vector-valued image.
CImg< T > get_tensor_at (const unsigned int x, const unsigned int y=0, const unsigned int z=0) const
 Return a new image corresponding to the diffusion tensor located at (x,y,z) of the current vector-valued image.
template<typename t >
CImg< T > & set_vector_at (const CImg< t > &vec, const unsigned int x, const unsigned int y=0, const unsigned int z=0)
 Set the image vec as the vector valued pixel located at (x,y,z) of the current vector-valued image.
template<typename t >
CImg< T > & set_matrix_at (const CImg< t > &mat, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0)
 Set the image vec as the square matrix-valued pixel located at (x,y,z) of the current vector-valued image.
template<typename t >
CImg< T > & set_tensor_at (const CImg< t > &ten, const unsigned int x=0, const unsigned int y=0, const unsigned int z=0)
 Set the image vec as the tensor valued pixel located at (x,y,z) of the current vector-valued image.
CImg< T > & vector ()
 Unroll all images values into a one-column vector.
CImg< T > get_vector () const
CImg< T > & matrix ()
 Realign pixel values of the image instance as a square matrix.
CImg< T > get_matrix () const
CImg< T > & tensor ()
 Realign pixel values of the image instance as a symmetric tensor.
CImg< T > get_tensor () const
CImg< T > & diagonal ()
 Get a diagonal matrix, whose diagonal coefficients are the coefficients of the input image.
CImg< T > get_diagonal () const
CImg< T > & identity_matrix ()
 Get an identity matrix having same dimension than image instance.
CImg< T > get_identity_matrix () const
CImg< T > & sequence (const T a0, const T a1)
 Return a N-numbered sequence vector from a0 to a1.
CImg< T > get_sequence (const T a0, const T a1) const
CImg< T > & transpose ()
 Transpose the current matrix.
CImg< T > get_transpose () const
template<typename t >
CImg< T > & cross (const CImg< t > &img)
 Compute the cross product between two 3d vectors.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_cross (const CImg< t > &img) const
CImg< T > & invert (const bool use_LU=true)
 Invert the current matrix.
CImg< Tfloat > get_invert (const bool use_LU=true) const
CImg< T > & pseudoinvert ()
 Compute the pseudo-inverse (Moore-Penrose) of the matrix.
CImg< Tfloat > get_pseudoinvert () const
template<typename t >
CImg< T > & solve (const CImg< t > &A)
 Solve a linear system AX=B where B=*this.
template<typename t >
CImg< typename cimg::superset2
< T, t, float >::type > 
get_solve (const CImg< t > &A) const
template<typename t >
CImg< T > & solve_tridiagonal (const CImg< t > &A)
 Solve a linear system AX=B where B=*this and A is a tridiagonal matrix A = [ b0,c0,0,...; a1,b1,c1,0,... ; ... ; ...,0,aN,bN ],.
template<typename t >
CImg< typename cimg::superset2
< T, t, float >::type > 
get_solve_tridiagonal (const CImg< t > &A) const
template<typename t >
const CImg< T > & eigen (CImg< t > &val, CImg< t > &vec) const
 Compute the eigenvalues and eigenvectors of a matrix.
CImgList< Tfloat > get_eigen () const
template<typename t >
const CImg< T > & symmetric_eigen (CImg< t > &val, CImg< t > &vec) const
 Compute the eigenvalues and eigenvectors of a symmetric matrix.
CImgList< Tfloat > get_symmetric_eigen () const
template<typename t >
CImg< T > & sort (CImg< t > &permutations, const bool increasing=true)
 Sort values of a vector and get corresponding permutations.
template<typename t >
CImg< T > get_sort (CImg< t > &permutations, const bool increasing=true) const
CImg< T > & sort (const bool increasing=true, const char axis=0)
 Sort image values.
CImg< T > get_sort (const bool increasing=true, const char axis=0) const
template<typename t >
const CImg< T > & SVD (CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iteration=40, const float lambda=0) const
 Compute the SVD of a general matrix.
CImgList< Tfloat > get_SVD (const bool sorting=true, const unsigned int max_iteration=40, const float lambda=0) const
template<typename t >
CImg< T > & dijkstra (const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous)
 Return minimal path in a graph, using the Dijkstra algorithm.
template<typename t >
CImg< T > get_dijkstra (const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous) const
CImg< T > & dijkstra (const unsigned int starting_node, const unsigned int ending_node=~0U)
 Return minimal path in a graph, using the Dijkstra algorithm.
CImg< Tfloat > get_dijkstra (const unsigned int starting_node, const unsigned int ending_node=~0U) const
CImg< floatT > get_streamline (const float x, const float y, const float z, const float L=256, const float dl=0.1f, const unsigned int interpolation_type=2, const bool is_backward_tracking=false, const bool is_oriented_only=false) const
 Return stream line of a 2d or 3d vector field.
template<typename tf , typename t >
static CImg< T > dijkstra (const tf &distance, const unsigned int nb_nodes, const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous)
 Compute minimal path in a graph, using the Dijkstra algorithm.
template<typename tf , typename t >
static CImg< T > dijkstra (const tf &distance, const unsigned int nb_nodes, const unsigned int starting_node, const unsigned int ending_node=~0U)
 Return minimal path in a graph, using the Dijkstra algorithm.
template<typename tfunc >
static CImg< floatT > streamline (const tfunc &func, const float x, const float y, const float z, const float L=256, const float dl=0.1f, const unsigned int interpolation_type=2, const bool is_backward_tracking=false, const bool is_oriented_only=false, const float x0=0, const float y0=0, const float z0=0, const float x1=0, const float y1=0, const float z1=0)
 Return stream line of a 3d vector field.
static CImg< floatT > streamline (const char *const expression, const float x, const float y, const float z, const float L=256, const float dl=0.1f, const unsigned int interpolation_type=2, const bool is_backward_tracking=true, const bool is_oriented_only=false, const float x0=0, const float y0=0, const float z0=0, const float x1=0, const float y1=0, const float z1=0)
 Return stream line of a vector field.
static CImg< T > string (const char *const str, const bool include_last_zero=true)
 Return an image containing the specified string.
static CImg< T > vector (const T &a0)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14)
 Return a vector with specified coefficients.
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15)
 Return a vector with specified coefficients.
static CImg< T > matrix (const T &a0)
 Return a 1x1 square matrix with specified coefficients.
static CImg< T > matrix (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a 2x2 square matrix with specified coefficients.
static CImg< T > matrix (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8)
 Return a 3x3 square matrix with specified coefficients.
static CImg< T > matrix (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15)
 Return a 4x4 square matrix with specified coefficients.
static CImg< T > matrix (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6, const T &a7, const T &a8, const T &a9, const T &a10, const T &a11, const T &a12, const T &a13, const T &a14, const T &a15, const T &a16, const T &a17, const T &a18, const T &a19, const T &a20, const T &a21, const T &a22, const T &a23, const T &a24)
 Return a 5x5 square matrix with specified coefficients.
static CImg< T > tensor (const T &a1)
 Return a 1x1 symmetric matrix with specified coefficients.
static CImg< T > tensor (const T &a1, const T &a2, const T &a3)
 Return a 2x2 symmetric matrix tensor with specified coefficients.
static CImg< T > tensor (const T &a1, const T &a2, const T &a3, const T &a4, const T &a5, const T &a6)
 Return a 3x3 symmetric matrix with specified coefficients.
static CImg< T > diagonal (const T &a0)
 Return a 1x1 diagonal matrix with specified coefficients.
static CImg< T > diagonal (const T &a0, const T &a1)
 Return a 2x2 diagonal matrix with specified coefficients.
static CImg< T > diagonal (const T &a0, const T &a1, const T &a2)
 Return a 3x3 diagonal matrix with specified coefficients.
static CImg< T > diagonal (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a 4x4 diagonal matrix with specified coefficients.
static CImg< T > diagonal (const T &a0, const T &a1, const T &a2, const T &a3, const T &a4)
 Return a 5x5 diagonal matrix with specified coefficients.
static CImg< T > identity_matrix (const unsigned int N)
 Return a NxN identity matrix.
static CImg< T > sequence (const unsigned int N, const T a0, const T a1)
 Return a N-numbered sequence vector from a0 to a1.
static CImg< T > rotation_matrix (const float x, const float y, const float z, const float w, const bool quaternion_data=false)
 Return a 3x3 rotation matrix along the (x,y,z)-axis with an angle w.

Value Manipulation

CImg< T > & fill (const T val)
 Fill an image by a value val.
CImg< T > get_fill (const T val) const
CImg< T > & fill (const T val0, const T val1)
 Fill sequentially all pixel values with values val0 and val1 respectively.
CImg< T > get_fill (const T val0, const T val1) const
CImg< T > & fill (const T val0, const T val1, const T val2)
 Fill sequentially all pixel values with values val0 and val1 and val2.
CImg< T > get_fill (const T val0, const T val1, const T val2) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3)
 Fill sequentially all pixel values with values val0 and val1 and val2 and val3.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4)
 Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5)
 Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4 and val5.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14) const
CImg< T > & fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14, const T val15)
 Fill sequentially pixel values.
CImg< T > get_fill (const T val0, const T val1, const T val2, const T val3, const T val4, const T val5, const T val6, const T val7, const T val8, const T val9, const T val10, const T val11, const T val12, const T val13, const T val14, const T val15) const
CImg< T > & fill (const char *const expression, const bool repeat_flag)
 Fill image values according to the given expression, which can be a formula or a list of values.
CImg< T > get_fill (const char *const values, const bool repeat_values) const
template<typename t >
CImg< T > & fill (const CImg< t > &values, const bool repeat_values=true)
 Fill image values according to the values found in the specified image.
template<typename t >
CImg< T > get_fill (const CImg< t > &values, const bool repeat_values=true) const
CImg< T > & fillX (const unsigned int y, const unsigned int z, const unsigned int c, const int a0,...)
 Fill image values along the X-axis at the specified pixel position (y,z,c).
CImg< T > & fillX (const unsigned int y, const unsigned int z, const unsigned int c, const double a0,...)
CImg< T > & fillY (const unsigned int x, const unsigned int z, const unsigned int c, const int a0,...)
 Fill image values along the Y-axis at the specified pixel position (x,z,c).
CImg< T > & fillY (const unsigned int x, const unsigned int z, const unsigned int c, const double a0,...)
CImg< T > & fillZ (const unsigned int x, const unsigned int y, const unsigned int c, const int a0,...)
 Fill image values along the Z-axis at the specified pixel position (x,y,c).
CImg< T > & fillZ (const unsigned int x, const unsigned int y, const unsigned int c, const double a0,...)
CImg< T > & fillC (const unsigned int x, const unsigned int y, const unsigned int z, const int a0,...)
 Fill image values along the C-axis at the specified pixel position (x,y,z).
CImg< T > & fillC (const unsigned int x, const unsigned int y, const unsigned int z, const double a0,...)
CImg< T > & discard (const T value)
 Remove specified value from the image buffer, and return resulting buffer as a one-column vector.
CImg< T > get_discard (const T value) const
template<typename t >
CImg< T > & discard (const CImg< t > &values)
 Remove specified values sequence from the image buffer, and return resulting buffer as a one-column vector.
template<typename t >
CImg< T > get_discard (const CImg< t > &values) const
CImg< T > & invert_endianness ()
 Invert endianness of the image buffer.
CImg< T > get_invert_endianness () const
CImg< T > & rand (const T val_min, const T val_max)
 Fill the image instance with random values between specified range.
CImg< T > get_rand (const T val_min, const T val_max) const
CImg< T > & round (const double y=1, const int rounding_type=0)
 Compute image with rounded pixel values.
CImg< T > get_round (const double y=1, const unsigned int rounding_type=0) const
CImg< T > & noise (const double sigma, const unsigned int noise_type=0)
 Add random noise to the values of the image instance.
CImg< T > get_noise (const double sigma, const unsigned int noise_type=0) const
CImg< T > & normalize (const T value_min, const T value_max)
 Linearly normalize values of the image instance between value_min and value_max.
CImg< Tfloat > get_normalize (const T value_min, const T value_max) const
CImg< T > & normalize ()
 Normalize multi-valued pixels of the image instance, with respect to their L2-norm.
CImg< Tfloat > get_normalize () const
CImg< T > & norm (const int norm_type=2)
 Compute L2-norm of each multi-valued pixel of the image instance.
CImg< Tfloat > get_norm (const int norm_type=2) const
CImg< T > & cut (const T value_min, const T value_max)
 Cut values of the image instance between value_min and value_max.
CImg< T > get_cut (const T value_min, const T value_max) const
CImg< T > & quantize (const unsigned int nb_levels, const bool keep_range=true)
 Uniformly quantize values of the image instance into nb_levels levels.
CImg< T > get_quantize (const unsigned int n, const bool keep_range=true) const
CImg< T > & threshold (const T value, const bool soft_threshold=false, const bool strict_threshold=false)
 Threshold values of the image instance.
CImg< T > get_threshold (const T value, const bool soft_threshold=false, const bool strict_threshold=false) const
CImg< T > & histogram (const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0)
 Compute the histogram of the image instance.
CImg< floatT > get_histogram (const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0) const
CImg< T > & equalize (const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0)
 Compute the histogram-equalized version of the image instance.
CImg< T > get_equalize (const unsigned int nblevels, const T val_min=(T) 0, const T val_max=(T) 0) const
template<typename t >
CImg< T > & index (const CImg< t > &palette, const bool dithering=false, const bool map_indexes=false)
 Index multi-valued pixels of the image instance, regarding to a predefined palette.
template<typename t >
CImg< typename CImg< t >::Tuint > get_index (const CImg< t > &palette, const bool dithering=false, const bool map_indexes=true) const
template<typename t >
CImg< T > & map (const CImg< t > &palette)
 Map predefined palette on the scalar (indexed) image instance.
template<typename t >
CImg< t > get_map (const CImg< t > &palette) const
CImg< T > & label (const bool is_high_connectivity=false, const Tfloat tolerance=0)
 Label connected components.
CImg< unsigned long > get_label (const bool is_high_connectivity=false, const Tfloat tolerance=0) const
template<typename t >
CImg< T > & label (const CImg< t > &connectivity_mask, const Tfloat tolerance=0)
template<typename t >
CImg< unsigned long > get_label (const CImg< t > &connectivity_mask, const Tfloat tolerance=0) const

Color Base Management

CImg< T > & sRGBtoRGB ()
 Convert color pixels from sRGB to RGB.
CImg< Tfloat > get_sRGBtoRGB () const
CImg< T > & RGBtosRGB ()
 Convert color pixels from RGB to sRGB.
CImg< Tfloat > get_RGBtosRGB () const
CImg< T > & RGBtoHSV ()
 Convert color pixels from RGB to HSV.
CImg< Tfloat > get_RGBtoHSV () const
CImg< T > & HSVtoRGB ()
 Convert color pixels from HSV to RGB.
CImg< Tuchar > get_HSVtoRGB () const
CImg< T > & RGBtoHSL ()
 Convert color pixels from RGB to HSL.
CImg< Tfloat > get_RGBtoHSL () const
CImg< T > & HSLtoRGB ()
 Convert color pixels from HSL to RGB.
CImg< Tuchar > get_HSLtoRGB () const
CImg< T > & RGBtoHSI ()
CImg< Tfloat > get_RGBtoHSI () const
CImg< T > & HSItoRGB ()
 Convert color pixels from HSI to RGB.
CImg< Tfloat > get_HSItoRGB () const
CImg< T > & RGBtoYCbCr ()
 Convert color pixels from RGB to YCbCr.
CImg< Tuchar > get_RGBtoYCbCr () const
CImg< T > & YCbCrtoRGB ()
 Convert color pixels from RGB to YCbCr.
CImg< Tuchar > get_YCbCrtoRGB () const
CImg< T > & RGBtoYUV ()
 Convert color pixels from RGB to YUV.
CImg< Tfloat > get_RGBtoYUV () const
CImg< T > & YUVtoRGB ()
 Convert color pixels from YUV to RGB.
CImg< Tuchar > get_YUVtoRGB () const
CImg< T > & RGBtoCMY ()
 Convert color pixels from RGB to CMY.
CImg< Tuchar > get_RGBtoCMY () const
CImg< T > & CMYtoRGB ()
 Convert CMY pixels of a color image into the RGB color space.
CImg< Tuchar > get_CMYtoRGB () const
CImg< T > & CMYtoCMYK ()
 Convert color pixels from CMY to CMYK.
CImg< Tuchar > get_CMYtoCMYK () const
CImg< T > & CMYKtoCMY ()
 Convert CMYK pixels of a color image into the CMY color space.
CImg< Tfloat > get_CMYKtoCMY () const
CImg< T > & RGBtoXYZ ()
 Convert color pixels from RGB to XYZ_709.
CImg< Tfloat > get_RGBtoXYZ () const
CImg< T > & XYZtoRGB ()
 Convert XYZ_709 pixels of a color image into the RGB color space.
CImg< Tuchar > get_XYZtoRGB () const
CImg< T > & XYZtoLab ()
 Convert XYZ_709 pixels of a color image into the (L*,a*,b*) color space.
CImg< Tfloat > get_XYZtoLab () const
CImg< T > & LabtoXYZ ()
 Convert Lab pixels of a color image into the XYZ color space.
CImg< Tfloat > get_LabtoXYZ () const
CImg< T > & XYZtoxyY ()
 Convert XYZ_709 pixels of a color image into the xyY color space.
CImg< Tfloat > get_XYZtoxyY () const
CImg< T > & xyYtoXYZ ()
 Convert xyY pixels of a color image into the XYZ_709 color space.
CImg< Tfloat > get_xyYtoXYZ () const
CImg< T > & RGBtoLab ()
 Convert a RGB image to a Lab one.
CImg< Tfloat > get_RGBtoLab () const
CImg< T > & LabtoRGB ()
 Convert a Lab image to a RGB one.
CImg< Tuchar > get_LabtoRGB () const
CImg< T > & RGBtoxyY ()
 Convert a RGB image to a xyY one.
CImg< Tfloat > get_RGBtoxyY () const
CImg< T > & xyYtoRGB ()
 Convert a xyY image to a RGB one.
CImg< Tuchar > get_xyYtoRGB () const
CImg< T > & RGBtoCMYK ()
 Convert a RGB image to a CMYK one.
CImg< Tfloat > get_RGBtoCMYK () const
CImg< T > & CMYKtoRGB ()
 Convert a CMYK image to a RGB one.
CImg< Tuchar > get_CMYKtoRGB () const
CImg< T > & RGBtoBayer ()
 Convert a RGB image to a Bayer-coded representation.
CImg< T > get_RGBtoBayer () const
CImg< T > & BayertoRGB (const unsigned int interpolation_type=3)
 Convert a Bayer-coded image to a RGB color image.
CImg< Tuchar > get_BayertoRGB (const unsigned int interpolation_type=3) const
static const CImg< Tuchar > & default_LUT256 ()
 Return a palette 'default' with 256 RGB entries.
static const CImg< Tuchar > & HSV_LUT256 ()
 Return palette 'HSV' with 256 RGB entries.
static const CImg< Tuchar > & lines_LUT256 ()
 Return palette 'lines' with 256 RGB entries.
static const CImg< Tuchar > & hot_LUT256 ()
 Return the palette 'hot' with 256 RGB entries.
static const CImg< Tuchar > & cool_LUT256 ()
 Return the palette 'cool' with 256 RGB entries.
static const CImg< Tuchar > & jet_LUT256 ()
 Return palette 'jet' with 256 RGB entries.
static const CImg< Tuchar > & flag_LUT256 ()
 Return palette 'flag' with 256 RGB entries.
static const CImg< Tuchar > & cube_LUT256 ()
 Return palette 'cube' with 256 RGB entries.

Geometric / Spatial Manipulation

CImg< T > & resize (const int size_x, const int size_y=-100, const int size_z=-100, const int size_c=-100, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0)
 Resize an image.
CImg< T > get_resize (const int size_x, const int size_y=-100, const int size_z=-100, const int size_c=-100, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0) const
template<typename t >
CImg< T > & resize (const CImg< t > &src, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0)
 Resize an image.
template<typename t >
CImg< T > get_resize (const CImg< t > &src, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0) const
CImg< T > & resize (const CImgDisplay &disp, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0)
 Resize an image.
CImg< T > get_resize (const CImgDisplay &disp, const int interpolation_type=1, const unsigned int border_conditions=0, const float centering_x=0, const float centering_y=0, const float centering_z=0, const float centering_c=0) const
CImg< T > & resize_halfXY ()
 Half-resize an image, using a special optimized filter.
CImg< T > get_resize_halfXY () const
CImg< T > & resize_doubleXY ()
 Upscale an image by a factor 2x.
CImg< T > get_resize_doubleXY () const
CImg< T > & resize_tripleXY ()
 Upscale an image by a factor 3x.
CImg< T > get_resize_tripleXY () const
CImg< T > & mirror (const char axis)
 Mirror an image along the specified axis.
CImg< T > get_mirror (const char axis) const
CImg< T > & shift (const int deltax, const int deltay=0, const int deltaz=0, const int deltac=0, const int border_condition=0)
 Shift the image.
CImg< T > get_shift (const int deltax, const int deltay=0, const int deltaz=0, const int deltac=0, const int border_condition=0) const
CImg< T > & permute_axes (const char *const order)
 Permute axes order.
CImg< T > get_permute_axes (const char *const order) const
CImg< T > & unroll (const char axis)
 Unroll all images values into specified axis.
CImg< T > get_unroll (const char axis) const
CImg< T > & rotate (const float angle, const unsigned int border_conditions=0, const unsigned int interpolation=1)
 Rotate an image.
CImg< T > get_rotate (const float angle, const unsigned int border_conditions=0, const unsigned int interpolation=1) const
CImg< T > & rotate (const float angle, const float cx, const float cy, const float zoom, const unsigned int border_conditions=3, const unsigned int interpolation=1)
 Rotate an image around a center point (cx,cy).
CImg< T > get_rotate (const float angle, const float cx, const float cy, const float zoom, const unsigned int border_conditions=3, const unsigned int interpolation=1) const
template<typename t >
CImg< T > & warp (const CImg< t > &warp, const bool is_relative=false, const bool interpolation=true, const unsigned int border_conditions=0)
 Warp an image.
template<typename t >
CImg< T > get_warp (const CImg< t > &warp, const bool is_relative=false, const bool interpolation=true, const unsigned int border_conditions=0) const
CImg< T > & projections2d (const unsigned int x0, const unsigned int y0, const unsigned int z0)
 Return a 2d representation of a 3d image, with three slices.
CImg< T > get_projections2d (const unsigned int x0, const unsigned int y0, const unsigned int z0) const
CImg< T > & crop (const int x0, const int y0, const int z0, const int c0, const int x1, const int y1, const int z1, const int c1, const bool border_condition=false)
 Get a square region of the image.
CImg< T > get_crop (const int x0, const int y0, const int z0, const int c0, const int x1, const int y1, const int z1, const int c1, const bool border_condition=false) const
CImg< T > & crop (const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const bool border_condition=false)
 Get a rectangular part of the image instance.
CImg< T > get_crop (const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const bool border_condition=false) const
CImg< T > & crop (const int x0, const int y0, const int x1, const int y1, const bool border_condition=false)
 Get a rectangular part of the image instance.
CImg< T > get_crop (const int x0, const int y0, const int x1, const int y1, const bool border_condition=false) const
CImg< T > & crop (const int x0, const int x1, const bool border_condition=false)
 Get a rectangular part of the image instance.
CImg< T > get_crop (const int x0, const int x1, const bool border_condition=false) const
CImg< T > & autocrop (const T value, const char *const axes="czyx")
 Autocrop an image, regarding of the specified backround value.
CImg< T > get_autocrop (const T value, const char *const axes="czyx") const
CImg< T > & autocrop (const T *const color, const char *const axes="zyx")
 Autocrop an image, regarding of the specified backround color.
CImg< T > get_autocrop (const T *const color, const char *const axes="zyx") const
template<typename t >
CImg< T > & autocrop (const CImg< t > &color, const char *const axes="zyx")
 Autocrop an image, regarding of the specified backround color.
template<typename t >
CImg< T > get_autocrop (const CImg< t > &color, const char *const axes="zyx") const
CImg< T > & column (const unsigned int x0)
 Get one column.
CImg< T > get_column (const unsigned int x0) const
CImg< T > & columns (const unsigned int x0, const unsigned int x1)
 Get a set of columns.
CImg< T > get_columns (const unsigned int x0, const unsigned int x1) const
CImg< T > & line (const unsigned int y0)
 Get a line.
CImg< T > get_line (const unsigned int y0) const
CImg< T > & lines (const unsigned int y0, const unsigned int y1)
 Get a set of lines.
CImg< T > get_lines (const unsigned int y0, const unsigned int y1) const
CImg< T > & slice (const unsigned int z0)
 Get a slice.
CImg< T > get_slice (const unsigned int z0) const
CImg< T > & slices (const unsigned int z0, const unsigned int z1)
 Get a set of slices.
CImg< T > get_slices (const unsigned int z0, const unsigned int z1) const
CImg< T > & channel (const unsigned int c0)
 Get a channel.
CImg< T > get_channel (const unsigned int c0) const
CImg< T > & channels (const unsigned int c0, const unsigned int c1)
 Get a set of channels.
CImg< T > get_channels (const unsigned int c0, const unsigned int c1) const
CImg< T > get_shared_points (const unsigned int x0, const unsigned int x1, const unsigned int y0=0, const unsigned int z0=0, const unsigned int c0=0)
 Get a shared-memory image referencing a set of points of the image instance.
const CImg< T > get_shared_points (const unsigned int x0, const unsigned int x1, const unsigned int y0=0, const unsigned int z0=0, const unsigned int c0=0) const
CImg< T > get_shared_lines (const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int c0=0)
 Return a shared-memory image referencing a set of lines of the image instance.
const CImg< T > get_shared_lines (const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int c0=0) const
CImg< T > get_shared_line (const unsigned int y0, const unsigned int z0=0, const unsigned int c0=0)
 Return a shared-memory image referencing one particular line (y0,z0,c0) of the image instance.
const CImg< T > get_shared_line (const unsigned int y0, const unsigned int z0=0, const unsigned int c0=0) const
CImg< T > get_shared_planes (const unsigned int z0, const unsigned int z1, const unsigned int c0=0)
 Return a shared memory image referencing a set of planes (z0->z1,c0) of the image instance.
const CImg< T > get_shared_planes (const unsigned int z0, const unsigned int z1, const unsigned int c0=0) const
CImg< T > get_shared_plane (const unsigned int z0, const unsigned int c0=0)
 Return a shared-memory image referencing one plane (z0,c0) of the image instance.
const CImg< T > get_shared_plane (const unsigned int z0, const unsigned int c0=0) const
CImg< T > get_shared_channels (const unsigned int c0, const unsigned int c1)
 Return a shared-memory image referencing a set of channels (c0->c1) of the image instance.
const CImg< T > get_shared_channels (const unsigned int c0, const unsigned int c1) const
CImg< T > get_shared_channel (const unsigned int c0)
 Return a shared-memory image referencing one channel c0 of the image instance.
const CImg< T > get_shared_channel (const unsigned int c0) const
CImg< T > get_shared ()
 Return a shared version of the image instance.
const CImg< T > get_shared () const
CImgList< T > get_split (const char axis, const int nb=0) const
 Split image into a list.
CImgList< T > get_split (const T value, const bool keep_values, const bool is_shared) const
 Split image into a list of one-column vectors, according to specified splitting value.
template<typename t >
CImgList< T > get_split (const CImg< t > &values, const bool keep_values, const bool is_shared) const
 Split image into a list of one-column vectors, according to specified sequence of splitting values.
template<typename t >
CImg< T > & append (const CImg< t > &img, const char axis='x', const float align=0)
 Append an image.
CImg< T > & append (const CImg< T > &img, const char axis='x', const float align=0)
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_append (const CImg< T > &img, const char axis='x', const float align=0) const
CImg< T > get_append (const CImg< T > &img, const char axis='x', const float align=0) const

Filtering / Transforms

template<typename t >
CImg< T > & correlate (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false)
 Compute the correlation of the image instance by a mask.
template<typename t >
CImg< typename cimg::superset2
< T, t, float >::type > 
get_correlate (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false) const
template<typename t >
CImg< T > & convolve (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false)
 Compute the convolution of the image by a mask.
template<typename t >
CImg< typename cimg::superset2
< T, t, float >::type > 
get_convolve (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false) const
template<typename t >
CImg< T > & erode (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false)
 Return the erosion of the image by a structuring element.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_erode (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false) const
CImg< T > & erode (const unsigned int sx, const unsigned int sy, const unsigned int sz=1)
 Erode the image by a rectangular structuring element of size sx,sy,sz.
CImg< T > get_erode (const unsigned int sx, const unsigned int sy, const unsigned int sz=1) const
CImg< T > & erode (const unsigned int s)
 Erode the image by a square structuring element of size sx.
CImg< T > get_erode (const unsigned int s) const
template<typename t >
CImg< T > & dilate (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false)
 Dilate the image by a structuring element.
template<typename t >
CImg< typename cimg::superset
< T, t >::type > 
get_dilate (const CImg< t > &mask, const unsigned int border_conditions=1, const bool is_normalized=false) const
CImg< T > & dilate (const unsigned int sx, const unsigned int sy, const unsigned int sz=1)
 Dilate the image by a rectangular structuring element of size sx,sy,sz.
CImg< T > get_dilate (const unsigned int sx, const unsigned int sy, const unsigned int sz=1) const
CImg< T > & dilate (const unsigned int s)
 Erode the image by a square structuring element of size sx.
CImg< T > get_dilate (const unsigned int s) const
template<typename t >
CImg< T > & watershed (const CImg< t > &priority, const bool fill_lines=true)
 Compute the watershed transform, from an image instance of non-zero labels.
template<typename t >
CImg< T > get_watershed (const CImg< t > &priority, const bool fill_lines=true) const
CImg< T > & deriche (const float sigma, const int order=0, const char axis='x', const bool cond=true)
 Compute the result of the Deriche filter.
CImg< Tfloat > get_deriche (const float sigma, const int order=0, const char axis='x', const bool cond=true) const
CImg< T > & blur (const float sigmax, const float sigmay, const float sigmaz, const bool cond=true)
 Return a blurred version of the image, using a Canny-Deriche filter.
CImg< Tfloat > get_blur (const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) const
CImg< T > & blur (const float sigma, const bool cond=true)
 Return a blurred version of the image, using a Canny-Deriche filter.
CImg< Tfloat > get_blur (const float sigma, const bool cond=true) const
template<typename t >
CImg< T > & blur_anisotropic (const CImg< t > &G, const float amplitude=60, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const bool fast_approx=1)
 Blur the image anisotropically following a field of diffusion tensors.
template<typename t >
CImg< T > get_blur_anisotropic (const CImg< t > &G, const float amplitude=60, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const bool fast_approx=true) const
CImg< T > & blur_anisotropic (const float amplitude, const float sharpness=0.7f, const float anisotropy=0.6f, const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const bool fast_approx=true)
 Blur an image following in an anisotropic way.
CImg< T > get_blur_anisotropic (const float amplitude, const float sharpness=0.7f, const float anisotropy=0.6f, const float alpha=0.6f, const float sigma=1.1f, const float dl=0.8f, const float da=30, const float gauss_prec=2, const unsigned int interpolation_type=0, const bool fast_approx=true) const
CImg< T > & blur_bilateral (const float sigma_x, const float sigma_y, const float sigma_z, const float sigma_r, const int bgrid_x, const int bgrid_y, const int bgrid_z, const int bgrid_r, const bool interpolation_type=true)
 Blur an image using the bilateral filter.
CImg< T > get_blur_bilateral (const float sigma_x, const float sigma_y, const float sigma_z, const float sigma_r, const int bgrid_x, const int bgrid_y, const int bgrid_z, const int bgrid_r, const bool interpolation_type=true) const
CImg< T > & blur_bilateral (const float sigma_s, const float sigma_r, const int bgrid_s=-33, const int bgrid_r=32, const bool interpolation_type=true)
 Blur an image using the bilateral filter.
CImg< T > get_blur_bilateral (const float sigma_s, const float sigma_r, const int bgrid_s=-33, const int bgrid_r=32, const bool interpolation_type=true) const
CImg< T > & blur_patch (const float sigma_s, const float sigma_p, const unsigned int patch_size=3, const unsigned int lookup_size=4, const float smoothness=0, const bool fast_approx=true)
 Blur an image in its patch-based space.
CImg< T > get_blur_patch (const float sigma_s, const float sigma_p, const unsigned int patch_size=3, const unsigned int lookup_size=4, const float smoothness=0, const bool fast_approx=true) const
CImg< T > & blur_median (const unsigned int n)
 Apply a median filter.
CImg< T > get_blur_median (const unsigned int n) const
CImg< T > & sharpen (const float amplitude, const bool sharpen_type=false, const float edge=1, const float alpha=0, const float sigma=0)
 Sharpen image using anisotropic shock filters or inverse diffusion.
CImg< T > get_sharpen (const float amplitude, const bool sharpen_type=false, const float edge=1, const float alpha=0, const float sigma=0) const
CImgList< Tfloat > get_gradient (const char *const axes=0, const int scheme=3) const
 Compute the list of images, corresponding to the XY-gradients of an image.
CImgList< Tfloat > get_hessian (const char *const axes=0) const
 Get components of the Hessian matrix of an image.
CImg< T > & laplacian ()
 Compute the laplacian of the image instance.
CImg< Tfloat > get_laplacian () const
CImg< T > & structure_tensors (const unsigned int scheme=2)
 Compute the structure tensor field of an image.
CImg< Tfloat > get_structure_tensors (const unsigned int scheme=2) const
CImg< T > & edge_tensors (const float sharpness=0.7f, const float anisotropy=0.6f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false)
 Get a diffusion tensor for edge-preserving anisotropic smoothing of an image.
CImg< Tfloat > get_edge_tensors (const float sharpness=0.7f, const float anisotropy=0.6f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false) const
CImg< T > & displacement (const CImg< T > &source, const float smoothness=0.1f, const float precision=5.0f, const unsigned int nb_scales=0, const unsigned int iteration_max=10000, const bool is_backward=false)
 Estimate a displacement field between specified source image and image instance.
CImg< Tfloat > get_displacement (const CImg< T > &source, const float smoothness=0.1f, const float precision=5.0f, const unsigned int nb_scales=0, const unsigned int iteration_max=10000, const bool is_backward=false) const
CImg< T > & distance (const T value, const unsigned int metric=2)
 Compute the distance transform according to a specified value.
CImg< Tfloat > get_distance (const T value, const unsigned int metric=2) const
template<typename t >
CImg< T > & distance (const T value, const CImg< t > &metric_mask)
 Compute the chamfer distance transform according to a specified value, with a custom metric.
template<typename t >
CImg< Tfloat > get_distance (const T value, const CImg< t > &metric_mask) const
CImg< T > & distance_dijkstra (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0)
 Compute the distance map to one specified point.
CImg< Tfloat > get_distance_dijkstra (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0) const
 Compute the distance map to one specified point [new-instance version].
CImg< T > & distance_eikonal (const unsigned int nb_iterations, const float band_size=0, const float time_step=0.5f)
 Compute distance function from 0-valued isophotes by the application of an Eikonal PDE.
CImg< Tfloat > get_distance_eikonal (const unsigned int nb_iterations, const float band_size=0, const float time_step=0.5f) const
CImg< T > & haar (const char axis, const bool invert=false, const unsigned int nb_scales=1)
 Compute the Haar multiscale wavelet transform (monodimensional version).
CImg< Tfloat > get_haar (const char axis, const bool invert=false, const unsigned int nb_scales=1) const
CImg< T > & haar (const bool invert=false, const unsigned int nb_scales=1)
 Compute the Haar multiscale wavelet transform.
CImg< Tfloat > get_haar (const bool invert=false, const unsigned int nb_scales=1) const
CImgList< Tfloat > get_FFT (const char axis, const bool invert=false) const
 Compute a 1d Fast Fourier Transform, along a specified axis.
CImgList< Tfloat > get_FFT (const bool invert=false) const
 Compute a n-d Fast-Fourier Transform.
static void FFT (CImg< T > &real, CImg< T > &imag, const char axis, const bool invert=false)
 Compute a 1d Fast Fourier Transform, along a specified axis.
static void FFT (CImg< T > &real, CImg< T > &imag, const bool invert=false)
 Compute a n-d Fast Fourier Transform.

3d Objects Management

CImg< T > & shift_object3d (const float tx, const float ty=0, const float tz=0)
 Shift a 3d object.
CImg< Tfloat > get_shift_object3d (const float tx, const float ty=0, const float tz=0) const
CImg< T > & shift_object3d ()
 Shift a 3d object so that it becomes centered.
CImg< Tfloat > get_shift_object3d () const
CImg< T > & resize_object3d (const float sx, const float sy=-100, const float sz=-100)
 Resize a 3d object.
CImg< Tfloat > get_resize_object3d (const float sx, const float sy=-100, const float sz=-100) const
CImg< T > resize_object3d ()
 Resize a 3d object so that its max dimension if one.
CImg< Tfloat > get_resize_object3d () const
template<typename tf , typename tp , typename tff >
CImg< T > & append_object3d (CImgList< tf > &primitives, const CImg< tp > &obj_vertices, const CImgList< tff > &obj_primitives)
 Append a 3d object to another one.
template<typename tp , typename tc , typename tt , typename tx >
const CImg< T > & texturize_object3d (CImgList< tp > &primitives, CImgList< tc > &colors, const CImg< tt > &texture, const CImg< tx > &coords=CImg< tx >::empty()) const
 Texturize primitives of a 3d object.
template<typename tf , typename tc , typename te >
CImg< floatT > get_elevation3d (CImgList< tf > &primitives, CImgList< tc > &colors, const CImg< te > &elevation) const
 Create and return a 3d elevation of the image instance.
template<typename tf , typename tc >
CImg< floatT > get_projections3d (CImgList< tf > &primitives, CImgList< tc > &colors, const unsigned int x0, const unsigned int y0, const unsigned int z0, const bool normalize_colors=false) const
 Create and return the 3d projection planes of the image instance.
template<typename tf >
CImg< floatT > get_isoline3d (CImgList< tf > &primitives, const float isovalue, const int size_x=-100, const int size_y=-100) const
 Create and return a isoline of the image instance as a 3d object.
template<typename tf >
CImg< floatT > get_isosurface3d (CImgList< tf > &primitives, const float isovalue, const int size_x=-100, const int size_y=-100, const int size_z=-100) const
 Create and return a isosurface of the image instance as a 3d object.
template<typename tp , typename tc , typename to >
CImg< T > & object3dtoCImg3d (const CImgList< tp > &primitives, const CImgList< tc > &colors, const to &opacities)
 Convert a 3d object into a CImg3d.
template<typename tp , typename tc >
CImg< T > & object3dtoCImg3d (const CImgList< tp > &primitives, const CImgList< tc > &colors)
template<typename tp >
CImg< T > & object3dtoCImg3d (const CImgList< tp > &primitives)
CImg< T > & object3dtoCImg3d ()
template<typename tp , typename tc , typename to >
CImg< floatT > get_object3dtoCImg3d (const CImgList< tp > &primitives, const CImgList< tc > &colors, const to &opacities) const
template<typename tp , typename tc >
CImg< floatT > get_object3dtoCImg3d (const CImgList< tp > &primitives, const CImgList< tc > &colors) const
template<typename tp >
CImg< floatT > get_object3dtoCImg3d (const CImgList< tp > &primitives) const
CImg< floatT > get_object3dtoCImg3d () const
template<typename tp , typename tc , typename to >
CImg< T > get_CImg3dtoobject3d (CImgList< tp > &primitives, CImgList< tc > &colors, CImgList< to > &opacities) const
 Convert a CImg3d (one-column image) into a 3d object.
template<typename tp , typename tc , typename to >
CImg< T > & CImg3dtoobject3d (CImgList< tp > &primitives, CImgList< tc > &colors, CImgList< to > &opacities)
template<typename tf , typename tfunc >
static CImg< floatT > elevation3d (CImgList< tf > &primitives, const tfunc &func, const float x0, const float y0, const float x1, const float y1, const int size_x=256, const int size_y=256)
 Get elevation3d of a function.
template<typename tf >
static CImg< floatT > elevation3d (CImgList< tf > &primitives, const char *const expression, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
template<typename tf , typename tfunc >
static CImg< floatT > isoline3d (CImgList< tf > &primitives, const tfunc &func, const float isovalue, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
 Get isoline as a 3d object.
template<typename tf >
static CImg< floatT > isoline3d (CImgList< tf > &primitives, const char *const expression, const float isovalue, const float x0, const float y0, const float x1, const float y1, const int sizex=256, const int sizey=256)
template<typename tf , typename tfunc >
static CImg< floatT > isosurface3d (CImgList< tf > &primitives, 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 int size_x=32, const int size_y=32, const int size_z=32)
 Get isosurface as a 3d object.
template<typename tf >
static CImg< floatT > isosurface3d (CImgList< tf > &primitives, const char *const expression, const float isovalue, const float x0, const float y0, const float z0, const float x1, const float y1, const float z1, const int dx=32, const int dy=32, const int dz=32)
template<typename tf >
static CImg< floatT > box3d (CImgList< tf > &primitives, const float size_x=200, const float size_y=100, const float size_z=100)
 Create and return a 3d box object.
template<typename tf >
static CImg< floatT > cone3d (CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
 Create and return a 3d cone.
template<typename tf >
static CImg< floatT > cylinder3d (CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
 Create and return a 3d cylinder.
template<typename tf >
static CImg< floatT > torus3d (CImgList< tf > &primitives, const float radius1=100, const float radius2=30, const unsigned int subdivisions1=24, const unsigned int subdivisions2=12)
 Create and return a 3d torus.
template<typename tf >
static CImg< floatT > plane3d (CImgList< tf > &primitives, const float size_x=100, const float size_y=100, const unsigned int subdivisions_x=10, const unsigned int subdivisions_y=10)
 Create and return a 3d XY-plane.
template<typename tf >
static CImg< floatT > sphere3d (CImgList< tf > &primitives, const float radius=50, const unsigned int subdivisions=3)
 Create and return a 3d sphere.
template<typename tf , typename t >
static CImg< floatT > ellipsoid3d (CImgList< tf > &primitives, const CImg< t > &tensor, const unsigned int subdivisions=3)
 Create and return a 3d ellipsoid.

Drawing Functions

template<typename tc >
CImg< T > & draw_point (const int x0, const int y0, const tc *const color, const float opacity=1)
 Draw a 2d colored point (pixel).
template<typename tc >
CImg< T > & draw_point (const int x0, const int y0, const int z0, const tc *const color, const float opacity=1)
 Draw a 3d colored point (voxel).
template<typename t , typename tc >
CImg< T > & draw_point (const CImg< t > &points, const tc *const color, const float opacity=1)
template<typename tc >
CImg< T > & draw_line (const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2d colored line.
template<typename tz , typename tc >
CImg< T > & draw_line (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2d colored line, with z-buffering.
template<typename tc >
CImg< T > & draw_line (const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 3d colored line.
template<typename tc >
CImg< T > & draw_line (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2d textured line.
template<typename tc >
CImg< T > & draw_line (const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2d textured line, with perspective correction.
template<typename tz , typename tc >
CImg< T > & draw_line (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2d textured line, with z-buffering and perspective correction.
template<typename t , typename tc >
CImg< T > & draw_line (const CImg< t > &points, const tc *const color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a set of consecutive colored lines in the image instance.
template<typename tc >
CImg< T > & draw_arrow (const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1, const float angle=30, const float length=-10, const unsigned int pattern=~0U)
 Draw a colored arrow in the image instance.
template<typename tc >
CImg< T > & draw_spline (const int x0, const int y0, const float u0, const float v0, const int x1, const int y1, const float u1, const float v1, const tc *const color, const float opacity=1, const float precision=0.25, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a cubic spline curve in the image instance.
template<typename tc >
CImg< T > & draw_spline (const int x0, const int y0, const int z0, const float u0, const float v0, const float w0, const int x1, const int y1, const int z1, const float u1, const float v1, const float w1, const tc *const color, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a cubic spline curve in the image instance (for volumetric images).
template<typename t >
CImg< T > & draw_spline (const int x0, const int y0, const float u0, const float v0, const int x1, const int y1, const float u1, const float v1, const CImg< t > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const float opacity=1, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a cubic spline curve in the image instance.
template<typename tp , typename tt , typename tc >
CImg< T > & draw_spline (const CImg< tp > &points, const CImg< tt > &tangents, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
template<typename tp , typename tc >
CImg< T > & draw_spline (const CImg< tp > &points, const tc *const color, const float opacity=1, const bool close_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a set of consecutive colored splines in the image instance.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float opacity=1)
 Draw a 2d filled colored triangle.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float opacity, const unsigned int pattern)
 Draw a 2d outlined colored triangle.
template<typename tz , typename tc >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const float opacity=1, const float brightness=1)
 Draw a 2d filled colored triangle, with z-buffering.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2d Gouraud-shaded colored triangle.
template<typename tz , typename tc >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2d Gouraud-shaded colored triangle, with z-buffering.
template<typename tc1 , typename tc2 , typename tc3 >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc1 *const color1, const tc2 *const color2, const tc3 *const color3, const float opacity=1)
 Draw a colored triangle with interpolated colors.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
 Draw a 2d textured triangle.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
 Draw a 2d textured triangle, with perspective correction.
template<typename tz , typename tc >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float opacity=1, const float brightness=1)
 Draw a 2d textured triangle, with z-buffering and perspective correction.
template<typename tc , typename tl >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const tc *const color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
 Draw a 2d Pseudo-Phong-shaded triangle.
template<typename tz , typename tc , typename tl >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const tc *const color, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
 Draw a 2d Pseudo-Phong-shaded triangle, with z-buffering.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2d Gouraud-shaded textured triangle.
template<typename tc >
CImg< T > & draw_triangle (const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2d Gouraud-shaded textured triangle, with perspective correction.
template<typename tz , typename tc >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2d Gouraud-shaded textured triangle, with z-buffering and perspective correction.
template<typename tc , typename tl >
CImg< T > & draw_triangle (const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
 Draw a 2d Pseudo-Phong-shaded textured triangle.
template<typename tc , typename tl >
CImg< T > & draw_triangle (const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
 Draw a 2d Pseudo-Phong-shaded textured triangle, with perspective correction.
template<typename tz , typename tc , typename tl >
CImg< T > & draw_triangle (CImg< tz > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const int x2, const int y2, const float z2, const CImg< tc > &texture, const int tx0, const int ty0, const int tx1, const int ty1, const int tx2, const int ty2, const CImg< tl > &light, const int lx0, const int ly0, const int lx1, const int ly1, const int lx2, const int ly2, const float opacity=1)
 Draw a 2d Pseudo-Phong-shaded textured triangle, with z-buffering and perspective correction.
CImg< T > & draw_rectangle (const int x0, const int y0, const int z0, const int c0, const int x1, const int y1, const int z1, const int c1, const T val, const float opacity=1)
 Draw a 4d filled rectangle in the image instance, at coordinates (x0,y0,z0,c0)-(x1,y1,z1,c1).
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity=1)
 Draw a 3d filled colored rectangle in the image instance, at coordinates (x0,y0,z0)-(x1,y1,z1).
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int z0, const int x1, const int y1, const int z1, const tc *const color, const float opacity, const unsigned int pattern)
 Draw a 3d outlined colored rectangle in the image instance.
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity=1)
 Draw a 2d filled colored rectangle in the image instance, at coordinates (x0,y0)-(x1,y1).
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int x1, const int y1, const tc *const color, const float opacity, const unsigned int pattern)
 Draw a 2d outlined colored rectangle.
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImg< t > &points, const tc *const color, const float opacity=1)
 Draw a filled polygon in the image instance.
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImg< t > &points, const tc *const color, const float opacity, const unsigned int pattern)
 Draw a outlined polygon in the image instance.
template<typename tc >
CImg< T > & draw_circle (const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
 Draw a filled circle.
template<typename tc >
CImg< T > & draw_circle (const int x0, const int y0, int radius, const tc *const color, const float opacity, const unsigned int)
 Draw an outlined circle.
template<typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const float r1, const float r2, const float angle, const tc *const color, const float opacity=1)
 Draw a filled ellipse.
template<typename t , typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const CImg< t > &tensor, const tc *const color, const float opacity=1)
 Draw a filled ellipse.
template<typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const float r1, const float r2, const float angle, const tc *const color, const float opacity, const unsigned int pattern)
 Draw an outlined ellipse.
template<typename t , typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const CImg< t > &tensor, const tc *const color, const float opacity, const unsigned int pattern)
 Draw an outlined ellipse.
template<typename t >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int c0, const CImg< t > &sprite, const float opacity=1)
 Draw an image.
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int c0, const CImg< T > &sprite, const float opacity=1)
template<typename t >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const CImg< t > &sprite, const float opacity=1)
 Draw an image.
template<typename t >
CImg< T > & draw_image (const int x0, const int y0, const CImg< t > &sprite, const float opacity=1)
 Draw an image.
template<typename t >
CImg< T > & draw_image (const int x0, const CImg< t > &sprite, const float opacity=1)
 Draw an image.
template<typename t >
CImg< T > & draw_image (const CImg< t > &sprite, const float opacity=1)
 Draw an image.
template<typename ti , typename tm >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int c0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw a sprite image in the image instance (masked version).
template<typename ti , typename tm >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw an image.
template<typename ti , typename tm >
CImg< T > & draw_image (const int x0, const int y0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw an image.
template<typename ti , typename tm >
CImg< T > & draw_image (const int x0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw an image.
template<typename ti , typename tm >
CImg< T > & draw_image (const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw an image.
template<typename tc1 , typename tc2 , typename t >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity, const CImgList< t > &font,...)
 Draw a text.
template<typename tc , typename t >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const tc *const foreground_color, const int, const float opacity, const CImgList< t > &font,...)
template<typename tc , typename t >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const int, const tc *const background_color, const float opacity, const CImgList< t > &font,...)
template<typename tc1 , typename tc2 >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity=1, const unsigned int font_height=13,...)
 Draw a text.
template<typename tc >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const tc *const foreground_color, const int background_color=0, const float opacity=1, const unsigned int font_height=13,...)
template<typename tc >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const int, const tc *const background_color, const float opacity=1, const unsigned int font_height=13,...)
template<typename t1 , typename t2 >
CImg< T > & draw_quiver (const CImg< t1 > &flow, const t2 *const color, const float opacity=1, const unsigned int sampling=25, const float factor=-20, const bool arrows=true, const unsigned int pattern=~0U)
 Draw a vector field in the image instance, using a colormap.
template<typename t1 , typename t2 >
CImg< T > & draw_quiver (const CImg< t1 > &flow, const CImg< t2 > &color, const float opacity=1, const unsigned int sampling=25, const float factor=-20, const bool arrows=true, const unsigned int pattern=~0U)
 Draw a vector field in the image instance, using a colormap.
template<typename t , typename tc >
CImg< T > & draw_axis (const CImg< t > &xvalues, const int y, const tc *const color, const float opacity=1, const unsigned int pattern=~0U)
 Draw a labeled horizontal axis on the image instance.
template<typename t , typename tc >
CImg< T > & draw_axis (const int x, const CImg< t > &yvalues, const tc *const color, const float opacity=1, const unsigned int pattern=~0U)
 Draw a labeled vertical axis on the image instance.
template<typename tx , typename ty , typename tc >
CImg< T > & draw_axes (const CImg< tx > &xvalues, const CImg< ty > &yvalues, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw a labeled horizontal+vertical axis on the image instance.
template<typename tc >
CImg< T > & draw_axes (const float x0, const float x1, const float y0, const float y1, const tc *const color, const float opacity=1, const int subdivisionx=-60, const int subdivisiony=-60, const float precisionx=0, const float precisiony=0, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw a labeled horizontal+vertical axis on the image instance.
template<typename tx , typename ty , typename tc >
CImg< T > & draw_grid (const CImg< tx > &xvalues, const CImg< ty > &yvalues, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw grid.
template<typename tc >
CImg< T > & draw_grid (const float deltax, const float deltay, const float offsetx, const float offsety, const bool invertx, const bool inverty, const tc *const color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw grid.
template<typename t , typename tc >
CImg< T > & draw_graph (const CImg< t > &data, const tc *const color, const float opacity=1, const unsigned int plot_type=1, const int vertex_type=1, const double ymin=0, const double ymax=0, const unsigned int pattern=~0U)
 Draw a 1d graph on the image instance.
template<typename tc , typename t >
CImg< T > & draw_fill (const int x, const int y, const int z, const tc *const color, const float opacity, CImg< t > &region, const float sigma=0, const bool high_connexity=false)
 Draw a 3d filled region starting from a point (x,y,\ z) in the image instance.
template<typename tc >
CImg< T > & draw_fill (const int x, const int y, const int z, const tc *const color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
 Draw a 3d filled region starting from a point (x,y,\ z) in the image instance.
template<typename tc >
CImg< T > & draw_fill (const int x, const int y, const tc *const color, const float opacity=1, const float sigma=0, const bool high_connexity=false)
 Draw a 2d filled region starting from a point (x,y) in the image instance.
CImg< T > & draw_plasma (const int x0, const int y0, const int x1, const int y1, const float alpha=1, const float beta=1, const float opacity=1)
 Draw a plasma random texture.
CImg< T > & draw_plasma (const float alpha=1, const float beta=1, const float opacity=1)
 Draw a plasma random texture.
template<typename tc >
CImg< T > & draw_mandelbrot (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color_palette, const float opacity=1, const double z0r=-2, const double z0i=-2, const double z1r=2, const double z1i=2, const unsigned int iteration_max=255, const bool normalized_iteration=false, const bool julia_set=false, const double paramr=0, const double parami=0)
 Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.
template<typename tc >
CImg< T > & draw_mandelbrot (const CImg< tc > &color_palette, const float opacity=1, const double z0r=-2, const double z0i=-2, const double z1r=2, const double z1i=2, const unsigned int iteration_max=255, const bool normalized_iteration=false, const bool julia_set=false, const double paramr=0, const double parami=0)
 Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float sigma, const tc *const color, const float opacity=1)
 Draw a 1d gaussian function in the image instance.
template<typename t , typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const CImg< t > &tensor, const tc *const color, const float opacity=1)
 Draw an anisotropic 2d gaussian function.
template<typename tc >
CImg< T > & draw_gaussian (const int xc, const int yc, const float r1, const float r2, const float ru, const float rv, const tc *const color, const float opacity=1)
 Draw an anisotropic 2d gaussian function.
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float sigma, const tc *const color, const float opacity=1)
 Draw an isotropic 2d gaussian function.
template<typename t , typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float zc, const CImg< t > &tensor, const tc *const color, const float opacity=1)
 Draw an anisotropic 3d gaussian function.
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float zc, const float sigma, const tc *const color, const float opacity=1)
 Draw an isotropic 3d gaussian function.
template<typename tp , typename tf , typename tc , typename to >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImg< to > &opacities, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5e8, const float specular_light=0.2f, const float specular_shine=0.1f)
 Draw a 3d object.
template<typename tp , typename tf , typename tc , typename to , typename tz >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImg< to > &opacities, const unsigned int render_type, const bool double_sided, const float focale, const float lightx, const float lighty, const float lightz, const float specular_light, const float specular_shine, CImg< tz > &zbuffer)
template<typename tp , typename tf , typename tc , typename to >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImgList< to > &opacities, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5e8, const float specular_light=0.2f, const float specular_shine=0.1f)
template<typename tp , typename tf , typename tc , typename to , typename tz >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const CImgList< to > &opacities, const unsigned int render_type, const bool double_sided, const float focale, const float lightx, const float lighty, const float lightz, const float specular_light, const float specular_shine, CImg< tz > &zbuffer)
template<typename tp , typename tf , typename tc >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const unsigned int render_type=4, const bool double_sided=false, const float focale=500, const float lightx=0, const float lighty=0, const float lightz=-5e8, const float specular_light=0.2f, const float specular_shine=0.1f)
 Draw a 3d object.
template<typename tp , typename tf , typename tc , typename tz >
CImg< T > & draw_object3d (const float x0, const float y0, const float z0, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const unsigned int render_type, const bool double_sided, const float focale, const float lightx, const float lighty, const float lightz, const float specular_light, const float specular_shine, CImg< tz > &zbuffer)

Data Input

CImg< T > & select (CImgDisplay &disp, const unsigned int feature_type=2, unsigned int *const XYZ=0)
 Simple interface to select a shape from an image.
CImg< T > & select (const char *const title, const unsigned int feature_type=2, unsigned int *const XYZ=0)
 Simple interface to select a shape from an image.
CImg< intT > get_select (CImgDisplay &disp, const unsigned int feature_type=2, unsigned int *const XYZ=0) const
 Simple interface to select a shape from an image.
CImg< intT > get_select (const char *const title, const unsigned int feature_type=2, unsigned int *const XYZ=0) const
 Simple interface to select a shape from an image.
CImg< intT > get_select_graph (CImgDisplay &disp, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
 Select sub-graph in a graph.
CImg< T > & load (const char *const filename)
 Load an image from a file.
CImg< T > & load_ascii (const char *const filename)
 Load an image from an ASCII file.
CImg< T > & load_ascii (std::FILE *const file)
 Load an image from an ASCII file.
CImg< T > & load_dlm (const char *const filename)
 Load an image from a DLM file.
CImg< T > & load_dlm (std::FILE *const file)
 Load an image from a DLM file.
CImg< T > & load_bmp (const char *const filename)
 Load an image from a BMP file.
CImg< T > & load_bmp (std::FILE *const file)
 Load an image from a BMP file.
CImg< T > & load_jpeg (const char *const filename)
 Load an image from a JPEG file.
CImg< T > & load_jpeg (std::FILE *const file)
 Load an image from a JPEG file.
CImg< T > & load_magick (const char *const filename)
 Load an image from a file, using Magick++ library.
CImg< T > & load_png (const char *const filename)
 Load an image from a PNG file.
CImg< T > & load_png (std::FILE *const file)
 Load an image from a PNG file.
CImg< T > & load_pnm (const char *const filename)
 Load an image from a PNM file.
CImg< T > & load_pnm (std::FILE *const file)
 Load an image from a PNM file.
CImg< T > & load_pfm (const char *const filename)
 Load an image from a PFM file.
CImg< T > & load_pfm (std::FILE *const file)
 Load an image from a PFM file.
CImg< T > & load_rgb (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGB file.
CImg< T > & load_rgb (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGB file.
CImg< T > & load_rgba (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGBA file.
CImg< T > & load_rgba (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGBA file.
CImg< T > & load_tiff (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
 Load an image from a TIFF file.
CImg< T > & load_minc2 (const char *const filename)
 Load an image from a MINC2 file.
CImg< T > & load_analyze (const char *const filename, float *const voxsize=0)
 Load an image from an ANALYZE7.5/NIFTI file.
CImg< T > & load_analyze (std::FILE *const file, float *const voxsize=0)
 Load an image from an ANALYZE7.5/NIFTI file.
CImg< T > & load_cimg (const char *const filename, const char axis='z', const float align=0)
 Load an image (list) from a .cimg file.
CImg< T > & load_cimg (std::FILE *const file, const char axis='z', const float align=0)
 Load an image (list) from a .cimg file.
CImg< T > & load_cimg (const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int c1, const char axis='z', const float align=0)
 Load a sub-image (list) from a .cimg file.
CImg< T > & load_cimg (std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int c1, const char axis='z', const float align=0)
 Load a sub-image (list) from a non-compressed .cimg file.
CImg< T > & load_inr (const char *const filename, float *const voxsize=0)
 Load an image from an INRIMAGE-4 file.
CImg< T > & load_inr (std::FILE *const file, float *const voxsize=0)
 Load an image from an INRIMAGE-4 file.
CImg< T > & load_exr (const char *const filename)
 Load an image from a EXR file.
CImg< T > & load_pandore (const char *const filename)
 Load an image from a PANDORE file.
CImg< T > & load_pandore (std::FILE *const file)
 Load an image from a PANDORE file.
CImg< T > & load_parrec (const char *const filename, const char axis='c', const float align=0)
 Load an image from a PAR-REC (Philips) file.
CImg< T > & load_raw (const char *const filename, const unsigned int sizex=0, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
 Load an image from a .RAW file.
CImg< T > & load_raw (std::FILE *const file, const unsigned int sizex=0, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
 Load an image from a .RAW file.
CImg< T > & load_ffmpeg (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true, const bool resume=false, const char axis='z', const float align=0)
 Load a video sequence using FFMPEG av's libraries.
CImg< T > & load_yuv (const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const float align=0)
 Load an image sequence from a YUV file.
CImg< T > & load_yuv (std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const float align=0)
 Load an image sequence from a YUV file.
template<typename tf , typename tc >
CImg< T > & load_off (const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
 Load a 3d object from a .OFF file.
template<typename tf , typename tc >
CImg< T > & load_off (std::FILE *const file, CImgList< tf > &primitives, CImgList< tc > &colors)
 Load a 3d object from a .OFF file.
CImg< T > & load_ffmpeg_external (const char *const filename, const char axis='z', const float align=0)
 Load a video sequence using FFMPEG's external tool 'ffmpeg'.
CImg< T > & load_graphicsmagick_external (const char *const filename)
 Load an image using GraphicsMagick's external tool 'gm'.
CImg< T > & load_gzip_external (const char *const filename)
 Load a gzipped image file, using external tool 'gunzip'.
CImg< T > & load_imagemagick_external (const char *const filename)
 Load an image using ImageMagick's external tool 'convert'.
CImg< T > & load_medcon_external (const char *const filename)
 Load a DICOM image file, using XMedcon's external tool 'medcon'.
CImg< T > & load_dcraw_external (const char *const filename)
 Load a RAW Color Camera image file, using external tool 'dcraw'.
CImg< T > & load_camera (const int camera_index=-1, const unsigned int skip_frames=0, const bool release_camera=false)
 Load an image from a camera stream, using OpenCV.
CImg< T > & load_other (const char *const filename)
 Load an image using ImageMagick's or GraphicsMagick's executables. If failed, try to load a .cimg[z] file format.
static CImg< T > get_load (const char *const filename)
static CImg< T > get_load_ascii (const char *const filename)
static CImg< T > get_load_ascii (std::FILE *const file)
static CImg< T > get_load_dlm (const char *const filename)
static CImg< T > get_load_dlm (std::FILE *const file)
static CImg< T > get_load_bmp (const char *const filename)
static CImg< T > get_load_bmp (std::FILE *const file)
static CImg< T > get_load_jpeg (const char *const filename)
static CImg< T > get_load_jpeg (std::FILE *const file)
static CImg< T > get_load_magick (const char *const filename)
static CImg< T > get_load_png (const char *const filename)
static CImg< T > get_load_png (std::FILE *const file)
static CImg< T > get_load_pnm (const char *const filename)
static CImg< T > get_load_pnm (std::FILE *const file)
static CImg< T > get_load_pfm (const char *const filename)
static CImg< T > get_load_pfm (std::FILE *const file)
static CImg< T > get_load_rgb (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
static CImg< T > get_load_rgb (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
static CImg< T > get_load_rgba (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
static CImg< T > get_load_rgba (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
static CImg< T > get_load_tiff (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1)
static CImg< T > get_load_analyze (const char *const filename, float *const voxsize=0)
static CImg< T > get_load_analyze (std::FILE *const file, float *const voxsize=0)
static CImg< T > get_load_cimg (const char *const filename, const char axis='z', const float align=0)
static CImg< T > get_load_cimg (std::FILE *const file, const char axis='z', const float align=0)
static CImg< T > get_load_cimg (const char *const filename, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int c1, const char axis='z', const float align=0)
static CImg< T > get_load_cimg (std::FILE *const file, const unsigned int n0, const unsigned int n1, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int c1, const char axis='z', const float align=0)
static CImg< T > get_load_inr (const char *const filename, float *const voxsize=0)
static CImg< T > get_load_inr (std::FILE *const file, float *voxsize=0)
static CImg< T > get_load_exr (const char *const filename)
static CImg< T > get_load_pandore (const char *const filename)
static CImg< T > get_load_pandore (std::FILE *const file)
static CImg< T > get_load_parrec (const char *const filename, const char axis='c', const float align=0)
static CImg< T > get_load_raw (const char *const filename, const unsigned int sizex=0, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
static CImg< T > get_load_raw (std::FILE *const file, const unsigned int sizex=0, const unsigned int sizey=1, const unsigned int sizez=1, const unsigned int sizev=1, const bool multiplexed=false, const bool invert_endianness=false)
static CImg< T > get_load_ffmpeg (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool pixel_format=true, const bool resume=false, const char axis='z', const float align=0)
static CImg< T > get_load_yuv (const char *const filename, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const float align=0)
static CImg< T > get_load_yuv (std::FILE *const file, const unsigned int sizex, const unsigned int sizey=1, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int step_frame=1, const bool yuv2rgb=true, const char axis='z', const float align=0)
template<typename tf , typename tc >
static CImg< T > get_load_off (const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
template<typename tf , typename tc >
static CImg< T > get_load_off (std::FILE *const file, CImgList< tf > &primitives, CImgList< tc > &colors)
static CImg< T > get_load_ffmpeg_external (const char *const filename, const char axis='z', const float align=0)
static CImg< T > get_load_graphicsmagick_external (const char *const filename)
static CImg< T > get_load_gzip_external (const char *const filename)
static CImg< T > get_load_imagemagick_external (const char *const filename)
static CImg< T > get_load_medcon_external (const char *const filename)
static CImg< T > get_load_dcraw_external (const char *const filename)
static CImg< T > get_load_camera (const int camera_index=-1, const unsigned int skip_frames=0, const bool release_camera=false)
static CImg< T > get_load_other (const char *const filename)

Data Output

const CImg< T > & print (const char *const title=0, const bool display_stats=true) const
 Display informations about the image on the standard error output.
const CImg< T > & display (CImgDisplay &disp) const
 Display an image into a CImgDisplay window.
const CImg< T > & display (CImgDisplay &disp, const bool display_info) const
 Display an image in a window with a title title, and wait a '_is_closed' or 'keyboard' event.
.
const CImg< T > & display (const char *const title=0, const bool display_info=true) const
 Display an image in a window with a title title, and wait a '_is_closed' or 'keyboard' event.
.
template<typename tp , typename tf , typename tc , typename to >
const CImg< T > & display_object3d (CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp , typename tf , typename tc , typename to >
const CImg< T > & display_object3d (const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp , typename tf , typename tc >
const CImg< T > & display_object3d (CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp , typename tf , typename tc >
const CImg< T > & display_object3d (const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp , typename tf >
const CImg< T > & display_object3d (CImgDisplay &disp, const CImg< tp > &vertices, const CImgList< tf > &primitives, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp , typename tf >
const CImg< T > & display_object3d (const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp >
const CImg< T > & display_object3d (CImgDisplay &disp, const CImg< tp > &vertices, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
template<typename tp >
const CImg< T > & display_object3d (const char *const title, const CImg< tp > &vertices, const bool centering=true, const int render_static=4, const int render_motion=1, const bool double_sided=true, const float focale=500, const float light_x=0, const float light_y=0, const float light_z=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, const bool display_axes=true, float *const pose_matrix=0) const
 High-level interface for displaying a 3d object.
const CImg< T > & display_graph (CImgDisplay &disp, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
 High-level interface for displaying a graph.
const CImg< T > & display_graph (const char *const title=0, const unsigned int plot_type=1, const unsigned int vertex_type=1, const char *const labelx=0, const double xmin=0, const double xmax=0, const char *const labely=0, const double ymin=0, const double ymax=0) const
 High-level interface for displaying a graph.
const CImg< T > & save (const char *const filename, const int number=-1) const
 Save the image as a file.
const CImg< T > & save_ascii (const char *const filename) const
 Save the image as an ASCII file (ASCII Raw + simple header).
const CImg< T > & save_ascii (std::FILE *const file) const
 Save the image as an ASCII file (ASCII Raw + simple header).
const CImg< T > & save_cpp (const char *const filename) const
 Save the image as a CPP source file.
const CImg< T > & save_cpp (std::FILE *const file) const
 Save the image as a CPP source file.
const CImg< T > & save_dlm (const char *const filename) const
 Save the image as a DLM file.
const CImg< T > & save_dlm (std::FILE *const file) const
 Save the image as a DLM file.
const CImg< T > & save_bmp (const char *const filename) const
 Save the image as a BMP file.
const CImg< T > & save_bmp (std::FILE *const file) const
 Save the image as a BMP file.
const CImg< T > & save_jpeg (const char *const filename, const unsigned int quality=100) const
 Save a file in JPEG format.
const CImg< T > & save_jpeg (std::FILE *const file, const unsigned int quality=100) const
 Save a file in JPEG format.
const CImg< T > & save_magick (const char *const filename, const unsigned int bytes_per_pixel=0) const
 Save the image using built-in ImageMagick++ library.
const CImg< T > & save_png (const char *const filename, const unsigned int bytes_per_pixel=0) const
 Save a file in PNG format.
const CImg< T > & save_png (std::FILE *const file, const unsigned int bytes_per_pixel=0) const
 Save a file in PNG format.
const CImg< T > & save_pnm (const char *const filename, const unsigned int bytes_per_pixel=0) const
 Save the image as a PNM file.
const CImg< T > & save_pnm (std::FILE *const file, const unsigned int bytes_per_pixel=0) const
 Save the image as a PNM file.
const CImg< T > & save_pnk (const char *const filename) const
 Save the image as a PNK file (PINK library extension of PGM).
const CImg< T > & save_pnk (std::FILE *const file) const
 Save the image as a PNk file (PINK library extension of PGM).
const CImg< T > & save_pfm (const char *const filename) const
 Save the image as a PFM file.
const CImg< T > & save_pfm (std::FILE *const file) const
 Save the image as a PFM file.
const CImg< T > & save_rgb (const char *const filename) const
 Save the image as a RGB file.
const CImg< T > & save_rgb (std::FILE *const file) const
 Save the image as a RGB file.
const CImg< T > & save_rgba (const char *const filename) const
 Save the image as a RGBA file.
const CImg< T > & save_rgba (std::FILE *const file) const
 Save the image as a RGBA file.
const CImg< T > & save_tiff (const char *const filename, const unsigned int compression=0) const
 Save a file in TIFF format.
const CImg< T > & save_minc2 (const char *const filename) const
 Save the image as a MINC2 file.
const CImg< T > & save_analyze (const char *const filename, const float *const voxsize=0) const
 Save the image as an ANALYZE7.5 or NIFTI file.
const CImg< T > & save_cimg (const char *const filename, const bool compression=false) const
 Save the image as a .cimg file.
const CImg< T > & save_cimg (std::FILE *const file, const bool compression=false) const
const CImg< T > & save_cimg (const char *const filename, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0) const
 Insert the image into an existing .cimg file, at specified coordinates.
const CImg< T > & save_cimg (std::FILE *const file, const unsigned int n0, const unsigned int x0, const unsigned int y0, const unsigned int z0, const unsigned int c0) const
 Insert the image into an existing .cimg file, at specified coordinates.
const CImg< T > & save_inr (const char *const filename, const float *const voxsize=0) const
 Save the image as an INRIMAGE-4 file.
const CImg< T > & save_inr (std::FILE *const file, const float *const voxsize=0) const
 Save the image as an INRIMAGE-4 file.
const CImg< T > & save_exr (const char *const filename) const
 Save the image as a EXR file.
const CImg< T > & save_pandore (const char *const filename, const unsigned int colorspace=0) const
 Save the image as a PANDORE-5 file.
const CImg< T > & save_pandore (std::FILE *const file, const unsigned int colorspace=0) const
 Save the image as a PANDORE-5 file.
const CImg< T > & save_raw (const char *const filename, const bool multiplexed=false) const
 Save the image as a RAW file.
const CImg< T > & save_raw (std::FILE *const file, const bool multiplexed=false) const
 Save the image as a RAW file.
const CImg< T > & save_ffmpeg (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const unsigned int fps=25, const unsigned int bitrate=2048) const
 Save the image as a video sequence file, using FFMPEG library.
const CImg< T > & save_yuv (const char *const filename, const bool rgb2yuv=true) const
 Save the image as a YUV video sequence file.
const CImg< T > & save_yuv (std::FILE *const file, const bool rgb2yuv=true) const
 Save the image as a YUV video sequence file.
template<typename tf , typename tc >
const CImg< T > & save_off (const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
 Save OFF files.
template<typename tf , typename tc >
const CImg< T > & save_off (std::FILE *const file, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
 Save OFF files.
const CImg< T > & save_ffmpeg_external (const char *const filename, const unsigned int first_frame=0, const unsigned int last_frame=~0U, const char *const codec="mpeg2video", const unsigned int fps=25, const unsigned int bitrate=2048) const
 Save the image as a video sequence file, using the external tool 'ffmpeg'.
const CImg< T > & save_graphicsmagick_external (const char *const filename, const unsigned int quality=100) const
 Save the image using GraphicsMagick's gm.
const CImg< T > & save_gzip_external (const char *const filename) const
 Save an image as a gzipped file, using external tool 'gzip'.
const CImg< T > & save_imagemagick_external (const char *const filename, const unsigned int quality=100) const
 Save the image using ImageMagick's convert.
const CImg< T > & save_medcon_external (const char *const filename) const
 Save an image as a Dicom file (need '(X)Medcon' : http://xmedcon.sourceforge.net )
const CImg< T > & save_other (const char *const filename, const unsigned int quality=100) const
static void save_empty_cimg (const char *const filename, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dc=1)
 Save an empty .cimg file with specified dimensions.
static void save_empty_cimg (std::FILE *const file, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dc=1)
 Save an empty .cimg file with specified dimensions.
static CImg< T > logo40x38 ()

Detailed Description

template<typename T>
struct cimg_library::CImg< T >

Class representing an image (up to 4 dimensions wide), each pixel being of type T.

This is the main class of the CImg Library. It declares and constructs an image, allows access to its pixel values, and is able to perform various image operations.

Image representation

A CImg image is defined as an instance of the container CImg<T>, which contains a regular grid of pixels, each pixel value being of type T. The image grid can have up to 4 dimensions : width, height, depth and number of channels. Usually, the three first dimensions are used to describe spatial coordinates (x,y,z), while the number of channels is rather used as a vector-valued dimension (it may describe the R,G,B color channels for instance). If you need a fifth dimension, you can use image lists CImgList<T> rather than simple images CImg<T>.

Thus, the CImg<T> class is able to represent volumetric images of vector-valued pixels, as well as images with less dimensions (1d scalar signal, 2d color images, ...). Most member functions of the class CImg<T> are designed to handle this maximum case of (3+1) dimensions.

Concerning the pixel value type T : fully supported template types are the basic C++ types : unsigned char, char, short, unsigned int, int, unsigned long, long, float, double, ... . Typically, fast image display can be done using CImg<unsigned char> images, while complex image processing algorithms may be rather coded using CImg<float> or CImg<double> images that have floating-point pixel values. The default value for the template T is float. Using your own template types may be possible. However, you will certainly have to define the complete set of arithmetic and logical operators for your class.

Image structure

The CImg<T> structure contains six fields :

  • _width defines the number of columns of the image (size along the X-axis).
  • _height defines the number of rows of the image (size along the Y-axis).
  • _depth defines the number of slices of the image (size along the Z-axis).
  • _spectrum defines the number of channels of the image (size along the C-axis).
  • _data defines a pointer to the pixel data (of type T).
  • _is_shared is a boolean that tells if the memory buffer data is shared with another image.

You can access these fields publicly although it is recommended to use the dedicated functions width(), height(), depth(), spectrum() and ptr() to do so. Image dimensions are not limited to a specific range (as long as you got enough available memory). A value of 1 usually means that the corresponding dimension is flat. If one of the dimensions is 0, or if the data pointer is null, the image is considered as empty. Empty images should not contain any pixel data and thus, will not be processed by CImg member functions (a CImgInstanceException will be thrown instead). Pixel data are stored in memory, in a non interlaced mode (See How pixel data are stored with CImg.).

Image declaration and construction

Declaring an image can be done by using one of the several available constructors. Here is a list of the most used :

  • Construct images from arbitrary dimensions :
    • CImg<char> img; declares an empty image.
    • CImg<unsigned char> img(128,128); declares a 128x128 greyscale image with unsigned char pixel values.
    • CImg<double> img(3,3); declares a 3x3 matrix with double coefficients.
    • CImg<unsigned char> img(256,256,1,3); declares a 256x256x1x3 (color) image (colors are stored as an image with three channels).
    • CImg<double> img(128,128,128); declares a 128x128x128 volumetric and greyscale image (with double pixel values).
    • CImg<> img(128,128,128,3); declares a 128x128x128 volumetric color image (with float pixels, which is the default value of the template parameter T).
    • Note : images pixels are not automatically initialized to 0. You may use the function fill() to do it, or use the specific constructor taking 5 parameters like this : CImg<> img(128,128,128,3,0); declares a 128x128x128 volumetric color image with all pixel values to 0.
  • Construct images from filenames :
    • CImg<unsigned char> img("image.jpg"); reads a JPEG color image from the file "image.jpg".
    • CImg<float> img("analyze.hdr"); reads a volumetric image (ANALYZE7.5 format) from the file "analyze.hdr".
    • Note : You need to install ImageMagick to be able to read common compressed image formats (JPG,PNG, ...) (See Files IO in CImg.).
  • Construct images from C-style arrays :
    • CImg<int> img(data_buffer,256,256); constructs a 256x256 greyscale image from a int* buffer data_buffer (of size 256x256=65536).
    • CImg<unsigned char> img(data_buffer,256,256,1,3,false); constructs a 256x256 color image from a unsigned char* buffer data_buffer (where R,G,B channels follow each others).
    • CImg<unsigned char> img(data_buffer,256,256,1,3,true); constructs a 256x256 color image from a unsigned char* buffer data_buffer (where R,G,B channels are multiplexed).

The complete list of constructors can be found here.

Most useful functions

The CImg<T> class contains a lot of functions that operates on images. Some of the most useful are :


Member Typedef Documentation

typedef T* iterator

Simple iterator type, to loop through each pixel value of an image instance.

Note:
  • The CImg<T>::iterator type is defined to be a T*.
  • You will seldom have to use iterators in CImg, most classical operations being achieved (often in a faster way) using methods of CImg<T>.
Sample code :
       CImg<float> img("reference.jpg");                                         // Load image from file.
       for (CImg<float>::iterator it = img.begin(), it<img.end(); ++it) *it = 0; // Set all pixels to '0', through a CImg iterator.
       img.fill(0);                                                              // Do the same with a built-in method.
See also:
const_iterator.
typedef const T* const_iterator

Simple const iterator type, to loop through each pixel value of a const image instance.

Note:
  • The CImg<T>::const_iterator type is defined to be a const T*.
  • You will seldom have to use iterators in CImg, most classical operations being achieved (often in a faster way) using methods of CImg<T>.
Sample code :
       const CImg<float> img("reference.jpg");                                    // Load image from file.
       float sum = 0;
       for (CImg<float>::iterator it = img.begin(), it<img.end(); ++it) sum+=*it; // Compute sum of all pixel values, through a CImg iterator.
       const float sum2 = img.sum();                                              // Do the same with a built-in method.
See also:
iterator.
typedef T value_type

Pixel value type.

Refer to the type of the pixel values of an image instance.

Note:
  • The CImg<T>::value_type type of a CImg<T> is defined to be a T.
  • CImg<T>::value_type is actually not used in CImg methods. It has been mainly defined for compatibility with STL naming conventions.

Constructor & Destructor Documentation

~CImg ( )

Destructor.

Destroy current image instance.

Note:
  • The pixel buffer data() is deallocated if necessary, e.g. for non-empty and non-shared image instances.
  • Destroying an empty or shared image does nothing actually.
Warning:
  • When destroying a non-shared image, make sure that you will not operate on a remaining shared image that shares its buffer with the destroyed instance, in order to avoid further invalid memory access (to a deallocated buffer).
See also:
CImg(), assign().
CImg ( )

Default constructor.

Construct a new empty image instance.

Note:
Sample code :
       CImg<float> img1, img2;      // Construct two empty images.
       img1.assign(256,256,1,3);    // Re-assign 'img1' to be a 256x256x1x3 (color) image.
       img2 = img1.get_rand(0,255); // Re-assign 'img2' to be a random-valued version of 'img1'.
       img2.assign();               // Re-assign 'img2' to be an empty image again.
See also:
~CImg(), assign(), is_empty().
CImg ( const unsigned int  size_x,
const unsigned int  size_y = 1,
const unsigned int  size_z = 1,
const unsigned int  size_c = 1 
) [explicit]

Construct image with specified size.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T.

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
Note:
  • It is able to create only non-shared images, and allocates thus a pixel buffer data() for each constructed image instance.
  • Setting one dimension size_x,size_y,size_z or size_c to 0 leads to the construction of an empty image.
  • A CImgInstanceException is thrown when the pixel buffer cannot be allocated (e.g. when requested size is too big for available memory).
Warning:
Sample code :
       CImg<float> img1(256,256,1,3);   // Construct a 256x256x1x3 (color) image, filled with garbage values.
       CImg<float> img2(256,256,1,3,0); // Construct a 256x256x1x3 (color) image, filled with value '0'.
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int,T), assign(unsigned int,unsigned int,unsigned int,unsigned int).
CImg ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const T  value 
)

Construct image with specified size and initialize pixel values.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T, and set all pixel values to specified value.

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value: Value used for initialization.
Note:
Warning:
  • It cannot be used to construct a vector-valued image and initialize it with vector-valued pixels (e.g. RGB vector, for color images). For this task, you may use fillC() after construction.
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), assign(unsigned int,unsigned int,unsigned int,unsigned int,T).
CImg ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const int  value0,
const int  value1,
  ... 
)

Construct image with specified size and initialize pixel values from a sequence of integers.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T, and initialize pixel values from the specified sequence of integers value0,value1,...

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value0: First value of the initialization sequence (must be an integer).
value1: Second value of the initialization sequence (must be an integer).
...
Note:
Warning:
  • You must specify exactly size_x*size_y*size_z*size_c integers in the initialization sequence. Otherwise, the constructor may crash or fill your image pixels with garbage.
Sample code :
       const CImg<float> img(2,2,1,3,      // Construct a 2x2 color (RGB) image.
                             0,255,0,255,  // Set the 4 values for the red component.
                             0,0,255,255,  // Set the 4 values for the green component.
                             64,64,64,64); // Set the 4 values for the blue component.
       img.resize(150,150).display();
ref_constructor1.jpg
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), CImg(unsigned int,unsigned int,unsigned int,unsigned int,double,double,...), assign(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...).
CImg ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const double  value0,
const double  value1,
  ... 
)

Construct image with specified size and initialize pixel values from a sequence of doubles.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T, and initialize pixel values from the specified sequence of doubles value0,value1,...

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value0: First value of the initialization sequence (must be a double).
value1: Second value of the initialization sequence (must be a double).
...
Note:
  • Similar to CImg(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...), but takes a sequence of double values instead of integers.
Warning:
  • You must specify exactly dx*dy*dz*dc doubles in the initialization sequence. Otherwise, the constructor may crash or fill your image with garbage. For instance, the code below will probably crash on most platforms :
             const CImg<float> img(2,2,1,1, 0.5,0.5,255,255); // FAIL : The two last arguments are 'int', not 'double' !
    
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), CImg(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...), assign(unsigned int,unsigned int,unsigned int,unsigned int,double,double,...).
CImg ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const char *const  values,
const bool  repeat_values 
)

Construct image with specified size and initialize pixel values from a value string.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T, and initializes pixel values from the specified string values.

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
values: Value string describing the way pixel values are set.
repeat_values: Flag telling if the value filling process is periodic.
Note:
  • Similar to CImg(unsigned int,unsigned int,unsigned int,unsigned int), but it also fills the pixel buffer with values described in the value string values.
  • Value string values may describe two different filling processes :
    • Either values is a sequences of values assigned to the image pixels, as in "1,2,3,7,8,2". In this case, set repeat_values to true to periodically fill the image with the value sequence.
    • Either, values is a formula, as in "cos(x/10)*sin(y/20)". In this case, parameter repeat_values is pointless.
  • For both cases, specifying repeat_values is mandatory. It disambiguates the possible overloading of constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int,T) with T being a const char*.
  • A CImgArgumentException is thrown when an invalid value string values is specified.
Sample code :
       const CImg<float> img1(129,129,1,3,"0,64,128,192,255",true),                   // Construct image filled from a value sequence.
                         img2(129,129,1,3,"if(c==0,255*abs(cos(x/10)),1.8*y)",false); // Construct image filled from a formula.
       (img1,img2).display();
ref_constructor2.jpg
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), assign(unsigned int,unsigned int,unsigned int,unsigned int,const char*,bool).
CImg ( const t *const  values,
const unsigned int  size_x,
const unsigned int  size_y = 1,
const unsigned int  size_z = 1,
const unsigned int  size_c = 1,
const bool  is_shared = false 
)

Construct image with specified size and initialize pixel values from a memory buffer.

Construct a new image instance of size size_x x size_y x size_z x size_c, with pixels of type T, and initializes pixel values from the specified t* memory buffer.

Parameters:
values: Pointer to the input memory buffer.
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
is_shared: Flag telling if input memory buffer must be shared by the current instance.
Note:
  • If is_shared is false, the image instance allocates its own pixel buffer, and values from the specified input buffer are copied to the instance buffer. If buffer types T and t are different, a regular static cast is performed during buffer copy.
  • Otherwise, the image instance does not allocate a new buffer, and uses the input memory buffer as its own pixel buffer. This case requires that types T and t are the same. Later, destroying such a shared image will not deallocate the pixel buffer, this task being obviously charged to the initial buffer allocator.
  • A CImgInstanceException is thrown when the pixel buffer cannot be allocated (e.g. when requested size is too big for available memory).
Warning:
  • You must take care when operating on a shared image, since it may have an invalid pixel buffer pointer data() (e.g. already deallocated).
Sample code :
       unsigned char tab[256*256] = { 0 };
       CImg<unsigned char> img1(tab,256,256,1,1,false), // Construct new non-shared image from buffer 'tab'.
                           img2(tab,256,256,1,1,true);  // Construct new shared-image from buffer 'tab'.
       tab[1024] = 255;                                 // Here, 'img2' is indirectly modified, but not 'img1'.
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), assign(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool), is_shared().
CImg ( const char *const  filename) [explicit]

Construct image from an image file.

Construct a new image instance with pixels of type T, and initialize pixel values with the data read from an image file.

Parameters:
filename: Input image filename.
Note:
  • Similar to CImg(unsigned int,unsigned int,unsigned int,unsigned int), but it reads the image dimensions and pixel values from the specified image file.
  • The recognition of the image file format by CImg higly depends on the tools installed on your system and on the external libraries you used to link your code against.
  • Considered pixel type T should better fit the file format specification, or data loss may occur during file load (e.g. constructing a CImg<unsigned char> from a float-valued image file).
  • A CImgIOException is thrown when the specified filename cannot be read, or if the file format is not recognized.
Sample code :
       const CImg<float> img("reference.jpg");
       img.display();
ref_image.jpg
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), assign(const char*).
CImg ( const CImg< t > &  img)

Copy constructor.

Construct a new image instance with pixels of type T, as a copy of an existing CImg<t> instance.

Parameters:
img: Input image to copy.
Note:
  • Constructed copy has the same size width() x height() x depth() x spectrum() and pixel values as the input image img.
  • If input image img is shared and if types T and t are the same, the constructed copy is also shared, and shares its pixel buffer with img. Modifying a pixel value in the constructed copy will thus also modifies it in the input image img. This behavior is needful to allow functions to return shared images.
  • Otherwise, the constructed copy allocates its own pixel buffer, and copies pixel values from the input image img into its buffer. The copied pixel values may be eventually statically casted if types T and t are different.
  • Constructing a copy from an image img when types t and T are the same is significantly faster than with different types.
  • A CImgInstanceException is thrown when the pixel buffer cannot be allocated (e.g. not enough available memory).
See also:
CImg(const CImg<t>&,bool), assign(const CImg<t>&),
CImg ( const CImg< t > &  img,
const bool  is_shared 
)

Advanced copy constructor.

Construct a new image instance with pixels of type T, as a copy of an existing CImg<t> instance, while forcing the shared state of the constructed copy.

Parameters:
img: Input image to copy.
is_shared: Desired shared state of the constructed copy.
Note:
  • Similar to CImg(const CImg<t>&), except that it allows to decide the shared state of the constructed image, which does not depend anymore on the shared state of the input image img :
    • If is_shared is true, the constructed copy will share its pixel buffer with the input image img. For that case, the pixel types T and t must be the same.
    • If is_shared is false, the constructed copy will allocate its own pixel buffer, whether the input image img is shared or not.
  • A CImgArgumentException is thrown when a shared copy is requested with different pixel types T and t.
See also:
CImg(const CImg<t>&), assign(const CImg<t>&,bool).
CImg ( const CImg< t > &  img,
const char *const  dimensions 
)

Construct image with dimensions borrowed from another image.

Construct a new image instance with pixels of type T, and size get from some dimensions of an existing CImg<t> instance.

Parameters:
img: Input image from which dimensions are borrowed.
dimensions: String describing the image size along the X,Y,Z and C-dimensions.
Note:
Sample code :
       const CImg<float> img1(256,128,1,3),      // 'img1' is a 256x128x1x3 image.
                         img2(img1,"xyzc"),      // 'img2' is a 256x128x1x3 image.
                         img3(img1,"y,x,z,c"),   // 'img3' is a 128x256x1x3 image.
                         img4(img1,"c,x,y,3",0), // 'img4' is a 3x128x256x3 image (with pixels initialized to '0').
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int), CImg(const CImg<t>&,const char*,T), assign(const CImg<t>&,const char*).
CImg ( const CImg< t > &  img,
const char *const  dimensions,
const T  value 
)

Construct image with dimensions borrowed from another image and initialize pixel values.

Construct a new image instance with pixels of type T, and size get from the dimensions of an existing CImg<t> instance, and set all pixel values to specified value.

Parameters:
img: Input image from which dimensions are borrowed.
dimensions: String describing the image size along the X,Y,Z and V-dimensions.
value: Value used for initialization.
Note:
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int,T), CImg(const CImg<t>&,const char*), assign(const CImg<t>&,const char*,T).
CImg ( const CImgDisplay disp) [explicit]

Construct image from a display window.

Construct a new image instance with pixels of type T, as a snapshot of an existing CImgDisplay instance.

Parameters:
disp: Input display window.
Note:
  • The width() and height() of the constructed image instance are the same as the specified CImgDisplay.
  • The depth() and spectrum() of the constructed image instance are respectively set to 1 and 3 (i.e. a 2d color image).
  • The image pixels are read as 8-bits RGB values.
See also:
CImgDisplay, assign(const CImgDisplay&).

Member Function Documentation

CImg<T>& assign ( )

In-place version of the default constructor/destructor.

In-place version of the default constructor CImg(). It simply resets the instance to an empty image.

Note:
  • It reinitializes the current image instance to a new constructed image instance.
  • Memory used by the previous pixel buffer of the image instance is deallocated if necessary (i.e. if instance was not empty nor shared).
  • If the image instance was shared, it is replaced by a (non-shared) empty image without a deallocation process.
  • It can be useful to force memory deallocation of a pixel buffer used by an image instance, before its formal destruction.
See also:
CImg(), ~CImg().
CImg<T>& assign ( const unsigned int  size_x,
const unsigned int  size_y = 1,
const unsigned int  size_z = 1,
const unsigned int  size_c = 1 
)

In-place version of a constructor.

In-place version of the constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int).

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(unsigned int,unsigned int,unsigned int,unsigned int,T). CImg(unsigned int,unsigned int,unsigned int,unsigned int).
CImg<T>& assign ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const T  value 
)

In-place version of a constructor.

In-place version of the constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int,T).

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value: Value for initialization.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(unsigned int,unsigned int,unsigned int,unsigned int), CImg(unsigned int,unsigned int,unsigned int,unsigned int,T).
CImg<T>& assign ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const int  value0,
const int  value1,
  ... 
)

In-place version of a constructor.

In-place version of the constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...).

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value0: First value of the initialization sequence (must be an integer).
value1: Second value of the initialization sequence (must be an integer).
...
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(unsigned int,unsigned int,unsigned int,unsigned int,double,double,...), CImg(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...).
CImg<T>& assign ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const double  value0,
const double  value1,
  ... 
)

In-place version of a constructor.

In-place version of the constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int,double,double,...).

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
value0: First value of the initialization sequence (must be a double).
value1: Second value of the initialization sequence (must be a double).
...
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(unsigned int,unsigned int,unsigned int,unsigned int,int,int,...), CImg(unsigned int,unsigned int,unsigned int,unsigned int,double,double,...).
CImg<T>& assign ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const char *const  values,
const bool  repeat_values 
)

In-place version of a constructor.

In-place version of the constructor CImg(unsigned int,unsigned int,unsigned int,unsigned int,const char*,bool).

Parameters:
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
values: Value string describing the way pixel values are set.
repeat_values: Flag telling if filling process is periodic.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
CImg(unsigned int,unsigned int,unsigned int,unsigned int,const char*,bool).
CImg<T>& assign ( const t *const  values,
const unsigned int  size_x,
const unsigned int  size_y = 1,
const unsigned int  size_z = 1,
const unsigned int  size_c = 1 
)

In-place version of a constructor.

In-place version of the constructor CImg(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool).

Parameters:
values: Pointer to the input memory buffer.
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool). CImg(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool).
CImg<T>& assign ( const t *const  values,
const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c,
const bool  is_shared 
)

In-place version of a constructor.

In-place version of the constructor CImg(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool).

Parameters:
values: Pointer to the input memory buffer.
size_x: Desired image width().
size_y: Desired image height().
size_z: Desired image depth().
size_c: Desired image spectrum().
is_shared: Flag telling if input memory buffer must be shared by the current instance.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(const t*,unsigned int,unsigned int,unsigned int,unsigned int). CImg(const t*,unsigned int,unsigned int,unsigned int,unsigned int,bool).
CImg<T>& assign ( const char *const  filename)

In-place version of a constructor.

In-place version of the constructor CImg(const char*).

Parameters:
filename: Input image filename.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
  • Equivalent to load(const char*).
See also:
CImg(const char*), load(const char*).
CImg<T>& assign ( const CImg< t > &  img)

In-place version of the default copy constructor.

In-place version of the constructor CImg(const CImg<t>&).

Parameters:
img: Input image to copy.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(const CImg<t>&,bool), CImg(const CImg<t>&).
CImg<T>& assign ( const CImg< t > &  img,
const bool  is_shared 
)

In-place version of the advanced copy constructor.

In-place version of the constructor CImg(const CImg<t>&,bool).

Parameters:
img: Input image to copy.
is_shared: Desired shared state of the constructed copy.
See also:
assign(const CImg<t>&), CImg(const CImg<t>&,bool).
CImg<T>& assign ( const CImg< t > &  img,
const char *const  dimensions 
)

In-place version of a constructor.

In-place version of the constructor CImg(const CImg<t>&,const char*).

Parameters:
img: Input image from which dimensions are borrowed.
dimensions: String describing the image size along the X,Y,Z and V-dimensions.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(const CImg<t>&,const char*,T), CImg(const CImg<t>&,const char*).
CImg<T>& assign ( const CImg< t > &  img,
const char *const  dimensions,
const T  value 
)

In-place version of a constructor.

In-place version of the constructor CImg(const CImg<t>&,const char*,T).

Parameters:
img: Input image from which dimensions are borrowed.
dimensions: String describing the image size along the X,Y,Z and V-dimensions.
value: Value for initialization.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
assign(const CImg<t>&,const char*), CImg(const CImg<t>&,const char*,T).
CImg<T>& assign ( const CImgDisplay disp)

In-place version of a constructor.

In-place version of the constructor CImg(const CImgDisplay&).

Parameters:
disp: Input CImgDisplay.
Note:
  • It reinitializes the current image instance to a new constructed image instance.
See also:
CImg(const CImgDisplay&).
CImg<T>& clear ( )

In-place version of the default constructor.

Equivalent to assign().

Note:
  • It has been defined for compatibility with STL naming conventions.
See also:
assign().
CImg<t>& move_to ( CImg< t > &  img)

Transfer content of an image instance into another one.

Transfer the dimensions and the pixel buffer content of an image instance into another one, and replace instance by an empty image. It avoids the copy of the pixel buffer when possible.

Parameters:
img: Destination image.
Note:
  • Pixel types T and t of source and destination images can be different, though the process is designed to be instantaneous when T and t are the same.
Sample code :
       CImg<float> src(256,256,1,3,0), // Construct a 256x256x1x3 (color) image filled with value '0'.
                   dest(16,16);        // Construct a 16x16x1x1 (scalar) image.
       src.move_to(dest);              // Now, 'src' is empty and 'dest' is the 256x256x1x3 image.
See also:
move_to(CImgList<t>&,unsigned int), swap(CImg<T>&).
CImgList<t>& move_to ( CImgList< t > &  list,
const unsigned int  pos = ~0U 
)

Transfer content of an image instance into a new image in an image list.

Transfer the dimensions and the pixel buffer content of an image instance into a newly inserted image at position pos in specified CImgList<t> instance.

Parameters:
list: Destination list.
pos: Position of the newly inserted image in the list.
Note:
  • When optionnal parameter pos is ommited, the image instance is transfered as a new image at the end of the specified list.
  • It is convenient to sequentially insert new images into image lists, with no additional copies of memory buffer.
Sample code :
       CImgList<float> list;             // Construct an empty image list.
       CImg<float> img("reference.jpg"); // Read image from filename.
       img.move_to(list);                // Transfer image content as a new item in the list (no buffer copy).
See also:
move_to(CImg<t>&), swap(CImg<T>&).
CImg<T>& swap ( CImg< T > &  img)

Swap fields of two image instances.

Parameters:
img: Image to swap fields with.
Note:
  • It can be used to interchange the content of two images in a very fast way. Can be convenient when dealing with algorithms requiring two swapping buffers.
Sample code :
      CImg<float> img1("lena.jpg"),
                  img2("milla.jpg");
      img1.swap(img2);               // Now, 'img1' is 'milla' and 'img2' is 'lena'.
static CImg<T>& empty ( ) [static]

Get a reference to an empty image.

Note:
This function is useful mainly to declare optional parameters having type CImg<T> in functions prototypes, e.g.
       void f(const int x=0, const int y=0, const CImg<float>& img=CImg<float>::empty());
T& operator() ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  c = 0 
)

Access to a pixel value.

Return a reference to a located pixel value of the image instance, being possibly const, whether the image instance is const or not. This is the standard method to get/set pixel values in CImg<T> images.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
  • Range of pixel coordinates start from (0,0,0,0) to (width()-1,height()-1,depth()-1,spectrum()-1).
  • Due to the particular arrangement of the pixel buffers defined in CImg, you can omit one coordinate if the corresponding dimension is equal to 1. For instance, pixels of a 2d image (depth() equal to 1) can be accessed by img(x,y,c) instead of img(x,y,0,c).
Warning:
  • There is no boundary checking done in this operator, to make it as fast as possible. You must take care of out-of-bounds access by yourself, if necessary. For debuging purposes, you may want to define macro 'cimg_verbosity'>=3 to enable additional boundary checking operations in this operator. In that case, warning messages will be printed on the error output when accessing out-of-bounds pixels.
Sample code :
       CImg<float> img(100,100,1,3,0);                   // Construct a 100x100x1x3 (color) image with pixels set to '0'.
       const float
          valR = img(10,10,0,0),                         // Read red value at coordinates (10,10).
          valG = img(10,10,0,1),                         // Read green value at coordinates (10,10)
          valB = img(10,10,2),                           // Read blue value at coordinates (10,10) (Z-coordinate can be omitted).
          avg = (valR + valG + valB)/3;                  // Compute average pixel value.
       img(10,10,0) = img(10,10,1) = img(10,10,2) = avg; // Replace the color pixel (10,10) by the average grey value.
See also:
at(), atX(), atXY(), atXYZ(), atXYZC().
T& operator() ( const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const unsigned int  c,
const unsigned long  wh,
const unsigned long  whd = 0 
)

Access to a pixel value.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
wh: Precomputed offset, must be equal to width()*height().
whd: Precomputed offset, must be equal to width()*height()*depth().
Note:
  • Similar to (but faster than) operator()(). It uses precomputed offsets to optimize memory access. You may use it to optimize the reading/writing of several pixel values in the same image (e.g. in a loop).
See also:
operator()().
operator T * ( )

Implicitely cast an image into a T*.

Implicitely cast a CImg<T> instance into a T* or const T* pointer, whether the image instance is const or not. The returned pointer points on the first value of the image pixel buffer.

Note:
  • It simply returns the pointer data() to the pixel buffer.
  • This implicit conversion is convenient to test the empty state of images (data() being 0 in this case), e.g.
           CImg<float> img1(100,100), img2; // 'img1' is a 100x100 image, 'img2' is an empty image.
           if (img1) {                      // Test succeeds, 'img1' is not an empty image.
             if (!img2) {                   // Test succeeds, 'img2' is an empty image.
               std::printf("'img1' is not empty, 'img2' is empty.");
             }
           }
    
  • It also allows to use brackets to access pixel values, without need for a CImg<T>::operator[](), e.g.
           CImg<float> img(100,100);
           const float value = img[99]; // Access to value of the last pixel on the first line.
           img[510] = 255;              // Set pixel value at (10,5).
    
See also:
operator()().
CImg<T>& operator= ( const T  value)

Assign a value to all image pixels.

Assign specified value to each pixel value of the image instance.

Parameters:
value: Value that will be assigned to image pixels.
Note:
  • The image size is never modified.
  • The value may be casted to pixel type T if necessary.
Sample code
       CImg<char> img(100,100); // Declare image (with garbage values).
       img = 0;                 // Set all pixel values to '0'.
       img = 1.2;               // Set all pixel values to '1' (cast of '1.2' as a 'char').
See also:
fill(const T).
CImg<T>& operator= ( const char *const  expression)

Assign pixels values from a specified expression.

Initialize all pixel values from the specified string expression.

Parameters:
expression: Value string describing the way pixel values are set.
Note:
  • String parameter expression may describe different things :
    • If expression is a list of values (as in "1,2,3,8,3,2"), or a formula (as in "(x*y)%255"), the pixel values are set from specified expression and the image size is not modified.
    • If expression is a filename (as in "reference.jpg"), the corresponding image file is loaded and replace the image instance. The image size is modified if necessary.
Sample code :
       CImg<float> img1(100,100), img2(img1), img3(img1); // Declare three 100x100 scalar images with unitialized pixel values.
       img1 = "0,50,100,150,200,250,200,150,100,50";      // Set pixel values of 'img1' from a value sequence.
       img2 = "10*((x*y)%25)";                            // Set pixel values of 'img2' from a formula.
       img3 = "reference.jpg";                            // Set pixel values of 'img3' from a file (image size is modified).
       (img1,img2,img3).display();
ref_operator_eq.jpg
See also:
fill(const char*, bool), load(const char*).
CImg<T>& operator= ( const CImg< t > &  img)

Copy an image into the current image instance.

Similar to the in-place copy constructor assign(const CImg<t>&).

CImg<T>& operator= ( const CImgDisplay disp)

Copy the content of a display window to the current image instance.

Similar to assign(const CImgDisplay&).

CImg<T>& operator+= ( const t  value)

In-place addition operator.

Add specified value to all pixels of an image instance.

Parameters:
value: Value to add.
Note:
  • Resulting pixel values are casted to fit the pixel type T. For instance, adding 0.2 to a CImg<char> is possible but does nothing indeed.
  • Overflow values are treated as with standard C++ numeric types. For instance,
           CImg<unsigned char> img(100,100,1,1,255); // Construct a 100x100 image with pixel values '255'.
           img+=1;                                   // Add '1' to each pixels -> Overflow.
           // here all pixels of image 'img' are equal to '0'.
    
  • To prevent value overflow, you may want to consider pixel type T as float or double, and use cut() after addition.
Sample code :
       CImg<unsigned char> img1("reference.jpg");          // Load a 8-bits RGB image (values in [0,255]).
       CImg<float> img2(img1);                             // Construct a float-valued copy of 'img1'.
       img2+=100;                                          // Add '100' to pixel values -> goes out of [0,255] but no problems with floats.
       img2.cut(0,255);                                    // Cut values in [0,255] to fit the 'unsigned char' constraint.
       img1 = img2;                                        // Rewrite safe result in 'unsigned char' version 'img1'.
       const CImg<unsigned char> img3 = (img1 + 100).cut(0,255); // Do the same in a more simple and elegant way.
       (img1,img2,img3).display();
ref_operator_plus.jpg
See also:
operator+(const t) const, operator-=(const t), operator*=(const t), operator/=(const t), operator%=(const t), operator&=(const t), operator|=(const t), operator^=(const t), operator<<=(const t), operator>>=(const t).
CImg<T>& operator+= ( const char *const  expression)

In-place addition operator.

Add values to image pixels, according to the specified string expression.

Parameters:
expression: Value string describing the way pixel values are added.
Note:
  • Similar to operator=(const char*), except that it adds values to the pixels of the current image instance, instead of assigning them.
See also:
operator+=(const t), operator=(const char*), operator+(const char*) const, operator-=(const char*), operator*=(const char*), operator/=(const char*), operator%=(const char*), operator&=(const char*), operator|=(const char*), operator^=(const char*), operator<<=(const char*), operator>>=(const char*).
CImg<T>& operator+= ( const CImg< t > &  img)

In-place addition operator.

Add values to image pixels, according to the values of the input image img.

Parameters:
img: Input image to add.
Note:
  • The size of the image instance is never modified.
  • It is not mandatory that input image img has the same size as the image instance. If less values are available in img, then the values are added cyclically. For instance, adding one WxH scalar image (spectrum() equal to 1) to one WxH color image (spectrum() equal to 3) means each color channel will be incremented with the same values at the same locations.
Sample code :
       CImg<float> img1("reference.jpg");                                   // Load a RGB color image (img1.spectrum()==3)
       const CImg<float> img2(img1.width(),img.height(),1,1,"255*(x/w)^2"); // Construct a scalar shading (img2.spectrum()==1).
       img1+=img2;                                                          // Add shading to each channel of 'img1'.
       img1.cut(0,255);                                                     // Prevent [0,255] overflow.
       (img2,img1).display();
ref_operator_plus1.jpg
See also:
operator+(const CImg<t>&) const, operator=(const CImg<t>&), operator-=(const CImg<t>&), operator*=(const CImg<t>&), operator/=(const CImg<t>&), operator%=(const CImg<t>&), operator&=(const CImg<t>&), operator|=(const CImg<t>&), operator^=(const CImg<t>&), operator<<=(const CImg<t>&), operator>>=(const CImg<t>&).
CImg<T>& operator++ ( )

In-place increment operator (prefix).

Add 1 to all image pixels, and return a reference to the current incremented image instance.

Note:
  • Writing ++img is equivalent to img+=1.
See also:
operator++(int), operator--().
CImg<T> operator++ ( int  )

In-place increment operator (postfix).

Add 1 to all image pixels, and return a new copy of the initial (pre-incremented) image instance.

Note:
  • Use the prefixed version operator++() if you don't need a copy of the initial (pre-incremented) image instance, since a useless image copy may be expensive in terms of memory usage.
See also:
operator++(), operator--(int).
CImg<T> operator+ ( ) const

Get a non-shared copy of the image instance.

Note:
  • Use this operator to ensure you get a non-shared copy of an image instance with same pixel type T. Indeed, the usual copy constructor CImg<T>(const CImg<T>&) returns a shared copy of a shared input image, and it may be not desirable to work on a regular copy (e.g. for a resize operation) if you have no informations about the shared state of the input image.
  • Writing (+img) is equivalent to CImg<T>(img,false).
See also:
CImg(const CImg<T>&), CImg(const CImg<T>&,bool), operator-() const, operator~() const.
CImg< typename cimg::superset<T,t>::type > operator+ ( const t  value) const

Addition operator.

Similar to operator+=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<Tfloat> operator+ ( const char *const  expression) const

Addition operator.

Similar to operator+=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg< typename cimg::superset<T,t>::type > operator+ ( const CImg< t > &  img) const

Addition operator.

Similar to operator+=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<T>& operator-= ( const t  value)

In-place substraction operator.

Similar to operator+=(const t), except that it performs a substraction instead of an addition.

CImg<T>& operator-= ( const char *const  expression)

In-place substraction operator.

Similar to operator+=(const char*), except that it performs a substraction instead of an addition.

CImg<T>& operator-= ( const CImg< t > &  img)

In-place substraction operator.

Similar to operator+=(const CImg<t>&), except that it performs a substraction instead of an addition.

CImg<T>& operator-- ( )

In-place decrement operator (prefix).

Similar to operator++(), except that it performs a decrement instead of an increment.

CImg<T> operator-- ( int  )

In-place decrement operator (postfix).

Similar to operator++(int), except that it performs a decrement instead of an increment.

CImg<T> operator- ( ) const

Replace each pixel by its opposite value.

Note:
  • If the computed opposite values are out-of-range, they are treated as with standard C++ numeric types. For instance, the unsigned char opposite of 1 is 255.
Sample code :
       const CImg<unsigned char>
         img1("reference.jpg"),   // Load a RGB color image.
         img2 = -img1;            // Compute its opposite (in 'unsigned char').
       (img1,img2).display();
ref_operator_minus.jpg
See also:
operator+(), operator~().
CImg< typename cimg::superset<T,t>::type > operator- ( const t  value) const

Substraction operator.

Similar to operator-=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<Tfloat> operator- ( const char *const  expression) const

Substraction operator.

Similar to operator-=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg< typename cimg::superset<T,t>::type > operator- ( const CImg< t > &  img) const

Substraction operator.

Similar to operator-=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<T>& operator*= ( const t  value)

In-place multiplication operator.

Similar to operator+=(const t), except that it performs a multiplication instead of an addition.

CImg<T>& operator*= ( const char *const  expression)

In-place multiplication operator.

Similar to operator+=(const char*), except that it performs a multiplication instead of an addition.

CImg<T>& operator*= ( const CImg< t > &  img)

In-place multiplication operator.

Replace the image instance by the matrix multiplication between the image instance and the specified matrix img.

Parameters:
img: Second operand of the matrix multiplication.
Note:
  • It does not compute a pointwise multiplication between two images. For this purpose, use mul(const CImg<t>&) instead.
  • The size of the image instance can be modified by this operator.
Sample code :
       CImg<float> A(2,2,1,1, 1,2,3,4);   // Construct 2x2 matrix A = [1,2;3,4].
       const CImg<float> X(1,2,1,1, 1,2); // Construct 1x2 vector X = [1;2].
       A*=X;                              // Assign matrix multiplication A*X to 'A'.
       // 'A' is now a 1x2 vector whose values are [5;11].
See also:
operator*(const CImg<t>&) const, mul().
CImg< typename cimg::superset<T,t>::type > operator* ( const t  value) const

Multiplication operator.

Similar to operator*=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<Tfloat> operator* ( const char *const  expression) const

Multiplication operator.

Similar to operator*=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg< typename cimg::superset<T,t>::type > operator* ( const CImg< t > &  img) const

Multiplication operator.

Similar to operator*=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<T>& operator/= ( const t  value)

In-place division operator.

Similar to operator+=(const t), except that it performs a division instead of an addition.

CImg<T>& operator/= ( const char *const  expression)

In-place division operator.

Similar to operator+=(const char*), except that it performs a division instead of an addition.

CImg<T>& operator/= ( const CImg< t > &  img)

In-place division operator.

Replace the image instance by the (right) matrix division between the image instance and the specified matrix img.

Parameters:
img: Second operand of the matrix division.
Note:
  • It does not compute a pointwise division between two images. For this purpose, use div(const CImg<t>&) instead.
  • It returns the matrix operation A*inverse(img).
  • The size of the image instance can be modified by this operator.
See also:
operator/(const CImg<t>&) const, operator*(const CImg<t>&) const, div().
CImg< typename cimg::superset<T,t>::type > operator/ ( const t  value) const

Division operator.

Similar to operator/=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<Tfloat> operator/ ( const char *const  expression) const

Division operator.

Similar to operator/=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg< typename cimg::superset<T,t>::type > operator/ ( const CImg< t > &  img) const

Division operator.

Similar to operator/=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<T>& operator%= ( const t  value)

In-place modulo operator.

Similar to operator+=(const t), except that it performs a modulo operation instead of an addition.

CImg<T>& operator%= ( const char *const  expression)

In-place modulo operator.

Similar to operator+=(const char*), except that it performs a modulo operation instead of an addition.

CImg<T>& operator%= ( const CImg< t > &  img)

In-place modulo operator.

Similar to operator+=(const CImg<t>&), except that it performs a modulo operation instead of an addition.

CImg< typename cimg::superset<T,t>::type > operator% ( const t  value) const

Modulo operator.

Similar to operator%=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<Tfloat> operator% ( const char *const  expression) const

Modulo operator.

Similar to operator%=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg< typename cimg::superset<T,t>::type > operator% ( const CImg< t > &  img) const

Modulo operator.

Similar to operator%=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image may be a superset of the initial pixel type T, if necessary.

CImg<T>& operator&= ( const t  value)

In-place bitwise AND operator.

Similar to operator+=(const t), except that it performs a bitwise AND operation instead of an addition.

CImg<T>& operator&= ( const char *const  expression)

In-place bitwise AND operator.

Similar to operator+=(const char*), except that it performs a bitwise AND operation instead of an addition.

CImg<T>& operator&= ( const CImg< t > &  img)

In-place bitwise AND operator.

Similar to operator+=(const CImg<t>&), except that it performs a bitwise AND operation instead of an addition.

CImg<T> operator& ( const t  value) const

Bitwise AND operator.

Similar to operator&=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator& ( const char *const  expression) const

Bitwise AND operator.

Similar to operator&=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator& ( const CImg< t > &  img) const

Bitwise AND operator.

Similar to operator&=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T>& operator|= ( const t  value)

In-place bitwise OR operator.

Similar to operator+=(const t), except that it performs a bitwise OR operation instead of an addition.

CImg<T>& operator|= ( const char *const  expression)

In-place bitwise OR operator.

Similar to operator+=(const char*), except that it performs a bitwise OR operation instead of an addition.

CImg<T>& operator|= ( const CImg< t > &  img)

In-place bitwise OR operator.

Similar to operator+=(const CImg<t>&), except that it performs a bitwise OR operation instead of an addition.

CImg<T> operator| ( const t  value) const

Bitwise OR operator.

Similar to operator|=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator| ( const char *const  expression) const

Bitwise OR operator.

Similar to operator|=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator| ( const CImg< t > &  img) const

Bitwise OR operator.

Similar to operator|=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T>& operator^= ( const t  value)

In-place bitwise XOR operator.

Similar to operator+=(const t), except that it performs a bitwise XOR operation instead of an addition.

Warning:
  • It does not compute the power of pixel values. For this purpose, use pow(const t) instead.
CImg<T>& operator^= ( const char *const  expression)

In-place bitwise XOR operator.

Similar to operator+=(const char*), except that it performs a bitwise XOR operation instead of an addition.

Warning:
  • It does not compute the power of pixel values. For this purpose, use pow(const char*) instead.
CImg<T>& operator^= ( const CImg< t > &  img)

In-place bitwise XOR operator.

Similar to operator+=(const CImg<t>&), except that it performs a bitwise XOR operation instead of an addition.

Warning:
  • It does not compute the power of pixel values. For this purpose, use pow(const CImg<t>&) instead.
CImg<T> operator^ ( const t  value) const

Bitwise XOR operator.

Similar to operator^=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator^ ( const char *const  expression) const

Bitwise XOR operator.

Similar to operator^=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator^ ( const CImg< t > &  img) const

Bitwise XOR operator.

Similar to operator^=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T>& operator<<= ( const t  value)

In-place bitwise left shift operator.

Similar to operator+=(const t), except that it performs a bitwise left shift instead of an addition.

CImg<T>& operator<<= ( const char *const  expression)

In-place bitwise left shift operator.

Similar to operator+=(const char*), except that it performs a bitwise left shift instead of an addition.

CImg<T>& operator<<= ( const CImg< t > &  img)

In-place bitwise left shift operator.

Similar to operator+=(const CImg<t>&), except that it performs a bitwise left shift instead of an addition.

CImg<T> operator<< ( const t  value) const

Bitwise left shift operator.

Similar to operator<<=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator<< ( const char *const  expression) const

Bitwise left shift operator.

Similar to operator<<=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator<< ( const CImg< t > &  img) const

Bitwise left shift operator.

Similar to operator<<=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T>& operator>>= ( const t  value)

In-place bitwise right shift operator.

Similar to operator+=(const t), except that it performs a bitwise right shift instead of an addition.

CImg<T>& operator>>= ( const char *const  expression)

In-place bitwise right shift operator.

Similar to operator+=(const char*), except that it performs a bitwise right shift instead of an addition.

CImg<T>& operator>>= ( const CImg< t > &  img)

In-place bitwise right shift operator.

Similar to operator+=(const CImg<t>&), except that it performs a bitwise right shift instead of an addition.

CImg<T> operator>> ( const t  value) const

Bitwise right shift operator.

Similar to operator>>=(const t), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator>> ( const char *const  expression) const

Bitwise right shift operator.

Similar to operator>>=(const char*), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator>> ( const CImg< t > &  img) const

Bitwise right shift operator.

Similar to operator>>=(const CImg<t>&), except that it returns a new image instance instead of operating in-place. The pixel type of the returned image is T.

CImg<T> operator~ ( ) const

Bitwise inversion operator.

Similar to operator-(), except that it compute the bitwise inverse instead of the opposite value.

bool operator== ( const CImg< t > &  img) const

Test if two images have the same size and values.

Return true if the image instance and the input image img have the same dimensions and pixel values, and false otherwise.

Parameters:
img: input image to compare with.
Note:
  • The pixel buffer pointers data() of the two compared images do not have to be the same for operator==() to return true. Only the dimensions and the pixel values matter. Thus, the comparison can be true even for different pixel types T and t.
Sample code :
       const CImg<float> img1(1,3,1,1, 0,1,2); // Construct a 1x3 vector [0;1;2] (with 'float' pixel values).
       const CImg<char> img2(1,3,1,1, 0,1,2);  // Construct a 1x3 vector [0;1;2] (with 'char' pixel values).
       if (img1==img2) {                       // Test succeeds, image dimensions and values are the same.
         std::printf("'img1' and 'img2' have same dimensions and values.");
       }
See also:
operator!=().
bool operator!= ( const CImg< t > &  img) const

Test if two images have different sizes or values.

Return true if the image instance and the input image img have different dimensions or pixel values, and false otherwise.

Parameters:
img: input image to compare with.
Note:
  • Writing img1!=img2 is equivalent to !(img1==img2).
See also:
operator==().
CImgList< typename cimg::superset<T,t>::type > operator, ( const CImg< t > &  img) const

Construct an image list from two images.

Return a new list of image (CImgList instance) containing exactly two elements :

  • A copy of the image instance, at position [0].
  • A copy of the specified image img, at position [1].
Parameters:
img: Input image that will be the second image of the resulting list.
Note:
  • The family of operator,() is convenient to easily create list of images, but it is also quite slow in practice (see warning below).
  • Constructed lists contain no shared images. If image instance or input image img are shared, they are inserted as new non-shared copies in the resulting list.
  • The pixel type of the returned list may be a superset of the initial pixel type T, if necessary.
Warning:
Sample code :
       const CImg<float>
          img1("reference.jpg"),
          img2 = img1.get_mirror('x'),
          img3 = img2.get_blur(5);
       const CImgList<float> list = (img1,img2); // Create list of two elements from 'img1' and 'img2'.
       (list,img3).display();                    // Display image list containing copies of 'img1','img2' and 'img3'.
ref_operator_comma.jpg
See also:
operator,(const CImgList<t>&) const, move_to(CImgList<t>&,unsigned int). CImgList<T>::insert(const CImg<t>&,unsigned int,bool).
CImgList< typename cimg::superset<T,t>::type > operator, ( const CImgList< t > &  list) const

Construct an image list from image instance and an input image list.

Return a new list of images (CImgList instance) containing exactly list.size() + 1 elements :

  • A copy of the image instance, at position [0].
  • A copy of the specified image list list, from positions [1] to [list.size()].
Parameters:
list: Input image list that will be appended to the image instance.
Note:
See also:
operator,(const CImg<t>&) const, CImgList<T>::insert(const CImgList<t>&,unsigned int,bool).
CImgList<T> operator< ( const char  axis) const

Split image along specified axis.

Return a new list of images (CImgList instance) containing the splitted components of the instance image along the specified axis.

Parameters:
axis: Splitting axis (can be 'x','y','z' or 'c')
Note:
Sample code :
       const CImg<unsigned char> img("reference.jpg"); // Load a RGB color image.
       const CImgList<unsigned char> list = (img<'c'); // Get a list of its three R,G,B channels.
       (img,list).display();
ref_operator_less.jpg
See also:
get_split(char,int) const.
static const char* pixel_type ( ) [static]

Get the type of image pixel values as a C string.

Return a char* string containing the usual type name of the image pixel values (i.e. a stringified version of the template parameter T).

Note:
  • The returned string may contain spaces (as in "unsigned char").
  • If the pixel type T does not correspond to a registered type, the string "unknown" is returned.
See also:
value_type.
int width ( ) const

Get the number of image columns.

Return the image width, i.e. the image dimension along the X-axis.

Note:
  • The width() of an empty image is equal to 0.
  • width() is typically equal to 1 when considering images as vectors for matrix calculations.
  • width() returns an int, although the image width is internally stored as an unsigned int. Using an int is safer and prevents arithmetic traps possibly encountered when doing calculations involving unsigned int variables. Access to the initial unsigned int variable is possible (though not recommended) by (*this)._width.
See also:
height(), depth(), spectrum(), size().
int height ( ) const

Get the number of image rows.

Return the image height, i.e. the image dimension along the Y-axis.

Note:
  • The height() of an empty image is equal to 0.
  • height() returns an int, although the image height is internally stored as an unsigned int. Using an int is safer and prevents arithmetic traps possibly encountered when doing calculations involving unsigned int variables. Access to the initial unsigned int variable is possible (though not recommended) by (*this)._height.
See also:
width(), depth(), spectrum(), size().
int depth ( ) const

Get the number of image slices.

Return the image depth, i.e. the image dimension along the Z-axis.

Note:
  • The depth() of an empty image is equal to 0.
  • depth() is typically equal to 1 when considering usual 2d images. When depth()> 1, the image is said to be volumetric.
  • depth() returns an int, although the image depth is internally stored as an unsigned int. Using an int is safer and prevents arithmetic traps possibly encountered when doing calculations involving unsigned int variables. Access to the initial unsigned int variable is possible (though not recommended) by (*this)._depth.
See also:
width(), height(), spectrum(), size().
int spectrum ( ) const

Get the number of image channels.

Return the number of image channels, i.e. the image dimension along the C-axis.

Note:
  • The spectrum() of an empty image is equal to 0.
  • spectrum() is typically equal to 1 when considering scalar-valued images, to 3 for RGB-coded color images, and to 4 for RGBA-coded color images (with alpha-channel). The number of channels of an image instance is not limited. The meaning of the pixel values is not linked up to the number of channels (e.g. a 4-channel image may indifferently stands for a RGBA or CMYK color image).
  • spectrum() returns an int, although the image spectrum is internally stored as an unsigned int. Using an int is safer and prevents arithmetic traps possibly encountered when doing calculations involving unsigned int variables. Access to the initial unsigned int variable is possible (though not recommended) by (*this)._spectrum.
See also:
width(), height(), depth(), size().
unsigned int size ( ) const

Get the total number of pixel values.

Return width()*height()*depth()*spectrum(), i.e. the total number of values of type T in the pixel buffer of the image instance.

Note:
  • The size() of an empty image is equal to 0.
  • The allocated memory size for a pixel buffer of a non-shared CImg<T> instance is equal to size()*sizeof(T).
Sample code :
       const CImg<float> img(100,100,1,3);               // Construct new 100x100 color image.
       if (img.size()==30000)                            // Test succeeds.
         std::printf("Pixel buffer uses %lu bytes",
                     img.size()*sizeof(float));
See also:
width(), height(), depth(), spectrum().
T* data ( )

Get a pointer to the first pixel value.

Return a T*, or a const T* pointer to the first value in the pixel buffer of the image instance, whether the instance is const or not.

Note:
See also:
operator T*() const, data(unsigned int,unsigned int,unsigned int,unsigned int).
T* data ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  c = 0 
)

Get a pointer to a located pixel value.

Return a T*, or a const T* pointer to the value located at (x,y,z,c) in the pixel buffer of the image instance, whether the instance is const or not.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
See also:
operator()(unsigned int,unsigned int,unsigned int,unsigned int), data().
int offset ( const int  x,
const int  y = 0,
const int  z = 0,
const int  c = 0 
) const

Get the offset to a located pixel value, with respect to the beginning of the pixel buffer.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
Sample code :
       const CImg<float> img(100,100,1,3);      // Define a 100x100 RGB-color image.
       const long off = img.offset(10,10,0,2);  // Get the offset of the blue value of the pixel located at (10,10).
       const float val = img[off];              // Get the blue value of this pixel.
See also:
operator()(unsigned int,unsigned int,unsigned int,unsigned int), data(unsigned int,unsigned int,unsigned int,unsigned int).
iterator begin ( )

Get a CImg<T>::iterator pointing to the first pixel value.

Note:
  • Equivalent to data().
  • It has been mainly defined for compatibility with STL naming conventions.
See also:
data().
iterator end ( )

Get a CImg<T>::iterator pointing next to the last pixel value.

Note:
  • Writing img.end() is equivalent to img.data() + img.size().
  • It has been mainly defined for compatibility with STL naming conventions.
Warning:
  • The returned iterator actually points to a value located outside the acceptable bounds of the pixel buffer. Trying to read or write the content of the returned iterator will probably result in a crash. Use it mainly as an strict upper bound for a CImg<T>::iterator.
Sample code :
       CImg<float> img(100,100,1,3);                                     // Define a 100x100 RGB color image.
       for (CImg<float>::iterator it = img.begin(); it<img.end(); ++it)  // 'img.end()' used here as an upper bound for the iterator.
         *it = 0;
See also:
data().
T& front ( )

Get a reference to the first pixel value.

Note:
  • Writing img.front() is equivalent to img[0], or img(0,0,0,0).
  • It has been mainly defined for compatibility with STL naming conventions.
See also:
data(), offset(), begin().
T& back ( )

Get a reference to the last pixel value.

Note:
  • Writing img.end() is equivalent to img[img.size()-1], or img(img.width()-1,img.height()-1,img.depth()-1,img.spectrum()-1).
  • It has been mainly defined for compatibility with STL naming conventions.
See also:
data(), offset(), end().
T& at ( const int  offset,
const T  out_value 
)

Access to a pixel value at a specified offset, using Dirichlet boundary conditions.

Return a reference to the pixel value of the image instance located at a specified offset, or to a specified default value in case of out-of-bounds access.

Parameters:
offset: Offset to the desired pixel value.
out_value: Default value returned if offset is outside image bounds.
Note:
  • Writing img.at(offset,out_value) is similar to img[offset], except that if offset is outside bounds (e.g. offset<0 or offset>=img.size()), a reference to a value out_value is safely returned instead.
  • Due to the additional boundary checking operation, this method is slower than operator()(). Use it when you are not sure about the validity of the specified pixel offset.
See also:
operator()(), offset(), at(int).
T& at ( const int  offset)

Access to a pixel value at a specified offset, using Neumann boundary conditions.

Return a reference to the pixel value of the image instance located at a specified offset, or to the nearest pixel location in the image instance in case of out-of-bounds access.

Parameters:
offset: Offset to the desired pixel value.
Note:
  • Similar to at(int,const T), except that an out-of-bounds access returns the value of the nearest pixel in the image instance, regarding the specified offset, i.e.
    • If offset<0, then img[0] is returned.
    • If offset>=img.size(), then img[img.size()-1] is returned.
  • Due to the additional boundary checking operation, this method is slower than operator()(). Use it when you are not sure about the validity of the specified pixel offset.
  • If you know your image instance is not empty, you may rather use the slightly faster method _at(int).
See also:
operator()(), offset(), at(int,const T).
T& atX ( const int  x,
const int  y,
const int  z,
const int  c,
const T  out_value 
)

Access to a pixel value, using Dirichlet boundary conditions for the X-coordinate.

Return a reference to the pixel value of the image instance located at (x,y,z,c), or to a specified default value in case of out-of-bounds access along the X-axis.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
out_value: Default value returned if (x,y,z,c) is outside image bounds.
Note:
  • Similar to operator()(), except that an out-of-bounds access along the X-axis returns the specified value out_value.
  • Due to the additional boundary checking operation, this method is slower than operator()(). Use it when you are not sure about the validity of the specified pixel coordinates.
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), at(int,const T). atX(int,int,int,int), atXY(int,int,int,int,const T), atXYZ(int,int,int,int,const T), atXYZC(int,int,int,int,const T).
T& atX ( const int  x,
const int  y = 0,
const int  z = 0,
const int  c = 0 
)

Access to a pixel value, using Neumann boundary conditions for the X-coordinate.

Return a reference to the pixel value of the image instance located at (x,y,z,c), or to the nearest pixel location in the image instance in case of out-of-bounds access along the X-axis.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
  • Similar to at(int,int,int,int,const T), except that an out-of-bounds access returns the value of the nearest pixel in the image instance, regarding the specified X-coordinate.
  • Due to the additional boundary checking operation, this method is slower than operator()(). Use it when you are not sure about the validity of the specified pixel coordinates.
  • If you know your image instance is not empty, you may rather use the slightly faster method _at(int,int,int,int).
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), at(int), atX(int,int,int,int,const T), atXY(int,int,int,int), atXYZ(int,int,int,int), atXYZC(int,int,int,int).
T& atXY ( const int  x,
const int  y,
const int  z,
const int  c,
const T  out_value 
)

Access to a pixel value, using Dirichlet boundary conditions for the X and Y-coordinates.

Similar to atX(int,int,int,int,const T), except that boundary checking is performed both on X and Y-coordinates.

T& atXY ( const int  x,
const int  y,
const int  z = 0,
const int  c = 0 
)

Access to a pixel value, using Neumann boundary conditions for the X and Y-coordinates.

Similar to atX(int,int,int,int), except that boundary checking is performed both on X and Y-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _atXY(int,int,int,int).
T& atXYZ ( const int  x,
const int  y,
const int  z,
const int  c,
const T  out_value 
)

Access to a pixel value, using Dirichlet boundary conditions for the X,Y and Z-coordinates.

Similar to atX(int,int,int,int,const T), except that boundary checking is performed both on X,Y and Z-coordinates.

T& atXYZ ( const int  x,
const int  y,
const int  z,
const int  c = 0 
)

Access to a pixel value, using Neumann boundary conditions for the X,Y and Z-coordinates.

Similar to atX(int,int,int,int), except that boundary checking is performed both on X,Y and Z-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _atXYZ(int,int,int,int).
T& atXYZC ( const int  x,
const int  y,
const int  z,
const int  c,
const T  out_value 
)

Access to a pixel value, using Dirichlet boundary conditions.

Similar to atX(int,int,int,int,const T), except that boundary checking is performed on all X,Y,Z and C-coordinates.

T& atXYZC ( const int  x,
const int  y,
const int  z,
const int  c 
)

Access to a pixel value, using Neumann boundary conditions.

Similar to atX(int,int,int,int), except that boundary checking is performed on all X,Y,Z and C-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _atXYZC(int,int,int,int).
Tfloat linear_atX ( const float  fx,
const int  y,
const int  z,
const int  c,
const T  out_value 
) const

Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X-coordinate.

Return a linearly-interpolated pixel value of the image instance located at (fx,y,z,c), or a specified default value in case of out-of-bounds access along the X-axis.

Parameters:
fx: X-coordinate of the pixel value (float-valued).
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
out_value: Default value returned if (fx,y,z,c) is outside image bounds.
Note:
  • Similar to atX(int,int,int,int,const T), except that the returned pixel value is approximated by a linear interpolation along the X-axis, if corresponding coordinates are not integers.
  • The type of the returned pixel value is extended to float, if the pixel type T is not float-valued.
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), atX(int,int,int,int,const T), linear_atX(float,int,int,int) const, linear_atXY(float,float,int,int,const T) const, linear_atXYZ(float,float,float,int,const T) const, linear_atXYZC(float,float,float,float,const T) const.
Tfloat linear_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  c = 0 
) const

Get pixel value, using linear interpolation and Neumann boundary conditions for the X-coordinate.

Return a linearly-interpolated pixel value of the image instance located at (fx,y,z,c), or the value of the nearest pixel location in the image instance in case of out-of-bounds access along the X-axis.

Parameters:
fx: X-coordinate of the pixel value (float-valued).
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
  • Similar to linear_atX(float,int,int,int,const T) const, except that an out-of-bounds access returns the value of the nearest pixel in the image instance, regarding the specified X-coordinate.
  • If you know your image instance is not empty, you may rather use the slightly faster method _linear_atX(float,int,int,int).
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), atX(int,int,int,int), linear_atX(float,int,int,int,const T) const, linear_atXY(float,float,int,int) const, linear_atXYZ(float,float,float,int) const, linear_atXYZC(float,float,float,float) const.
Tfloat linear_atXY ( const float  fx,
const float  fy,
const int  z,
const int  c,
const T  out_value 
) const

Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X and Y-coordinates.

Similar to linear_atX(float,int,int,int,const T) const, except that the linear interpolation and the boundary checking are achieved both for X and Y-coordinates.

Tfloat linear_atXY ( const float  fx,
const float  fy,
const int  z = 0,
const int  c = 0 
) const

Get pixel value, using linear interpolation and Neumann boundary conditions for the X and Y-coordinates.

Similar to linear_atX(float,int,int,int) const, except that the linear interpolation and the boundary checking are achieved both for X and Y-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _linear_atXY(float,float,int,int).
Tfloat linear_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  c,
const T  out_value 
) const

Get pixel value, using linear interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.

Similar to linear_atX(float,int,int,int,const T) const, except that the linear interpolation and the boundary checking are achieved both for X,Y and Z-coordinates.

Tfloat linear_atXYZ ( const float  fx,
const float  fy = 0,
const float  fz = 0,
const int  c = 0 
) const

Get pixel value, using linear interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.

Similar to linear_atX(float,int,int,int) const, except that the linear interpolation and the boundary checking are achieved both for X,Y and Z-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _linear_atXYZ(float,float,float,int).
Tfloat linear_atXYZC ( const float  fx,
const float  fy,
const float  fz,
const float  fc,
const T  out_value 
) const

Get pixel value, using linear interpolation and Dirichlet boundary conditions for all X,Y,Z and C-coordinates.

Similar to linear_atX(float,int,int,int,const T) const, except that the linear interpolation and the boundary checking are achieved for all X,Y,Z and C-coordinates.

Tfloat linear_atXYZC ( const float  fx,
const float  fy = 0,
const float  fz = 0,
const float  fc = 0 
) const

Get pixel value, using linear interpolation and Neumann boundary conditions for all X,Y,Z and C-coordinates.

Similar to linear_atX(float,int,int,int) const, except that the linear interpolation and the boundary checking are achieved for all X,Y,Z and C-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _linear_atXYZC(float,float,float,float).
Tfloat cubic_atX ( const float  fx,
const int  y,
const int  z,
const int  c,
const T  out_value 
) const

Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X-coordinate.

Return a cubicly-interpolated pixel value of the image instance located at (fx,y,z,c), or a specified default value in case of out-of-bounds access along the X-axis.

Parameters:
fx: X-coordinate of the pixel value (float-valued).
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
out_value: Default value returned if (fx,y,z,c) is outside image bounds.
Note:
  • Similar to linear_atX(float,int,int,int,const T) const, except that the returned pixel value is approximated by a cubic interpolation along the X-axis.
  • The type of the returned pixel value is extended to float, if the pixel type T is not float-valued.
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), atX(int,int,int,int,const T), linear_atX(float,int,int,int,const T) const, cubic_atX(float,int,int,int) const, cubic_atXY(float,float,int,int,const T) const, cubic_atXYZ(float,float,float,int,const T) const.
Tfloat cubic_atX ( const float  fx,
const int  y,
const int  z,
const int  c,
const T  out_value,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X-coordinate.

Similar to cubic_atX(float,int,int,int,const T) const, except that you can specify the authorized minimum and maximum of the returned value.

Tfloat cubic_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  c = 0 
) const

Get pixel value, using cubic interpolation and Neumann boundary conditions for the X-coordinate.

Return a cubicly-interpolated pixel value of the image instance located at (fx,y,z,c), or the value of the nearest pixel location in the image instance in case of out-of-bounds access along the X-axis.

Parameters:
fx: X-coordinate of the pixel value (float-valued).
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
  • Similar to cubic_atX(float,int,int,int,const T) const, except that the returned pixel value is approximated by a cubic interpolation along the X-axis.
  • If you know your image instance is not empty, you may rather use the slightly faster method _cubic_atX(float,int,int,int).
Warning:
  • There is no boundary checking performed for the Y,Z and C-coordinates, so they must be inside image bounds.
See also:
operator()(), atX(int,int,int,int), linear_atX(float,int,int,int) const, cubic_atX(float,int,int,int,const T) const, cubic_atXY(float,float,int,int) const, cubic_atXYZ(float,float,float,int) const.
Tfloat cubic_atX ( const float  fx,
const int  y,
const int  z,
const int  c,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X-coordinate.

Similar to cubic_atX(float,int,int,int) const, except that you can specify the authorized minimum and maximum of the returned value.

Tfloat cubic_atXY ( const float  fx,
const float  fy,
const int  z,
const int  c,
const T  out_value 
) const

Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X and Y-coordinates.

Similar to cubic_atX(float,int,int,int,const T) const, except that the cubic interpolation and boundary checking are achieved both for X and Y-coordinates.

Tfloat cubic_atXY ( const float  fx,
const float  fy,
const int  z,
const int  c,
const T  out_value,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X and Y-coordinates.

Similar to cubic_atXY(float,float,int,int,const T) const, except that you can specify the authorized minimum and maximum of the returned value.

Tfloat cubic_atXY ( const float  fx,
const float  fy,
const int  z = 0,
const int  c = 0 
) const

Get pixel value, using cubic interpolation and Neumann boundary conditions for the X and Y-coordinates.

Similar to cubic_atX(float,int,int,int) const, except that the cubic interpolation and boundary checking are achieved for both X and Y-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _cubic_atXY(float,float,int,int).
Tfloat cubic_atXY ( const float  fx,
const float  fy,
const int  z,
const int  c,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X and Y-coordinates.

Similar to cubic_atXY(float,float,int,int) const, except that you can specify the authorized minimum and maximum of the returned value.

Tfloat cubic_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  c,
const T  out_value 
) const

Get pixel value, using cubic interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.

Similar to cubic_atX(float,int,int,int,const T) const, except that the cubic interpolation and boundary checking are achieved both for X,Y and Z-coordinates.

Tfloat cubic_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  c,
const T  out_value,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Dirichlet boundary conditions for the X,Y and Z-coordinates.

Similar to cubic_atXYZ(float,float,float,int,const T) const, except that you can specify the authorized minimum and maximum of the returned value.

Tfloat cubic_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  c = 0 
) const

Get pixel value, using cubic interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.

Similar to cubic_atX(float,int,int,int) const, except that the cubic interpolation and boundary checking are achieved both for X,Y and Z-coordinates.

Note:
  • If you know your image instance is not empty, you may rather use the slightly faster method _cubic_atXYZ(float,float,float,int).
Tfloat cubic_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  c,
const Tfloat  min_value,
const Tfloat  max_value 
) const

Get damped pixel value, using cubic interpolation and Neumann boundary conditions for the X,Y and Z-coordinates.

Similar to cubic_atXYZ(float,float,float,int) const, except that you can specify the authorized minimum and maximum of the returned value.

CImg<T>& set_linear_atXY ( const T &  value,
const float  fx,
const float  fy = 0,
const int  z = 0,
const int  c = 0,
const bool  is_added = false 
)

Set pixel value, using linear interpolation for the X and Y-coordinates.

Set pixel value at specified coordinates (fx,fy,z,c) in the image instance, in a way that the value is spread amongst several neighbors if the pixel coordinates are indeed float-valued.

Parameters:
value: Pixel value to set.
fx: X-coordinate of the pixel value (float-valued).
fy: Y-coordinate of the pixel value (float-valued).
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
is_added: Boolean telling if the pixel value is added to (true), or simply replace (false) the current image pixel(s).
Returns:
A reference to the current image instance.
Note:
  • If specified coordinates are outside image bounds, no operations are performed.
See also:
linear_atXY(), set_linear_atXYZ().
CImg<T>& set_linear_atXYZ ( const T &  value,
const float  fx,
const float  fy = 0,
const float  fz = 0,
const int  c = 0,
const bool  is_added = false 
)

Set pixel value, using linear interpolation for the X,Y and Z-coordinates.

Similar to set_linear_atXY(const T&,float,float,int,int,bool), except that the linear interpolation is achieved both for X,Y and Z-coordinates.

CImg<charT> value_string ( const char  separator = ',',
const unsigned int  max_size = 0 
) const

Get a C-string containing a list of all values of the image instance.

Return a new CImg<char> image whose buffer data() is a char* string describing the list of all pixel values of the image instance (written in base 10), separated by specified separator character.

Parameters:
separator: a char character which specifies the separator between values in the returned C-string.
max_size: Maximum size of the returned image.
Note:
  • The returned image is never empty.
  • For an empty image instance, the returned string is "".
  • If max_size is equal to 0, there are no limits on the size of the returned string.
  • Otherwise, if the maximum number of string characters is exceeded, the value string is cut off and terminated by character '\0'. In that case, the returned image size is max_size + 1.
See also:
pixel_type().
bool is_shared ( ) const

Test shared state of the pixel buffer.

Return true if image instance has a shared memory buffer, and false otherwise.

Note:
  • A shared image do not own his pixel buffer data() and will not deallocate it on destruction.
  • Most of the time, a CImg<T> image instance will not be shared.
  • A shared image can only be obtained by a limited set of constructors and methods (see list below).
See also:
CImg(const t *const,unsigned int,unsigned int,unsigned int,unsigned int,bool), CImg(const CImg<t>&), CImg(const CImg<t>&,bool), assign(const t *const,unsigned int,unsigned int,unsigned int,unsigned int,bool), get_shared_points(), get_shared_line(), get_shared_lines(), get_shared_plane(), get_shared_planes(), get_shared_channel(), get_shared_channels(), get_shared().
bool is_empty ( ) const

Test if image instance is empty.

Return true, if image instance is empty, i.e. does not contain any pixel values, has dimensions 0 x 0 x 0 x 0 and a pixel buffer pointer set to 0 (null pointer), and false otherwise.

See also:
CImg(), assign().
bool is_sameX ( const unsigned int  size_x) const

Test if image width is equal to a specified value.

Return true if image instance has size_x columns, and false otherwise.

Parameters:
size_x: Desired width to test with.
Note:
  • Return the boolean width()==size_x.
See also:
is_sameX(const CImg<t>&) const, is_sameX(const CImgDisplay&) const, is_sameY(unsigned int) const, is_sameZ(unsigned int) const, is_sameC(unsigned int) const, is_sameXY(unsigned int,unsigned int) const, is_sameXYZ(unsigned int,unsigned int,unsigned int) const, is_sameXYZC(unsigned int,unsigned int,unsigned int,unsigned int) const.
bool is_sameX ( const CImg< t > &  img) const

Test if image width is the same as that of another image.

Return true if image instance has img.width() columns, and false otherwise.

Parameters:
img: Input image to test width() with.
Note:
See also:
is_sameX(unsigned int) const, is_sameX(const CImgDisplay&) const, is_sameY(const CImg<t>&) const, is_sameZ(const CImg<t>&) const, is_sameC(const CImg<t>&) const, is_sameXY(const CImg<t>&) const, is_sameXYZ(const CImg<t>&) const, is_sameXYZC(const CImg<t>&) const.
bool is_sameX ( const CImgDisplay disp) const

Test if image width is the same as that of an existing display window.

Return true if image instance has disp.width() columns, and false otherwise.

Parameters:
disp: Input display window to test width() with.
Note:
See also:
is_sameX(unsigned int) const, is_sameX(const CImg<t>&) const, is_sameY(const CImgDisplay&) const, is_sameXY(const CImgDisplay&) const,
bool is_sameY ( const unsigned int  size_y) const

Test if image height is equal to a specified value.

Similar to is_sameX(unsigned int) const, except that the test focuses on the image height().

bool is_sameY ( const CImg< t > &  img) const

Test if image height is the same as that of another image.

Similar to is_sameX(const CImg<t>&) const, except that the test focuses on the image height().

bool is_sameY ( const CImgDisplay disp) const

Test if image height is the same as that of an existing display window.

Similar to is_sameX(const CImgDisplay&) const, except that the test focuses on the image height().

bool is_sameZ ( const unsigned int  size_z) const

Test if image depth is equal to a specified value.

Similar to is_sameX(unsigned int) const, except that the test focuses on the image depth().

bool is_sameZ ( const CImg< t > &  img) const

Test if image depth is the same as that of another image.

Similar to is_sameX(const CImg<t>&) const, except that the test focuses on the image depth().

bool is_sameC ( const unsigned int  size_c) const

Test if image spectrum is equal to a specified value.

Similar to is_sameX(unsigned int) const, except that the test focuses on the image spectrum().

bool is_sameC ( const CImg< t > &  img) const

Test if image spectrum is the same as that of another image.

Similar to is_sameX(const CImg<t>&) const, except that the test focuses on the image spectrum().

bool is_sameXY ( const unsigned int  size_x,
const unsigned int  size_y 
) const

Test if image width and height are equal to specified values.

Test if is_sameX(unsigned int) const and is_sameY(unsigned int) const are both verified.

bool is_sameXY ( const CImg< t > &  img) const

Test if image width and height are the same as that of another image.

Test if is_sameX(const CImg<t>&) const and is_sameY(const CImg<t>&) const are both verified.

bool is_sameXY ( const CImgDisplay disp) const

Test if image width and height are the same as that of an existing display window.

Test if is_sameX(const CImgDisplay&) const and is_sameY(const CImgDisplay&) const are both verified.

bool is_sameXZ ( const unsigned int  size_x,
const unsigned int  size_z 
) const

Test if image width and depth are equal to specified values.

Test if is_sameX(unsigned int) const and is_sameZ(unsigned int) const are both verified.

bool is_sameXZ ( const CImg< t > &  img) const

Test if image width and depth are the same as that of another image.

Test if is_sameX(const CImg<t>&) const and is_sameZ(const CImg<t>&) const are both verified.

bool is_sameXC ( const unsigned int  size_x,
const unsigned int  size_c 
) const

Test if image width and spectrum are equal to specified values.

Test if is_sameX(unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameXC ( const CImg< t > &  img) const

Test if image width and spectrum are the same as that of another image.

Test if is_sameX(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameYZ ( const unsigned int  size_y,
const unsigned int  size_z 
) const

Test if image height and depth are equal to specified values.

Test if is_sameY(unsigned int) const and is_sameZ(unsigned int) const are both verified.

bool is_sameYZ ( const CImg< t > &  img) const

Test if image height and depth are the same as that of another image.

Test if is_sameY(const CImg<t>&) const and is_sameZ(const CImg<t>&) const are both verified.

bool is_sameYC ( const unsigned int  size_y,
const unsigned int  size_c 
) const

Test if image height and spectrum are equal to specified values.

Test if is_sameY(unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameYC ( const CImg< t > &  img) const

Test if image height and spectrum are the same as that of another image.

Test if is_sameY(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameZC ( const unsigned int  size_z,
const unsigned int  size_c 
) const

Test if image depth and spectrum are equal to specified values.

Test if is_sameZ(unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameZC ( const CImg< t > &  img) const

Test if image depth and spectrum are the same as that of another image.

Test if is_sameZ(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameXYZ ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z 
) const

Test if image width, height and depth are equal to specified values.

Test if is_sameXY(unsigned int,unsigned int) const and is_sameZ(unsigned int) const are both verified.

bool is_sameXYZ ( const CImg< t > &  img) const

Test if image width, height and depth are the same as that of another image.

Test if is_sameXY(const CImg<t>&) const and is_sameZ(const CImg<t>&) const are both verified.

bool is_sameXYC ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_c 
) const

Test if image width, height and spectrum are equal to specified values.

Test if is_sameXY(unsigned int,unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameXYC ( const CImg< t > &  img) const

Test if image width, height and spectrum are the same as that of another image.

Test if is_sameXY(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameXZC ( const unsigned int  size_x,
const unsigned int  size_z,
const unsigned int  size_c 
) const

Test if image width, depth and spectrum are equal to specified values.

Test if is_sameXZ(unsigned int,unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameXZC ( const CImg< t > &  img) const

Test if image width, depth and spectrum are the same as that of another image.

Test if is_sameXZ(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameYZC ( const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c 
) const

Test if image height, depth and spectrum are equal to specified values.

Test if is_sameYZ(unsigned int,unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameYZC ( const CImg< t > &  img) const

Test if image height, depth and spectrum are the same as that of another image.

Test if is_sameYZ(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool is_sameXYZC ( const unsigned int  size_x,
const unsigned int  size_y,
const unsigned int  size_z,
const unsigned int  size_c 
) const

Test if image width, height, depth and spectrum are equal to specified values.

Test if is_sameXYZ(unsigned int,unsigned int,unsigned int) const and is_sameC(unsigned int) const are both verified.

bool is_sameXYZC ( const CImg< t > &  img) const

Test if image width, height, depth and spectrum are the same as that of another image.

Test if is_sameXYZ(const CImg<t>&) const and is_sameC(const CImg<t>&) const are both verified.

bool containsXYZC ( const int  x,
const int  y = 0,
const int  z = 0,
const int  c = 0 
) const

Test if specified coordinates are inside image bounds.

Return true if pixel located at (x,y,z,c) is inside bounds of the image instance, and false otherwise.

Parameters:
x: X-coordinate of the pixel value.
y: Y-coordinate of the pixel value.
z: Z-coordinate of the pixel value.
c: C-coordinate of the pixel value.
Note:
  • Return true only if all these conditions are verified :
See also:
contains(const T&,t&,t&,t&,t&) const, contains(const T&,t&,t&,t&) const, contains(const T&,t&,t&) const, contains(const T&,t&) const, contains(const T&) const.
bool contains ( const T &  pixel,
t &  x,
t &  y,
t &  z,
t &  c 
) const

Test if pixel value is inside image bounds and get its X,Y,Z and C-coordinates.

Return true, if specified reference refers to a pixel value inside bounds of the image instance, and false otherwise.

Parameters:
pixel: Reference to pixel value to test.
[out]x: X-coordinate of the pixel value, if test succeeds.
[out]y: Y-coordinate of the pixel value, if test succeeds.
[out]z: Z-coordinate of the pixel value, if test succeeds.
[out]c: C-coordinate of the pixel value, if test succeeds.
Note:
  • Useful to convert an offset to a buffer value into pixel value coordinates :
           const CImg<float> img(100,100,1,3);      // Construct a 100x100 RGB color image.
           const unsigned int offset = 1249;        // Offset to the pixel (49,12,0,0).
           unsigned int x,y,z,c;
           if (img.contains(img[offset],x,y,z,c)) { // Convert offset to (x,y,z,c) coordinates.
             std::printf("Offset %u refers to pixel located at (%u,%u,%u,%u).\n",
                         offset,x,y,z,c);
           }
    
See also:
containsXYZC(int,int,int,int) const, contains(const T&,t&,t&,t&) const, contains(const T&,t&,t&) const, contains(const T&,t&) const, contains(const T&) const.
bool contains ( const T &  pixel,
t &  x,
t &  y,
t &  z 
) const

Test if pixel value is inside image bounds and get its X,Y and Z-coordinates.

Similar to contains(const T&,t&,t&,t&,t&) const, except that only the X,Y and Z-coordinates are set.

bool contains ( const T &  pixel,
t &  x,
t &  y 
) const

Test if pixel value is inside image bounds and get its X and Y-coordinates.

Similar to contains(const T&,t&,t&,t&,t&) const, except that only the X and Y-coordinates are set.

bool contains ( const T &  pixel,
t &  x 
) const

Test if pixel value is inside image bounds and get its X-coordinate.

Similar to contains(const T&,t&,t&,t&,t&) const, except that only the X-coordinate is set.

bool contains ( const T &  pixel) const

Test if pixel value is inside image bounds.

Similar to contains(const T&,t&,t&,t&,t&) const, except that no pixel coordinates are set.

bool is_overlapped ( const CImg< t > &  img) const

Test if pixel buffers of instance and input images overlap.

Return true, if pixel buffers attached to image instance and input image img overlap, and false otherwise.

Parameters:
img: Input image to compare with.
Note:
  • Buffer overlapping may happen when manipulating shared images.
  • If two image buffers overlap, operating on one of the image will probably modify the other one.
  • Most of the time, CImg<T> instances are non-shared and do not overlap between each others.
Sample code :
       const CImg<float>
         img1("reference.jpg"),             // Load RGB-color image.
         img2 = img1.get_shared_channel(1); // Get shared version of the green channel.
       if (img1.is_overlapped(img2)) {      // Test succeeds, 'img1' and 'img2' overlaps.
         std::printf("Buffers overlap !\n");
       }
See also:
is_shared().
bool is_object3d ( const CImgList< tp > &  primitives,
const CImgList< tc > &  colors,
const to &  opacities,
const bool  is_full_check = true,
char *const  error_message = 0 
) const

Test if the set {*this,primitives,colors,opacities} defines a valid 3d object.

Return true is the 3d object represented by the set {*this,primitives,colors,opacities} defines a valid 3d object, and false otherwise. The vertex coordinates are defined by the instance image.

Parameters:
primitives: List of primitives of the 3d object.
colors: List of colors of the 3d object.
opacities: List (or image) of opacities of the 3d object.
is_full_check: Boolean telling if full checking of the 3d object must be performed.
[out]error_message: C-string to contain the error message, if the test does not succeed.
Note:
  • Set is_full_checking to false to speed-up the 3d object checking. In this case, only the size of each 3d object component is checked.
  • Size of the string error_message should be at least 128-bytes long, to be able to contain the error message.
See also:
is_CImg3d(), draw_object3d(), display_object3d().
bool is_CImg3d ( const bool  is_full_check = true,
char *const  error_message = 0 
) const

Test if image instance represents a valid serialization of a 3d object.

Return true if the image instance represents a valid serialization of a 3d object, and false otherwise.

Parameters:
is_full_check: Boolean telling if full checking of the instance must be performed.
[out]error_message: C-string to contain the error message, if the test does not succeed.
Note:
  • Set is_full_checking to false to speed-up the 3d object checking. In this case, only the size of each 3d object component is checked.
  • Size of the string error_message should be at least 128-bytes long, to be able to contain the error message.
See also:
is_object3d(), object3dtoCImg3d(const CImgList<tp>&,const CImgList<tc>&,const to&), draw_object3d(), display_object3d().
CImg<T>& sqr ( )

Compute the square value of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its square value $I_{(x,y,z,c)}^2$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
Sample code :
       const CImg<float> img("reference.jpg");
       (img,img.get_sqr().normalize(0,255)).display();
ref_sqr.jpg
See also:
get_sqr() const, sqrt(), pow(), exp(), log(), log10().
CImg<T>& sqrt ( )

Compute the square root of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its square root $\sqrt{I_{(x,y,z,c)}}$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
Sample code :
       const CImg<float> img("reference.jpg");
       (img,img.get_sqrt().normalize(0,255)).display();
ref_sqrt.jpg
See also:
get_sqrt() const,, sqr(), pow(), exp(), log(), log10().
CImg<T>& exp ( )

Compute the exponential of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its exponential $e^{I_{(x,y,z,c)}}$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_exp() const, sqr(), sqrt(), pow(), log(), log10().
CImg<T>& log ( )

Compute the logarithm of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its logarithm $log_e(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_log() const, sqr(), sqrt(), pow(), exp(), log10().
CImg<T>& log10 ( )

Compute the base-10 logarithm of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its base-10 logarithm $log_{10}(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_log10(), sqr(), sqrt(), pow(), exp(), log().
CImg<T>& abs ( )

Compute the absolute value of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its absolute value $|I_{(x,y,z,c)}|$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_abs(), sign().
CImg<T>& sign ( )

Compute the sign of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its sign $sign(I_{(x,y,z,c)})$.

Note:
  • The sign is set to :
    • 1 if pixel value is strictly positive.
    • -1 if pixel value is strictly negative.
    • 0 if pixel value is equal to 0.
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_sign(), abs().
CImg<T>& cos ( )

Compute the cosine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its cosine $cos(I_{(x,y,z,c)})$.

Note:
  • Pixel values are regarded as being in radian.
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_cos(), sin(), sinc(), tan().
CImg<T>& sin ( )

Compute the sine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its sine $sin(I_{(x,y,z,c)})$.

Note:
  • Pixel values are regarded as being in radian.
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_sin(), cos(), sinc(), tan().
CImg<T>& sinc ( )

Compute the sinc of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its sinc $sinc(I_{(x,y,z,c)})$.

Note:
  • Pixel values are regarded as being exin radian.
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_sinc(), cos(), sin(), tan().
CImg<T>& tan ( )

Compute the tangent of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its tangent $tan(I_{(x,y,z,c)})$.

Note:
  • Pixel values are regarded as being exin radian.
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_tan(), cos(), sin(), sinc().
CImg<T>& cosh ( )

Compute the hyperbolic cosine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its hyperbolic cosine $cosh(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_cosh(), sinh(), tanh().
CImg<T>& sinh ( )

Compute the hyperbolic sine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its hyperbolic sine $sinh(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_sinh(), cosh(), tanh().
CImg<T>& tanh ( )

Compute the hyperbolic tangent of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its hyperbolic tangent $tanh(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_tanh(), cosh(), sinh().
CImg<T>& acos ( )

Compute the arccosine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its arccosine $acos(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_acos(), asin(), atan().
CImg<T>& asin ( )

Compute the arcsine of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its arcsine $asin(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_asin(), acos(), atan().
CImg<T>& atan ( )

Compute the arctangent of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its arctangent $atan(I_{(x,y,z,c)})$.

Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
See also:
get_atan(), acos(), asin().
CImg<T>& atan2 ( const CImg< t > &  img)

Compute the arctangent2 of each pixel value.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its arctangent2 $atan2(I_{(x,y,z,c)})$.

Parameters:
img: The image whose pixel values specify the second argument of the atan2() function.
Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
Sample code :
       const CImg<float>
          img_x(100,100,1,1,"x-w/2",false),   // Define an horizontal centered gradient, from '-width/2' to 'width/2'.
          img_y(100,100,1,1,"y-h/2",false),   // Define a vertical centered gradient, from '-height/2' to 'height/2'.
          img_atan2 = img_y.get_atan2(img_x); // Compute atan2(y,x) for each pixel value.
       (img_x,img_y,img_atan2).display();
ref_atan2.jpg
See also:
get_atan2(), atan().
CImg<T>& mul ( const CImg< t > &  img)

In-place pointwise multiplication.

Compute the pointwise multiplication between the image instance and the specified input image img.

Parameters:
img: Input image, as the second operand of the multiplication.
Note:
Sample code :
       CImg<float>
         img("reference.jpg"),
         shade(img.width,img.height(),1,1,"-(x-w/2)^2-(y-h/2)^2",false);
       shade.normalize(0,1);
       (img,shade,img.get_mul(shade)).display();
ref_mul.jpg
See also:
get_mul(), div(), operator*=(const CImg<t>&).
CImg<T>& div ( const CImg< t > &  img)

In-place pointwise division.

Similar to mul(const CImg<t>&), except that it performs a pointwise division instead of a multiplication.

See also:
get_div(const CImg<t>&) const, operator/=(const CImg<t>&)
CImg<T>& pow ( const double  p)

Raise each pixel value to a specified power.

Replace each pixel value $I_{(x,y,z,c)}$ of the image instance by its power $I_{(x,y,z,c)}^p$.

Parameters:
p: Used exponent.
Note:
  • The [in-place version] of this method statically casts the computed values to the pixel type T.
  • The [new-instance version] returns a CImg<float> image, if the pixel type T is not float-valued.
Sample code :
       const CImg<float>
         img0("reference.jpg"),           // Load reference color image.
         img1 = (img0/255).pow(1.8)*=255, // Compute gamma correction, with gamma = 1.8.
         img2 = (img0/255).pow(0.5)*=255; // Compute gamma correction, with gamma = 0.5.
       (img0,img1,img2).display();
ref_pow.jpg
See also:
get_pow(double) const, pow(const char*), pow(const CImg<t>&), sqr(), sqrt(), exp(), log(), log10().
CImg<T>& pow ( const char *const  expression)

Raise each pixel value to a power, specified from an expression.

Similar to operator+=(const char*), except it performs a pointwise exponentiation instead of an addition.

See also:
get_pow(const char*) const, pow(double), pow(CImg<t>&).
CImg<T>& pow ( const CImg< t > &  img)

Raise each pixel value to a power, pointwisely specified from another image.

Similar to operator+=(const CImg<t>& img), except that it performs an exponentiation instead of an addition.

See also:
get_pow(const CImg<t>&) const, pow(double), pow(const char*).
CImg<T>& rol ( const unsigned int  n = 1)

Compute the bitwise left rotation of each pixel value.

Similar to operator<<=(unsigned int), except that it performs a left rotation instead of a left shift.

See also:
get_rol(unsigned int) const, rol(const char*), rol(const CImg<t>&), operator<<=(unsigned int), operator>>=(unsigned int).
CImg<T>& rol ( const char *const  expression)

Compute the bitwise left rotation of each pixel value.

Similar to operator<<=(const char*), except that it performs a left rotation instead of a left shift.

See also:
get_rol(const char*) const, rol(unsigned int), rol(const CImg<t>&), operator<<=(const char*), operator>>=(const char*).
CImg<T>& rol ( const CImg< t > &  img)

Compute the bitwise left rotation of each pixel value.

Similar to operator<<=(const CImg<t>&), except that it performs a left rotation instead of a left shift.

See also:
get_rol(const CImg<t>&) const, rol(unsigned int), rol(const char*), operator<<=(const CImg<t>&), operator>>=(const CImg<t>&).
CImg<T>& ror ( const unsigned int  n = 1)

Compute the bitwise right rotation of each pixel value.

Similar to operator>>=(unsigned int), except that it performs a right rotation instead of a right shift.

See also:
get_ror(unsigned int) const, ror(const char*), ror(const CImg<t>&), operator<<=(unsigned int), operator>>=(unsigned int).
CImg<T>& ror ( const char *const  expression)

Compute the bitwise right rotation of each pixel value.

Similar to operator>>=(const char*), except that it performs a right rotation instead of a right shift.

See also:
get_ror(const char*) const, ror(unsigned int), ror(const CImg<t>&), operator<<=(const char*), operator>>=(const char*).
CImg<T>& ror ( const CImg< t > &  img)

Compute the bitwise right rotation of each pixel value.

Similar to operator>>=(const CImg<t>&), except that it performs a right rotation instead of a right shift.

See also:
get_ror(const CImg<t>&), ror(unsigned int), ror(const char *), operator<<=(const CImg<t>&), operator>>=(const CImg<t>&).
Tdouble variance ( const unsigned int  variance_method = 1) const

Return the variance of the image.

Parameters:
variance_methodDetermines how to calculate the variance

0 Second moment: $ v = 1/N \sum\limits_{k=1}^{N} (x_k - \bar x)^2 = 1/N \left( \sum\limits_{k=1}^N x_k^2 - \left( \sum\limits_{k=1}^N x_k \right)^2 / N \right) $ with $ \bar x = 1/N \sum\limits_{k=1}^N x_k $
1 Best unbiased estimator: $ v = \frac{1}{N-1} \sum\limits_{k=1}^{N} (x_k - \bar x)^2 $
2 Least median of squares
3 Least trimmed of squares
Tdouble variance_noise ( const unsigned int  variance_method = 2) const

Estimate noise variance of the image instance.

Parameters:
variance_method: method to compute the variance
Note:
Because of structures such as edges in images it is recommanded to use a robust variance estimation. The variance of the noise is estimated by computing the variance of the Laplacian $(\Delta I)^2 $ scaled by a factor $c$ insuring $ c E[(\Delta I)^2]= \sigma^2$ where $\sigma$ is the noise variance.
See also:
variance()
double eval ( const char *const  expression,
const double  x = 0,
const double  y = 0,
const double  z = 0,
const double  c = 0 
) const

Evaluate math expression.

If you make successive evaluations on the same image and with the same expression, you can set 'expr' to 0 after the first call, to skip the math parsing step.

static CImg<T> dijkstra ( const tf &  distance,
const unsigned int  nb_nodes,
const unsigned int  starting_node,
const unsigned int  ending_node,
CImg< t > &  previous 
) [static]

Compute minimal path in a graph, using the Dijkstra algorithm.

Parameters:
distanceAn object having operator()(unsigned int i, unsigned int j) which returns distance between two nodes (i,j).
nb_nodesNumber of graph nodes.
starting_nodeIndice of the starting node.
ending_nodeIndice of the ending node (set to ~0U to ignore ending node).
previousArray that gives the previous node indice in the path to the starting node (optional parameter).
Returns:
Array of distances of each node to the starting node.
CImg<T>& dijkstra ( const unsigned int  starting_node,
const unsigned int  ending_node,
CImg< t > &  previous 
)

Return minimal path in a graph, using the Dijkstra algorithm.

image instance corresponds to the adjacency matrix of the graph.

Parameters:
starting_nodeIndice of the starting node.
previousArray that gives the previous node indice in the path to the starting node (optional parameter).
Returns:
Array of distances of each node to the starting node.
static CImg<floatT> streamline ( const tfunc &  func,
const float  x,
const float  y,
const float  z,
const float  L = 256,
const float  dl = 0.1f,
const unsigned int  interpolation_type = 2,
const bool  is_backward_tracking = false,
const bool  is_oriented_only = false,
const float  x0 = 0,
const float  y0 = 0,
const float  z0 = 0,
const float  x1 = 0,
const float  y1 = 0,
const float  z1 = 0 
) [static]

Return stream line of a 3d vector field.

Parameters:
interpolation_typeType of interpolation (can be 0=nearest int, 1=linear, 2=2nd-order RK, 3=4th-order RK.
CImg<T>& fill ( const T  val)

Fill an image by a value val.

Parameters:
val= fill value
Note:
All pixel values of the image instance will be initialized by val.
CImg<T>& round ( const double  y = 1,
const int  rounding_type = 0 
)

Compute image with rounded pixel values.

Parameters:
yRounding precision.
rounding_typeRoundin type, can be 0 (nearest), 1 (forward), -1(backward).
CImg<T>& noise ( const double  sigma,
const unsigned int  noise_type = 0 
)

Add random noise to the values of the image instance.

Parameters:
sigmaAmplitude of the random additive noise. If sigma<0, it stands for a percentage of the global value range.
noise_typeType of additive noise (can be 0=gaussian, 1=uniform, 2=Salt and Pepper, 3=Poisson or 4=Rician).
Returns:
A reference to the modified image instance.
Note:
  • For Poisson noise (noise_type=3), parameter sigma is ignored, as Poisson noise only depends on the image value itself.
  • Function CImg<T>::get_noise() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_noise(40);
       (img,res.normalize(0,255)).display();
ref_noise.jpg
CImg<T>& normalize ( const T  value_min,
const T  value_max 
)

Linearly normalize values of the image instance between value_min and value_max.

Parameters:
value_minMinimum desired value of the resulting image.
value_maxMaximum desired value of the resulting image.
Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_normalize() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_normalize(160,220);
       (img,res).display();
ref_normalize2.jpg
CImg<T>& normalize ( )

Normalize multi-valued pixels of the image instance, with respect to their L2-norm.

Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_normalize() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_normalize();
       (img,res.normalize(0,255)).display();
ref_normalize.jpg
CImg<T>& norm ( const int  norm_type = 2)

Compute L2-norm of each multi-valued pixel of the image instance.

Parameters:
norm_typeType of computed vector norm (can be 0=Linf, 1=L1 or 2=L2).
Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_norm() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_norm();
       (img,res.normalize(0,255)).display();
ref_norm.jpg
CImg<T>& cut ( const T  value_min,
const T  value_max 
)

Cut values of the image instance between value_min and value_max.

Parameters:
value_minMinimum desired value of the resulting image.
value_maxMaximum desired value of the resulting image.
Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_cut() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_cut(160,220);
       (img,res).display();
ref_cut.jpg
CImg<T>& quantize ( const unsigned int  nb_levels,
const bool  keep_range = true 
)

Uniformly quantize values of the image instance into nb_levels levels.

Parameters:
nb_levelsNumber of quantization levels.
keep_rangeTells if resulting values keep the same range as the original ones.
Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_quantize() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_quantize(4);
       (img,res).display();
ref_quantize.jpg
CImg<T>& threshold ( const T  value,
const bool  soft_threshold = false,
const bool  strict_threshold = false 
)

Threshold values of the image instance.

Parameters:
valueThreshold value
soft_thresholdTells if soft thresholding must be applied (instead of hard one).
strict_thresholdTells if threshold value is strict.
Returns:
A reference to the modified image instance. Resulting pixel values are either equal to 0 or 1.
Note:
  • Function CImg<T>::get_threshold() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_threshold(128);
       (img,res.normalize(0,255)).display();
ref_threshold.jpg
CImg<T>& histogram ( const unsigned int  nb_levels,
const T  value_min = (T)0,
const T  value_max = (T)0 
)

Compute the histogram of the image instance.

Parameters:
nb_levelsNumber of desired histogram levels.
value_minMinimum pixel value considered for the histogram computation. All pixel values lower than value_min will not be counted.
value_maxMaximum pixel value considered for the histogram computation. All pixel values higher than value_max will not be counted.
Returns:
image instance is replaced by its histogram, defined as a CImg<T>(nb_levels) image.
Note:
  • The histogram H of an image I is the 1d function where H(x) counts the number of occurences of the value x in the image I.
  • If value_min==value_max==0 (default behavior), the function first estimates the whole range of pixel values then uses it to compute the histogram.
  • The resulting histogram is always defined in 1d. Histograms of multi-valued images are not multi-dimensional.
  • Function CImg<T>::get_histogram() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img = CImg<float>("reference.jpg").histogram(256);
       img.display_graph(0,3);
ref_histogram.jpg
CImg<T>& equalize ( const unsigned int  nb_levels,
const T  value_min = (T)0,
const T  value_max = (T)0 
)

Compute the histogram-equalized version of the image instance.

Parameters:
nb_levelsNumber of histogram levels used for the equalization.
value_minMinimum pixel value considered for the histogram computation. All pixel values lower than value_min will not be counted.
value_maxMaximum pixel value considered for the histogram computation. All pixel values higher than value_max will not be counted.
Returns:
A reference to the modified image instance.
Note:
  • If value_min==value_max==0 (default behavior), the function first estimates the whole range of pixel values then uses it to equalize the histogram.
  • Function CImg<T>::get_equalize() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), res = img.get_equalize(256);
       (img,res).display();
ref_equalize.jpg
CImg<T>& index ( const CImg< t > &  palette,
const bool  dithering = false,
const bool  map_indexes = false 
)

Index multi-valued pixels of the image instance, regarding to a predefined palette.

Parameters:
paletteMulti-valued palette used as the basis for multi-valued pixel indexing.
ditheringTells if Floyd-Steinberg dithering is activated or not.
map_indexesTell if the values of the resulting image are the palette indices or the palette vectors.
Returns:
A reference to the modified image instance.
Note:
  • img.index(palette,dithering,1) is equivalent to img.index(palette,dithering,0).map(palette).
  • Function CImg<T>::get_index() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"), palette(3,1,1,3, 0,128,255, 0,128,255, 0,128,255);
       const CImg<float> res = img.get_index(palette,true,true);
       (img,res).display();
ref_index.jpg
CImg<T>& map ( const CImg< t > &  palette)

Map predefined palette on the scalar (indexed) image instance.

Parameters:
paletteMulti-valued palette used for mapping the indexes.
Returns:
A reference to the modified image instance.
Note:
  • Function CImg<T>::get_map() is also defined. It returns a non-shared modified copy of the image instance.
Sample code :
       const CImg<float> img("reference.jpg"),
                         palette1(3,1,1,3, 0,128,255, 0,128,255, 0,128,255),
                         palette2(3,1,1,3, 255,0,0, 0,255,0, 0,0,255),
                         res = img.get_index(palette1,false).map(palette2);
       (img,res).display();
ref_map.jpg
CImg<T>& label ( const bool  is_high_connectivity = false,
const Tfloat  tolerance = 0 
)

Label connected components.

Parameters:
is_high_connectivityBoolean that choose between 4(false)- or 8(true)-connectivity in 2d case, and between 6(false)- or 26(true)-connectivity in 3d case.
Note:
The algorithm of connected components computation has been primarily done by A. Meijster, according to the publication : 'W.H. Hesselink, A. Meijster, C. Bron, "Concurrent Determination of Connected Components.", In: Science of Computer Programming 41 (2001), pp. 173--194'. The submitted code has then been modified to fit CImg coding style and constraints.
CImg<T>& RGBtoHSI ( )

Convert color pixels from RGB to HSI. Reference: "Digital Image Processing, 2nd. edition", R. Gonzalez and R. Woods. Prentice Hall, 2002.

CImg<T>& RGBtoBayer ( )

Convert a RGB image to a Bayer-coded representation.

Note:
First (upper-left) pixel if the red component of the pixel color.
CImg<T>& resize ( const int  size_x,
const int  size_y = -100,
const int  size_z = -100,
const int  size_c = -100,
const int  interpolation_type = 1,
const unsigned int  border_conditions = 0,
const float  centering_x = 0,
const float  centering_y = 0,
const float  centering_z = 0,
const float  centering_c = 0 
)

Resize an image.

Parameters:
size_xNumber of columns (new size along the X-axis).
size_yNumber of rows (new size along the Y-axis).
size_zNumber of slices (new size along the Z-axis).
size_cNumber of vector-channels (new size along the C-axis).
interpolation_typeMethod of interpolation :

  • -1 = no interpolation : raw memory resizing.
  • 0 = no interpolation : additional space is filled according to border_condition.
  • 1 = nearest-neighbor interpolation.
  • 2 = moving average interpolation.
  • 3 = linear interpolation.
  • 4 = grid interpolation.
  • 5 = bicubic interpolation.
  • 6 = lanczos interpolation.
border_conditionsBorder condition type.
centering_xSet centering type (only if interpolation_type=0).
centering_ySet centering type (only if interpolation_type=0).
centering_zSet centering type (only if interpolation_type=0).
centering_cSet centering type (only if interpolation_type=0).
Note:
If pd[x,y,z,v]<0, it corresponds to a percentage of the original size (the default value is -100).
CImg<T>& resize_doubleXY ( )

Upscale an image by a factor 2x.

Use anisotropic upscaling algorithm described at http://scale2x.sourceforge.net/algorithm.html

CImg<T>& resize_tripleXY ( )

Upscale an image by a factor 3x.

Use anisotropic upscaling algorithm described at http://scale2x.sourceforge.net/algorithm.html

CImg<T>& shift ( const int  deltax,
const int  deltay = 0,
const int  deltaz = 0,
const int  deltac = 0,
const int  border_condition = 0 
)

Shift the image.

Parameters:
deltaxAmount of displacement along the X-axis.
deltayAmount of displacement along the Y-axis.
deltazAmount of displacement along the Z-axis.
deltacAmount of displacement along the C-axis.
border_conditionBorder condition.
  • border_condition can be :
    • 0 : Zero border condition (Dirichlet).
    • 1 : Nearest neighbors (Neumann).
    • 2 : Repeat Pattern (Fourier style).
CImg<T>& permute_axes ( const char *const  order)

Permute axes order.

This function permutes image axes.

Parameters:
permut= String describing the permutation (4 characters).
CImg<T>& rotate ( const float  angle,
const unsigned int  border_conditions = 0,
const unsigned int  interpolation = 1 
)

Rotate an image.

Parameters:
angle= rotation angle (in degrees).
cond= rotation type. can be :

  • 0 = zero-value at borders
  • 1 = nearest pixel.
  • 2 = cyclic.
Note:
Returned image will probably have a different size than the image instance *this.
CImg<T>& rotate ( const float  angle,
const float  cx,
const float  cy,
const float  zoom,
const unsigned int  border_conditions = 3,
const unsigned int  interpolation = 1 
)

Rotate an image around a center point (cx,cy).

Parameters:
angle= rotation angle (in degrees).
cx= X-coordinate of the rotation center.
cy= Y-coordinate of the rotation center.
zoom= zoom.
cond= rotation type. can be :

  • 0 = zero-value at borders
  • 1 = repeat image at borders
  • 2 = zero-value at borders and linear interpolation
CImg<T>& crop ( const int  x0,
const int  y0,
const int  z0,
const int  c0,
const int  x1,
const int  y1,
const int  z1,
const int  c1,
const bool  border_condition = false 
)

Get a square region of the image.

Parameters:
x0= X-coordinate of the upper-left crop rectangle corner.
y0= Y-coordinate of the upper-left crop rectangle corner.
z0= Z-coordinate of the upper-left crop rectangle corner.
c0= C-coordinate of the upper-left crop rectangle corner.
x1= X-coordinate of the lower-right crop rectangle corner.
y1= Y-coordinate of the lower-right crop rectangle corner.
z1= Z-coordinate of the lower-right crop rectangle corner.
c1= C-coordinate of the lower-right crop rectangle corner.
border_condition= Dirichlet (false) or Neumann border conditions.
CImg<T>& crop ( const int  x0,
const int  y0,
const int  z0,
const int  x1,
const int  y1,
const int  z1,
const bool  border_condition = false 
)

Get a rectangular part of the image instance.

Parameters:
x0= X-coordinate of the upper-left crop rectangle corner.
y0= Y-coordinate of the upper-left crop rectangle corner.
z0= Z-coordinate of the upper-left crop rectangle corner.
x1= X-coordinate of the lower-right crop rectangle corner.
y1= Y-coordinate of the lower-right crop rectangle corner.
z1= Z-coordinate of the lower-right crop rectangle corner.
border_condition= determine the type of border condition if some of the desired region is outside the image.
CImg<T>& crop ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const bool  border_condition = false 
)

Get a rectangular part of the image instance.

Parameters:
x0= X-coordinate of the upper-left crop rectangle corner.
y0= Y-coordinate of the upper-left crop rectangle corner.
x1= X-coordinate of the lower-right crop rectangle corner.
y1= Y-coordinate of the lower-right crop rectangle corner.
border_condition= determine the type of border condition if some of the desired region is outside the image.
CImg<T>& crop ( const int  x0,
const int  x1,
const bool  border_condition = false 
)

Get a rectangular part of the image instance.

Parameters:
x0= X-coordinate of the upper-left crop rectangle corner.
x1= X-coordinate of the lower-right crop rectangle corner.
border_condition= determine the type of border condition if some of the desired region is outside the image.
CImgList<T> get_split ( const CImg< t > &  values,
const bool  keep_values,
const bool  is_shared 
) const

Split image into a list of one-column vectors, according to specified sequence of splitting values.

Parameters:
valuesThe splitting pattern of values.
keep_valuesCan be :

  • false : Discard splitting values in resulting list.
  • true : Keep splitting values as separate images in resulting list.
CImg<T>& correlate ( const CImg< t > &  mask,
const unsigned int  border_conditions = 1,
const bool  is_normalized = false 
)

Compute the correlation of the image instance by a mask.

The correlation of the image instance *this by the mask mask is defined to be :

res(x,y,z) = sum_{i,j,k} (*this)(x+i,y+j,z+k)*mask(i,j,k)

Parameters:
mask= the correlation kernel.
border_conditions= the border condition type (0=zero, 1=dirichlet)
is_normalized= enable local normalization.
CImg<T>& convolve ( const CImg< t > &  mask,
const unsigned int  border_conditions = 1,
const bool  is_normalized = false 
)

Compute the convolution of the image by a mask.

The result res of the convolution of an image img by a mask mask is defined to be :

res(x,y,z) = sum_{i,j,k} img(x-i,y-j,z-k)*mask(i,j,k)

Parameters:
mask= the correlation kernel.
border_conditions= the border condition type (0=zero, 1=dirichlet)
is_normalized= enable local normalization.
CImg<T>& deriche ( const float  sigma,
const int  order = 0,
const char  axis = 'x',
const bool  cond = true 
)

Compute the result of the Deriche filter.

The Canny-Deriche filter is a recursive algorithm allowing to compute blurred derivatives of order 0,1 or 2 of an image.

CImg<T>& blur ( const float  sigmax,
const float  sigmay,
const float  sigmaz,
const bool  cond = true 
)

Return a blurred version of the image, using a Canny-Deriche filter.

Blur the image with an anisotropic exponential filter (Deriche filter of order 0).

CImg<T>& blur_anisotropic ( const CImg< t > &  G,
const float  amplitude = 60,
const float  dl = 0.8f,
const float  da = 30,
const float  gauss_prec = 2,
const unsigned int  interpolation_type = 0,
const bool  fast_approx = 1 
)

Blur the image anisotropically following a field of diffusion tensors.

Parameters:
G= Field of square roots of diffusion tensors/vectors used to drive the smoothing.
amplitude= amplitude of the smoothing.
dl= spatial discretization.
da= angular discretization.
gauss_prec= precision of the gaussian function.
interpolationUsed interpolation scheme (0 = nearest-neighbor, 1 = linear, 2 = Runge-Kutta)
fast_approx= Tell to use the fast approximation or not.
CImg<T>& blur_bilateral ( const float  sigma_x,
const float  sigma_y,
const float  sigma_z,
const float  sigma_r,
const int  bgrid_x,
const int  bgrid_y,
const int  bgrid_z,
const int  bgrid_r,
const bool  interpolation_type = true 
)

Blur an image using the bilateral filter.

Parameters:
sigma_xAmount of blur along the X-axis.
sigma_yAmount of blur along the Y-axis.
sigma_zAmount of blur along the Z-axis.
sigma_rAmount of blur along the range axis.
bgrid_xSize of the bilateral grid along the X-axis.
bgrid_ySize of the bilateral grid along the Y-axis.
bgrid_zSize of the bilateral grid along the Z-axis.
bgrid_rSize of the bilateral grid along the range axis.
interpolation_typeUse interpolation for image slicing.
Note:
This algorithm uses the optimisation technique proposed by S. Paris and F. Durand, in ECCV'2006 (extended for 3d volumetric images).
CImgList<Tfloat> get_gradient ( const char *const  axes = 0,
const int  scheme = 3 
) const

Compute the list of images, corresponding to the XY-gradients of an image.

Parameters:
scheme= Numerical scheme used for the gradient computation :

  • -1 = Backward finite differences
  • 0 = Centered finite differences
  • 1 = Forward finite differences
  • 2 = Using Sobel masks
  • 3 = Using rotation invariant masks
  • 4 = Using Deriche recusrsive filter.
CImg<T>& displacement ( const CImg< T > &  source,
const float  smoothness = 0.1f,
const float  precision = 5.0f,
const unsigned int  nb_scales = 0,
const unsigned int  iteration_max = 10000,
const bool  is_backward = false 
)

Estimate a displacement field between specified source image and image instance.

Parameters:
is_backward: if false, match I2(X+U(X)) = I1(X), else match I2(X) = I1(X-U(X)).
CImg<T>& distance ( const T  value,
const unsigned int  metric = 2 
)

Compute the distance transform according to a specified value.

The distance transform implementation has been submitted by A. Meijster, and implements the article 'W.H. Hesselink, A. Meijster, J.B.T.M. Roerdink, "A general algorithm for computing distance transforms in linear time.", In: Mathematical Morphology and its Applications to Image and Signal Processing, J. Goutsias, L. Vincent, and D.S. Bloomberg (eds.), Kluwer, 2000, pp. 331-340.' The submitted code has then been modified to fit CImg coding style and constraints.

CImg<T>& distance ( const T  value,
const CImg< t > &  metric_mask 
)

Compute the chamfer distance transform according to a specified value, with a custom metric.

The algorithm code has been initially proposed by A. Meijster, and modified by D. Tschumperlé.

CImg<T>& haar ( const char  axis,
const bool  invert = false,
const unsigned int  nb_scales = 1 
)

Compute the Haar multiscale wavelet transform (monodimensional version).

Parameters:
axisAxis considered for the transform.
invertSet inverse of direct transform.
nb_scalesNumber of scales used for the transform.
CImg<T>& haar ( const bool  invert = false,
const unsigned int  nb_scales = 1 
)

Compute the Haar multiscale wavelet transform.

Parameters:
invertSet inverse of direct transform.
nb_scalesNumber of scales used for the transform.
CImg<floatT> get_elevation3d ( CImgList< tf > &  primitives,
CImgList< tc > &  colors,
const CImg< te > &  elevation 
) const

Create and return a 3d elevation of the image instance.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
[out]colorsThe returned list of the 3d object colors.
elevationThe input elevation map.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       const CImg<float> img("reference.jpg");
       CImgList<unsigned int> faces3d;
       CImgList<unsigned char> colors3d;
       const CImg<float> points3d = img.get_elevation3d(faces3d,colors,img.get_norm()*0.2);
       CImg<unsigned char>().display_object3d("Elevation3d",points3d,faces3d,colors3d);
ref_elevation3d.jpg
CImg<floatT> get_isoline3d ( CImgList< tf > &  primitives,
const float  isovalue,
const int  size_x = -100,
const int  size_y = -100 
) const

Create and return a isoline of the image instance as a 3d object.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
isovalueThe returned list of the 3d object colors.
size_xThe number of subdivisions along the X-axis.
size_yThe number of subdisivions along the Y-axis.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       const CImg<float> img("reference.jpg");
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = img.get_isoline3d(faces3d,100);
       CImg<unsigned char>().display_object3d("Isoline3d",points3d,faces3d,colors3d);
ref_isoline3d.jpg
CImg<floatT> get_isosurface3d ( CImgList< tf > &  primitives,
const float  isovalue,
const int  size_x = -100,
const int  size_y = -100,
const int  size_z = -100 
) const

Create and return a isosurface of the image instance as a 3d object.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
isovalueThe returned list of the 3d object colors.
size_xThe number of subdivisions along the X-axis.
size_yThe number of subdisivions along the Y-axis.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       const CImg<float> img = CImg<unsigned char>("reference.jpg").resize(-100,-100,20);
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = img.get_isosurface3d(faces3d,100);
       CImg<unsigned char>().display_object3d("Isosurface3d",points3d,faces3d,colors3d);
ref_isosurface3d.jpg
static CImg<floatT> box3d ( CImgList< tf > &  primitives,
const float  size_x = 200,
const float  size_y = 100,
const float  size_z = 100 
) [static]

Create and return a 3d box object.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
size_xThe width of the box (dimension along the X-axis).
size_yThe height of the box (dimension along the Y-axis).
size_zThe depth of the box (dimension along the Z-axis).
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::box3d(faces3d,10,20,30);
       CImg<unsigned char>().display_object3d("Box3d",points3d,faces3d);
ref_box3d.jpg
static CImg<floatT> cone3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const float  size_z = 100,
const unsigned int  subdivisions = 24 
) [static]

Create and return a 3d cone.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
radiusThe radius of the cone basis.
size_zThe cone's height.
subdivisionsThe number of basis angular subdivisions.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::cone3d(faces3d,50);
       CImg<unsigned char>().display_object3d("Cone3d",points3d,faces3d);
ref_cone3d.jpg
static CImg<floatT> cylinder3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const float  size_z = 100,
const unsigned int  subdivisions = 24 
) [static]

Create and return a 3d cylinder.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
radiusThe radius of the cylinder basis.
size_zThe cylinder's height.
subdivisionsThe number of basis angular subdivisions.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::cylinder3d(faces3d,50);
       CImg<unsigned char>().display_object3d("Cylinder3d",points3d,faces3d);
ref_cylinder3d.jpg
static CImg<floatT> torus3d ( CImgList< tf > &  primitives,
const float  radius1 = 100,
const float  radius2 = 30,
const unsigned int  subdivisions1 = 24,
const unsigned int  subdivisions2 = 12 
) [static]

Create and return a 3d torus.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
radius1The large radius.
radius2The small radius.
subdivisions1The number of angular subdivisions for the large radius.
subdivisions2The number of angular subdivisions for the small radius.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::torus3d(faces3d,20,4);
       CImg<unsigned char>().display_object3d("Torus3d",points3d,faces3d);
ref_torus3d.jpg
static CImg<floatT> plane3d ( CImgList< tf > &  primitives,
const float  size_x = 100,
const float  size_y = 100,
const unsigned int  subdivisions_x = 10,
const unsigned int  subdivisions_y = 10 
) [static]

Create and return a 3d XY-plane.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
size_xThe width of the plane (dimension along the X-axis).
size_yThe height of the plane (dimensions along the Y-axis).
subdivisions_xThe number of planar subdivisions along the X-axis.
subdivisions_yThe number of planar subdivisions along the Y-axis.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::plane3d(faces3d,100,50);
       CImg<unsigned char>().display_object3d("Plane3d",points3d,faces3d);
ref_plane3d.jpg
static CImg<floatT> sphere3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const unsigned int  subdivisions = 3 
) [static]

Create and return a 3d sphere.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
radiusThe radius of the sphere (dimension along the X-axis).
subdivisionsThe number of recursive subdivisions from an initial icosahedron.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> points3d = CImg<float>::sphere3d(faces3d,100,4);
       CImg<unsigned char>().display_object3d("Sphere3d",points3d,faces3d);
ref_sphere3d.jpg
static CImg<floatT> ellipsoid3d ( CImgList< tf > &  primitives,
const CImg< t > &  tensor,
const unsigned int  subdivisions = 3 
) [static]

Create and return a 3d ellipsoid.

Parameters:
[out]primitivesThe returned list of the 3d object primitives (template type tf should be at least unsigned int).
tensorThe tensor which gives the shape and size of the ellipsoid.
subdivisionsThe number of recursive subdivisions from an initial stretched icosahedron.
Returns:
The N vertices (xi,yi,zi) of the 3d object as a Nx3 CImg<float> image (0<=i<=N-1).
Sample code :
       CImgList<unsigned int> faces3d;
       const CImg<float> tensor = CImg<float>::diagonal(10,7,3),
                         points3d = CImg<float>::ellipsoid3d(faces3d,tensor,4);
       CImg<unsigned char>().display_object3d("Ellipsoid3d",points3d,faces3d);
ref_ellipsoid3d.jpg
CImg<T>& draw_point ( const int  x0,
const int  y0,
const tc *const  color,
const float  opacity = 1 
)

Draw a 2d colored point (pixel).

Parameters:
x0X-coordinate of the point.
y0Y-coordinate of the point.
colorPointer to spectrum() consecutive values, defining the color values.
opacityDrawing opacity (optional).
Note:
  • Clipping is supported.
  • To set pixel values without clipping needs, you should use the faster CImg::operator()() function.
Example:
       CImg<unsigned char> img(100,100,1,3,0);
       const unsigned char color[] = { 255,128,64 };
       img.draw_point(50,50,color);
CImg<T>& draw_line ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a 2d colored line.

Parameters:
x0X-coordinate of the starting line point.
y0Y-coordinate of the starting line point.
x1X-coordinate of the ending line point.
y1Y-coordinate of the ending line point.
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
init_hatchFlag telling if a reinitialization of the hash state must be done (optional).
Note:
  • Clipping is supported.
  • Line routine uses Bresenham's algorithm.
  • Set init_hatch = false to draw consecutive hatched segments without breaking the line pattern.
Example:
       CImg<unsigned char> img(100,100,1,3,0);
       const unsigned char color[] = { 255,128,64 };
        img.draw_line(40,40,80,70,color);
CImg<T>& draw_line ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const CImg< tc > &  texture,
const int  tx0,
const int  ty0,
const int  tx1,
const int  ty1,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a 2d textured line.

Parameters:
x0X-coordinate of the starting line point.
y0Y-coordinate of the starting line point.
x1X-coordinate of the ending line point.
y1Y-coordinate of the ending line point.
textureTexture image defining the pixel colors.
tx0X-coordinate of the starting texture point.
ty0Y-coordinate of the starting texture point.
tx1X-coordinate of the ending texture point.
ty1Y-coordinate of the ending texture point.
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
init_hatchFlag telling if the hash variable must be reinitialized (optional).
Note:
  • Clipping is supported but not for texture coordinates.
  • Line routine uses the well known Bresenham's algorithm.
Example:
       CImg<unsigned char> img(100,100,1,3,0), texture("texture256x256.ppm");
       const unsigned char color[] = { 255,128,64 };
       img.draw_line(40,40,80,70,texture,0,0,255,255);
CImg<T>& draw_line ( const CImg< t > &  points,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a set of consecutive colored lines in the image instance.

Parameters:
pointsCoordinates of vertices, stored as a list of vectors.
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
init_hatchIf set to true, init hatch motif.
Note:
  • This function uses several call to the single CImg::draw_line() procedure, depending on the vectors size in points.
Example:
       CImg<unsigned char> img(100,100,1,3,0);
       const unsigned char color[] = { 255,128,64 };
       CImgList<int> points;
       points.insert(CImg<int>::vector(0,0)).
             .insert(CImg<int>::vector(70,10)).
             .insert(CImg<int>::vector(80,60)).
             .insert(CImg<int>::vector(10,90));
       img.draw_line(points,color);
CImg<T>& draw_arrow ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const tc *const  color,
const float  opacity = 1,
const float  angle = 30,
const float  length = -10,
const unsigned int  pattern = ~0U 
)

Draw a colored arrow in the image instance.

Parameters:
x0X-coordinate of the starting arrow point (tail).
y0Y-coordinate of the starting arrow point (tail).
x1X-coordinate of the ending arrow point (head).
y1Y-coordinate of the ending arrow point (head).
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
angleAperture angle of the arrow head (optional).
lengthLength of the arrow head. If negative, describes a percentage of the arrow length (optional).
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
Note:
  • Clipping is supported.
CImg<T>& draw_spline ( const int  x0,
const int  y0,
const float  u0,
const float  v0,
const int  x1,
const int  y1,
const float  u1,
const float  v1,
const tc *const  color,
const float  opacity = 1,
const float  precision = 0.25,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a cubic spline curve in the image instance.

Parameters:
x0X-coordinate of the starting curve point
y0Y-coordinate of the starting curve point
u0X-coordinate of the starting velocity
v0Y-coordinate of the starting velocity
x1X-coordinate of the ending curve point
y1Y-coordinate of the ending curve point
u1X-coordinate of the ending velocity
v1Y-coordinate of the ending velocity
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
precisionCurve drawing precision (optional).
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
init_hatchIf true, init hatch motif.
Note:
  • The curve is a 2d cubic Bezier spline, from the set of specified starting/ending points and corresponding velocity vectors.
  • The spline is drawn as a serie of connected segments. The precision parameter sets the average number of pixels in each drawn segment.
  • A cubic Bezier curve is sometimes defined by a set of 4 points { (x0,y0), (xa,ya), (xb,yb), (x1,y1) } where (x0,y0) is the starting point, (x1,y1) is the ending point and (xa,ya), (xb,yb) are two control points. The starting and ending velocities (u0,v0) and (u1,v1) can be deduced easily from the control points as u0 = (xa - x0), v0 = (ya - y0), u1 = (x1 - xb) and v1 = (y1 - yb).
Example:
       CImg<unsigned char> img(100,100,1,3,0);
       const unsigned char color[] = { 255,255,255 };
       img.draw_spline(30,30,0,100,90,40,0,-100,color);
CImg<T>& draw_spline ( const int  x0,
const int  y0,
const int  z0,
const float  u0,
const float  v0,
const float  w0,
const int  x1,
const int  y1,
const int  z1,
const float  u1,
const float  v1,
const float  w1,
const tc *const  color,
const float  opacity = 1,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a cubic spline curve in the image instance (for volumetric images).

Note:
CImg<T>& draw_spline ( const int  x0,
const int  y0,
const float  u0,
const float  v0,
const int  x1,
const int  y1,
const float  u1,
const float  v1,
const CImg< t > &  texture,
const int  tx0,
const int  ty0,
const int  tx1,
const int  ty1,
const float  opacity = 1,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)

Draw a cubic spline curve in the image instance.

Parameters:
x0X-coordinate of the starting curve point
y0Y-coordinate of the starting curve point
u0X-coordinate of the starting velocity
v0Y-coordinate of the starting velocity
x1X-coordinate of the ending curve point
y1Y-coordinate of the ending curve point
u1X-coordinate of the ending velocity
v1Y-coordinate of the ending velocity
textureTexture image defining line pixel colors.
tx0X-coordinate of the starting texture point.
ty0Y-coordinate of the starting texture point.
tx1X-coordinate of the ending texture point.
ty1Y-coordinate of the ending texture point.
precisionCurve drawing precision (optional).
opacityDrawing opacity (optional).
patternAn integer whose bits describe the line pattern (optional).
init_hatchif true, reinit hatch motif.
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const tc *const  color,
const float  brightness0,
const float  brightness1,
const float  brightness2,
const float  opacity = 1 
)

Draw a 2d Gouraud-shaded colored triangle.

Parameters:
x0= X-coordinate of the first corner in the image instance.
y0= Y-coordinate of the first corner in the image instance.
x1= X-coordinate of the second corner in the image instance.
y1= Y-coordinate of the second corner in the image instance.
x2= X-coordinate of the third corner in the image instance.
y2= Y-coordinate of the third corner in the image instance.
color= array of spectrum() values of type T, defining the global drawing color.
brightness0= brightness of the first corner (in [0,2]).
brightness1= brightness of the second corner (in [0,2]).
brightness2= brightness of the third corner (in [0,2]).
opacity= opacity of the drawing.
Note:
Clipping is supported.
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const CImg< tc > &  texture,
const int  tx0,
const int  ty0,
const int  tx1,
const int  ty1,
const int  tx2,
const int  ty2,
const float  opacity = 1,
const float  brightness = 1 
)

Draw a 2d textured triangle.

Parameters:
x0= X-coordinate of the first corner in the image instance.
y0= Y-coordinate of the first corner in the image instance.
x1= X-coordinate of the second corner in the image instance.
y1= Y-coordinate of the second corner in the image instance.
x2= X-coordinate of the third corner in the image instance.
y2= Y-coordinate of the third corner in the image instance.
texture= texture image used to fill the triangle.
tx0= X-coordinate of the first corner in the texture image.
ty0= Y-coordinate of the first corner in the texture image.
tx1= X-coordinate of the second corner in the texture image.
ty1= Y-coordinate of the second corner in the texture image.
tx2= X-coordinate of the third corner in the texture image.
ty2= Y-coordinate of the third corner in the texture image.
opacity= opacity of the drawing.
brightness= brightness of the drawing (in [0,2]).
Note:
Clipping is supported, but texture coordinates do not support clipping.
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const tc *const  color,
const CImg< tl > &  light,
const int  lx0,
const int  ly0,
const int  lx1,
const int  ly1,
const int  lx2,
const int  ly2,
const float  opacity = 1 
)

Draw a 2d Pseudo-Phong-shaded triangle.

Parameters:
x0= X-coordinate of the first corner in the image instance.
y0= Y-coordinate of the first corner in the image instance.
x1= X-coordinate of the second corner in the image instance.
y1= Y-coordinate of the second corner in the image instance.
x2= X-coordinate of the third corner in the image instance.
y2= Y-coordinate of the third corner in the image instance.
color= array of spectrum() values of type T, defining the global drawing color.
light= light image.
lx0= X-coordinate of the first corner in the light image.
ly0= Y-coordinate of the first corner in the light image.
lx1= X-coordinate of the second corner in the light image.
ly1= Y-coordinate of the second corner in the light image.
lx2= X-coordinate of the third corner in the light image.
ly2= Y-coordinate of the third corner in the light image.
opacity= opacity of the drawing.
Note:
Clipping is supported, but texture coordinates do not support clipping.
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const CImg< tc > &  texture,
const int  tx0,
const int  ty0,
const int  tx1,
const int  ty1,
const int  tx2,
const int  ty2,
const float  brightness0,
const float  brightness1,
const float  brightness2,
const float  opacity = 1 
)

Draw a 2d Gouraud-shaded textured triangle.

Parameters:
x0= X-coordinate of the first corner in the image instance.
y0= Y-coordinate of the first corner in the image instance.
x1= X-coordinate of the second corner in the image instance.
y1= Y-coordinate of the second corner in the image instance.
x2= X-coordinate of the third corner in the image instance.
y2= Y-coordinate of the third corner in the image instance.
texture= texture image used to fill the triangle.
tx0= X-coordinate of the first corner in the texture image.
ty0= Y-coordinate of the first corner in the texture image.
tx1= X-coordinate of the second corner in the texture image.
ty1= Y-coordinate of the second corner in the texture image.
tx2= X-coordinate of the third corner in the texture image.
ty2= Y-coordinate of the third corner in the texture image.
brightness0= brightness value of the first corner.
brightness1= brightness value of the second corner.
brightness2= brightness value of the third corner.
opacity= opacity of the drawing.
Note:
Clipping is supported, but texture coordinates do not support clipping.
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const CImg< tc > &  texture,
const int  tx0,
const int  ty0,
const int  tx1,
const int  ty1,
const int  tx2,
const int  ty2,
const CImg< tl > &  light,
const int  lx0,
const int  ly0,
const int  lx1,
const int  ly1,
const int  lx2,
const int  ly2,
const float  opacity = 1 
)

Draw a 2d Pseudo-Phong-shaded textured triangle.

Parameters:
x0= X-coordinate of the first corner in the image instance.
y0= Y-coordinate of the first corner in the image instance.
x1= X-coordinate of the second corner in the image instance.
y1= Y-coordinate of the second corner in the image instance.
x2= X-coordinate of the third corner in the image instance.
y2= Y-coordinate of the third corner in the image instance.
texture= texture image used to fill the triangle.
tx0= X-coordinate of the first corner in the texture image.
ty0= Y-coordinate of the first corner in the texture image.
tx1= X-coordinate of the second corner in the texture image.
ty1= Y-coordinate of the second corner in the texture image.
tx2= X-coordinate of the third corner in the texture image.
ty2= Y-coordinate of the third corner in the texture image.
light= light image.
lx0= X-coordinate of the first corner in the light image.
ly0= Y-coordinate of the first corner in the light image.
lx1= X-coordinate of the second corner in the light image.
ly1= Y-coordinate of the second corner in the light image.
lx2= X-coordinate of the third corner in the light image.
ly2= Y-coordinate of the third corner in the light image.
opacity= opacity of the drawing.
Note:
Clipping is supported, but texture coordinates do not support clipping.
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  z0,
const int  c0,
const int  x1,
const int  y1,
const int  z1,
const int  c1,
const T  val,
const float  opacity = 1 
)

Draw a 4d filled rectangle in the image instance, at coordinates (x0,y0,z0,c0)-(x1,y1,z1,c1).

Parameters:
x0X-coordinate of the upper-left rectangle corner.
y0Y-coordinate of the upper-left rectangle corner.
z0Z-coordinate of the upper-left rectangle corner.
c0C-coordinate of the upper-left rectangle corner.
x1X-coordinate of the lower-right rectangle corner.
y1Y-coordinate of the lower-right rectangle corner.
z1Z-coordinate of the lower-right rectangle corner.
c1C-coordinate of the lower-right rectangle corner.
valScalar value used to fill the rectangle area.
opacityDrawing opacity (optional).
Note:
  • Clipping is supported.
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  z0,
const int  x1,
const int  y1,
const int  z1,
const tc *const  color,
const float  opacity = 1 
)

Draw a 3d filled colored rectangle in the image instance, at coordinates (x0,y0,z0)-(x1,y1,z1).

Parameters:
x0X-coordinate of the upper-left rectangle corner.
y0Y-coordinate of the upper-left rectangle corner.
z0Z-coordinate of the upper-left rectangle corner.
x1X-coordinate of the lower-right rectangle corner.
y1Y-coordinate of the lower-right rectangle corner.
z1Z-coordinate of the lower-right rectangle corner.
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
Note:
  • Clipping is supported.
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const tc *const  color,
const float  opacity = 1 
)

Draw a 2d filled colored rectangle in the image instance, at coordinates (x0,y0)-(x1,y1).

Parameters:
x0X-coordinate of the upper-left rectangle corner.
y0Y-coordinate of the upper-left rectangle corner.
x1X-coordinate of the lower-right rectangle corner.
y1Y-coordinate of the lower-right rectangle corner.
colorPointer to spectrum() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
Note:
  • Clipping is supported.
CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const tc *const  color,
const float  opacity = 1 
)

Draw a filled circle.

Parameters:
x0X-coordinate of the circle center.
y0Y-coordinate of the circle center.
radiusCircle radius.
colorArray of spectrum() values of type T, defining the drawing color.
opacityDrawing opacity.
Note:
  • Circle version of the Bresenham's algorithm is used.
CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const tc *const  color,
const float  opacity,
const unsigned  int 
)

Draw an outlined circle.

Parameters:
x0X-coordinate of the circle center.
y0Y-coordinate of the circle center.
radiusCircle radius.
colorArray of spectrum() values of type T, defining the drawing color.
opacityDrawing opacity.
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const float  r1,
const float  r2,
const float  angle,
const tc *const  color,
const float  opacity = 1 
)

Draw a filled ellipse.

Parameters:
x0= X-coordinate of the ellipse center.
y0= Y-coordinate of the ellipse center.
r1= First radius of the ellipse.
r2= Second radius of the ellipse.
angle= Angle of the first radius.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity = 1 
)

Draw a filled ellipse.

Parameters:
x0= X-coordinate of the ellipse center.
y0= Y-coordinate of the ellipse center.
tensor= Diffusion tensor describing the ellipse.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const float  r1,
const float  r2,
const float  angle,
const tc *const  color,
const float  opacity,
const unsigned int  pattern 
)

Draw an outlined ellipse.

Parameters:
x0= X-coordinate of the ellipse center.
y0= Y-coordinate of the ellipse center.
r1= First radius of the ellipse.
r2= Second radius of the ellipse.
ru= X-coordinate of the orientation vector related to the first radius.
rv= Y-coordinate of the orientation vector related to the first radius.
color= array of spectrum() values of type T, defining the drawing color.
pattern= If zero, the ellipse is filled, else pattern is an integer whose bits describe the outline pattern.
opacity= opacity of the drawing.
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity,
const unsigned int  pattern 
)

Draw an outlined ellipse.

Parameters:
x0= X-coordinate of the ellipse center.
y0= Y-coordinate of the ellipse center.
tensor= Diffusion tensor describing the ellipse.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const int  c0,
const CImg< t > &  sprite,
const float  opacity = 1 
)

Draw an image.

Parameters:
spriteSprite image.
x0X-coordinate of the sprite position.
y0Y-coordinate of the sprite position.
z0Z-coordinate of the sprite position.
c0C-coordinate of the sprite position.
opacityDrawing opacity (optional).
Note:
  • Clipping is supported.
CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const int  c0,
const CImg< ti > &  sprite,
const CImg< tm > &  mask,
const float  opacity = 1,
const float  mask_valmax = 1 
)

Draw a sprite image in the image instance (masked version).

Parameters:
spriteSprite image.
maskMask image.
x0X-coordinate of the sprite position in the image instance.
y0Y-coordinate of the sprite position in the image instance.
z0Z-coordinate of the sprite position in the image instance.
c0C-coordinate of the sprite position in the image instance.
mask_valmaxMaximum pixel value of the mask image mask (optional).
opacityDrawing opacity.
Note:
  • Pixel values of mask set the opacity of the corresponding pixels in sprite.
  • Clipping is supported.
  • Dimensions along x,y and z of sprite and mask must be the same.
CImg<T>& draw_text ( const int  x0,
const int  y0,
const char *const  text,
const tc1 *const  foreground_color,
const tc2 *const  background_color,
const float  opacity,
const CImgList< t > &  font,
  ... 
)

Draw a text.

Parameters:
x0X-coordinate of the text in the image instance.
y0Y-coordinate of the text in the image instance.
foreground_colorArray of spectrum() values of type T, defining the foreground color (0 means 'transparent').
background_colorArray of spectrum() values of type T, defining the background color (0 means 'transparent').
fontFont used for drawing text.
opacityDrawing opacity.
format'printf'-style format string, followed by arguments.
Note:
Clipping is supported.
CImg<T>& draw_text ( const int  x0,
const int  y0,
const char *const  text,
const tc1 *const  foreground_color,
const tc2 *const  background_color,
const float  opacity = 1,
const unsigned int  font_height = 13,
  ... 
)

Draw a text.

Parameters:
x0X-coordinate of the text in the image instance.
y0Y-coordinate of the text in the image instance.
foreground_colorArray of spectrum() values of type T, defining the foreground color (0 means 'transparent').
background_colorArray of spectrum() values of type T, defining the background color (0 means 'transparent').
font_sizeSize of the font (exact match for 13,24,32,57).
opacityDrawing opacity.
format'printf'-style format string, followed by arguments.
Note:
Clipping is supported.
CImg<T>& draw_quiver ( const CImg< t1 > &  flow,
const t2 *const  color,
const float  opacity = 1,
const unsigned int  sampling = 25,
const float  factor = -20,
const bool  arrows = true,
const unsigned int  pattern = ~0U 
)

Draw a vector field in the image instance, using a colormap.

Parameters:
flowImage of 2d vectors used as input data.
colorImage of spectrum()-D vectors corresponding to the color of each arrow.
samplingLength (in pixels) between each arrow.
factorLength factor of each arrow (if <0, computed as a percentage of the maximum length).
opacityOpacity of the drawing.
patternUsed pattern to draw lines.
Note:
Clipping is supported.
CImg<T>& draw_quiver ( const CImg< t1 > &  flow,
const CImg< t2 > &  color,
const float  opacity = 1,
const unsigned int  sampling = 25,
const float  factor = -20,
const bool  arrows = true,
const unsigned int  pattern = ~0U 
)

Draw a vector field in the image instance, using a colormap.

Parameters:
flowImage of 2d vectors used as input data.
colorImage of spectrum()-D vectors corresponding to the color of each arrow.
samplingLength (in pixels) between each arrow.
factorLength factor of each arrow (if <0, computed as a percentage of the maximum length).
opacityOpacity of the drawing.
patternUsed pattern to draw lines.
Note:
Clipping is supported.
CImg<T>& draw_axis ( const CImg< t > &  xvalues,
const int  y,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U 
)

Draw a labeled horizontal axis on the image instance.

Parameters:
xvaluesLower bound of the x-range.
yY-coordinate of the horizontal axis in the image instance.
colorArray of spectrum() values of type T, defining the drawing color.
opacityDrawing opacity.
patternDrawing pattern.
opacity_outDrawing opacity of 'outside' axes.
Note:
if precision==0, precision of the labels is automatically computed.
CImg<T>& draw_graph ( const CImg< t > &  data,
const tc *const  color,
const float  opacity = 1,
const unsigned int  plot_type = 1,
const int  vertex_type = 1,
const double  ymin = 0,
const double  ymax = 0,
const unsigned int  pattern = ~0U 
)

Draw a 1d graph on the image instance.

Parameters:
dataImage containing the graph values I = f(x).
colorArray of spectrum() values of type T, defining the drawing color.
opacityDrawing opacity.
plot_typeDefine the type of the plot :

  • 0 = No plot.
  • 1 = Plot using segments.
  • 2 = Plot using cubic splines.
  • 3 = Plot with bars.
vertex_typeDefine the type of points :

  • 0 = No points.
  • 1 = Point.
  • 2 = Straight cross.
  • 3 = Diagonal cross.
  • 4 = Filled circle.
  • 5 = Outlined circle.
  • 6 = Square.
  • 7 = Diamond.
yminLower bound of the y-range.
ymaxUpper bound of the y-range.
patternDrawing pattern.
Note:
  • if ymin==ymax==0, the y-range is computed automatically from the input samples.
CImg<T>& draw_fill ( const int  x,
const int  y,
const int  z,
const tc *const  color,
const float  opacity,
CImg< t > &  region,
const float  sigma = 0,
const bool  high_connexity = false 
)

Draw a 3d filled region starting from a point (x,y,\ z) in the image instance.

Parameters:
xX-coordinate of the starting point of the region to fill.
yY-coordinate of the starting point of the region to fill.
zZ-coordinate of the starting point of the region to fill.
colorAn array of spectrum() values of type T, defining the drawing color.
regionImage that will contain the mask of the filled region mask, as an output.
sigmaTolerance concerning neighborhood values.
opacityOpacity of the drawing.
high_connexityTells if 8-connexity must be used (only for 2d images).
Returns:
region is initialized with the binary mask of the filled region.
CImg<T>& draw_fill ( const int  x,
const int  y,
const int  z,
const tc *const  color,
const float  opacity = 1,
const float  sigma = 0,
const bool  high_connexity = false 
)

Draw a 3d filled region starting from a point (x,y,\ z) in the image instance.

Parameters:
x= X-coordinate of the starting point of the region to fill.
y= Y-coordinate of the starting point of the region to fill.
z= Z-coordinate of the starting point of the region to fill.
color= an array of spectrum() values of type T, defining the drawing color.
sigma= tolerance concerning neighborhood values.
opacity= opacity of the drawing.
CImg<T>& draw_fill ( const int  x,
const int  y,
const tc *const  color,
const float  opacity = 1,
const float  sigma = 0,
const bool  high_connexity = false 
)

Draw a 2d filled region starting from a point (x,y) in the image instance.

Parameters:
x= X-coordinate of the starting point of the region to fill.
y= Y-coordinate of the starting point of the region to fill.
color= an array of spectrum() values of type T, defining the drawing color.
sigma= tolerance concerning neighborhood values.
opacity= opacity of the drawing.
CImg<T>& draw_plasma ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const float  alpha = 1,
const float  beta = 1,
const float  opacity = 1 
)

Draw a plasma random texture.

Parameters:
x0= X-coordinate of the upper-left corner of the plasma.
y0= Y-coordinate of the upper-left corner of the plasma.
x1= X-coordinate of the lower-right corner of the plasma.
y1= Y-coordinate of the lower-right corner of the plasma.
alpha= Alpha-parameter of the plasma.
beta= Beta-parameter of the plasma.
opacity= opacity of the drawing.
CImg<T>& draw_plasma ( const float  alpha = 1,
const float  beta = 1,
const float  opacity = 1 
)

Draw a plasma random texture.

Parameters:
alpha= Alpha-parameter of the plasma.
beta= Beta-parameter of the plasma.
opacity= opacity of the drawing.
CImg<T>& draw_gaussian ( const float  xc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)

Draw a 1d gaussian function in the image instance.

Parameters:
xc= X-coordinate of the gaussian center.
sigma= Standard variation of the gaussian distribution.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity = 1 
)

Draw an anisotropic 2d gaussian function.

Parameters:
xc= X-coordinate of the gaussian center.
yc= Y-coordinate of the gaussian center.
tensor= 2x2 covariance matrix.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)

Draw an isotropic 2d gaussian function.

Parameters:
xc= X-coordinate of the gaussian center.
yc= Y-coordinate of the gaussian center.
sigma= standard variation of the gaussian distribution.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  zc,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity = 1 
)

Draw an anisotropic 3d gaussian function.

Parameters:
xc= X-coordinate of the gaussian center.
yc= Y-coordinate of the gaussian center.
zc= Z-coordinate of the gaussian center.
tensor= 3x3 covariance matrix.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  zc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)

Draw an isotropic 3d gaussian function.

Parameters:
xc= X-coordinate of the gaussian center.
yc= Y-coordinate of the gaussian center.
zc= Z-coordinate of the gaussian center.
sigma= standard variation of the gaussian distribution.
color= array of spectrum() values of type T, defining the drawing color.
opacity= opacity of the drawing.
CImg<T>& draw_object3d ( const float  x0,
const float  y0,
const float  z0,
const CImg< tp > &  vertices,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors,
const CImg< to > &  opacities,
const unsigned int  render_type = 4,
const bool  double_sided = false,
const float  focale = 500,
const float  lightx = 0,
const float  lighty = 0,
const float  lightz = -5e8,
const float  specular_light = 0.2f,
const float  specular_shine = 0.1f 
)

Draw a 3d object.

Parameters:
X= X-coordinate of the 3d object position
Y= Y-coordinate of the 3d object position
Z= Z-coordinate of the 3d object position
vertices= Image Nx3 describing 3d point coordinates
primitives= List of P primitives
colors= List of P color (or textures)
opacities= Image or list of P opacities
render_type= Render type (0=Points, 1=Lines, 2=Faces (no light), 3=Faces (flat), 4=Faces(Gouraud)
double_sided= Tell if object faces have two sides or are oriented.
focale= length of the focale (0 for parallel projection)
lightx= X-coordinate of the light
lighty= Y-coordinate of the light
lightz= Z-coordinate of the light
specular_shine= Shininess of the object
CImg<T>& select ( CImgDisplay disp,
const unsigned int  feature_type = 2,
unsigned int *const  XYZ = 0 
)

Simple interface to select a shape from an image.

Parameters:
selectionArray of 6 values containing the selection result
feature_typeDetermine feature to select (0=point, 1=vector, 2=rectangle, 3=circle)
dispDisplay window used to make the selection
XYZInitial XYZ position (for volumetric images only)
colorColor of the shape selector.
CImg<T>& load ( const char *const  filename)

Load an image from a file.

Parameters:
filenameis the name of the image file to load.
Note:
The extension of filename defines the file format. If no filename extension is provided, CImg<T>::get_load() will try to load a .cimg file.
CImg<T>& load_tiff ( const char *const  filename,
const unsigned int  first_frame = 0,
const unsigned int  last_frame = ~0U,
const unsigned int  step_frame = 1 
)

Load an image from a TIFF file.

  • libtiff support is enabled by defining the precompilation directive cimg_use_tif.
  • When libtiff is enabled, 2D and 3D (multipage) several channel per pixel are supported for char,uchar,short,ushort,float and double pixel type.
See also:
CImg<T>& load_other(const char*)
CImg<T>& save_tiff(const char*, const unsigned int)
const CImg<T>& print ( const char *const  title = 0,
const bool  display_stats = true 
) const

Display informations about the image on the standard error output.

Parameters:
titleName for the considered image (optional).
display_statsCompute and display image statistics (optional).
const CImg<T>& save ( const char *const  filename,
const int  number = -1 
) const

Save the image as a file.

The used file format is defined by the file extension in the filename filename. Parameter number can be used to add a 6-digit number to the filename before saving.

const CImg<T>& save_tiff ( const char *const  filename,
const unsigned int  compression = 0 
) const

Save a file in TIFF format.

  • libtiff support is enabled by defining the precompilation directive cimg_use_tif.
  • When libtiff is enabled, 2D and 3D (multipage) several channel per pixel are supported for char,uchar,short,ushort,float and double pixel type.
  • If cimg_use_tif is not defined at compilation time the function uses CImg<T>&save_other(const char*).
Parameters:
compression1:None, 2:CCITTRLE, 3:CCITTFAX3, 4:CCITTFAX4, 5:LZW, 6:JPEG
See also:
CImg<T>& save_other(const char*)
CImg<T>& load_tiff(const char*)
const CImg<T>& save_graphicsmagick_external ( const char *const  filename,
const unsigned int  quality = 100 
) const

Save the image using GraphicsMagick's gm.

Function that saves the image for other file formats that are not natively handled by CImg, using the tool 'gm' from the GraphicsMagick package.
This is the case for all compressed image formats (GIF,PNG,JPG,TIF, ...). You need to install the GraphicsMagick package in order to get this function working properly (see http://www.graphicsmagick.org ).

const CImg<T>& save_imagemagick_external ( const char *const  filename,
const unsigned int  quality = 100 
) const

Save the image using ImageMagick's convert.

Function that saves the image for other file formats that are not natively handled by CImg, using the tool 'convert' from the ImageMagick package.
This is the case for all compressed image formats (GIF,PNG,JPG,TIF, ...). You need to install the ImageMagick package in order to get this function working properly (see http://www.imagemagick.org ).


Support This Project