Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CImg< T > Struct Template Reference

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

#include <CImg.h>

Inheritance diagram for CImg< T >:
Collaboration diagram for CImg< T >:

Classes

struct  _cimg_math_parser
 
struct  _marching2d_func
 
struct  _marching2d_func_expr
 
struct  _marching2d_func_float
 
struct  _marching3d_func
 
struct  _marching3d_func_expr
 
struct  _marching3d_func_float
 

Public Types

typedef T * iterator
 Iterator type for CImg<T>. More...
 
typedef const T * const_iterator
 Const iterator type for CImg<T>. More...
 
typedef T value_type
 Value type. More...
 
typedef cimg::superset< T,
bool >::type 
Tbool
 
typedef cimg::superset< T,
unsigned char >::type 
Tuchar
 
typedef cimg::superset< T,
char >::type 
Tchar
 
typedef cimg::superset< T,
unsigned short >::type 
Tushort
 
typedef cimg::superset< T,
short >::type 
Tshort
 
typedef cimg::superset< T,
unsigned int >::type 
Tuint
 
typedef cimg::superset< T, int >
::type 
Tint
 
typedef cimg::superset< T,
unsigned long >::type 
Tulong
 
typedef cimg::superset< T,
long >::type 
Tlong
 
typedef cimg::superset< T,
float >::type 
Tfloat
 
typedef cimg::superset< T,
double >::type 
Tdouble
 
typedef cimg::last< T, bool >::type boolT
 
typedef cimg::last< T,
unsigned char >::type 
ucharT
 
typedef cimg::last< T, char >::type charT
 
typedef cimg::last< T,
unsigned short >::type 
ushortT
 
typedef cimg::last< T, short >
::type 
shortT
 
typedef cimg::last< T,
unsigned int >::type 
uintT
 
typedef cimg::last< T, int >::type intT
 
typedef cimg::last< T,
unsigned long >::type 
ulongT
 
typedef cimg::last< T, long >::type longT
 
typedef cimg::last< T, float >
::type 
floatT
 
typedef cimg::last< T, double >
::type 
doubleT
 

Public Member Functions

Overloaded Operators
T & operator[] (const unsigned int off)
 Fast access to pixel value for reading or writing, using an offset to the image pixel. More...
 
const T & operator[] (const unsigned int off) const
 
T & operator() (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0)
 Fast access to pixel value for reading or writing. More...
 
const T & operator() (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const
 
 operator bool () const
 Return true if image is not empty. More...
 
CImg< T > & operator= (const T val)
 Operator=(). More...
 
CImg< T > & operator= (const char *const expression)
 Operator=(). More...
 
template<typename t >
CImg< T > & operator= (const CImg< t > &img)
 Operator=(). More...
 
CImg< T > & operator= (const CImg< T > &img)
 
CImg< T > & operator= (const CImgDisplay &disp)
 Operator=(). More...
 
template<typename t >
CImg< T > & operator+= (const t val)
 Operator+=(). More...
 
CImg< T > & operator+= (const char *const expression)
 Operator+=(). More...
 
template<typename t >
CImg< T > & operator+= (const CImg< t > &img)
 Operator+=(). More...
 
CImg< T > & operator++ ()
 Operator++() (prefix). More...
 
CImg< T > operator++ (int)
 Operator++() (postfix). More...
 
CImg< T > operator+ () const
 Operator+() (unary). More...
 
template<typename t >
CImg< _cimg_Ttoperator+ (const t val) const
 Operator+(). More...
 
CImg< Tfloatoperator+ (const char *const expression) const
 Operator+(). More...
 
template<typename t >
CImg< _cimg_Ttoperator+ (const CImg< t > &img) const
 Operator+(). More...
 
template<typename t >
CImg< T > & operator-= (const t val)
 Operator-=(). More...
 
CImg< T > & operator-= (const char *const expression)
 Operator-=(). More...
 
template<typename t >
CImg< T > & operator-= (const CImg< t > &img)
 Operator-=(). More...
 
CImg< T > & operator-- ()
 Operator–() (prefix). More...
 
CImg< T > operator-- (int)
 Operator–() (postfix). More...
 
CImg< T > operator- () const
 Operator-() (unary). More...
 
template<typename t >
CImg< _cimg_Ttoperator- (const t val) const
 Operator-(). More...
 
CImg< Tfloatoperator- (const char *const expression) const
 Operator-(). More...
 
template<typename t >
CImg< _cimg_Ttoperator- (const CImg< t > &img) const
 Operator-(). More...
 
template<typename t >
CImg< T > & operator*= (const t val)
 Operator*=(). More...
 
CImg< T > & operator*= (const char *const expression)
 Operator*=(). More...
 
template<typename t >
CImg< T > & operator*= (const CImg< t > &img)
 Operator*=(). More...
 
template<typename t >
CImg< _cimg_Ttoperator* (const t val) const
 Operator*(). More...
 
CImg< Tfloatoperator* (const char *const expression) const
 Operator*(). More...
 
template<typename t >
CImg< _cimg_Ttoperator* (const CImg< t > &img) const
 Operator*(). More...
 
template<typename t >
CImg< T > & operator/= (const t val)
 Operator/=(). More...
 
CImg< T > & operator/= (const char *const expression)
 Operator/=(). More...
 
template<typename t >
CImg< T > & operator/= (const CImg< t > &img)
 Operator/=(). More...
 
template<typename t >
CImg< _cimg_Ttoperator/ (const t val) const
 Operator/(). More...
 
CImg< Tfloatoperator/ (const char *const expression) const
 Operator/(). More...
 
template<typename t >
CImg< _cimg_Ttoperator/ (const CImg< t > &img) const
 Operator/(). More...
 
template<typename t >
CImg< T > & operator%= (const t val)
 Operator%=(). More...
 
CImg< T > & operator%= (const char *const expression)
 Operator%=(). More...
 
template<typename t >
CImg< T > & operator%= (const CImg< t > &img)
 Operator%=(). More...
 
template<typename t >
CImg< _cimg_Ttoperator% (const t val) const
 Operator%(). More...
 
CImg< Tfloatoperator% (const char *const expression) const
 Operator%(). More...
 
template<typename t >
CImg< _cimg_Ttoperator% (const CImg< t > &img) const
 Operator%(). More...
 
template<typename t >
CImg< T > & operator&= (const t val)
 Operator&=(). More...
 
CImg< T > & operator&= (const char *const expression)
 Operator&=(). More...
 
template<typename t >
CImg< T > & operator&= (const CImg< t > &img)
 Operator&=(). More...
 
template<typename t >
CImg< T > operator& (const t val) const
 Operator&(). More...
 
template<typename t >
CImg< T > & operator|= (const t val)
 Operator|=(). More...
 
CImg< T > & operator|= (const char *const expression)
 Operator|=(). More...
 
template<typename t >
CImg< T > & operator|= (const CImg< t > &img)
 Operator|=(). More...
 
template<typename t >
CImg< T > operator| (const t val) const
 Operator|(). More...
 
template<typename t >
CImg< T > & operator^= (const t val)
 Operator^=(). More...
 
CImg< T > & operator^= (const char *const expression)
 Operator^=(). More...
 
template<typename t >
CImg< T > & operator^= (const CImg< t > &img)
 Operator^=(). More...
 
template<typename t >
CImg< T > operator^ (const t val) const
 Operator^(). More...
 
CImg< T > operator~ () const
 Operator~(). More...
 
CImg< T > & operator<<= (const int n)
 Operator<<=(). More...
 
CImg< T > operator<< (const int n) const
 Operator<<(). More...
 
CImg< T > & operator>>= (const int n)
 Operator>>=(). More...
 
CImg< T > operator>> (const int n) const
 Operator>>(). More...
 
template<typename t >
bool operator== (const CImg< t > &img) const
 Operator==(). More...
 
template<typename t >
bool operator!= (const CImg< t > &img) const
 Operator!=(). More...
 
template<typename t >
CImgList< _cimg_Ttoperator, (const CImg< t > &img) const
 Operator,(). More...
 
template<typename t >
CImgList< _cimg_Ttoperator, (CImgList< t > &list) const
 Operator,(). More...
 
CImgList< T > operator< (const char axis) const
 Operator<(). More...
 
Instance Checking
bool is_empty () const
 Return true if current image is empty. More...
 
bool is_sameX (const unsigned int dx) const
 Return true if image (*this) has the specified width. More...
 
template<typename t >
bool is_sameX (const CImg< t > &img) const
 Return true if images (*this) and img have same width. More...
 
bool is_sameX (const CImgDisplay &disp) const
 Return true if images (*this) and the display disp have same width. More...
 
bool is_sameY (const unsigned int dy) const
 Return true if image (*this) has the specified height. More...
 
template<typename t >
bool is_sameY (const CImg< t > &img) const
 Return true if images (*this) and img have same height. More...
 
bool is_sameY (const CImgDisplay &disp) const
 Return true if images (*this) and the display disp have same height. More...
 
bool is_sameZ (const unsigned int dz) const
 Return true if image (*this) has the specified depth. More...
 
template<typename t >
bool is_sameZ (const CImg< t > &img) const
 Return true if images (*this) and img have same depth. More...
 
bool is_sameV (const unsigned int dv) const
 Return true if image (*this) has the specified number of channels. More...
 
template<typename t >
bool is_sameV (const CImg< t > &img) const
 Return true if images (*this) and img have same dim. More...
 
bool is_sameXY (const unsigned int dx, const unsigned int dy) const
 Return true if image (*this) has the specified width and height. More...
 
template<typename t >
bool is_sameXY (const CImg< t > &img) const
 Return true if images have same width and same height. More...
 
bool is_sameXY (const CImgDisplay &disp) const
 Return true if image (*this) and the display disp have same width and same height. More...
 
bool is_sameXZ (const unsigned int dx, const unsigned int dz) const
 Return true if image (*this) has the specified width and depth. More...
 
template<typename t >
bool is_sameXZ (const CImg< t > &img) const
 Return true if images have same width and same depth. More...
 
bool is_sameXV (const unsigned int dx, const unsigned int dv) const
 Return true if image (*this) has the specified width and number of channels. More...
 
template<typename t >
bool is_sameXV (const CImg< t > &img) const
 Return true if images have same width and same number of channels. More...
 
bool is_sameYZ (const unsigned int dy, const unsigned int dz) const
 Return true if image (*this) has the specified height and depth. More...
 
template<typename t >
bool is_sameYZ (const CImg< t > &img) const
 Return true if images have same height and same depth. More...
 
bool is_sameYV (const unsigned int dy, const unsigned int dv) const
 Return true if image (*this) has the specified height and number of channels. More...
 
template<typename t >
bool is_sameYV (const CImg< t > &img) const
 Return true if images have same height and same number of channels. More...
 
bool is_sameZV (const unsigned int dz, const unsigned int dv) const
 Return true if image (*this) has the specified depth and number of channels. More...
 
template<typename t >
bool is_sameZV (const CImg< t > &img) const
 Return true if images have same depth and same number of channels. More...
 
bool is_sameXYZ (const unsigned int dx, const unsigned int dy, const unsigned int dz) const
 Return true if image (*this) has the specified width, height and depth. More...
 
template<typename t >
bool is_sameXYZ (const CImg< t > &img) const
 Return true if images have same width, same height and same depth. More...
 
bool is_sameXYV (const unsigned int dx, const unsigned int dy, const unsigned int dv) const
 Return true if image (*this) has the specified width, height and depth. More...
 
template<typename t >
bool is_sameXYV (const CImg< t > &img) const
 Return true if images have same width, same height and same number of channels. More...
 
bool is_sameXZV (const unsigned int dx, const unsigned int dz, const unsigned int dv) const
 Return true if image (*this) has the specified width, height and number of channels. More...
 
template<typename t >
bool is_sameXZV (const CImg< t > &img) const
 Return true if images have same width, same depth and same number of channels. More...
 
bool is_sameYZV (const unsigned int dy, const unsigned int dz, const unsigned int dv) const
 Return true if image (*this) has the specified height, depth and number of channels. More...
 
template<typename t >
bool is_sameYZV (const CImg< t > &img) const
 Return true if images have same heigth, same depth and same number of channels. More...
 
bool is_sameXYZV (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv) const
 Return true if image (*this) has the specified width, height, depth and number of channels. More...
 
template<typename t >
bool is_sameXYZV (const CImg< t > &img) const
 Return true if images (*this) and img have same width, same height, same depth and same number of channels. More...
 
bool containsXYZV (const int x, const int y=0, const int z=0, const int v=0) const
 Return true if pixel (x,y,z,v) is inside image boundaries. More...
 
template<typename t >
bool contains (const T &pixel, t &x, t &y, t &z, t &v) const
 Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y,z,v). More...
 
template<typename t >
bool contains (const T &pixel, t &x, t &y, t &z) const
 Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y,z). More...
 
template<typename t >
bool contains (const T &pixel, t &x, t &y) const
 Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y). More...
 
template<typename t >
bool contains (const T &pixel, t &x) const
 Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x). More...
 
bool contains (const T &pixel) const
 Return true if specified referenced value is inside the image boundaries. More...
 
template<typename t >
bool is_overlapped (const CImg< t > &img) const
 Return true if the memory buffers of the two images overlaps. More...
 
template<typename tf >
bool is_object3d (const CImgList< tf > &primitives, const bool check_primitives=true, const bool throw_exception=false, const char *const calling_function=0) const
 Return true if the couple (instance,primitives) stands for a valid 3D object. More...
 
Mathematical Functions
CImg< T > & sqr ()
 Compute the square value of each pixel. More...
 
CImg< Tfloatget_sqr () const
 
CImg< T > & sqrt ()
 Compute the square root of each pixel value. More...
 
CImg< Tfloatget_sqrt () const
 
CImg< T > & exp ()
 Compute the exponential of each pixel value. More...
 
CImg< Tfloatget_exp () const
 
CImg< T > & log ()
 Compute the log of each each pixel value. More...
 
CImg< Tfloatget_log () const
 
CImg< T > & log10 ()
 Compute the log10 of each each pixel value. More...
 
CImg< Tfloatget_log10 () const
 
CImg< T > & abs ()
 Compute the absolute value of each pixel value. More...
 
CImg< Tfloatget_abs () const
 
CImg< T > & cos ()
 Compute the cosinus of each pixel value. More...
 
CImg< Tfloatget_cos () const
 
CImg< T > & sin ()
 Compute the sinus of each pixel value. More...
 
CImg< Tfloatget_sin () const
 
CImg< T > & tan ()
 Compute the tangent of each pixel. More...
 
CImg< Tfloatget_tan () const
 
CImg< T > & cosh ()
 Compute the hyperbolic cosine of each pixel value. More...
 
CImg< Tfloatget_cosh () const
 
CImg< T > & sinh ()
 Compute the hyperbolic sine of each pixel value. More...
 
CImg< Tfloatget_sinh () const
 
CImg< T > & tanh ()
 Compute the hyperbolic tangent of each pixel value. More...
 
CImg< Tfloatget_tanh () const
 
CImg< T > & acos ()
 Compute the arc-cosine of each pixel value. More...
 
CImg< Tfloatget_acos () const
 
CImg< T > & asin ()
 Compute the arc-sinus of each pixel value. More...
 
CImg< Tfloatget_asin () const
 
CImg< T > & atan ()
 Compute the arc-tangent of each pixel. More...
 
CImg< Tfloatget_atan () const
 
template<typename t >
CImg< T > & atan2 (const CImg< t > &img)
 Compute the arc-tangent of each pixel. More...
 
template<typename t >
CImg< Tfloatget_atan2 (const CImg< t > &img) const
 
template<typename t >
CImg< T > & mul (const CImg< t > &img)
 Pointwise multiplication between two images. More...
 
template<typename t >
CImg< _cimg_Ttget_mul (const CImg< t > &img) const
 
template<typename t >
CImg< T > & div (const CImg< t > &img)
 Pointwise division between two images. More...
 
template<typename t >
CImg< _cimg_Ttget_div (const CImg< t > &img) const
 
CImg< T > & pow (const double p)
 Compute the power by p of each pixel value. More...
 
CImg< Tfloatget_pow (const double p) const
 
template<typename t >
CImg< T > & pow (const CImg< t > &img)
 Compute the power of each pixel value. More...
 
template<typename t >
CImg< Tfloatget_pow (const CImg< t > &img) const
 
CImg< T > & pow (const char *const expression)
 Compute the power of each pixel value. More...
 
CImg< Tfloatget_pow (const char *const expression) const
 
CImg< T > & min (const T val)
 Pointwise min operator between an image and a value. More...
 
CImg< T > get_min (const T val) const
 
template<typename t >
CImg< T > & min (const CImg< t > &img)
 Pointwise min operator between two images. More...
 
template<typename t >
CImg< _cimg_Ttget_min (const CImg< t > &img) const
 
CImg< T > & min (const char *const expression)
 Pointwise min operator between an image and a string. More...
 
CImg< Tfloatget_min (const char *const expression) const
 
CImg< T > & max (const T val)
 Pointwise max operator between an image and a value. More...
 
CImg< T > get_max (const T val) const
 
template<typename t >
CImg< T > & max (const CImg< t > &img)
 Pointwise max operator between two images. More...
 
template<typename t >
CImg< _cimg_Ttget_max (const CImg< t > &img) const
 
CImg< T > & max (const char *const expression)
 Pointwise max operator between an image and a string. More...
 
CImg< Tfloatget_max (const char *const expression) const
 
T & min ()
 Return a reference to the minimum pixel value of the instance image. More...
 
const T & min () const
 
T & max ()
 Return a reference to the maximum pixel value of the instance image. More...
 
const T & max () const
 
template<typename t >
T & minmax (t &max_val)
 Return a reference to the minimum pixel value and return also the maximum pixel value. More...
 
template<typename t >
const T & minmax (t &max_val) const
 
template<typename t >
T & maxmin (t &min_val)
 Return a reference to the maximum pixel value and return also the minimum pixel value. More...
 
template<typename t >
const T & maxmin (t &min_val) const
 
kth_smallest (const unsigned int k) const
 Return the kth smallest element of the image. More...
 
median () const
 Return the median value of the image. More...
 
Tfloat sum () const
 Return the sum of all the pixel values in an image. More...
 
Tfloat mean () const
 Return the mean pixel value of the instance image. More...
 
Tfloat variance (const unsigned int variance_method=1) const
 Return the variance of the image. More...
 
template<typename t >
Tfloat variancemean (const unsigned int variance_method, t &mean) const
 Return the variance and the mean of the image. More...
 
template<typename t >
Tfloat MSE (const CImg< t > &img) const
 Compute the MSE (Mean-Squared Error) between two images. More...
 
template<typename t >
Tfloat PSNR (const CImg< t > &img, const Tfloat valmax=(Tfloat) 255) const
 Compute the PSNR between two images. More...
 
double eval (const char *const expression, const double x=0, const double y=0, const double z=0, const double v=0) const
 Evaluate math expression. More...
 
CImg< T > & stats (const unsigned int variance_method=1)
 Compute a statistics vector (min,max,mean,variance,xmin,ymin,zmin,vmin,xmax,ymax,zmax,vmax). More...
 
CImg< Tfloatget_stats (const unsigned int variance_method=1) const
 
Value Manipulation
CImg< T > & fill (const T val)
 Fill an image by a value val. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 v, const int a0,...)
 Fill image values along the X-axis at the specified pixel position (y,z,v). More...
 
CImg< T > & fillX (const unsigned int y, const unsigned int z, const unsigned int v, const double a0,...)
 
CImg< T > & fillY (const unsigned int x, const unsigned int z, const unsigned int v, const int a0,...)
 Fill image values along the Y-axis at the specified pixel position (x,z,v). More...
 
CImg< T > & fillY (const unsigned int x, const unsigned int z, const unsigned int v, const double a0,...)
 
CImg< T > & fillZ (const unsigned int x, const unsigned int y, const unsigned int v, const int a0,...)
 Fill image values along the Z-axis at the specified pixel position (x,y,v). More...
 
CImg< T > & fillZ (const unsigned int x, const unsigned int y, const unsigned int v, const double a0,...)
 
CImg< T > & fillV (const unsigned int x, const unsigned int y, const unsigned int z, const int a0,...)
 Fill image values along the V-axis at the specified pixel position (x,y,z). More...
 
CImg< T > & fillV (const unsigned int x, const unsigned int y, const unsigned int z, const double a0,...)
 
CImg< T > & invert_endianness ()
 Invert endianness of the image buffer. More...
 
CImg< T > get_invert_endianness () const
 
CImg< T > & rand (const T val_min, const T val_max)
 Fill the instance image with random values between specified range. More...
 
CImg< T > get_rand (const T val_min, const T val_max) const
 
CImg< T > & round (const float x, const int rounding_type=0)
 Compute image with rounded pixel values. More...
 
CImg< T > get_round (const float x, 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 instance image. More...
 
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 instance image between value_min and value_max. More...
 
CImg< Tfloatget_normalize (const T value_min, const T value_max) const
 
CImg< T > & normalize ()
 Normalize multi-valued pixels of the instance image, with respect to their L2-norm. More...
 
CImg< Tfloatget_normalize () const
 
CImg< T > & norm (const int norm_type=2)
 Compute L2-norm of each multi-valued pixel of the instance image. More...
 
CImg< Tfloatget_norm (const int norm_type=2) const
 
CImg< T > & cut (const T value_min, const T value_max)
 Cut values of the instance image between value_min and value_max. More...
 
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 instance image into nb_levels levels. More...
 
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 instance image. More...
 
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 instance image. More...
 
CImg< floatTget_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 instance image. More...
 
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 instance image, regarding to a predefined palette. More...
 
template<typename t >
CImg< typename cimg::superset
< t, unsigned int >::type > 
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) instance image. More...
 
template<typename t >
CImg< t > get_map (const CImg< t > &palette) const
 
CImg< T > & label_regions ()
 Create a map of indexed labels counting disconnected regions with same intensities. More...
 
CImg< uintTget_label_regions () const
 
Geometric / Spatial Manipulation
CImg< T > & resize (const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
 Resize an image. More...
 
CImg< T > get_resize (const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
 
template<typename t >
CImg< T > & resize (const CImg< t > &src, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
 Resize an image. More...
 
template<typename t >
CImg< T > get_resize (const CImg< t > &src, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
 
CImg< T > & resize (const CImgDisplay &disp, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
 Resize an image. More...
 
CImg< T > get_resize (const CImgDisplay &disp, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
 
CImg< T > & resize_halfXY ()
 Half-resize an image, using a special optimized filter. More...
 
CImg< T > get_resize_halfXY () const
 
CImg< T > & resize_doubleXY ()
 Upscale an image by a factor 2x. More...
 
CImg< T > get_resize_doubleXY () const
 
CImg< T > & resize_tripleXY ()
 Upscale an image by a factor 3x. More...
 
CImg< T > get_resize_tripleXY () const
 
CImg< T > & mirror (const char axis)
 Mirror an image along the specified axis. More...
 
CImg< T > get_mirror (const char axis) const
 
CImg< T > & translate (const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, const int border_condition=0)
 Translate the image. More...
 
CImg< T > get_translate (const int deltax, const int deltay=0, const int deltaz=0, const int deltav=0, const int border_condition=0) const
 
template<typename t >
CImg< t > _get_permute_axes (const char *permut, const t &) const
 
CImg< T > & permute_axes (const char *order)
 Permute axes order. More...
 
CImg< T > get_permute_axes (const char *order) const
 
CImg< T > & unroll (const char axis)
 Unroll all images values into specified axis. More...
 
CImg< T > get_unroll (const char axis) const
 
CImg< T > & rotate (const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1)
 Rotate an image. More...
 
CImg< T > get_rotate (const float angle, const unsigned int border_conditions=3, 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). More...
 
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 relative=false, const bool interpolation=true, const unsigned int border_conditions=0)
 Warp an image. More...
 
template<typename t >
CImg< T > get_warp (const CImg< t > &warp, const bool 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, const int dx=-100, const int dy=-100, const int dz=-100)
 Return a 2D representation of a 3D image, with three slices. More...
 
CImg< T > get_projections2d (const unsigned int x0, const unsigned int y0, const unsigned int z0, const int dx=-100, const int dy=-100, const int dz=-100) const
 
CImg< T > & crop (const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
 Get a square region of the image. More...
 
CImg< T > get_crop (const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, 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 instance image. More...
 
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 instance image. More...
 
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 instance image. More...
 
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="vzyx")
 Autocrop an image, regarding of the specified backround value. More...
 
CImg< T > get_autocrop (const T value, const char *const axes="vzyx") const
 
CImg< T > & autocrop (const T *const color, const char *const axes="zyx")
 Autocrop an image, regarding of the specified backround color. More...
 
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. More...
 
template<typename t >
CImg< T > get_autocrop (const CImg< t > &color, const char *const axes="zyx") const
 
CImg< intT_autocrop (const T value, const char axis) const
 
CImg< T > & column (const unsigned int x0)
 Get one column. More...
 
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. More...
 
CImg< T > get_columns (const unsigned int x0, const unsigned int x1) const
 
CImg< T > & line (const unsigned int y0)
 Get a line. More...
 
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. More...
 
CImg< T > get_lines (const unsigned int y0, const unsigned int y1) const
 
CImg< T > & slice (const unsigned int z0)
 Get a slice. More...
 
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. More...
 
CImg< T > get_slices (const unsigned int z0, const unsigned int z1) const
 
CImg< T > & channel (const unsigned int v0)
 Get a channel. More...
 
CImg< T > get_channel (const unsigned int v0) const
 
CImg< T > & channels (const unsigned int v0, const unsigned int v1)
 Get a set of channels. More...
 
CImg< T > get_channels (const unsigned int v0, const unsigned int v1) 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 v0=0)
 Get a shared-memory image referencing a set of points of the instance image. More...
 
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 v0=0) const
 
CImg< T > get_shared_lines (const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0)
 Return a shared-memory image referencing a set of lines of the instance image. More...
 
const CImg< T > get_shared_lines (const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0) const
 
CImg< T > get_shared_line (const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
 Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image. More...
 
const CImg< T > get_shared_line (const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0) const
 
CImg< T > get_shared_planes (const unsigned int z0, const unsigned int z1, const unsigned int v0=0)
 Return a shared memory image referencing a set of planes (z0->z1,v0) of the instance image. More...
 
const CImg< T > get_shared_planes (const unsigned int z0, const unsigned int z1, const unsigned int v0=0) const
 
CImg< T > get_shared_plane (const unsigned int z0, const unsigned int v0=0)
 Return a shared-memory image referencing one plane (z0,v0) of the instance image. More...
 
const CImg< T > get_shared_plane (const unsigned int z0, const unsigned int v0=0) const
 
CImg< T > get_shared_channels (const unsigned int v0, const unsigned int v1)
 Return a shared-memory image referencing a set of channels (v0->v1) of the instance image. More...
 
const CImg< T > get_shared_channels (const unsigned int v0, const unsigned int v1) const
 
CImg< T > get_shared_channel (const unsigned int v0)
 Return a shared-memory image referencing one channel v0 of the instance image. More...
 
const CImg< T > get_shared_channel (const unsigned int v0) const
 
CImgList< T > get_split (const char axis, const int nb=0) const
 Split image into a list. More...
 
CImgList< T > get_split (const T value, const bool keep_values, const bool shared, const char axis='y') const
 
template<typename t >
CImg< T > & append (const CImg< t > &img, const char axis='x', const char align='p')
 Append an image. More...
 
CImg< T > & append (const CImg< T > &img, const char axis='x', const char align='p')
 
template<typename t >
CImg< _cimg_Ttget_append (const CImg< T > &img, const char axis='x', const char align='p') const
 
CImg< T > get_append (const CImg< T > &img, const char axis='x', const char align='p') const
 
Drawing Functions
template<typename tc >
CImg< T > & _draw_scanline (const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
 
template<typename tc >
CImg< T > & _draw_scanline (const tc *const color, const float opacity=1)
 
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). More...
 
template<typename tc >
CImg< T > & draw_point (const int x0, const int y0, const CImg< tc > &color, const float opacity=1)
 Draw a 2D colored point (pixel). More...
 
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). More...
 
template<typename tc >
CImg< T > & draw_point (const int x0, const int y0, const int z0, const CImg< tc > &color, const float opacity=1)
 Draw a 3D colored point (voxel). More...
 
template<typename t , typename tc >
CImg< T > & _draw_point (const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity)
 
template<typename t , typename tc >
CImg< T > & draw_point (const CImgList< t > &points, const tc *const color, const float opacity=1)
 Draw a cloud of colored points. More...
 
template<typename t , typename tc >
CImg< T > & draw_point (const CImgList< t > &points, const CImg< tc > &color, const float opacity=1)
 Draw a cloud of colored points. More...
 
template<typename t , typename tc >
CImg< T > & draw_point (const CImg< t > &points, const tc *const color, const float opacity=1)
 Draw a cloud of colored points. More...
 
template<typename t , typename tc >
CImg< T > & draw_point (const CImg< t > &points, const CImg< tc > &color, const float opacity=1)
 Draw a cloud of colored points. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_line (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2D colored line. More...
 
template<typename tc >
CImg< T > & draw_line (CImg< floatT > &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. More...
 
template<typename tc >
CImg< T > & draw_line (CImg< floatT > &zbuffer, const int x0, const int y0, const float z0, const int x1, const int y1, const float z1, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 2D colored line, with z-buffering. More...
 
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. More...
 
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 CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a 3D colored line. More...
 
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. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_line (CImg< floatT > &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. More...
 
template<typename t , typename tc >
CImg< T > & _draw_line (const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern, const bool init_hatch)
 
template<typename t , typename tc >
CImg< T > & draw_line (const CImgList< 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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_line (const CImgList< t > &points, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a set of consecutive colored lines in the instance image. More...
 
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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_line (const CImg< t > &points, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a set of consecutive colored lines in the instance image. More...
 
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 instance image. More...
 
template<typename tc >
CImg< T > & draw_arrow (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1, const float angle=30, const float length=-10, const unsigned int pattern=~0U)
 Draw a colored arrow in the instance image. More...
 
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
 Draw a cubic spline curve in the instance image. More...
 
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 CImg< tc > &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 instance image. More...
 
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 instance image (for volumetric images). More...
 
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 CImg< tc > &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 instance image (for volumetric images). More...
 
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 instance image. More...
 
template<typename tp , typename tt , typename tc >
CImg< T > & _draw_spline (const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
 
template<typename tp , typename tc >
CImg< T > & _draw_spline (const tp &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
 
template<typename tp , typename tt , typename tc >
CImg< T > & draw_spline (const CImgList< tp > &points, const CImgList< 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)
 Draw a set of consecutive colored splines in the instance image. More...
 
template<typename tp , typename tt , typename tc >
CImg< T > & draw_spline (const CImgList< tp > &points, const CImgList< tt > &tangents, const CImg< tc > &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 instance image. More...
 
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)
 Draw a set of consecutive colored splines in the instance image. More...
 
template<typename tp , typename tt , typename tc >
CImg< T > & draw_spline (const CImg< tp > &points, const CImg< tt > &tangents, const CImg< tc > &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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_spline (const CImgList< t > &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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_spline (const CImgList< t > &points, CImg< tc > &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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_spline (const CImg< t > &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 lines in the instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_spline (const CImg< t > &points, const CImg< tc > &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 lines in the instance image. More...
 
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 float brightness)
 
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. More...
 
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 > &color, const float opacity=1)
 Draw a 2D filled colored triangle. More...
 
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. More...
 
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 > &color, const float opacity, const unsigned int pattern)
 Draw a 2D outlined colored triangle. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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 > &color, const float opacity=1, const float brightness=1)
 Draw a 2D filled colored triangle, with z-buffering. More...
 
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. More...
 
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 > &color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a 2D Gouraud-shaded colored triangle. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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 > &color, const float brightness0, const float brightness1, const float brightness2, const float opacity=1)
 Draw a Gouraud triangle with z-buffer consideration. More...
 
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. More...
 
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 CImg< tc1 > &color1, const CImg< tc2 > &color2, const CImg< tc3 > &color3, const float opacity=1)
 
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. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
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. More...
 
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 > &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. More...
 
template<typename tc , typename tl >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
template<typename tc , typename tl >
CImg< T > & draw_triangle (CImg< floatT > &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 > &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. More...
 
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. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
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. More...
 
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. More...
 
template<typename tc , typename tl >
CImg< T > & draw_triangle (CImg< floatT > &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. More...
 
CImg< T > & draw_rectangle (const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
 Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1). More...
 
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 instance image, at coordinates (x0,y0,z0)-(x1,y1,z1). More...
 
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 CImg< tc > &color, const float opacity=1)
 Draw a 3D filled colored rectangle in the instance image, at coordinates (x0,y0,z0)-(x1,y1,z1). More...
 
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 instance image. More...
 
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 CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw a 3D outlined colored rectangle in the instance image. More...
 
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 instance image, at coordinates (x0,y0)-(x1,y1). More...
 
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity=1)
 Draw a 2D filled colored rectangle in the instance image, at coordinates (x0,y0)-(x1,y1). More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_rectangle (const int x0, const int y0, const int x1, const int y1, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw a 2D outlined colored rectangle. More...
 
template<typename t , typename tc >
CImg< T > & _draw_polygon (const t &points, const unsigned int N, const tc *const color, const float opacity)
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImgList< t > &points, const tc *const color, const float opacity=1)
 Draw a filled polygon in the instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImgList< t > &points, const CImg< tc > &color, const float opacity=1)
 Draw a filled polygon in the instance image. More...
 
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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImg< t > &points, const CImg< tc > &color, const float opacity=1)
 Draw a filled polygon in the instance image. More...
 
template<typename t , typename tc >
CImg< T > & _draw_polygon (const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern)
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImgList< t > &points, const tc *const color, const float opacity, const unsigned int pattern)
 Draw a polygon outline. More...
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImgList< t > &points, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw a polygon outline. More...
 
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 polygon outline. More...
 
template<typename t , typename tc >
CImg< T > & draw_polygon (const CImg< t > &points, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw a polygon outline. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_circle (const int x0, const int y0, int radius, const CImg< tc > &color, const float opacity=1)
 Draw a filled circle. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_circle (const int x0, const int y0, int radius, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw an outlined circle. More...
 
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)
 
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. More...
 
template<typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const float r1, const float r2, const float angle, const CImg< tc > &color, const float opacity=1)
 Draw a filled ellipse. More...
 
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. More...
 
template<typename t , typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
 Draw a filled ellipse. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const float r1, const float r2, const float angle, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw an outlined ellipse. More...
 
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. More...
 
template<typename t , typename tc >
CImg< T > & draw_ellipse (const int x0, const int y0, const CImg< t > &tensor, const CImg< tc > &color, const float opacity, const unsigned int pattern)
 Draw an outlined ellipse. More...
 
template<typename t >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
 Draw an image. More...
 
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int v0, 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. More...
 
template<typename t >
CImg< T > & draw_image (const int x0, const int y0, const CImg< t > &sprite, const float opacity=1)
 Draw an image. More...
 
template<typename t >
CImg< T > & draw_image (const int x0, const CImg< t > &sprite, const float opacity=1)
 Draw an image. More...
 
template<typename t >
CImg< T > & draw_image (const CImg< t > &sprite, const float opacity=1)
 Draw an image. More...
 
template<typename ti , typename tm >
CImg< T > & draw_image (const int x0, const int y0, const int z0, const int v0, const CImg< ti > &sprite, const CImg< tm > &mask, const float opacity=1, const float mask_valmax=1)
 Draw a sprite image in the instance image (masked version). More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename tc1 , typename tc2 , typename t >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const CImg< tc1 > &foreground_color, const CImg< tc2 > &background_color, const float opacity, const CImgList< t > &font,...)
 Draw a text. More...
 
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,...)
 Draw a text. More...
 
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,...)
 Draw a text. More...
 
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_size=11,...)
 Draw a text. More...
 
template<typename tc1 , typename tc2 >
CImg< T > & draw_text (const int x0, const int y0, const char *const text, const CImg< tc1 > &foreground_color, const CImg< tc2 > &background_color, const float opacity=1, const unsigned int font_size=11,...)
 Draw a text. More...
 
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_size=11,...)
 Draw a text. More...
 
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_size=11,...)
 Draw a text. More...
 
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)
 
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 instance image, using a colormap. More...
 
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 instance image, using a colormap. More...
 
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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_axis (const CImg< t > &xvalues, const int y, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U)
 Draw a labeled horizontal axis on the instance image. More...
 
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 instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_axis (const int x, const CImg< t > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int pattern=~0U)
 Draw a labeled vertical axis on the instance image. More...
 
template<typename tx , typename ty , typename tc >
CImg< T > & draw_axis (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 instance image. More...
 
template<typename tx , typename ty , typename tc >
CImg< T > & draw_axis (const CImg< tx > &xvalues, const CImg< ty > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw a labeled horizontal+vertical axis on the instance image. More...
 
template<typename tc >
CImg< T > & draw_axis (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 instance image. More...
 
template<typename tc >
CImg< T > & draw_axis (const float x0, const float x1, const float y0, const float y1, const CImg< tc > &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 instance image. More...
 
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. More...
 
template<typename tx , typename ty , typename tc >
CImg< T > & draw_grid (const CImg< tx > &xvalues, const CImg< ty > &yvalues, const CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw grid. More...
 
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. More...
 
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 CImg< tc > &color, const float opacity=1, const unsigned int patternx=~0U, const unsigned int patterny=~0U)
 Draw grid. More...
 
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 bool expand=false, const unsigned int pattern=~0U)
 Draw a 1D graph on the instance image. More...
 
template<typename t , typename tc >
CImg< T > & draw_graph (const CImg< t > &data, const CImg< tc > &color, const float opacity=1, const unsigned int plot_type=1, const unsigned int vertex_type=1, const double ymin=0, const double ymax=0, const bool expand=false, const unsigned int pattern=~0U)
 Draw a 1D graph on the instance image. More...
 
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 instance image. More...
 
template<typename tc , typename t >
CImg< T > & draw_fill (const int x, const int y, const int z, const CImg< tc > &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 instance image. More...
 
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 instance image. More...
 
template<typename tc >
CImg< T > & draw_fill (const int x, const int y, const int z, const CImg< tc > &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 instance image. More...
 
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 instance image. More...
 
template<typename tc >
CImg< T > & draw_fill (const int x, const int y, const CImg< tc > &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 instance image. More...
 
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. More...
 
CImg< T > & draw_plasma (const float alpha=1, const float beta=1, const float opacity=1)
 Draw a plasma random texture. More...
 
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 itermax=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. More...
 
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 itermax=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. More...
 
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 instance image. More...
 
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float sigma, const CImg< tc > &color, const float opacity=1)
 Draw a 1D gaussian function in the instance image. More...
 
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. More...
 
template<typename t , typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
 Draw an anisotropic 2D gaussian function. More...
 
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. More...
 
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 CImg< tc > &color, const float opacity=1)
 Draw an anisotropic 2D gaussian function. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float sigma, const CImg< tc > &color, const float opacity=1)
 Draw an isotropic 2D gaussian function. More...
 
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. More...
 
template<typename t , typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float zc, const CImg< t > &tensor, const CImg< tc > &color, const float opacity=1)
 Draw an anisotropic 3D gaussian function. More...
 
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. More...
 
template<typename tc >
CImg< T > & draw_gaussian (const float xc, const float yc, const float zc, const float sigma, const CImg< tc > &color, const float opacity=1)
 Draw an isotropic 3D gaussian function. More...
 
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=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
 Draw a 3D object. More...
 
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=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
 
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=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
 Draw a 3D object. More...
 
template<typename tc , typename to >
void __draw_object3d (const unsigned int n_primitive, const unsigned int nb_opacities, const CImgList< to > &opacities, const CImg< tc > &color, const int nx0, const int ny0, const CImg< T > &sprite, const float opac)
 
template<typename tc , typename to >
void __draw_object3d (const unsigned int, const unsigned int, const CImg< to > &, const CImg< tc > &, const int nx0, const int ny0, const CImg< T > &sprite, const float opac)
 
template<typename tp , typename tf , typename tc , typename to >
CImg< T > & _draw_object3d (void *const pboard, CImg< floatT > &zbuffer, const float X, const float Y, const float Z, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const unsigned int nb_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)
 

Public Attributes

unsigned int width
 Variable representing the width of the instance image (i.e. dimensions along the X-axis). More...
 
unsigned int height
 Variable representing the height of the instance image (i.e. dimensions along the Y-axis). More...
 
unsigned int depth
 Variable representing the depth of the instance image (i.e. dimensions along the Z-axis). More...
 
unsigned int dim
 Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis). More...
 
bool is_shared
 Variable telling if pixel buffer of the instance image is shared with another one. More...
 
T * data
 Pointer to the first pixel of the pixel buffer. More...
 

Constructors / Destructor / Instance Management

 ~CImg ()
 Destructor. More...
 
 CImg ()
 Default constructor. More...
 
 CImg (const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
 Constructs a new image with given size (dx,dy,dz,dv). More...
 
 CImg (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val)
 Construct an image with given size (dx,dy,dz,dv) and with pixel having a default value val. More...
 
 CImg (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const int val0, const int val1,...)
 Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (int version). More...
 
 CImg (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const double val0, const double val1,...)
 Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (double version). More...
 
 CImg (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const char *const values, const bool repeat_values)
 Construct an image with given size and with specified values given in a string. More...
 
template<typename t >
 CImg (const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1, const bool shared=false)
 Construct an image from a raw memory buffer. More...
 
 CImg (const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1, const bool shared=false)
 
 CImg (const char *const filename)
 Construct an image from an image file. More...
 
template<typename t >
 CImg (const CImg< t > &img)
 Default copy constructor. More...
 
 CImg (const CImg< T > &img)
 
template<typename t >
 CImg (const CImg< t > &img, const bool shared)
 Advanced copy constructor. More...
 
 CImg (const CImg< T > &img, const bool shared)
 
template<typename t >
 CImg (const CImg< t > &img, const char *const dimensions)
 Construct an image using dimensions of another image. More...
 
template<typename t >
 CImg (const CImg< t > &img, const char *const dimensions, const T val)
 Construct an image using dimensions of another image, and fill it with given values. More...
 
template<typename t >
 CImg (const CImg< t > &img, const char *const dimensions, const char *const values, const bool repeat_values)
 Construct an image using dimensions of another image, and fill it with given values. More...
 
 CImg (const CImgDisplay &disp)
 Construct an image from the content of a CImgDisplay instance. More...
 
CImg< T > get_shared ()
 Return a shared version of the instance image. More...
 
const CImg< T > get_shared () const
 
CImg< T > & clear ()
 In-place version of the default constructor (STL-compliant name). More...
 
CImg< T > & assign ()
 In-place version of the default constructor/destructor. More...
 
CImg< T > & assign (const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const T val)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const int val0, const int val1,...)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const double val0, const double val1,...)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const char *const values, const bool repeat_values)
 In-place version of the corresponding constructor. More...
 
template<typename t >
CImg< T > & assign (const t *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const T *const data_buffer, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
 
template<typename t >
CImg< T > & assign (const t *const data_buffer, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const bool shared)
 In-place version of the previous constructor, allowing to force the shared state of the instance image. More...
 
CImg< T > & assign (const T *const data_buffer, const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv, const bool shared)
 
CImg< T > & assign (const char *const filename)
 In-place version of the previous constructor. More...
 
template<typename t >
CImg< T > & assign (const CImg< t > &img)
 In-place version of the default copy constructor. More...
 
template<typename t >
CImg< T > & assign (const CImg< t > &img, const bool shared)
 In-place version of the advanced constructor. More...
 
template<typename t >
CImg< T > & assign (const CImg< t > &img, const char *const dimensions)
 In-place version of the previous constructor. More...
 
template<typename t >
CImg< T > & assign (const CImg< t > &img, const char *const dimensions, const T val)
 In-place version of the previous constructor. More...
 
template<typename t >
CImg< T > & assign (const CImg< t > &img, const char *const dimensions, const char *const values, const bool repeat_values)
 In-place version of the previous constructor. More...
 
CImg< T > & assign (const CImgDisplay &disp)
 In-place version of the previous constructor. More...
 
template<typename t >
CImg< t > & transfer_to (CImg< t > &img)
 Transfer the content of the instance image into another one in a way that memory copies are avoided if possible. More...
 
CImg< T > & transfer_to (CImg< T > &img)
 
template<typename t >
CImgList< t > & transfer_to (CImgList< t > &list, const unsigned int pos=~0U)
 
CImg< T > & swap (CImg< T > &img)
 Swap all fields of two images. Use with care ! More...
 
static CImg< T > & empty ()
 Return a reference to an empty image. More...
 

Instance Characteristics

int dimx () const
 Return the number of columns of the instance image (size along the X-axis, i.e image width). More...
 
int dimy () const
 Return the number of rows of the instance image (size along the Y-axis, i.e image height). More...
 
int dimz () const
 Return the number of slices of the instance image (size along the Z-axis). More...
 
int dimv () const
 Return the number of vector channels of the instance image (size along the V-axis). More...
 
unsigned int size () const
 Return the number of image buffer elements. More...
 
T * ptr ()
 Return a pointer to the pixel buffer. More...
 
const T * ptr () const
 
T * ptr (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0)
 Return a pointer to the pixel value located at (x,y,z,v). More...
 
const T * ptr (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int v=0) const
 
int offset (const int x, const int y=0, const int z=0, const int v=0) const
 Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data. More...
 
iterator begin ()
 Return an iterator to the first image pixel. More...
 
const_iterator begin () const
 
iterator end ()
 Return an iterator pointing after the last image pixel (STL-compliant name). More...
 
const_iterator end () const
 
const T & front () const
 Return reference to the first image pixel (STL-compliant name). More...
 
T & front ()
 
const T & back () const
 Return a reference to the last image pixel (STL-compliant name). More...
 
T & back ()
 
T & at (const int off, const T out_val)
 Read a pixel value with Dirichlet boundary conditions. More...
 
at (const int off, const T out_val) const
 
T & at (const int off)
 Read a pixel value with Neumann boundary conditions. More...
 
at (const int off) const
 
T & _at (const int off)
 
_at (const int off) const
 
T & atXYZV (const int x, const int y, const int z, const int v, const T out_val)
 Read a pixel value with Dirichlet boundary conditions. More...
 
atXYZV (const int x, const int y, const int z, const int v, const T out_val) const
 
T & atXYZV (const int x, const int y, const int z, const int v)
 Read a pixel value with Neumann boundary conditions. More...
 
atXYZV (const int x, const int y, const int z, const int v) const
 
T & _atXYZV (const int x, const int y, const int z, const int v)
 
_atXYZV (const int x, const int y, const int z, const int v) const
 
T & atXYZ (const int x, const int y, const int z, const int v, const T out_val)
 Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x,y,z). More...
 
atXYZ (const int x, const int y, const int z, const int v, const T out_val) const
 
T & atXYZ (const int x, const int y, const int z, const int v=0)
 Read a pixel value with Neumann boundary conditions for the three first coordinates (x,y,z). More...
 
atXYZ (const int x, const int y, const int z, const int v=0) const
 
T & _atXYZ (const int x, const int y, const int z, const int v=0)
 
_atXYZ (const int x, const int y, const int z, const int v=0) const
 
T & atXY (const int x, const int y, const int z, const int v, const T out_val)
 Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x,y). More...
 
atXY (const int x, const int y, const int z, const int v, const T out_val) const
 
T & atXY (const int x, const int y, const int z=0, const int v=0)
 Read a pixel value with Neumann boundary conditions for the two first coordinates (x,y). More...
 
atXY (const int x, const int y, const int z=0, const int v=0) const
 
T & _atXY (const int x, const int y, const int z=0, const int v=0)
 
_atXY (const int x, const int y, const int z=0, const int v=0) const
 
T & atX (const int x, const int y, const int z, const int v, const T out_val)
 Read a pixel value with Dirichlet boundary conditions for the first coordinates (x). More...
 
atX (const int x, const int y, const int z, const int v, const T out_val) const
 
T & atX (const int x, const int y=0, const int z=0, const int v=0)
 Read a pixel value with Neumann boundary conditions for the first coordinates (x). More...
 
atX (const int x, const int y=0, const int z=0, const int v=0) const
 
T & _atX (const int x, const int y=0, const int z=0, const int v=0)
 
_atX (const int x, const int y=0, const int z=0, const int v=0) const
 
Tfloat linear_atXYZV (const float fx, const float fy, const float fz, const float fv, const T out_val) const
 Read a pixel value using linear interpolation and Dirichlet boundary conditions. More...
 
Tfloat linear_atXYZV (const float fx, const float fy=0, const float fz=0, const float fv=0) const
 Read a pixel value using linear interpolation and Neumann boundary conditions. More...
 
Tfloat _linear_atXYZV (const float fx, const float fy=0, const float fz=0, const float fv=0) const
 
Tfloat linear_atXYZ (const float fx, const float fy, const float fz, const int v, const T out_val) const
 Read a pixel value using linear interpolation and Dirichlet boundary conditions (first three coordinates). More...
 
Tfloat linear_atXYZ (const float fx, const float fy=0, const float fz=0, const int v=0) const
 Read a pixel value using linear interpolation and Neumann boundary conditions (first three coordinates). More...
 
Tfloat _linear_atXYZ (const float fx, const float fy=0, const float fz=0, const int v=0) const
 
Tfloat linear_atXY (const float fx, const float fy, const int z, const int v, const T out_val) const
 Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinates). More...
 
Tfloat linear_atXY (const float fx, const float fy, const int z=0, const int v=0) const
 Read a pixel value using linear interpolation and Neumann boundary conditions (first two coordinates). More...
 
Tfloat _linear_atXY (const float fx, const float fy, const int z=0, const int v=0) const
 
Tfloat linear_atX (const float fx, const int y, const int z, const int v, const T out_val) const
 Read a pixel value using linear interpolation and Dirichlet boundary conditions (first coordinate). More...
 
Tfloat linear_atX (const float fx, const int y=0, const int z=0, const int v=0) const
 Read a pixel value using linear interpolation and Neumann boundary conditions (first coordinate). More...
 
Tfloat _linear_atX (const float fx, const int y=0, const int z=0, const int v=0) const
 
Tfloat cubic_atXY (const float fx, const float fy, const int z, const int v, const T out_val) const
 Read a pixel value using cubic interpolation and Dirichlet boundary conditions. More...
 
Tfloat cubic_atXY (const float fx, const float fy, const int z=0, const int v=0) const
 Read a pixel value using cubic interpolation and Neumann boundary conditions. More...
 
Tfloat _cubic_atXY (const float fx, const float fy, const int z=0, const int v=0) const
 
Tfloat cubic_atX (const float fx, const int y, const int z, const int v, const T out_val) const
 Read a pixel value using cubic interpolation and Dirichlet boundary conditions (first coordinates). More...
 
Tfloat cubic_atX (const float fx, const int y=0, const int z=0, const int v=0) const
 Read a pixel value using cubic interpolation and Neumann boundary conditions (first coordinates). More...
 
Tfloat _cubic_atX (const float fx, const int y=0, const int z=0, const int v=0) const
 
CImgset_linear_atXYZ (const T &val, const float fx, const float fy=0, const float fz=0, const int v=0, const bool add=false)
 Set a pixel value, with 3D float coordinates, using linear interpolation. More...
 
CImgset_linear_atXY (const T &val, const float fx, const float fy=0, const int z=0, const int v=0, const bool add=false)
 Set a pixel value, with 2D float coordinates, using linear interpolation. More...
 
CImg< charTvalue_string (const char separator=',', const unsigned int max_size=0) const
 Return a C-string containing the values of the instance image. More...
 
static const char * pixel_type ()
 Return the type of the pixel values. More...
 

Vector / Matrix Operations

Tfloat magnitude (const int magnitude_type=2) const
 Return the norm of the current vector/matrix. ntype = norm type (0=L2, 1=L1, -1=Linf). More...
 
Tfloat trace () const
 Return the trace of the image, viewed as a matrix. More...
 
Tfloat det () const
 Return the determinant of the image, viewed as a matrix. More...
 
template<typename t >
Tfloat dot (const CImg< t > &img) const
 Return the dot product of the current vector/matrix with the vector/matrix img. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
CImg< T > & vector ()
 Unroll all images values into a one-column vector. More...
 
CImg< T > get_vector () const
 
CImg< T > & matrix ()
 Realign pixel values of the instance image as a square matrix. More...
 
CImg< T > get_matrix () const
 
CImg< T > & tensor ()
 Realign pixel values of the instance image as a symmetric tensor. More...
 
CImg< T > get_tensor () const
 
CImg< T > & diagonal ()
 Get a diagonal matrix, whose diagonal coefficients are the coefficients of the input image. More...
 
CImg< T > get_diagonal () const
 
CImg< T > & identity_matrix ()
 Get an identity matrix having same dimension than instance image. More...
 
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. More...
 
CImg< T > get_sequence (const T a0, const T a1) const
 
CImg< T > & transpose ()
 Transpose the current matrix. More...
 
CImg< T > get_transpose () const
 
template<typename t >
CImg< T > & cross (const CImg< t > &img)
 Compute the cross product between two 3d vectors. More...
 
template<typename t >
CImg< _cimg_Ttget_cross (const CImg< t > &img) const
 
CImg< T > & invert (const bool use_LU=true)
 Invert the current matrix. More...
 
CImg< Tfloatget_invert (const bool use_LU=true) const
 
CImg< T > & pseudoinvert ()
 Compute the pseudo-inverse (Moore-Penrose) of the matrix. More...
 
CImg< Tfloatget_pseudoinvert () const
 
template<typename t >
CImg< T > & solve (const CImg< t > &A)
 Solve a linear system AX=B where B=*this. More...
 
template<typename t >
CImg< _cimg_Ttfloatget_solve (const CImg< t > &A) const
 
template<typename t , typename ti >
CImg< T > & _solve (const CImg< t > &A, const CImg< ti > &indx)
 
template<typename t >
CImg< T > & solve_tridiagonal (const CImg< t > &a, const CImg< t > &b, const CImg< t > &c)
 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 ]. More...
 
template<typename t >
CImg< _cimg_Ttfloatget_solve_tridiagonal (const CImg< t > &a, const CImg< t > &b, const CImg< t > &c) const
 
template<typename t >
const CImg< T > & eigen (CImg< t > &val, CImg< t > &vec) const
 Compute the eigenvalues and eigenvectors of a matrix. More...
 
CImgList< Tfloatget_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. More...
 
CImgList< Tfloatget_symmetric_eigen () const
 
template<typename t >
CImg< T > & sort (CImg< t > &permutations, const bool increasing=true)
 Sort values of a vector and get permutations. More...
 
template<typename t >
CImg< T > get_sort (CImg< t > &permutations, const bool increasing=true) const
 
CImg< T > & sort (const bool increasing=true)
 Sort image values. More...
 
CImg< T > get_sort (const bool increasing=true) const
 
template<typename t >
CImg< T > & _quicksort (const int min, const int max, CImg< t > &permutations, const bool increasing)
 
template<typename t >
const CImg< T > & SVD (CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
 Compute the SVD of a general matrix. More...
 
CImgList< Tfloatget_SVD (const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
 
template<typename t >
CImg< T > & _LU (CImg< t > &indx, bool &d)
 
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. More...
 
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. More...
 
CImg< Tfloatget_dijkstra (const unsigned int starting_node, const unsigned int ending_node=~0U) const
 
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. More...
 
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. More...
 
static CImg< T > vector (const T &a0)
 Return a vector with specified coefficients. More...
 
static CImg< T > vector (const T &a0, const T &a1)
 Return a vector with specified coefficients. More...
 
static CImg< T > vector (const T &a0, const T &a1, const T &a2)
 Return a vector with specified coefficients. More...
 
static CImg< T > vector (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a vector with specified coefficients. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static CImg< T > matrix (const T &a0)
 Return a 1x1 square matrix with specified coefficients. More...
 
static CImg< T > matrix (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a 2x2 square matrix with specified coefficients. More...
 
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. More...
 
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. More...
 
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. More...
 
static CImg< T > tensor (const T &a1)
 Return a 1x1 symmetric matrix with specified coefficients. More...
 
static CImg< T > tensor (const T &a1, const T &a2, const T &a3)
 Return a 2x2 symmetric matrix tensor with specified coefficients. More...
 
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. More...
 
static CImg< T > diagonal (const T &a0)
 Return a 1x1 diagonal matrix with specified coefficients. More...
 
static CImg< T > diagonal (const T &a0, const T &a1)
 Return a 2x2 diagonal matrix with specified coefficients. More...
 
static CImg< T > diagonal (const T &a0, const T &a1, const T &a2)
 Return a 3x3 diagonal matrix with specified coefficients. More...
 
static CImg< T > diagonal (const T &a0, const T &a1, const T &a2, const T &a3)
 Return a 4x4 diagonal matrix with specified coefficients. More...
 
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. More...
 
static CImg< T > identity_matrix (const unsigned int N)
 Return a NxN identity matrix. More...
 
static CImg< T > sequence (const unsigned int N, const T a0, const T a1)
 Return a N-numbered sequence vector from a0 to a1. More...
 
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. More...
 

Color Base Management

CImg< T > & RGBtoHSV ()
 Convert color pixels from (R,G,B) to (H,S,V). More...
 
CImg< Tfloatget_RGBtoHSV () const
 
CImg< T > & HSVtoRGB ()
 Convert color pixels from (H,S,V) to (R,G,B). More...
 
CImg< Tucharget_HSVtoRGB () const
 
CImg< T > & RGBtoHSL ()
 Convert color pixels from (R,G,B) to (H,S,L). More...
 
CImg< Tfloatget_RGBtoHSL () const
 
CImg< T > & HSLtoRGB ()
 Convert color pixels from (H,S,L) to (R,G,B). More...
 
CImg< Tucharget_HSLtoRGB () const
 
CImg< T > & RGBtoHSI ()
 Convert color pixels from (R,G,B) to (H,S,I). More...
 
CImg< Tfloatget_RGBtoHSI () const
 
CImg< T > & HSItoRGB ()
 Convert color pixels from (H,S,I) to (R,G,B). More...
 
CImg< Tfloatget_HSItoRGB () const
 
CImg< T > & RGBtoYCbCr ()
 Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8. More...
 
CImg< Tucharget_RGBtoYCbCr () const
 
CImg< T > & YCbCrtoRGB ()
 Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8. More...
 
CImg< Tucharget_YCbCrtoRGB () const
 
CImg< T > & RGBtoYUV ()
 Convert color pixels from (R,G,B) to (Y,U,V). More...
 
CImg< Tfloatget_RGBtoYUV () const
 
CImg< T > & YUVtoRGB ()
 Convert color pixels from (Y,U,V) to (R,G,B). More...
 
CImg< Tucharget_YUVtoRGB () const
 
CImg< T > & RGBtoCMY ()
 Convert color pixels from (R,G,B) to (C,M,Y). More...
 
CImg< Tfloatget_RGBtoCMY () const
 
CImg< T > & CMYtoRGB ()
 Convert (C,M,Y) pixels of a color image into the (R,G,B) color space. More...
 
CImg< Tucharget_CMYtoRGB () const
 
CImg< T > & CMYtoCMYK ()
 Convert color pixels from (C,M,Y) to (C,M,Y,K). More...
 
CImg< Tfloatget_CMYtoCMYK () const
 
CImg< T > & CMYKtoCMY ()
 Convert (C,M,Y,K) pixels of a color image into the (C,M,Y) color space. More...
 
CImg< Tfloatget_CMYKtoCMY () const
 
CImg< T > & RGBtoXYZ ()
 Convert color pixels from (R,G,B) to (X,Y,Z)_709. More...
 
CImg< Tfloatget_RGBtoXYZ () const
 
CImg< T > & XYZtoRGB ()
 Convert (X,Y,Z)_709 pixels of a color image into the (R,G,B) color space. More...
 
CImg< Tucharget_XYZtoRGB () const
 
CImg< T > & XYZtoLab ()
 Convert (X,Y,Z)_709 pixels of a color image into the (L*,a*,b*) color space. More...
 
CImg< Tfloatget_XYZtoLab () const
 
CImg< T > & LabtoXYZ ()
 Convert (L,a,b) pixels of a color image into the (X,Y,Z) color space. More...
 
CImg< Tfloatget_LabtoXYZ () const
 
CImg< T > & XYZtoxyY ()
 Convert (X,Y,Z)_709 pixels of a color image into the (x,y,Y) color space. More...
 
CImg< Tfloatget_XYZtoxyY () const
 
CImg< T > & xyYtoXYZ ()
 Convert (x,y,Y) pixels of a color image into the (X,Y,Z)_709 color space. More...
 
CImg< Tfloatget_xyYtoXYZ () const
 
CImg< T > & RGBtoLab ()
 Convert a (R,G,B) image to a (L,a,b) one. More...
 
CImg< Tfloatget_RGBtoLab () const
 
CImg< T > & LabtoRGB ()
 Convert a (L,a,b) image to a (R,G,B) one. More...
 
CImg< Tucharget_LabtoRGB () const
 
CImg< T > & RGBtoxyY ()
 Convert a (R,G,B) image to a (x,y,Y) one. More...
 
CImg< Tfloatget_RGBtoxyY () const
 
CImg< T > & xyYtoRGB ()
 Convert a (x,y,Y) image to a (R,G,B) one. More...
 
CImg< Tucharget_xyYtoRGB () const
 
CImg< T > & RGBtoCMYK ()
 Convert a (R,G,B) image to a (C,M,Y,K) one. More...
 
CImg< Tfloatget_RGBtoCMYK () const
 
CImg< T > & CMYKtoRGB ()
 Convert a (C,M,Y,K) image to a (R,G,B) one. More...
 
CImg< Tucharget_CMYKtoRGB () const
 
CImg< T > & RGBtoBayer ()
 Convert a (R,G,B) image to a Bayer-coded representation. More...
 
CImg< T > get_RGBtoBayer () const
 
CImg< T > & BayertoRGB (const unsigned int interpolation_type=3)
 Convert a Bayer-coded image to a (R,G,B) color image. More...
 
CImg< Tucharget_BayertoRGB (const unsigned int interpolation_type=3) const
 
static CImg< Tuchardefault_LUT256 ()
 Return a default indexed color palette with 256 (R,G,B) entries. More...
 
static CImg< Tucharrainbow_LUT256 ()
 Return a rainbow indexed color palette with 256 (R,G,B) entries. More...
 
static CImg< Tucharcontrast_LUT256 ()
 Return a contrasted indexed color palette with 256 (R,G,B) entries. More...
 

Filtering / Transforms

template<typename t >
CImg< T > & correlate (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false)
 Compute the correlation of the instance image by a mask. More...
 
template<typename t >
CImg< _cimg_Ttfloatget_correlate (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false) const
 
template<typename t >
CImg< T > & convolve (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_convol=false)
 Compute the convolution of the image by a mask. More...
 
template<typename t >
CImg< _cimg_Ttfloatget_convolve (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_convol=false) const
 
template<typename t >
CImg< T > & erode (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false)
 Return the erosion of the image by a structuring element. More...
 
template<typename t >
CImg< _cimg_Ttget_erode (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false) const
 
CImg< T > & erode (const unsigned int n, const unsigned int cond=1)
 Erode the image by a square structuring element of size n. More...
 
CImg< T > get_erode (const unsigned int n, const unsigned int cond=1) const
 
template<typename t >
CImg< T > & dilate (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false)
 Dilate the image by a structuring element. More...
 
template<typename t >
CImg< _cimg_Ttget_dilate (const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false) const
 
CImg< T > & dilate (const unsigned int n, const unsigned int cond=1)
 Dilate the image by a square structuring element of size n. More...
 
CImg< T > get_dilate (const unsigned int n, const unsigned int cond=1) 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. More...
 
CImg< Tfloatget_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. More...
 
CImg< Tfloatget_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. More...
 
CImg< Tfloatget_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 unsigned int fast_approx=1)
 Blur the image anisotropically following a field of diffusion tensors. More...
 
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 unsigned int fast_approx=1) const
 
CImg< T > & blur_anisotropic (const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, 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 unsigned int fast_approx=1)
 Blur an image following in an anisotropic way. More...
 
CImg< T > get_blur_anisotropic (const float amplitude, const float sharpness=0.7f, const float anisotropy=0.3f, 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 unsigned int fast_approx=1) 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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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< Tfloatget_gradient (const char *const axes=0, const int scheme=3) const
 Compute the list of images, corresponding to the XY-gradients of an image. More...
 
CImgList< Tfloatget_hessian (const char *const axes=0) const
 Get components of the Hessian matrix of an image. More...
 
CImg< T > & structure_tensor (const unsigned int scheme=1)
 Compute the structure tensor field of an image. More...
 
CImg< Tfloatget_structure_tensor (const unsigned int scheme=1) const
 
CImg< T > & edge_tensors (const float sharpness=0.7f, const float anisotropy=0.3f, 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. More...
 
CImg< T > get_edge_tensors (const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false) const
 
CImg< T > & displacement_field (const CImg< T > &target, const float smooth=0.1f, const float precision=0.1f, const unsigned int nb_scales=0, const unsigned int itermax=1000, const bool backward=true)
 Estimate a displacement field between instance image and given target image. More...
 
CImg< Tfloatget_displacement_field (const CImg< T > &target, const float smoothness=0.1f, const float precision=0.1f, const unsigned int nb_scales=0, const unsigned int itermax=1000, const bool backward=true) const
 
CImg< T > & distance (const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true)
 Compute the Euclidean distance map to a shape of specified isovalue. More...
 
CImg< floatTget_distance (const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true) const
 
CImg< T > & distance_hamilton (const unsigned int nb_iter, const float band_size=0, const float precision=0.5f)
 Compute distance function from 0-valued isophotes by the application of an Hamilton-Jacobi PDE. More...
 
CImg< Tfloatget_distance_hamilton (const unsigned int nb_iter, const float band_size=0, const float precision=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). More...
 
CImg< Tfloatget_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. More...
 
CImg< Tfloatget_haar (const bool invert=false, const unsigned int nb_scales=1) const
 
CImgList< Tfloatget_FFT (const char axis, const bool invert=false) const
 Compute a 1D Fast Fourier Transform, along a specified axis. More...
 
CImgList< Tfloatget_FFT (const bool invert=false) const
 Compute a N-D Fast-Fourier Transform. More...
 
static float _distance_f (const int x, const int i, const float gi2, const float fact)
 
static int _distance_sep (const int i, const int u, const int gi2, const int gu2, const float fact)
 
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. More...
 
static void FFT (CImg< T > &real, CImg< T > &imag, const bool invert=false)
 Compute a N-D Fast Fourier Transform. More...
 

3D Objects Management

CImg< T > & translate_object3d (const float tx, const float ty=0, const float tz=0)
 Translate a 3D object. More...
 
CImg< Tfloatget_translate_object3d (const float tx, const float ty=0, const float tz=0) const
 
CImg< T > & translate_object3d ()
 Translate a 3D object so that it becomes centered. More...
 
CImg< Tfloatget_translate_object3d () const
 
CImg< T > & resize_object3d (const float sx, const float sy=-100, const float sz=-100)
 Resize a 3D object. More...
 
CImg< Tfloatget_resize_object3d (const float sx, const float sy=-100, const float sz=-100) const
 
CImg< T > resize_object3d () const
 Resize a 3D object so that its max dimension if one. More...
 
CImg< Tfloatget_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. More...
 
template<typename tf , typename tc , typename te >
CImg< floatTget_elevation3d (CImgList< tf > &primitives, CImgList< tc > &colors, const CImg< te > &elevation) const
 Create and return a 3D elevation of the instance image. More...
 
template<typename tf >
CImg< floatTget_isocurve3d (CImgList< tf > &primitives, const float isovalue, const int size_x=-100, const int size_y=-100) const
 Create and return a isocurve of the instance image as a 3D object. More...
 
template<typename tf >
CImg< floatTget_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 instance image as a 3D object. More...
 
template<typename tf , typename tfunc >
static CImg< floatTelevation3d (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. More...
 
template<typename tf >
static CImg< floatTelevation3d (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< floatTisocurve3d (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 isocurve as a 3D object. More...
 
template<typename tf >
static CImg< floatTisocurve3d (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 t >
static int _marching2d_indice (const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int nx)
 
template<typename tf , typename tfunc >
static CImg< floatTisosurface3d (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. More...
 
template<typename tf >
static CImg< floatTisosurface3d (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 t >
static int _marching3d_indice (const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int y, const unsigned int nx, const unsigned int ny)
 
template<typename tf >
static CImg< floatTbox3d (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. More...
 
template<typename tf >
static CImg< floatTcone3d (CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
 Create and return a 3D cone. More...
 
template<typename tf >
static CImg< floatTcylinder3d (CImgList< tf > &primitives, const float radius=50, const float size_z=100, const unsigned int subdivisions=24)
 Create and return a 3D cylinder. More...
 
template<typename tf >
static CImg< floatTtorus3d (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. More...
 
template<typename tf >
static CImg< floatTplane3d (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, const bool double_sided=false)
 Create and return a 3D XY-plane. More...
 
template<typename tf >
static CImg< floatTsphere3d (CImgList< tf > &primitives, const float radius=50, const unsigned int subdivisions=3)
 Create and return a 3D sphere. More...
 
template<typename tf , typename t >
static CImg< floatTellipsoid3d (CImgList< tf > &primitives, const CImg< t > &tensor, const unsigned int subdivisions=3)
 Create and return a 3D ellipsoid. More...
 

Data Input

CImg< T > & select (CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0)
 Simple interface to select a shape from an image. More...
 
CImg< T > & select (const char *const title, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0)
 Simple interface to select a shape from an image. More...
 
CImg< intTget_select (CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
 Simple interface to select a shape from an image. More...
 
CImg< intTget_select (const char *const title, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
 Simple interface to select a shape from an image. More...
 
CImg< intT_get_select (CImgDisplay &disp, const char *const title, const int coords_type, unsigned int *const XYZ, const unsigned char *const color, const int origX, const int origY, const int origZ) const
 
CImg< intTget_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. More...
 
CImg< T > & load (const char *const filename)
 Load an image from a file. More...
 
CImg< T > & load_ascii (const char *const filename)
 Load an image from an ASCII file. More...
 
CImg< T > & load_ascii (std::FILE *const file)
 Load an image from an ASCII file. More...
 
CImg< T > & _load_ascii (std::FILE *const file, const char *const filename)
 
CImg< T > & load_dlm (const char *const filename)
 Load an image from a DLM file. More...
 
CImg< T > & load_dlm (std::FILE *const file)
 Load an image from a DLM file. More...
 
CImg< T > & _load_dlm (std::FILE *const file, const char *const filename)
 
CImg< T > & load_bmp (const char *const filename)
 Load an image from a BMP file. More...
 
CImg< T > & load_bmp (std::FILE *const file)
 Load an image from a BMP file. More...
 
CImg< T > & _load_bmp (std::FILE *const file, const char *const filename)
 
CImg< T > & load_jpeg (const char *const filename)
 Load an image from a JPEG file. More...
 
CImg< T > & load_jpeg (std::FILE *const file)
 Load an image from a JPEG file. More...
 
CImg< T > & _load_jpeg (std::FILE *const file, const char *const filename)
 
CImg< T > & load_magick (const char *const filename)
 Load an image from a file, using Magick++ library. More...
 
CImg< T > & load_png (const char *const filename)
 Load an image from a PNG file. More...
 
CImg< T > & load_png (std::FILE *const file)
 Load an image from a PNG file. More...
 
CImg< T > & _load_png (std::FILE *const file, const char *const filename)
 
CImg< T > & load_pnm (const char *const filename)
 Load an image from a PNM file. More...
 
CImg< T > & load_pnm (std::FILE *const file)
 Load an image from a PNM file. More...
 
CImg< T > & _load_pnm (std::FILE *const file, const char *const filename)
 
CImg< T > & load_rgb (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGB file. More...
 
CImg< T > & load_rgb (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGB file. More...
 
CImg< T > & _load_rgb (std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
 
CImg< T > & load_rgba (const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGBA file. More...
 
CImg< T > & load_rgba (std::FILE *const file, const unsigned int dimw, const unsigned int dimh=1)
 Load an image from a RGBA file. More...
 
CImg< T > & _load_rgba (std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
 
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. More...
 
CImg< T > & load_analyze (const char *const filename, float *const voxsize=0)
 Load an image from an ANALYZE7.5/NIFTI file. More...
 
CImg< T > & load_analyze (std::FILE *const file, float *const voxsize=0)
 Load an image from an ANALYZE7.5/NIFTI file. More...
 
CImg< T > & _load_analyze (std::FILE *const file, const char *const filename, float *const voxsize=0)
 
CImg< T > & load_cimg (const char *const filename, const char axis='z', const char align='p')
 Load an image (list) from a .cimg file. More...
 
CImg< T > & load_cimg (std::FILE *const file, const char axis='z', const char align='p')
 Load an image (list) from a .cimg file. More...
 
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 v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
 Load a sub-image (list) from a .cimg file. More...
 
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 v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
 Load a sub-image (list) from a non-compressed .cimg file. More...
 
CImg< T > & load_inr (const char *const filename, float *const voxsize=0)
 Load an image from an INRIMAGE-4 file. More...
 
CImg< T > & load_inr (std::FILE *const file, float *const voxsize=0)
 Load an image from an INRIMAGE-4 file. More...
 
CImg< T > & _load_inr (std::FILE *const file, const char *const filename, float *const voxsize)
 
CImg< T > & load_pandore (const char *const filename)
 Load an image from a PANDORE file. More...
 
CImg< T > & load_pandore (std::FILE *const file)
 Load an image from a PANDORE file. More...
 
CImg< T > & _load_pandore (std::FILE *const file, const char *const filename)
 
CImg< T > & load_parrec (const char *const filename, const char axis='v', const char align='p')
 Load an image from a PAR-REC (Philips) file. More...
 
CImg< T > & load_raw (const char *const filename, const unsigned int sizex, 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. More...
 
CImg< T > & load_raw (std::FILE *const file, const unsigned int sizex, 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. More...
 
CImg< T > & _load_raw (std::FILE *const file, const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int sizez, const unsigned int sizev, const bool multiplexed, const bool invert_endianness)
 
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 char align='p')
 Load a video sequence using FFMPEG av's libraries. More...
 
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 char align='p')
 Load an image sequence from a YUV file. More...
 
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 char align='p')
 Load an image sequence from a YUV file. More...
 
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. More...
 
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. More...
 
template<typename tf , typename tc >
CImg< T > & _load_off (std::FILE *const file, const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
 
CImg< T > & load_ffmpeg_external (const char *const filename, const char axis='z', const char align='p')
 Load a video sequence using FFMPEG's external tool 'ffmpeg'. More...
 
CImg< T > & load_graphicsmagick_external (const char *const filename)
 Load an image using GraphicsMagick's external tool 'gm'. More...
 
CImg< T > & load_gzip_external (const char *const filename)
 Load a gzipped image file, using external tool 'gunzip'. More...
 
CImg< T > & load_imagemagick_external (const char *const filename)
 Load an image using ImageMagick's external tool 'convert'. More...
 
CImg< T > & load_medcon_external (const char *const filename)
 Load a DICOM image file, using XMedcon's external tool 'medcon'. More...
 
CImg< T > & load_dcraw_external (const char *const filename)
 Load a RAW Color Camera image file, using external tool 'dcraw'. More...
 
CImg< T > & load_other (const char *const filename)
 Load an image using ImageMagick's or GraphicsMagick's executables. More...
 
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_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 char align='p')
 
static CImg< T > get_load_cimg (std::FILE *const file, const char axis='z', const char align='p')
 
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 v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
 
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 v0, const unsigned int x1, const unsigned int y1, const unsigned int z1, const unsigned int v1, const char axis='z', const char align='p')
 
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 void _load_inr_header (std::FILE *file, int out[8], float *const voxsize)
 
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='v', const char align='p')
 
static CImg< T > get_load_raw (const char *const filename, const unsigned int sizex, 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, 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 char align='p')
 
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 char align='p')
 
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 char align='p')
 
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 char align='p')
 
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_other (const char *const filename)
 

Data Output

const CImg< T > & print (const char *title=0, const bool display_stats=true) const
 Display informations about the image on the standard error output. More...
 
const CImg< T > & display (CImgDisplay &disp) const
 Display an image into a CImgDisplay window. More...
 
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.
. More...
 
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.
. More...
 
const CImg< T > & _display (CImgDisplay &disp, const char *const title, const bool display_info) const
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
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 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. More...
 
template<typename tp , typename tf , typename tc , typename to >
const CImg< T > & _display_object3d (CImgDisplay &disp, const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering, const int render_static, const int render_motion, const bool double_sided, const float focale, const float specular_light, const float specular_shine, const bool display_axes, float *const pose_matrix) const
 
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. More...
 
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. More...
 
const CImg< T > & save (const char *const filename, const int number=-1) const
 Save the image as a file. More...
 
const CImg< T > & _save_ascii (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_ascii (const char *const filename) const
 Save the image as an ASCII file (ASCII Raw + simple header). More...
 
const CImg< T > & save_ascii (std::FILE *const file) const
 Save the image as an ASCII file (ASCII Raw + simple header). More...
 
const CImg< T > & _save_cpp (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_cpp (const char *const filename) const
 Save the image as a CPP source file. More...
 
const CImg< T > & save_cpp (std::FILE *const file) const
 Save the image as a CPP source file. More...
 
const CImg< T > & _save_dlm (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_dlm (const char *const filename) const
 Save the image as a DLM file. More...
 
const CImg< T > & save_dlm (std::FILE *const file) const
 Save the image as a DLM file. More...
 
const CImg< T > & _save_bmp (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_bmp (const char *const filename) const
 Save the image as a BMP file. More...
 
const CImg< T > & save_bmp (std::FILE *const file) const
 Save the image as a BMP file. More...
 
const CImg< T > & _save_jpeg (std::FILE *const file, const char *const filename, const unsigned int quality) const
 
const CImg< T > & save_jpeg (const char *const filename, const unsigned int quality=100) const
 Save a file in JPEG format. More...
 
const CImg< T > & save_jpeg (std::FILE *const file, const unsigned int quality=100) const
 Save a file in JPEG format. More...
 
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. More...
 
const CImg< T > & _save_png (std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
 
const CImg< T > & save_png (const char *const filename, const unsigned int bytes_per_pixel=0) const
 Save a file in PNG format. More...
 
const CImg< T > & save_png (std::FILE *const file, const unsigned int bytes_per_pixel=0) const
 Save a file in PNG format. More...
 
const CImg< T > & _save_pnm (std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
 
const CImg< T > & save_pnm (const char *const filename, const unsigned int bytes_per_pixel=0) const
 Save the image as a PNM file. More...
 
const CImg< T > & save_pnm (std::FILE *const file, const unsigned int bytes_per_pixel=0) const
 Save the image as a PNM file. More...
 
const CImg< T > & _save_rgb (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_rgb (const char *const filename) const
 Save the image as a RGB file. More...
 
const CImg< T > & save_rgb (std::FILE *const file) const
 Save the image as a RGB file. More...
 
const CImg< T > & _save_rgba (std::FILE *const file, const char *const filename) const
 
const CImg< T > & save_rgba (const char *const filename) const
 Save the image as a RGBA file. More...
 
const CImg< T > & save_rgba (std::FILE *const file) const
 Save the image as a RGBA file. More...
 
const CImg< T > & save_tiff (const char *const filename) const
 Save a file in TIFF format. More...
 
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. More...
 
const CImg< T > & save_cimg (const char *const filename, const bool compress=false) const
 Save the image as a .cimg file. More...
 
const CImg< T > & save_cimg (std::FILE *const file, const bool compress=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 v0) const
 Insert the image into an existing .cimg file, at specified coordinates. More...
 
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 v0) const
 Insert the image into an existing .cimg file, at specified coordinates. More...
 
const CImg< T > & _save_inr (std::FILE *const file, const char *const filename, const float *const voxsize) const
 
const CImg< T > & save_inr (const char *const filename, const float *const voxsize=0) const
 Save the image as an INRIMAGE-4 file. More...
 
const CImg< T > & save_inr (std::FILE *const file, const float *const voxsize=0) const
 Save the image as an INRIMAGE-4 file. More...
 
unsigned int _save_pandore_header_length (unsigned int id, unsigned int *dims, const unsigned int colorspace) const
 
const CImg< T > & _save_pandore (std::FILE *const file, const char *const filename, const unsigned int colorspace) const
 
const CImg< T > & save_pandore (const char *const filename, const unsigned int colorspace=0) const
 Save the image as a PANDORE-5 file. More...
 
const CImg< T > & save_pandore (std::FILE *const file, const unsigned int colorspace=0) const
 Save the image as a PANDORE-5 file. More...
 
const CImg< T > & _save_raw (std::FILE *const file, const char *const filename, const bool multiplexed) const
 
const CImg< T > & save_raw (const char *const filename, const bool multiplexed=false) const
 Save the image as a RAW file. More...
 
const CImg< T > & save_raw (std::FILE *const file, const bool multiplexed=false) const
 Save the image as a RAW file. More...
 
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
 Save the image as a video sequence file, using FFMPEG library. More...
 
const CImg< T > & save_yuv (const char *const filename, const bool rgb2yuv=true) const
 Save the image as a YUV video sequence file. More...
 
const CImg< T > & save_yuv (std::FILE *const file, const bool rgb2yuv=true) const
 Save the image as a YUV video sequence file. More...
 
template<typename tf , typename tc >
const CImg< T > & _save_off (std::FILE *const file, const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
 
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. More...
 
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. More...
 
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
 Save the image as a video sequence file, using the external tool 'ffmpeg'. More...
 
const CImg< T > & save_graphicsmagick_external (const char *const filename, const unsigned int quality=100) const
 Save the image using GraphicsMagick's gm. More...
 
const CImg< T > & save_gzip_external (const char *const filename) const
 Save an image as a gzipped file, using external tool 'gzip'. More...
 
const CImg< T > & save_imagemagick_external (const char *const filename, const unsigned int quality=100) const
 Save the image using ImageMagick's convert. More...
 
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 ) More...
 
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 dv=1)
 Save an empty .cimg file with specified dimensions. More...
 
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 dv=1)
 Save an empty .cimg file with specified dimensions. More...
 
static CImg< T > logo40x38 ()
 

Detailed Description

template<typename T = float>
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).
  • dim defines the number of channels of the image (size along the V-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 dimx(), dimy(), dimz(), dimv() 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 cimg_storage).

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 cimg_files_io).
  • 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 :

Definition at line 1905 of file CImg.h.

Member Typedef Documentation

typedef cimg::last<T,bool>::type boolT

Definition at line 9783 of file CImg.h.

typedef cimg::last<T,char>::type charT

Definition at line 9785 of file CImg.h.

typedef const T* const_iterator

Const iterator type for CImg<T>.

Remarks
  • A const_iterator is a const T* pointer (address of a pixel value in the pixel buffer).
  • Iterators are not directly used in CImg functions, they have been introduced for compatibility with the STL.

Definition at line 9766 of file CImg.h.

typedef cimg::last<T,double>::type doubleT

Definition at line 9793 of file CImg.h.

typedef cimg::last<T,float>::type floatT

Definition at line 9792 of file CImg.h.

typedef cimg::last<T,int>::type intT

Definition at line 9789 of file CImg.h.

typedef T* iterator

Iterator type for CImg<T>.

Remarks
  • An iterator is a T* pointer (address of a pixel value in the pixel buffer).
  • Iterators are not directly used in CImg functions, they have been introduced for compatibility with the STL.

Definition at line 9758 of file CImg.h.

typedef cimg::last<T,long>::type longT

Definition at line 9791 of file CImg.h.

typedef cimg::last<T,short>::type shortT

Definition at line 9787 of file CImg.h.

typedef cimg::superset<T,bool>::type Tbool

Definition at line 9772 of file CImg.h.

typedef cimg::superset<T,char>::type Tchar

Definition at line 9774 of file CImg.h.

typedef cimg::superset<T,double>::type Tdouble

Definition at line 9782 of file CImg.h.

typedef cimg::superset<T,float>::type Tfloat

Definition at line 9781 of file CImg.h.

typedef cimg::superset<T,int>::type Tint

Definition at line 9778 of file CImg.h.

typedef cimg::superset<T,long>::type Tlong

Definition at line 9780 of file CImg.h.

typedef cimg::superset<T,short>::type Tshort

Definition at line 9776 of file CImg.h.

typedef cimg::superset<T,unsigned char>::type Tuchar

Definition at line 9773 of file CImg.h.

typedef cimg::superset<T,unsigned int>::type Tuint

Definition at line 9777 of file CImg.h.

typedef cimg::superset<T,unsigned long>::type Tulong

Definition at line 9779 of file CImg.h.

typedef cimg::superset<T,unsigned short>::type Tushort

Definition at line 9775 of file CImg.h.

typedef cimg::last<T,unsigned char>::type ucharT

Definition at line 9784 of file CImg.h.

typedef cimg::last<T,unsigned int>::type uintT

Definition at line 9788 of file CImg.h.

typedef cimg::last<T,unsigned long>::type ulongT

Definition at line 9790 of file CImg.h.

typedef cimg::last<T,unsigned short>::type ushortT

Definition at line 9786 of file CImg.h.

typedef T value_type

Value type.

Definition at line 9769 of file CImg.h.

Constructor & Destructor Documentation

~CImg ( )
inline

Destructor.

The destructor destroys the instance image.

Remarks
  • Destructing an empty or shared image does nothing.
  • Otherwise, all memory used to store the pixel data of the instance image is freed.
  • When destroying a non-shared image, be sure that every shared instances of the same image are also destroyed to avoid further access to desallocated memory buffers.

Definition at line 9845 of file CImg.h.

9845  {
9846  if (data && !is_shared) delete[] data;
9847  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
CImg ( )
inline

Default constructor.

The default constructor creates an empty instance image.

Remarks
  • An empty image does not contain any data and has all of its dimensions width, height, depth, dim set to 0 as well as its pointer to the pixel buffer data.
  • An empty image is non-shared.

Definition at line 9857 of file CImg.h.

9857 :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {}
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1 
)
inlineexplicit

Constructs a new image with given size (dx,dy,dz,dv).

This constructors create an instance image of size (dx,dy,dz,dv) with pixels of type T.

Parameters
dxDesired size along the X-axis, i.e. the width of the image.
dyDesired size along the Y-axis, i.e. the height of the image.
dzDesired size along the Z-axis, i.e. the depth of the image.
dvDesired size along the V-axis, i.e. the number of image channels dim.
Remarks
  • If one of the input dimension dx,dy,dz or dv is set to 0, the created image is empty and all has its dimensions set to 0. No memory for pixel data is then allocated.
  • This constructor creates only non-shared images.
  • Image pixels allocated by this constructor are not initialized. Use the constructor CImg(const unsigned int,const unsigned int,const unsigned int,const unsigned int,const T) to get an image of desired size with pixels set to a particular value.

Definition at line 9874 of file CImg.h.

9874  :
9875  is_shared(false) {
9876  const unsigned int siz = dx*dy*dz*dv;
9877  if (siz) { width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; }
9878  else { width = height = depth = dim = 0; data = 0; }
9879  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const T  val 
)
inline

Construct an image with given size (dx,dy,dz,dv) and with pixel having a default value val.

This constructor creates an instance image of size (dx,dy,dz,dv) with pixels of type T and sets all pixel values of the created instance image to val.

Parameters
dxDesired size along the X-axis, i.e. the width of the image.
dyDesired size along the Y-axis, i.e. the height of the image.
dzDesired size along the Z-axis, i.e. the depth of the image.
dvDesired size along the V-axis, i.e. the number of image channels dim.
valDefault value for image pixels.
Remarks

Definition at line 9893 of file CImg.h.

9893  :
9894  is_shared(false) {
9895  const unsigned int siz = dx*dy*dz*dv;
9896  if (siz) { width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; fill(val); }
9897  else { width = height = depth = dim = 0; data = 0; }
9898  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const int  val0,
const int  val1,
  ... 
)
inline

Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (int version).

Definition at line 9901 of file CImg.h.

9902  :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
9903 #define _CImg_stdarg(img,a0,a1,N,t) { \
9904  unsigned int _siz = (unsigned int)N; \
9905  if (_siz--) { \
9906  va_list ap; \
9907  va_start(ap,a1); \
9908  T *ptrd = (img).data; \
9909  *(ptrd++) = (T)a0; \
9910  if (_siz--) { \
9911  *(ptrd++) = (T)a1; \
9912  for (; _siz; --_siz) *(ptrd++) = (T)va_arg(ap,t); \
9913  } \
9914  va_end(ap); \
9915  }}
9916  assign(dx,dy,dz,dv);
9917  _CImg_stdarg(*this,val0,val1,dx*dy*dz*dv,int);
9918  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define _CImg_stdarg(img, a0, a1, N, t)
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const double  val0,
const double  val1,
  ... 
)
inline

Construct an image with given size (dx,dy,dz,dv) and with specified pixel values (double version).

Definition at line 9921 of file CImg.h.

9922  :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
9923  assign(dx,dy,dz,dv);
9924  _CImg_stdarg(*this,val0,val1,dx*dy*dz*dv,double);
9925  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define _CImg_stdarg(img, a0, a1, N, t)
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const char *const  values,
const bool  repeat_values 
)
inline

Construct an image with given size and with specified values given in a string.

Definition at line 9928 of file CImg.h.

9929  :is_shared(false) {
9930  const unsigned int siz = dx*dy*dz*dv;
9931  if (siz) { width = dx; height = dy; depth = dz; dim = dv; data = new T[siz]; fill(values,repeat_values); }
9932  else { width = height = depth = dim = 0; data = 0; }
9933  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const t *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1,
const bool  shared = false 
)
inline

Construct an image from a raw memory buffer.

This constructor creates an instance image of size (dx,dy,dz,dv) and fill its pixel buffer by copying data values from the input raw pixel buffer data_buffer.

Definition at line 9941 of file CImg.h.

9942  :is_shared(false) {
9943  if (shared)
9944  throw CImgArgumentException("CImg<%s>::CImg() : Cannot construct a shared instance image from a (%s*) buffer "
9945  "(different pixel types).",
9946  pixel_type(),CImg<t>::pixel_type());
9947  const unsigned int siz = dx*dy*dz*dv;
9948  if (data_buffer && siz) {
9949  width = dx; height = dy; depth = dz; dim = dv; data = new T[siz];
9950  const t *ptrs = data_buffer + siz; cimg_for(*this,ptrd,T) *ptrd = (T)*(--ptrs);
9951  } else { width = height = depth = dim = 0; data = 0; }
9952  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const T *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1,
const bool  shared = false 
)
inline

Definition at line 9954 of file CImg.h.

9955  {
9956  const unsigned int siz = dx*dy*dz*dv;
9957  if (data_buffer && siz) {
9958  width = dx; height = dy; depth = dz; dim = dv; is_shared = shared;
9959  if (is_shared) data = const_cast<T*>(data_buffer);
9960  else { data = new T[siz]; std::memcpy(data,data_buffer,siz*sizeof(T)); }
9961  } else { width = height = depth = dim = 0; is_shared = false; data = 0; }
9962  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const char *const  filename)
inlineexplicit

Construct an image from an image file.

This constructor creates an instance image by reading it from a file.

Parameters
filenameFilename of the image file.
Remarks
  • The image format is deduced from the filename only by looking for the filename extension i.e. without analyzing the file itself.
  • Recognized image formats depend on the tools installed on your system or the external libraries you use to link your code with. More informations on this topic can be found in cimg_files_io.
  • If the filename is not found, a CImgIOException is thrown by this constructor.

Definition at line 9975 of file CImg.h.

9975  :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
9976  assign(filename);
9977  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< t > &  img)
inline

Default copy constructor.

The default copy constructor creates a new instance image having same dimensions (width, height, depth, dim) and same pixel values as the input image img.

Parameters
imgThe input image to copy.
Remarks
  • If the input image img is non-shared or have a different template type t != T, the default copy constructor allocates a new pixel buffer and copy the pixel data of img into it. In this case, the pointers data to the pixel buffers of the two images are different and the resulting instance image is non-shared.
  • If the input image img is shared and has the same template type t == T, the default copy constructor does not allocate a new pixel buffer and the resulting instance image shares its pixel buffer with the input image img, which means that modifying pixels of img also modifies the created instance image.
  • Copying an image having a different template type t != T performs a crude static cast conversion of each pixel value from type t to type T.
  • Copying an image having the same template type t == T is significantly faster.

Definition at line 9998 of file CImg.h.

9998  :is_shared(false) {
9999  const unsigned int siz = img.size();
10000  if (img.data && siz) {
10001  width = img.width; height = img.height; depth = img.depth; dim = img.dim; data = new T[siz];
10002  const t *ptrs = img.data + siz; cimg_for(*this,ptrd,T) *ptrd = (T)*(--ptrs);
10003  } else { width = height = depth = dim = 0; data = 0; }
10004  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< T > &  img)
inline

Definition at line 10006 of file CImg.h.

10006  {
10007  const unsigned int siz = img.size();
10008  if (img.data && siz) {
10009  width = img.width; height = img.height; depth = img.depth; dim = img.dim; is_shared = img.is_shared;
10010  if (is_shared) data = const_cast<T*>(img.data);
10011  else { data = new T[siz]; std::memcpy(data,img.data,siz*sizeof(T)); }
10012  } else { width = height = depth = dim = 0; is_shared = false; data = 0; }
10013  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< t > &  img,
const bool  shared 
)
inline

Advanced copy constructor.

The advanced copy constructor - as the default constructor CImg(const CImg< t >&) - creates a new instance image having same dimensions width, height, depth, dim and same pixel values as the input image img. But it also decides if the created instance image shares its memory with the input image img (if the input parameter shared is set to true) or not (if the input parameter shared is set to false).

Parameters
imgThe input image to copy.
sharedBoolean flag that decides if the copy is shared on non-shared.
Remarks
  • It is not possible to create a shared copy if the input image img is empty or has a different pixel type t != T.
  • If a non-shared copy of the input image img is created, a new memory buffer is allocated for pixel data.
  • If a shared copy of the input image img is created, no extra memory is allocated and the pixel buffer of the instance image is the same as the one used by the input image img.

Definition at line 10030 of file CImg.h.

10030  :is_shared(false) {
10031  if (shared)
10032  throw CImgArgumentException("CImg<%s>::CImg() : Cannot construct a shared instance image from a CImg<%s> instance "
10033  "(different pixel types).",
10034  pixel_type(),CImg<t>::pixel_type());
10035  const unsigned int siz = img.size();
10036  if (img.data && siz) {
10037  width = img.width; height = img.height; depth = img.depth; dim = img.dim; data = new T[siz];
10038  const t *ptrs = img.data + siz; cimg_for(*this,ptrd,T) *ptrd = (T)*(--ptrs);
10039  } else { width = height = depth = dim = 0; data = 0; }
10040  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< T > &  img,
const bool  shared 
)
inline

Definition at line 10042 of file CImg.h.

10042  {
10043  const unsigned int siz = img.size();
10044  if (img.data && siz) {
10045  width = img.width; height = img.height; depth = img.depth; dim = img.dim; is_shared = shared;
10046  if (is_shared) data = const_cast<T*>(img.data);
10047  else { data = new T[siz]; std::memcpy(data,img.data,siz*sizeof(T)); }
10048  } else { width = height = depth = dim = 0; is_shared = false; data = 0; }
10049  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< t > &  img,
const char *const  dimensions 
)
inline

Construct an image using dimensions of another image.

Definition at line 10053 of file CImg.h.

10053  :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
10054  assign(img,dimensions);
10055  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< t > &  img,
const char *const  dimensions,
const T  val 
)
inline

Construct an image using dimensions of another image, and fill it with given values.

Definition at line 10059 of file CImg.h.

10059  :
10060  width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
10061  assign(img,dimensions).fill(val);
10062  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImg< t > &  img,
const char *const  dimensions,
const char *const  values,
const bool  repeat_values 
)
inline

Construct an image using dimensions of another image, and fill it with given values.

Definition at line 10066 of file CImg.h.

10066  :
10067  width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
10068  assign(img,dimensions).fill(values,repeat_values);
10069  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg ( const CImgDisplay disp)
inlineexplicit

Construct an image from the content of a CImgDisplay instance.

Definition at line 10072 of file CImg.h.

10072  :width(0),height(0),depth(0),dim(0),is_shared(false),data(0) {
10073  disp.snapshot(*this);
10074  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Member Function Documentation

void __draw_object3d ( const unsigned int  n_primitive,
const unsigned int  nb_opacities,
const CImgList< to > &  opacities,
const CImg< tc > &  color,
const int  nx0,
const int  ny0,
const CImg< T > &  sprite,
const float  opac 
)
inline

Definition at line 27611 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d().

27612  {
27613  if (n_primitive<nb_opacities && opacities[n_primitive].is_sameXY(color))
27614  draw_image(nx0,ny0,sprite,opacities[n_primitive].get_resize(sprite.width,sprite.height,1,sprite.dim,1));
27615  else draw_image(nx0,ny0,sprite,opac);
27616  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650

Here is the caller graph for this function:

void __draw_object3d ( const unsigned  int,
const unsigned  int,
const CImg< to > &  ,
const CImg< tc > &  ,
const int  nx0,
const int  ny0,
const CImg< T > &  sprite,
const float  opac 
)
inline

Definition at line 27619 of file CImg.h.

27620  {
27621  draw_image(nx0,ny0,sprite,opac);
27622  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
T& _at ( const int  off)
inline

Definition at line 11211 of file CImg.h.

Referenced by CImg< uintT >::at().

11211  {
11212  const unsigned int siz = (unsigned int)size();
11213  return (*this)[off<0?0:(unsigned int)off>=siz?siz-1:off];
11214  }
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075

Here is the caller graph for this function:

T _at ( const int  off) const
inline

Definition at line 11216 of file CImg.h.

11216  {
11217  const unsigned int siz = (unsigned int)size();
11218  return (*this)[off<0?0:(unsigned int)off>=siz?siz-1:off];
11219  }
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T& _atX ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
)
inline

Definition at line 11347 of file CImg.h.

Referenced by CImg< uintT >::atX(), and CImg< uintT >::get_warp().

11347  {
11348  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x),y,z,v);
11349  }
void int int REAL REAL * y
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T _atX ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11351 of file CImg.h.

11351  {
11352  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x),y,z,v);
11353  }
void int int REAL REAL * y
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& _atXY ( const int  x,
const int  y,
const int  z = 0,
const int  v = 0 
)
inline

Definition at line 11315 of file CImg.h.

Referenced by CImg< uintT >::atXY(), and CImg< uintT >::get_warp().

11315  {
11316  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y),z,v);
11317  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T _atXY ( const int  x,
const int  y,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11319 of file CImg.h.

11319  {
11320  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y),z,v);
11321  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& _atXYZ ( const int  x,
const int  y,
const int  z,
const int  v = 0 
)
inline

Definition at line 11281 of file CImg.h.

Referenced by CImg< uintT >::atXYZ(), CImg< uintT >::get_correlate(), CImg< uintT >::get_dilate(), CImg< uintT >::get_erode(), and CImg< uintT >::get_warp().

11281  {
11282  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x),y<0?0:(y>=dimy()?dimy()-1:y),
11283  z<0?0:(z>=dimz()?dimz()-1:z),v);
11284  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T _atXYZ ( const int  x,
const int  y,
const int  z,
const int  v = 0 
) const
inline

Definition at line 11286 of file CImg.h.

11286  {
11287  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x),y<0?0:(y>=dimy()?dimy()-1:y),
11288  z<0?0:(z>=dimz()?dimz()-1:z),v);
11289  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& _atXYZV ( const int  x,
const int  y,
const int  z,
const int  v 
)
inline

Definition at line 11246 of file CImg.h.

Referenced by CImg< uintT >::atXYZV(), CImg< uintT >::get_crop(), CImg< uintT >::get_resize(), and CImg< uintT >::get_warp().

11246  {
11247  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y),
11248  z<0?0:(z>=dimz()?dimz()-1:z), v<0?0:(v>=dimv()?dimv()-1:v));
11249  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

T _atXYZV ( const int  x,
const int  y,
const int  z,
const int  v 
) const
inline

Definition at line 11251 of file CImg.h.

11251  {
11252  return (*this)(x<0?0:(x>=dimx()?dimx()-1:x), y<0?0:(y>=dimy()?dimy()-1:y),
11253  z<0?0:(z>=dimz()?dimz()-1:z), v<0?0:(v>=dimv()?dimv()-1:v));
11254  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
CImg<intT> _autocrop ( const T  value,
const char  axis 
) const
inline

Definition at line 18355 of file CImg.h.

Referenced by CImg< uintT >::autocrop().

18355  {
18356  CImg<intT> res;
18357  int x0 = -1, y0 = -1, z0 = -1, v0 = -1, x1 = -1, y1 = -1, z1 = -1, v1 = -1;
18358  switch (cimg::uncase(axis)) {
18359  case 'x' : {
18360  cimg_forX(*this,x) cimg_forYZV(*this,y,z,v)
18361  if ((*this)(x,y,z,v)!=value) { x0 = x; x = dimx(); y = dimy(); z = dimz(); v = dimv(); }
18362  if (x0>=0) {
18363  for (int x = dimx()-1; x>=0; --x) cimg_forYZV(*this,y,z,v)
18364  if ((*this)(x,y,z,v)!=value) { x1 = x; x = 0; y = dimy(); z = dimz(); v = dimv(); }
18365  }
18366  res = CImg<intT>::vector(x0,x1);
18367  } break;
18368  case 'y' : {
18369  cimg_forY(*this,y) cimg_forXZV(*this,x,z,v)
18370  if ((*this)(x,y,z,v)!=value) { y0 = y; x = dimx(); y = dimy(); z = dimz(); v = dimv(); }
18371  if (y0>=0) {
18372  for (int y = dimy()-1; y>=0; --y) cimg_forXZV(*this,x,z,v)
18373  if ((*this)(x,y,z,v)!=value) { y1 = y; x = dimx(); y = 0; z = dimz(); v = dimv(); }
18374  }
18375  res = CImg<intT>::vector(y0,y1);
18376  } break;
18377  case 'z' : {
18378  cimg_forZ(*this,z) cimg_forXYV(*this,x,y,v)
18379  if ((*this)(x,y,z,v)!=value) { z0 = z; x = dimx(); y = dimy(); z = dimz(); v = dimv(); }
18380  if (z0>=0) {
18381  for (int z = dimz()-1; z>=0; --z) cimg_forXYV(*this,x,y,v)
18382  if ((*this)(x,y,z,v)!=value) { z1 = z; x = dimx(); y = dimy(); z = 0; v = dimv(); }
18383  }
18384  res = CImg<intT>::vector(z0,z1);
18385  } break;
18386  case 'v' : {
18387  cimg_forV(*this,v) cimg_forXYZ(*this,x,y,z)
18388  if ((*this)(x,y,z,v)!=value) { v0 = v; x = dimx(); y = dimy(); z = dimz(); v = dimv(); }
18389  if (v0>=0) {
18390  for (int v = dimv()-1; v>=0; --v) cimg_forXYZ(*this,x,y,z)
18391  if ((*this)(x,y,z,v)!=value) { v1 = v; x = dimx(); y = dimy(); z = dimz(); v = 0; }
18392  }
18393  res = CImg<intT>::vector(v0,v1);
18394  } break;
18395  default :
18396  throw CImgArgumentException("CImg<%s>::autocrop() : unknow axis '%c', must be 'x','y','z' or 'v'",
18397  pixel_type(),axis);
18398  }
18399  return res;
18400  }
if(dy > dx)
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
#define cimg_forZ(img, z)
Definition: CImg.h:595
#define cimg_forY(img, y)
Definition: CImg.h:594
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

Tfloat _cubic_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11722 of file CImg.h.

Referenced by CImg< uintT >::cubic_atX().

11722  {
11723  const float
11724  nfx = fx<0?0:(fx>width-1?width-1:fx);
11725  const int
11726  x = (int)nfx;
11727  const float
11728  dx = nfx-x;
11729  const int
11730  px = x-1<0?0:x-1, nx = dx>0?x+1:x, ax = x+2>=dimx()?dimx()-1:x+2;
11731  const Tfloat
11732  Ip = (Tfloat)(*this)(px,y,z,v), Ic = (Tfloat)(*this)(x,y,z,v),
11733  In = (Tfloat)(*this)(nx,y,z,v), Ia = (Tfloat)(*this)(ax,y,z,v),
11734  valm = cimg::min(Ip,In,Ic,Ia), valM = cimg::max(Ip,In,Ic,Ia),
11735  u0 = Ic - Ip,
11736  u1 = Ia - In,
11737  a = 2*(Ic-In) + u0 + u1,
11738  b = 3*(In-Ic) - 2*u0 - u1,
11739  val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic;
11740  return val<valm?valm:(val>valM?valM:val);
11741  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781

Here is the caller graph for this function:

Tfloat _cubic_atXY ( const float  fx,
const float  fy,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11644 of file CImg.h.

Referenced by CImg< uintT >::cubic_atXY(), and CImg< uintT >::get_resize().

11644  {
11645  const float
11646  nfx = fx<0?0:(fx>width-1?width-1:fx),
11647  nfy = fy<0?0:(fy>height-1?height-1:fy);
11648  const int
11649  x = (int)nfx,
11650  y = (int)nfy;
11651  const float
11652  dx = nfx-x, dx2 = dx*dx, dx3 = dx2*dx,
11653  dy = nfy-y;
11654  const int
11655  px = x-1<0?0:x-1, nx = dx>0?x+1:x, ax = x+2>=dimx()?dimx()-1:x+2,
11656  py = y-1<0?0:y-1, ny = dy>0?y+1:y, ay = y+2>=dimy()?dimy()-1:y+2;
11657  const Tfloat
11658  Ipp = (Tfloat)(*this)(px,py,z,v), Icp = (Tfloat)(*this)(x,py,z,v),
11659  Inp = (Tfloat)(*this)(nx,py,z,v), Iap = (Tfloat)(*this)(ax,py,z,v),
11660  Ipc = (Tfloat)(*this)(px,y,z,v), Icc = (Tfloat)(*this)(x,y,z,v),
11661  Inc = (Tfloat)(*this)(nx,y,z,v), Iac = (Tfloat)(*this)(ax,y,z,v),
11662  Ipn = (Tfloat)(*this)(px,ny,z,v), Icn = (Tfloat)(*this)(x,ny,z,v),
11663  Inn = (Tfloat)(*this)(nx,ny,z,v), Ian = (Tfloat)(*this)(ax,ny,z,v),
11664  Ipa = (Tfloat)(*this)(px,ay,z,v), Ica = (Tfloat)(*this)(x,ay,z,v),
11665  Ina = (Tfloat)(*this)(nx,ay,z,v), Iaa = (Tfloat)(*this)(ax,ay,z,v),
11666  valm = cimg::min(cimg::min(Ipp,Icp,Inp,Iap),cimg::min(Ipc,Icc,Inc,Iac),cimg::min(Ipn,Icn,Inn,Ian),cimg::min(Ipa,Ica,Ina,Iaa)),
11667  valM = cimg::max(cimg::max(Ipp,Icp,Inp,Iap),cimg::max(Ipc,Icc,Inc,Iac),cimg::max(Ipn,Icn,Inn,Ian),cimg::max(Ipa,Ica,Ina,Iaa)),
11668  u0p = Icp - Ipp,
11669  u1p = Iap - Inp,
11670  ap = 2*(Icp-Inp) + u0p + u1p,
11671  bp = 3*(Inp-Icp) - 2*u0p - u1p,
11672  u0c = Icc - Ipc,
11673  u1c = Iac - Inc,
11674  ac = 2*(Icc-Inc) + u0c + u1c,
11675  bc = 3*(Inc-Icc) - 2*u0c - u1c,
11676  u0n = Icn - Ipn,
11677  u1n = Ian - Inn,
11678  an = 2*(Icn-Inn) + u0n + u1n,
11679  bn = 3*(Inn-Icn) - 2*u0n - u1n,
11680  u0a = Ica - Ipa,
11681  u1a = Iaa - Ina,
11682  aa = 2*(Ica-Ina) + u0a + u1a,
11683  ba = 3*(Ina-Ica) - 2*u0a - u1a,
11684  valp = ap*dx3 + bp*dx2 + u0p*dx + Icp,
11685  valc = ac*dx3 + bc*dx2 + u0c*dx + Icc,
11686  valn = an*dx3 + bn*dx2 + u0n*dx + Icn,
11687  vala = aa*dx3 + ba*dx2 + u0a*dx + Ica,
11688  u0 = valc - valp,
11689  u1 = vala - valn,
11690  a = 2*(valc-valn) + u0 + u1,
11691  b = 3*(valn-valc) - 2*u0 - u1,
11692  val = a*dy*dy*dy + b*dy*dy + u0*dy + valc;
11693  return val<valm?valm:(val>valM?valM:val);
11694  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy

Here is the caller graph for this function:

const CImg<T>& _display ( CImgDisplay disp,
const char *const  title,
const bool  display_info 
) const
inline

Definition at line 31479 of file CImg.h.

Referenced by CImg< uintT >::display().

31479  {
31480  if (is_empty())
31481  throw CImgInstanceException("CImg<%s>::display() : Instance image (%u,%u,%u,%u,%p) is empty.",
31483  unsigned int oldw = 0, oldh = 0, XYZ[3], key = 0, mkey = 0;
31484  int x0 = 0, y0 = 0, z0 = 0, x1 = dimx()-1, y1 = dimy()-1, z1 = dimz()-1;
31485  float frametiming = 5;
31486 
31487  char ntitle[256] = { 0 };
31488  if (!disp) {
31489  if (!title) std::sprintf(ntitle,"CImg<%s> (%ux%ux%ux%u)",pixel_type(),width,height,depth,dim);
31490  disp.assign(cimg_fitscreen(width,height,depth),title?title:ntitle,1);
31491  }
31492  std::strncpy(ntitle,disp.title,255);
31493  if (display_info) print(ntitle);
31494 
31495  CImg<T> zoom;
31496  for (bool reset_view = true, resize_disp = false; !key && !disp.is_closed; ) {
31497  if (reset_view) {
31498  XYZ[0] = (x0 + x1)/2; XYZ[1] = (y0 + y1)/2; XYZ[2] = (z0 + z1)/2;
31499  x0 = 0; y0 = 0; z0 = 0; x1 = width-1; y1 = height-1; z1 = depth-1;
31500  oldw = disp.width; oldh = disp.height;
31501  reset_view = false;
31502  }
31503  if (!x0 && !y0 && !z0 && x1==dimx()-1 && y1==dimy()-1 && z1==dimz()-1) zoom.assign();
31504  else zoom = get_crop(x0,y0,z0,x1,y1,z1);
31505 
31506  const unsigned int
31507  dx = 1 + x1 - x0, dy = 1 + y1 - y0, dz = 1 + z1 - z0,
31508  tw = dx + (dz>1?dz:0), th = dy + (dz>1?dz:0);
31509  if (resize_disp) {
31510  const unsigned int
31511  ttw = tw*disp.width/oldw, tth = th*disp.height/oldh,
31512  dM = cimg::max(ttw,tth), diM = cimg::max(disp.width,disp.height),
31513  imgw = cimg::max(16U,ttw*diM/dM), imgh = cimg::max(16U,tth*diM/dM);
31514  disp.normalscreen().resize(cimg_fitscreen(imgw,imgh,1),false);
31515  resize_disp = false;
31516  }
31517  oldw = tw; oldh = th;
31518 
31519  bool
31520  go_up = false, go_down = false, go_left = false, go_right = false,
31521  go_inc = false, go_dec = false, go_in = false, go_out = false,
31522  go_in_center = false;
31523  const CImg<T>& visu = zoom?zoom:*this;
31524  const CImg<intT> selection = visu._get_select(disp,0,2,XYZ,0,x0,y0,z0);
31525  if (disp.wheel) {
31526  if (disp.is_keyCTRLLEFT) { if (!mkey || mkey==1) go_out = !(go_in = disp.wheel>0); go_in_center = false; mkey = 1; }
31527  else if (disp.is_keySHIFTLEFT) { if (!mkey || mkey==2) go_right = !(go_left = disp.wheel>0); mkey = 2; }
31528  else if (disp.is_keyALT || depth==1) { if (!mkey || mkey==3) go_down = !(go_up = disp.wheel>0); mkey = 3; }
31529  else mkey = 0;
31530  disp.wheel = 0;
31531  } else mkey = 0;
31532  const int
31533  sx0 = selection(0), sy0 = selection(1), sz0 = selection(2),
31534  sx1 = selection(3), sy1 = selection(4), sz1 = selection(5);
31535  if (sx0>=0 && sy0>=0 && sz0>=0 && sx1>=0 && sy1>=0 && sz1>=0) {
31536  x1 = x0 + sx1; y1 = y0 + sy1; z1 = z0 + sz1; x0+=sx0; y0+=sy0; z0+=sz0;
31537  if (sx0==sx1 && sy0==sy1 && sz0==sz1) reset_view = true;
31538  resize_disp = true;
31539  } else switch (key = disp.key) {
31540  case 0 : case cimg::keyCTRLLEFT : case cimg::keyPAD5 : case cimg::keySHIFTLEFT : case cimg::keyALT : disp.key = key = 0; break;
31541  case cimg::keyP : if (visu.depth>1 && disp.is_keyCTRLLEFT) { // Special mode : play stack of frames
31542  const unsigned int
31543  w1 = visu.width*disp.width/(visu.width+(visu.depth>1?visu.depth:0)),
31544  h1 = visu.height*disp.height/(visu.height+(visu.depth>1?visu.depth:0));
31545  disp.resize(cimg_fitscreen(w1,h1,1),false).key = disp.wheel = key = 0;
31546  for (unsigned int timer = 0; !key && !disp.is_closed && !disp.button; ) {
31547  if (disp.is_resized) disp.resize(false);
31548  if (!timer) {
31549  visu.get_slice(XYZ[2]).display(disp.set_title("%s | z=%d",ntitle,XYZ[2]));
31550  if (++XYZ[2]>=visu.depth) XYZ[2] = 0;
31551  }
31552  if (++timer>(unsigned int)frametiming) timer = 0;
31553  if (disp.wheel) { frametiming-=disp.wheel/3.0f; disp.wheel = 0; }
31554  switch (key = disp.key) {
31555  case 0 : case cimg::keyCTRLLEFT : disp.key = key = 0; break;
31556  case cimg::keyPAGEUP : frametiming-=0.3f; key = 0; break;
31557  case cimg::keyPAGEDOWN : frametiming+=0.3f; key = 0; break;
31558  case cimg::keyD : if (disp.is_keyCTRLLEFT) {
31559  disp.normalscreen().resize(CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,false),
31560  CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,true),false);
31561  disp.key = key = 0;
31562  } break;
31563  case cimg::keyC : if (disp.is_keyCTRLLEFT) {
31564  disp.normalscreen().resize(cimg_fitscreen(2*disp.width/3,2*disp.height/3,1),false);
31565  disp.key = key = 0;
31566  } break;
31567  case cimg::keyR : if (disp.is_keyCTRLLEFT) {
31568  disp.normalscreen().resize(cimg_fitscreen(width,height,depth),false);
31569  disp.key = key = 0;
31570  } break;
31571  case cimg::keyF : if (disp.is_keyCTRLLEFT)
31572  disp.resize(disp.screen_dimx(),disp.screen_dimy(),false).toggle_fullscreen().key = key = 0;
31573  break;
31574  }
31575  frametiming = frametiming<1?1:(frametiming>39?39:frametiming);
31576  disp.wait(20);
31577  }
31578  const unsigned int
31579  w2 = (visu.width + (visu.depth>1?visu.depth:0))*disp.width/visu.width,
31580  h2 = (visu.height + (visu.depth>1?visu.depth:0))*disp.height/visu.height;
31581  disp.resize(cimg_fitscreen(w2,h2,1),false).set_title(ntitle);
31582  key = disp.key = disp.button = disp.wheel = 0;
31583  } break;
31584  case cimg::keyHOME : case cimg::keyBACKSPACE : reset_view = resize_disp = true; key = 0; break;
31585  case cimg::keyPADADD : go_in = true; go_in_center = true; key = 0; break;
31586  case cimg::keyPADSUB : go_out = true; key = 0; break;
31587  case cimg::keyARROWLEFT : case cimg::keyPAD4: go_left = true; key = 0; break;
31588  case cimg::keyARROWRIGHT : case cimg::keyPAD6: go_right = true; key = 0; break;
31589  case cimg::keyARROWUP : case cimg::keyPAD8: go_up = true; key = 0; break;
31590  case cimg::keyARROWDOWN : case cimg::keyPAD2: go_down = true; key = 0; break;
31591  case cimg::keyPAD7 : go_up = go_left = true; key = 0; break;
31592  case cimg::keyPAD9 : go_up = go_right = true; key = 0; break;
31593  case cimg::keyPAD1 : go_down = go_left = true; key = 0; break;
31594  case cimg::keyPAD3 : go_down = go_right = true; key = 0; break;
31595  case cimg::keyPAGEUP : go_inc = true; key = 0; break;
31596  case cimg::keyPAGEDOWN : go_dec = true; key = 0; break;
31597  }
31598  if (go_in) {
31599  const int
31600  mx = go_in_center?disp.dimx()/2:disp.mouse_x,
31601  my = go_in_center?disp.dimy()/2:disp.mouse_y,
31602  mX = mx*(width+(depth>1?depth:0))/disp.width,
31603  mY = my*(height+(depth>1?depth:0))/disp.height;
31604  int X = XYZ[0], Y = XYZ[1], Z = XYZ[2];
31605  if (mX<dimx() && mY<dimy()) { X = x0 + mX*(1+x1-x0)/width; Y = y0 + mY*(1+y1-y0)/height; Z = XYZ[2]; }
31606  if (mX<dimx() && mY>=dimy()) { X = x0 + mX*(1+x1-x0)/width; Z = z0 + (mY-height)*(1+z1-z0)/depth; Y = XYZ[1]; }
31607  if (mX>=dimx() && mY<dimy()) { Y = y0 + mY*(1+y1-y0)/height; Z = z0 + (mX-width)*(1+z1-z0)/depth; X = XYZ[0]; }
31608  if (x1-x0>4) { x0 = X - 7*(X-x0)/8; x1 = X + 7*(x1-X)/8; }
31609  if (y1-y0>4) { y0 = Y - 7*(Y-y0)/8; y1 = Y + 7*(y1-Y)/8; }
31610  if (z1-z0>4) { z0 = Z - 7*(Z-z0)/8; z1 = Z + 7*(z1-Z)/8; }
31611  }
31612  if (go_out) {
31613  const int
31614  deltax = (x1-x0)/8, deltay = (y1-y0)/8, deltaz = (z1-z0)/8,
31615  ndeltax = deltax?deltax:(width>1?1:0),
31616  ndeltay = deltay?deltay:(height>1?1:0),
31617  ndeltaz = deltaz?deltaz:(depth>1?1:0);
31618  x0-=ndeltax; y0-=ndeltay; z0-=ndeltaz;
31619  x1+=ndeltax; y1+=ndeltay; z1+=ndeltaz;
31620  if (x0<0) { x1-=x0; x0 = 0; if (x1>=dimx()) x1 = dimx()-1; }
31621  if (y0<0) { y1-=y0; y0 = 0; if (y1>=dimy()) y1 = dimy()-1; }
31622  if (z0<0) { z1-=z0; z0 = 0; if (z1>=dimz()) z1 = dimz()-1; }
31623  if (x1>=dimx()) { x0-=(x1-dimx()+1); x1 = dimx()-1; if (x0<0) x0 = 0; }
31624  if (y1>=dimy()) { y0-=(y1-dimy()+1); y1 = dimy()-1; if (y0<0) y0 = 0; }
31625  if (z1>=dimz()) { z0-=(z1-dimz()+1); z1 = dimz()-1; if (z0<0) z0 = 0; }
31626  }
31627  if (go_left) {
31628  const int delta = (x1-x0)/5, ndelta = delta?delta:(width>1?1:0);
31629  if (x0-ndelta>=0) { x0-=ndelta; x1-=ndelta; }
31630  else { x1-=x0; x0 = 0; }
31631  }
31632  if (go_right) {
31633  const int delta = (x1-x0)/5, ndelta = delta?delta:(width>1?1:0);
31634  if (x1+ndelta<dimx()) { x0+=ndelta; x1+=ndelta; }
31635  else { x0+=(dimx()-1-x1); x1 = dimx()-1; }
31636  }
31637  if (go_up) {
31638  const int delta = (y1-y0)/5, ndelta = delta?delta:(height>1?1:0);
31639  if (y0-ndelta>=0) { y0-=ndelta; y1-=ndelta; }
31640  else { y1-=y0; y0 = 0; }
31641  }
31642  if (go_down) {
31643  const int delta = (y1-y0)/5, ndelta = delta?delta:(height>1?1:0);
31644  if (y1+ndelta<dimy()) { y0+=ndelta; y1+=ndelta; }
31645  else { y0+=(dimy()-1-y1); y1 = dimy()-1; }
31646  }
31647  if (go_inc) {
31648  const int delta = (z1-z0)/5, ndelta = delta?delta:(depth>1?1:0);
31649  if (z0-ndelta>=0) { z0-=ndelta; z1-=ndelta; }
31650  else { z1-=z0; z0 = 0; }
31651  }
31652  if (go_dec) {
31653  const int delta = (z1-z0)/5, ndelta = delta?delta:(depth>1?1:0);
31654  if (z1+ndelta<dimz()) { z0+=ndelta; z1+=ndelta; }
31655  else { z0+=(depth-1-z1); z1 = depth-1; }
31656  }
31657  }
31658  disp.key = key;
31659  return *this;
31660  }
const unsigned int keyPAD3
Definition: CImg.h:2748
const unsigned int keyP
Definition: CImg.h:2709
static unsigned int _fitscreen(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const int dmin=128, const int dmax=-85, const bool return_last=false)
Definition: CImg.h:6437
const unsigned int keyPAGEUP
Definition: CImg.h:2698
const unsigned int keyCTRLLEFT
Definition: CImg.h:2734
NT dx
#define cimg_fitscreen(dx, dy, dz)
Definition: CImg.h:6436
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const unsigned int keyPADADD
Definition: CImg.h:2755
const unsigned int keyC
Definition: CImg.h:2727
const unsigned int keyARROWLEFT
Definition: CImg.h:2742
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
const unsigned int keyPAD1
Definition: CImg.h:2746
const unsigned int keyPAD6
Definition: CImg.h:2751
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const unsigned int keyPAD9
Definition: CImg.h:2754
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
const unsigned int keyPAD2
Definition: CImg.h:2747
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
const unsigned int keyHOME
Definition: CImg.h:2697
const CImg< T > & print(const char *title=0, const bool display_stats=true) const
Display informations about the image on the standard error output.
Definition: CImg.h:31432
const unsigned int keyPAGEDOWN
Definition: CImg.h:2712
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
const unsigned int keyF
Definition: CImg.h:2717
const unsigned int keySHIFTLEFT
Definition: CImg.h:2724
const unsigned int keyARROWUP
Definition: CImg.h:2733
const unsigned int keyARROWRIGHT
Definition: CImg.h:2744
const unsigned int keyPAD7
Definition: CImg.h:2752
const unsigned int keyPAD4
Definition: CImg.h:2749
const unsigned int keyPADSUB
Definition: CImg.h:2756
const unsigned int keyR
Definition: CImg.h:2703
NT dy
const unsigned int keyPAD5
Definition: CImg.h:2750
const unsigned int keyALT
Definition: CImg.h:2736
const unsigned int keyD
Definition: CImg.h:2716
const unsigned int keyBACKSPACE
Definition: CImg.h:2695
const unsigned int keyPAD8
Definition: CImg.h:2753
const unsigned int keyARROWDOWN
Definition: CImg.h:2743
static T_Key key
Definition: vinci_lass.c:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _display_object3d ( CImgDisplay disp,
const char *const  title,
const CImg< tp > &  vertices,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors,
const to &  opacities,
const bool  centering,
const int  render_static,
const int  render_motion,
const bool  double_sided,
const float  focale,
const float  specular_light,
const float  specular_shine,
const bool  display_axes,
float *const  pose_matrix 
) const
inline

Definition at line 31788 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d(), and CImg< uintT >::display_object3d().

31797  {
31798 
31799  // Check input arguments
31800  if (is_empty()) {
31801  if (disp) return CImg<T>(disp.width,disp.height,1,colors[0].size(),0).
31802  _display_object3d(disp,title,vertices,primitives,colors,opacities,centering,
31803  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31804  display_axes,pose_matrix);
31805  else return CImg<T>(cimg_fitscreen(640,480,1),1,colors?colors[0].size():3,0).
31806  _display_object3d(disp,title,vertices,primitives,colors,opacities,centering,
31807  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31808  display_axes,pose_matrix);
31809  }
31810  vertices.is_object3d(primitives,true,true);
31811  if (vertices.width && !primitives) {
31812  CImgList<tf> nprimitives(vertices.width,1,1,1,1);
31813  cimglist_for(nprimitives,l) nprimitives(l,0) = l;
31814  return _display_object3d(disp,title,vertices,nprimitives,colors,opacities,centering,
31815  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31816  display_axes,pose_matrix);
31817  }
31818  if (!disp) {
31819  char ntitle[256] = { 0 };
31820  if (!title) { std::sprintf(ntitle,"CImg<%s> (%u vertices, %u primitives)",pixel_type(),vertices.width,primitives.width); }
31821  disp.assign(cimg_fitscreen(width,height,depth),title?title:ntitle,1);
31822  }
31823 
31824  CImgList<tc> _colors;
31825  if (!colors) _colors.insert(primitives.width,CImg<tc>::vector(200,200,200));
31826  const CImgList<tc> &ncolors = colors?colors:_colors;
31827 
31828  // Init 3D objects and compute object statistics
31829  CImg<floatT>
31830  pose, rot_mat, zbuffer(disp.width,disp.height,1,1,0),
31831  centered_vertices = centering?CImg<floatT>(vertices.width,3):CImg<floatT>(),
31832  rotated_vertices(vertices.width,3),
31833  bbox_vertices, rotated_bbox_vertices,
31834  axes_vertices, rotated_axes_vertices,
31835  bbox_opacities, axes_opacities;
31836  CImgList<uintT> bbox_primitives, axes_primitives;
31837  CImgList<T> bbox_colors, bbox_colors2, axes_colors;
31838  float dx = 0, dy = 0, dz = 0, ratio = 1;
31839 
31840  T minval = (T)0, maxval = (T)255;
31841  if (disp.normalization && colors) {
31842  minval = colors.minmax(maxval);
31843  if (minval==maxval) { minval = (T)0; maxval = (T)255; }
31844  }
31845  unsigned int ns_width = 0, ns_height = 0;
31846  const float meanval = (float)mean();
31847  bool color_model = true;
31848  if (cimg::abs(meanval-minval)>cimg::abs(meanval-maxval)) color_model = false;
31849  const CImg<T>
31850  background_color(1,1,1,dim,color_model?minval:maxval),
31851  foreground_color(1,1,1,dim,color_model?maxval:minval);
31852 
31853  float xm = cimg::type<float>::max(), xM = 0, ym = xm, yM = 0, zm = xm, zM = 0;
31854  cimg_forX(vertices,i) {
31855  const float x = (float)vertices(i,0), y = (float)vertices(i,1), z = (float)vertices(i,2);
31856  if (x<xm) xm = x;
31857  if (x>xM) xM = x;
31858  if (y<ym) ym = y;
31859  if (y>yM) yM = y;
31860  if (z<zm) zm = z;
31861  if (z>zM) zM = z;
31862  }
31863  const float delta = cimg::max(xM-xm,yM-ym,zM-zm);
31864 
31865  if (display_axes) {
31866  rotated_axes_vertices = axes_vertices.assign(7,3,1,1,
31867  0,20,0,0,22,-6,-6,
31868  0,0,20,0,-6,22,-6,
31869  0,0,0,20,0,0,22);
31870  axes_opacities.assign(3,1,1,1,1);
31871  axes_colors.assign(3,dim,1,1,1,foreground_color[0]);
31872  axes_primitives.assign(3,1,2,1,1, 0,1, 0,2, 0,3);
31873  }
31874 
31875  // Begin user interaction loop
31876  CImg<T> visu0(*this), visu;
31877  bool init = true, clicked = false, redraw = true;
31878  unsigned int key = 0;
31879  int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
31880  disp.show().flush();
31881 
31882  while (!disp.is_closed && !key) {
31883 
31884  // Init object position and scale if necessary
31885  if (init) {
31886  ratio = delta>0?(2.0f*cimg::min(disp.width,disp.height)/(3.0f*delta)):0;
31887  dx = 0.5f*(xM + xm); dy = 0.5f*(yM + ym); dz = 0.5f*(zM + zm);
31888  if (centering) {
31889  cimg_forX(centered_vertices,l) {
31890  centered_vertices(l,0) = (float)((vertices(l,0) - dx)*ratio);
31891  centered_vertices(l,1) = (float)((vertices(l,1) - dy)*ratio);
31892  centered_vertices(l,2) = (float)((vertices(l,2) - dz)*ratio);
31893  }
31894  }
31895 
31896  if (render_static<0 || render_motion<0) {
31897  rotated_bbox_vertices = bbox_vertices.assign(8,3,1,1,
31898  xm,xM,xM,xm,xm,xM,xM,xm,
31899  ym,ym,yM,yM,ym,ym,yM,yM,
31900  zm,zm,zm,zm,zM,zM,zM,zM);
31901  bbox_primitives.assign(6,1,4,1,1, 0,3,2,1, 4,5,6,7, 1,2,6,5, 0,4,7,3, 0,1,5,4, 2,3,7,6);
31902  bbox_colors.assign(6,dim,1,1,1,background_color[0]);
31903  bbox_colors2.assign(6,dim,1,1,1,foreground_color[0]);
31904  bbox_opacities.assign(bbox_colors.width,1,1,1,0.3f);
31905  }
31906 
31907  if (!pose) {
31908  if (pose_matrix) pose = CImg<floatT>(pose_matrix,4,4,1,1,false);
31909  else pose = CImg<floatT>::identity_matrix(4);
31910  }
31911  init = false;
31912  redraw = true;
31913  }
31914 
31915  // Rotate and Draw 3D object
31916  if (redraw) {
31917  const float
31918  r00 = pose(0,0), r10 = pose(1,0), r20 = pose(2,0), r30 = pose(3,0),
31919  r01 = pose(0,1), r11 = pose(1,1), r21 = pose(2,1), r31 = pose(3,1),
31920  r02 = pose(0,2), r12 = pose(1,2), r22 = pose(2,2), r32 = pose(3,2);
31921  if ((clicked && render_motion>=0) || (!clicked && render_static>=0)) {
31922  if (centering) cimg_forX(centered_vertices,l) {
31923  const float x = centered_vertices(l,0), y = centered_vertices(l,1), z = centered_vertices(l,2);
31924  rotated_vertices(l,0) = r00*x + r10*y + r20*z + r30;
31925  rotated_vertices(l,1) = r01*x + r11*y + r21*z + r31;
31926  rotated_vertices(l,2) = r02*x + r12*y + r22*z + r32;
31927  } else cimg_forX(vertices,l) {
31928  const float
31929  x = (float)vertices(l,0),
31930  y = (float)vertices(l,1),
31931  z = (float)vertices(l,2);
31932  rotated_vertices(l,0) = r00*x + r10*y + r20*z + r30;
31933  rotated_vertices(l,1) = r01*x + r11*y + r21*z + r31;
31934  rotated_vertices(l,2) = r02*x + r12*y + r22*z + r32;
31935  }
31936  } else {
31937  if (!centering) cimg_forX(bbox_vertices,l) {
31938  const float x = bbox_vertices(l,0), y = bbox_vertices(l,1), z = bbox_vertices(l,2);
31939  rotated_bbox_vertices(l,0) = r00*x + r10*y + r20*z + r30;
31940  rotated_bbox_vertices(l,1) = r01*x + r11*y + r21*z + r31;
31941  rotated_bbox_vertices(l,2) = r02*x + r12*y + r22*z + r32;
31942  } else cimg_forX(bbox_vertices,l) {
31943  const float x = (bbox_vertices(l,0) - dx)*ratio, y = (bbox_vertices(l,1) - dy)*ratio, z = (bbox_vertices(l,2) - dz)*ratio;
31944  rotated_bbox_vertices(l,0) = r00*x + r10*y + r20*z + r30;
31945  rotated_bbox_vertices(l,1) = r01*x + r11*y + r21*z + r31;
31946  rotated_bbox_vertices(l,2) = r02*x + r12*y + r22*z + r32;
31947  }
31948  }
31949 
31950  // Draw object
31951  visu = visu0;
31952  if ((clicked && render_motion<0) || (!clicked && render_static<0))
31953  visu.draw_object3d(visu.width/2.0f,visu.height/2.0f,0,rotated_bbox_vertices,bbox_primitives,bbox_colors,bbox_opacities,2,false,focale).
31954  draw_object3d(visu.width/2.0f,visu.height/2.0f,0,rotated_bbox_vertices,bbox_primitives,bbox_colors2,1,false,focale);
31955  else visu.draw_object3d(visu.width/2.0f,visu.height/2.0f,0,
31956  rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
31957  double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
31958  (!clicked && render_static>0)?zbuffer.fill(0):CImg<floatT>::empty());
31959 
31960  // Draw axes
31961  if (display_axes) {
31962  const float Xaxes = 25, Yaxes = visu.height - 35.0f;
31963  cimg_forX(axes_vertices,l) {
31964  const float x = axes_vertices(l,0), y = axes_vertices(l,1), z = axes_vertices(l,2);
31965  rotated_axes_vertices(l,0) = r00*x + r10*y + r20*z;
31966  rotated_axes_vertices(l,1) = r01*x + r11*y + r21*z;
31967  rotated_axes_vertices(l,2) = r02*x + r12*y + r22*z;
31968  }
31969  axes_opacities(0,0) = (rotated_axes_vertices(1,2)>0)?0.5f:1.0f;
31970  axes_opacities(1,0) = (rotated_axes_vertices(2,2)>0)?0.5f:1.0f;
31971  axes_opacities(2,0) = (rotated_axes_vertices(3,2)>0)?0.5f:1.0f;
31972  visu.draw_object3d(Xaxes,Yaxes,0,rotated_axes_vertices,axes_primitives,axes_colors,axes_opacities,1,false,focale).
31973  draw_text((int)(Xaxes+rotated_axes_vertices(4,0)),
31974  (int)(Yaxes+rotated_axes_vertices(4,1)),
31975  "X",axes_colors[0].data,0,axes_opacities(0,0),11).
31976  draw_text((int)(Xaxes+rotated_axes_vertices(5,0)),
31977  (int)(Yaxes+rotated_axes_vertices(5,1)),
31978  "Y",axes_colors[1].data,0,axes_opacities(1,0),11).
31979  draw_text((int)(Xaxes+rotated_axes_vertices(6,0)),
31980  (int)(Yaxes+rotated_axes_vertices(6,1)),
31981  "Z",axes_colors[2].data,0,axes_opacities(2,0),11);
31982  }
31983  visu.display(disp);
31984  if (!clicked || render_motion==render_static) redraw = false;
31985  }
31986 
31987  // Handle user interaction
31988  disp.wait();
31989  if ((disp.button || disp.wheel) && disp.mouse_x>=0 && disp.mouse_y>=0) {
31990  redraw = true;
31991  if (!clicked) { x0 = x1 = disp.mouse_x; y0 = y1 = disp.mouse_y; if (!disp.wheel) clicked = true; }
31992  else { x1 = disp.mouse_x; y1 = disp.mouse_y; }
31993  if (disp.button&1) {
31994  const float
31995  R = 0.45f*cimg::min(disp.width,disp.height),
31996  R2 = R*R,
31997  u0 = (float)(x0-disp.dimx()/2),
31998  v0 = (float)(y0-disp.dimy()/2),
31999  u1 = (float)(x1-disp.dimx()/2),
32000  v1 = (float)(y1-disp.dimy()/2),
32001  n0 = (float)std::sqrt(u0*u0+v0*v0),
32002  n1 = (float)std::sqrt(u1*u1+v1*v1),
32003  nu0 = n0>R?(u0*R/n0):u0,
32004  nv0 = n0>R?(v0*R/n0):v0,
32005  nw0 = (float)std::sqrt(cimg::max(0,R2-nu0*nu0-nv0*nv0)),
32006  nu1 = n1>R?(u1*R/n1):u1,
32007  nv1 = n1>R?(v1*R/n1):v1,
32008  nw1 = (float)std::sqrt(cimg::max(0,R2-nu1*nu1-nv1*nv1)),
32009  u = nv0*nw1-nw0*nv1,
32010  v = nw0*nu1-nu0*nw1,
32011  w = nv0*nu1-nu0*nv1,
32012  n = (float)std::sqrt(u*u+v*v+w*w),
32013  alpha = (float)std::asin(n/R2);
32014  rot_mat = CImg<floatT>::rotation_matrix(u,v,w,alpha);
32015  rot_mat *= pose.get_crop(0,0,2,2);
32016  pose.draw_image(rot_mat);
32017  x0=x1; y0=y1;
32018  }
32019  if (disp.button&2) { pose(3,2)+=(y1-y0); x0 = x1; y0 = y1; }
32020  if (disp.wheel) { pose(3,2)-=focale*disp.wheel/10; disp.wheel = 0; }
32021  if (disp.button&4) { pose(3,0)+=(x1-x0); pose(3,1)+=(y1-y0); x0 = x1; y0 = y1; }
32022  if ((disp.button&1) && (disp.button&2)) { init = true; disp.button = 0; x0 = x1; y0 = y1; pose = CImg<floatT>::identity_matrix(4); }
32023  } else if (clicked) { x0 = x1; y0 = y1; clicked = false; redraw = true; }
32024 
32025  switch (key = disp.key) {
32026  case 0 : case cimg::keyCTRLLEFT : disp.key = key = 0; break;
32027  case cimg::keyD: if (disp.is_keyCTRLLEFT) {
32028  disp.normalscreen().resize(CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,false),
32029  CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,true),false).is_resized = true;
32030  disp.key = key = 0;
32031  } break;
32032  case cimg::keyC : if (disp.is_keyCTRLLEFT) {
32033  disp.normalscreen().resize(cimg_fitscreen(2*disp.width/3,2*disp.height/3,1),false).is_resized = true;
32034  disp.key = key = 0;
32035  } break;
32036  case cimg::keyR : if (disp.is_keyCTRLLEFT) {
32037  disp.normalscreen().resize(cimg_fitscreen(width,height,depth),false).is_resized = true;
32038  disp.key = key = 0;
32039  } break;
32040  case cimg::keyF : if (disp.is_keyCTRLLEFT) {
32041  if (!ns_width || !ns_height ||
32042  ns_width>(unsigned int)disp.screen_dimx() || ns_height>(unsigned int)disp.screen_dimy()) {
32043  ns_width = disp.screen_dimx()*3U/4;
32044  ns_height = disp.screen_dimy()*3U/4;
32045  }
32046  if (disp.is_fullscreen) disp.resize(ns_width,ns_height,false);
32047  else {
32048  ns_width = (unsigned int)disp.width; ns_height = disp.height;
32049  disp.resize(disp.screen_dimx(),disp.screen_dimy(),false);
32050  }
32051  disp.toggle_fullscreen().is_resized = true;
32052  disp.key = key = 0;
32053  } break;
32054  case cimg::keyZ : if (disp.is_keyCTRLLEFT) { // Enable/Disable Z-buffer
32055  if (zbuffer) zbuffer.assign();
32056  else zbuffer.assign(disp.width,disp.height,1,1,0);
32057  disp.key = key = 0; redraw = true;
32058  } break;
32059  case cimg::keyS : if (disp.is_keyCTRLLEFT) { // Save snapshot
32060  static unsigned int snap_number = 0;
32061  char filename[32] = { 0 };
32062  std::FILE *file;
32063  do {
32064  std::sprintf(filename,"CImg_%.4u.bmp",snap_number++);
32065  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
32066  } while (file);
32067  (+visu).draw_text(2,2,"Saving BMP snapshot...",foreground_color,background_color,1,11).display(disp);
32068  visu.save(filename);
32069  visu.draw_text(2,2,"Snapshot '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32070  disp.key = key = 0;
32071  } break;
32072  case cimg::keyO : if (disp.is_keyCTRLLEFT) { // Save object as an .OFF file
32073  static unsigned int snap_number = 0;
32074  char filename[32] = { 0 };
32075  std::FILE *file;
32076  do {
32077  std::sprintf(filename,"CImg_%.4u.off",snap_number++);
32078  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
32079  } while (file);
32080  visu.draw_text(2,2,"Saving object...",foreground_color,background_color,1,11).display(disp);
32081  vertices.save_off(filename,primitives,ncolors);
32082  visu.draw_text(2,2,"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32083  disp.key = key = 0;
32084  } break;
32085 #ifdef cimg_use_board
32086  case cimg::keyP : if (disp.is_keyCTRLLEFT) { // Save object as a .EPS file
32087  static unsigned int snap_number = 0;
32088  char filename[32] = { 0 };
32089  std::FILE *file;
32090  do {
32091  std::sprintf(filename,"CImg_%.4u.eps",snap_number++);
32092  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
32093  } while (file);
32094  visu.draw_text(2,2,"Saving EPS snapshot...",foreground_color,background_color,1,11).display(disp);
32095  LibBoard::Board board;
32096  (+visu).draw_object3d(board,visu.width/2.0f,visu.height/2.0f,0,
32097  rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
32098  double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
32099  zbuffer.fill(0));
32100  board.saveEPS(filename);
32101  visu.draw_text(2,2,"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32102  disp.key = key = 0;
32103  } break;
32104  case cimg::keyV : if (disp.is_keyCTRLLEFT) { // Save object as a .SVG file
32105  static unsigned int snap_number = 0;
32106  char filename[32] = { 0 };
32107  std::FILE *file;
32108  do {
32109  std::sprintf(filename,"CImg_%.4u.svg",snap_number++);
32110  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
32111  } while (file);
32112  visu.draw_text(2,2,"Saving SVG snapshot...",foreground_color,background_color,1,11).display(disp);
32113  LibBoard::Board board;
32114  (+visu).draw_object3d(board,visu.width/2.0f,visu.height/2.0f,0,
32115  rotated_vertices,primitives,ncolors,opacities,clicked?render_motion:render_static,
32116  double_sided,focale,visu.dimx()/2.0f,visu.dimy()/2.0f,-5000,specular_light,specular_shine,
32117  zbuffer.fill(0));
32118  board.saveSVG(filename);
32119  visu.draw_text(2,2,"Object '%s' saved.",foreground_color,background_color,1,11,filename).display(disp);
32120  disp.key = key = 0;
32121  } break;
32122 #endif
32123  }
32124  if (disp.is_resized) { disp.resize(false); visu0 = get_resize(disp,1); if (zbuffer) zbuffer.assign(disp.width,disp.height); redraw = true; }
32125  }
32126  if (pose_matrix) std::memcpy(pose_matrix,pose.data,16*sizeof(float));
32127  disp.button = 0;
32128  disp.key = key;
32129  return *this;
32130  }
if(dy > dx)
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.
Definition: CImg.h:26338
const unsigned int keyP
Definition: CImg.h:2709
static unsigned int _fitscreen(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const int dmin=128, const int dmax=-85, const bool return_last=false)
Definition: CImg.h:6437
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_forX(img, x)
Definition: CImg.h:593
const unsigned int keyV
Definition: CImg.h:2728
void int int REAL REAL * y
Definition: read.cpp:74
const unsigned int keyCTRLLEFT
Definition: CImg.h:2734
NT dx
#define cimg_fitscreen(dx, dy, dz)
Definition: CImg.h:6436
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Tfloat mean() const
Return the mean pixel value of the instance image.
Definition: CImg.h:13032
const unsigned int keyC
Definition: CImg.h:2727
CImg< T > & identity_matrix()
Get an identity matrix having same dimension than instance image.
Definition: CImg.h:13416
double sqrt(double d)
Definition: double.h:73
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
static CImg< T > & empty()
Return a reference to an empty image.
Definition: CImg.h:10351
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
Draw a 3D object.
Definition: CImg.h:27522
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
const unsigned int keyO
Definition: CImg.h:2708
blockLoc i
Definition: read.cpp:79
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
const unsigned int keyF
Definition: CImg.h:2717
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimglist_for(list, l)
Definition: CImg.h:1877
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
const unsigned int keyZ
Definition: CImg.h:2725
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
const unsigned int keyR
Definition: CImg.h:2703
NT dy
const unsigned int keyS
Definition: CImg.h:2715
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.
Definition: CImg.h:14395
const unsigned int keyD
Definition: CImg.h:2716
static T_Key key
Definition: vinci_lass.c:76
const CImg< T > & _display_object3d(CImgDisplay &disp, const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering, const int render_static, const int render_motion, const bool double_sided, const float focale, const float specular_light, const float specular_shine, const bool display_axes, float *const pose_matrix) const
Definition: CImg.h:31788
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg< T > & asin()
Compute the arc-sinus of each pixel value.
Definition: CImg.h:12650

Here is the caller graph for this function:

static float _distance_f ( const int  x,
const int  i,
const float  gi2,
const float  fact 
)
inlinestatic

Definition at line 20537 of file CImg.h.

Referenced by CImg< uintT >::get_distance().

20537  {
20538  const float xmi = fact*((float)x - i);
20539  return xmi*xmi + gi2;
20540  }
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

static int _distance_sep ( const int  i,
const int  u,
const int  gi2,
const int  gu2,
const float  fact 
)
inlinestatic

Definition at line 20541 of file CImg.h.

Referenced by CImg< uintT >::get_distance().

20541  {
20542  const float fact2 = fact*fact;
20543  return (int)(fact2*(u*u - i*i) + gu2 - gi2)/(int)(2*fact2*(u - i));
20544  }
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

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

Definition at line 25951 of file CImg.h.

Referenced by CImg< uintT >::draw_ellipse().

25953  {
25954  if (is_empty()) return *this;
25955  if (!color)
25956  throw CImgArgumentException("CImg<%s>::draw_ellipse : Specified color is (null).",
25957  pixel_type());
25958  _draw_scanline(color,opacity);
25959  const float
25960  nr1 = cimg::abs(r1), nr2 = cimg::abs(r2),
25961  nangle = (float)(angle*cimg::valuePI/180),
25962  u = (float)std::cos(nangle),
25963  v = (float)std::sin(nangle),
25964  rmax = cimg::max(nr1,nr2),
25965  l1 = (float)std::pow(rmax/(nr1>0?nr1:1e-6),2),
25966  l2 = (float)std::pow(rmax/(nr2>0?nr2:1e-6),2),
25967  a = l1*u*u + l2*v*v,
25968  b = u*v*(l1-l2),
25969  c = l1*v*v + l2*u*u;
25970  const int
25971  yb = (int)std::sqrt(a*rmax*rmax/(a*c-b*b)),
25972  tymin = y0 - yb - 1,
25973  tymax = y0 + yb + 1,
25974  ymin = tymin<0?0:tymin,
25975  ymax = tymax>=dimy()?height-1:tymax;
25976  int oxmin = 0, oxmax = 0;
25977  bool first_line = true;
25978  for (int y = ymin; y<=ymax; ++y) {
25979  const float
25980  Y = y-y0 + (y<y0?0.5f:-0.5f),
25981  delta = b*b*Y*Y-a*(c*Y*Y-rmax*rmax),
25982  sdelta = delta>0?(float)std::sqrt(delta)/a:0.0f,
25983  bY = b*Y/a,
25984  fxmin = x0-0.5f-bY-sdelta,
25985  fxmax = x0+0.5f-bY+sdelta;
25986  const int xmin = (int)fxmin, xmax = (int)fxmax;
25987  if (!pattern) _draw_scanline(xmin,xmax,y,color,opacity);
25988  else {
25989  if (first_line) {
25990  if (y0-yb>=0) _draw_scanline(xmin,xmax,y,color,opacity);
25991  else draw_point(xmin,y,color,opacity).draw_point(xmax,y,color,opacity);
25992  first_line = false;
25993  } else {
25994  if (xmin<oxmin) _draw_scanline(xmin,oxmin-1,y,color,opacity);
25995  else _draw_scanline(oxmin+(oxmin==xmin?0:1),xmin,y,color,opacity);
25996  if (xmax<oxmax) _draw_scanline(xmax,oxmax-1,y,color,opacity);
25997  else _draw_scanline(oxmax+(oxmax==xmax?0:1),xmax,y,color,opacity);
25998  if (y==tymax) _draw_scanline(xmin+1,xmax-1,y,color,opacity);
25999  }
26000  }
26001  oxmin = xmin; oxmax = xmax;
26002  }
26003  return *this;
26004  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
void int int REAL REAL * y
Definition: read.cpp:74
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
NT & sin
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
Definition: CImg.h:22095
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
double pow(double value, const Exponent &exp)
NT & cos

Here is the caller graph for this function:

CImg<T>& _draw_line ( const t &  points,
const unsigned int  W,
const unsigned int  H,
const tc *const  color,
const float  opacity,
const unsigned int  pattern,
const bool  init_hatch 
)
inline

Definition at line 22950 of file CImg.h.

Referenced by CImg< uintT >::draw_line().

22952  {
22953  if (is_empty() || !points || W<2) return *this;
22954  bool ninit_hatch = init_hatch;
22955  switch (H) {
22956  case 0 : case 1 :
22957  throw CImgArgumentException("CImg<%s>::draw_line() : Given list of points is not valid.",
22958  pixel_type());
22959  case 2 : {
22960  const int x0 = (int)points(0,0), y0 = (int)points(0,1);
22961  int ox = x0, oy = y0;
22962  for (unsigned int i = 1; i<W; ++i) {
22963  const int x = (int)points(i,0), y = (int)points(i,1);
22964  draw_line(ox,oy,x,y,color,opacity,pattern,ninit_hatch);
22965  ninit_hatch = false;
22966  ox = x; oy = y;
22967  }
22968  } break;
22969  default : {
22970  const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
22971  int ox = x0, oy = y0, oz = z0;
22972  for (unsigned int i = 1; i<W; ++i) {
22973  const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2);
22974  draw_line(ox,oy,oz,x,y,z,color,opacity,pattern,ninit_hatch);
22975  ninit_hatch = false;
22976  ox = x; oy = y; oz = z;
22977  }
22978  }
22979  }
22980  return *this;
22981  }
void int int REAL REAL * y
Definition: read.cpp:74
Definition: points.h:30
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:22330

Here is the caller graph for this function:

CImg<T>& _draw_object3d ( void *const  pboard,
CImg< floatT > &  zbuffer,
const float  X,
const float  Y,
const float  Z,
const CImg< tp > &  vertices,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors,
const to &  opacities,
const unsigned int  nb_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 
)
inline

Definition at line 27625 of file CImg.h.

Referenced by CImg< uintT >::draw_object3d().

27634  {
27635  if (is_empty() || !vertices || !primitives) return *this;
27636  vertices.is_object3d(primitives,false,true);
27637 #ifndef cimg_use_board
27638  if (pboard) return *this;
27639 #endif
27640  const float
27641  nspec = 1.0f-(specular_light<0.0f?0.0f:(specular_light>1.0f?1.0f:specular_light)),
27642  nspec2 = 1.0f+(specular_shine<0.0f?0.0f:specular_shine),
27643  nsl1 = (nspec2-1)/cimg::sqr(nspec-1),
27644  nsl2 = (1-2*nsl1*nspec),
27645  nsl3 = nspec2-nsl1-nsl2;
27646 
27647  // Create light texture for phong-like rendering
27648  static CImg<floatT> light_texture;
27649  if (render_type==5) {
27650  if (colors.width>primitives.width) light_texture.assign(colors[primitives.width])/=255;
27651  else {
27652  static float olightx = 0, olighty = 0, olightz = 0, ospecular_shine = 0;
27653  if (!light_texture || lightx!=olightx || lighty!=olighty || lightz!=olightz || specular_shine!=ospecular_shine) {
27654  light_texture.assign(512,512);
27655  const float white[] = { 1 },
27656  dlx = lightx-X, dly = lighty-Y, dlz = lightz-Z,
27657  nl = (float)std::sqrt(dlx*dlx+dly*dly+dlz*dlz),
27658  nlx = light_texture.width/2*(1+dlx/nl),
27659  nly = light_texture.height/2*(1+dly/nl);
27660  light_texture.draw_gaussian(nlx,nly,light_texture.width/3.0f,white);
27661  cimg_forXY(light_texture,x,y) {
27662  const float factor = light_texture(x,y);
27663  if (factor>nspec) light_texture(x,y) = cimg::min(2,nsl1*factor*factor+nsl2*factor+nsl3);
27664  }
27665  olightx = lightx; olighty = lighty; olightz = lightz; ospecular_shine = specular_shine;
27666  }
27667  }
27668  }
27669 
27670  // Compute 3D to 2D projection
27671  CImg<floatT> projections(vertices.width,2);
27672  cimg_forX(projections,l) {
27673  const float
27674  x = (float)vertices(l,0),
27675  y = (float)vertices(l,1),
27676  z = (float)vertices(l,2);
27677  const float projectedz = z + Z + focale;
27678  projections(l,1) = Y + focale*y/projectedz;
27679  projections(l,0) = X + focale*x/projectedz;
27680  }
27681 
27682  // Compute and sort visible primitives
27683  CImg<uintT> visibles(primitives.width);
27684  CImg<floatT> zrange(primitives.width);
27685  unsigned int nb_visibles = 0;
27686  const float zmin = -focale+1.5f;
27687  { cimglist_for(primitives,l) {
27688  const CImg<tf>& primitive = primitives[l];
27689  switch (primitive.size()) {
27690 
27691  case 1 : { // Point
27692  const unsigned int i0 = (unsigned int)primitive(0);
27693  const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2));
27694  if (z0>zmin && x0>=0 && x0<width && y0>=0 && y0<height) {
27695  visibles(nb_visibles) = (unsigned int)l;
27696  zrange(nb_visibles++) = z0;
27697  }
27698  } break;
27699  case 5 : { // Sphere
27700  const unsigned int
27701  i0 = (unsigned int)primitive(0),
27702  i1 = (unsigned int)primitive(1),
27703  i2 = (unsigned int)primitive(2);
27704  const float x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2));
27705  int radius;
27706  if (i2) radius = (int)(i2*focale/(z0+focale));
27707  else {
27708  const float x1 = projections(i1,0), y1 = projections(i1,1);
27709  const int deltax = (int)(x1-x0), deltay = (int)(y1-y0);
27710  radius = (int)std::sqrt((float)(deltax*deltax + deltay*deltay));
27711  }
27712  if (z0>zmin && x0+radius>=0 && x0-radius<width && y0+radius>=0 && y0-radius<height) {
27713  visibles(nb_visibles) = (unsigned int)l;
27714  zrange(nb_visibles++) = z0;
27715  }
27716  } break;
27717  case 2 : // Segment
27718  case 6 : {
27719  const unsigned int
27720  i0 = (unsigned int)primitive(0),
27721  i1 = (unsigned int)primitive(1);
27722  const float
27723  x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27724  x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2));
27725  float xm, xM, ym, yM;
27726  if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
27727  if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
27728  if (z0>zmin && z1>zmin && xM>=0 && xm<width && yM>=0 && ym<height) {
27729  visibles(nb_visibles) = (unsigned int)l;
27730  zrange(nb_visibles++) = 0.5f*(z0+z1);
27731  }
27732  } break;
27733  case 3 : // Triangle
27734  case 9 : {
27735  const unsigned int
27736  i0 = (unsigned int)primitive(0),
27737  i1 = (unsigned int)primitive(1),
27738  i2 = (unsigned int)primitive(2);
27739  const float
27740  x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27741  x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2)),
27742  x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z + vertices(i2,2));
27743  float xm, xM, ym, yM;
27744  if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
27745  if (x2<xm) xm = x2;
27746  if (x2>xM) xM = x2;
27747  if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
27748  if (y2<ym) ym = y2;
27749  if (y2>yM) yM = y2;
27750  if (z0>zmin && z1>zmin && z2>zmin && xM>=0 && xm<width && yM>=0 && ym<height) {
27751  const float d = (x1-x0)*(y2-y0)-(x2-x0)*(y1-y0);
27752  if (double_sided || d<0) {
27753  visibles(nb_visibles) = (unsigned int)l;
27754  zrange(nb_visibles++) = (z0+z1+z2)/3;
27755  }
27756  }
27757  } break;
27758  case 4 : // Rectangle
27759  case 12 : {
27760  const unsigned int
27761  i0 = (unsigned int)primitive(0),
27762  i1 = (unsigned int)primitive(1),
27763  i2 = (unsigned int)primitive(2),
27764  i3 = (unsigned int)primitive(3);
27765  const float
27766  x0 = projections(i0,0), y0 = projections(i0,1), z0 = (float)(Z + vertices(i0,2)),
27767  x1 = projections(i1,0), y1 = projections(i1,1), z1 = (float)(Z + vertices(i1,2)),
27768  x2 = projections(i2,0), y2 = projections(i2,1), z2 = (float)(Z + vertices(i2,2)),
27769  x3 = projections(i3,0), y3 = projections(i3,1), z3 = (float)(Z + vertices(i3,2));
27770  float xm, xM, ym, yM;
27771  if (x0<x1) { xm = x0; xM = x1; } else { xm = x1; xM = x0; }
27772  if (x2<xm) xm = x2;
27773  if (x2>xM) xM = x2;
27774  if (x3<xm) xm = x3;
27775  if (x3>xM) xM = x3;
27776  if (y0<y1) { ym = y0; yM = y1; } else { ym = y1; yM = y0; }
27777  if (y2<ym) ym = y2;
27778  if (y2>yM) yM = y2;
27779  if (y3<ym) ym = y3;
27780  if (y3>yM) yM = y3;
27781  if (z0>zmin && z1>zmin && z2>zmin && z3>zmin && xM>=0 && xm<width && yM>=0 && ym<height) {
27782  const float d = (x1 - x0)*(y2 - y0) - (x2 - x0)*(y1 - y0);
27783  if (double_sided || d<0) {
27784  visibles(nb_visibles) = (unsigned int)l;
27785  zrange(nb_visibles++) = (z0 + z1 + z2 + z3)/4;
27786  }
27787  }
27788  } break;
27789  default :
27790  throw CImgArgumentException("CImg<%s>::draw_object3d() : Primitive %u is invalid (size = %u, can be 1,2,3,4,5,6,9 or 12)",
27791  pixel_type(),l,primitive.size());
27792  }
27793  }
27794  }
27795  if (nb_visibles<=0) return *this;
27796  CImg<uintT> permutations;
27797  CImg<floatT>(zrange.data,nb_visibles,1,1,1,true).sort(permutations,false);
27798 
27799  // Compute light properties
27800  CImg<floatT> lightprops;
27801  switch (render_type) {
27802  case 3 : { // Flat Shading
27803  lightprops.assign(nb_visibles);
27804  cimg_forX(lightprops,l) {
27805  const CImg<tf>& primitive = primitives(visibles(permutations(l)));
27806  const unsigned int psize = primitive.size();
27807  if (psize==3 || psize==4 || psize==9 || psize==12) {
27808  const unsigned int
27809  i0 = (unsigned int)primitive(0),
27810  i1 = (unsigned int)primitive(1),
27811  i2 = (unsigned int)primitive(2);
27812  const float
27813  x0 = (float)vertices(i0,0), y0 = (float)vertices(i0,1), z0 = (float)vertices(i0,2),
27814  x1 = (float)vertices(i1,0), y1 = (float)vertices(i1,1), z1 = (float)vertices(i1,2),
27815  x2 = (float)vertices(i2,0), y2 = (float)vertices(i2,1), z2 = (float)vertices(i2,2),
27816  dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
27817  dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
27818  nx = dy1*dz2 - dz1*dy2,
27819  ny = dz1*dx2 - dx1*dz2,
27820  nz = dx1*dy2 - dy1*dx2,
27821  norm = (float)std::sqrt(1e-5f + nx*nx + ny*ny + nz*nz),
27822  lx = X + (x0 + x1 + x2)/3 - lightx,
27823  ly = Y + (y0 + y1 + y2)/3 - lighty,
27824  lz = Z + (z0 + z1 + z2)/3 - lightz,
27825  nl = (float)std::sqrt(1e-5f + lx*lx + ly*ly + lz*lz),
27826  factor = cimg::max(cimg::abs(-lx*nx-ly*ny-lz*nz)/(norm*nl),0);
27827  lightprops[l] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
27828  } else lightprops[l] = 1;
27829  }
27830  } break;
27831 
27832  case 4 : // Gouraud Shading
27833  case 5 : { // Phong-Shading
27834  CImg<floatT> vertices_normals(vertices.width,3,1,1,0);
27835  for (unsigned int l = 0; l<nb_visibles; ++l) {
27836  const CImg<tf>& primitive = primitives[visibles(l)];
27837  const unsigned int psize = primitive.size();
27838  const bool
27839  triangle_flag = (psize==3) || (psize==9),
27840  rectangle_flag = (psize==4) || (psize==12);
27841  if (triangle_flag || rectangle_flag) {
27842  const unsigned int
27843  i0 = (unsigned int)primitive(0),
27844  i1 = (unsigned int)primitive(1),
27845  i2 = (unsigned int)primitive(2),
27846  i3 = rectangle_flag?(unsigned int)primitive(3):0;
27847  const float
27848  x0 = (float)vertices(i0,0), y0 = (float)vertices(i0,1), z0 = (float)vertices(i0,2),
27849  x1 = (float)vertices(i1,0), y1 = (float)vertices(i1,1), z1 = (float)vertices(i1,2),
27850  x2 = (float)vertices(i2,0), y2 = (float)vertices(i2,1), z2 = (float)vertices(i2,2),
27851  dx1 = x1 - x0, dy1 = y1 - y0, dz1 = z1 - z0,
27852  dx2 = x2 - x0, dy2 = y2 - y0, dz2 = z2 - z0,
27853  nnx = dy1*dz2 - dz1*dy2,
27854  nny = dz1*dx2 - dx1*dz2,
27855  nnz = dx1*dy2 - dy1*dx2,
27856  norm = 1e-5f + (float)std::sqrt(nnx*nnx + nny*nny + nnz*nnz),
27857  nx = nnx/norm,
27858  ny = nny/norm,
27859  nz = nnz/norm;
27860  vertices_normals(i0,0)+=nx; vertices_normals(i0,1)+=ny; vertices_normals(i0,2)+=nz;
27861  vertices_normals(i1,0)+=nx; vertices_normals(i1,1)+=ny; vertices_normals(i1,2)+=nz;
27862  vertices_normals(i2,0)+=nx; vertices_normals(i2,1)+=ny; vertices_normals(i2,2)+=nz;
27863  if (rectangle_flag) { vertices_normals(i3,0)+=nx; vertices_normals(i3,1)+=ny; vertices_normals(i3,2)+=nz; }
27864  }
27865  }
27866 
27867  if (double_sided) cimg_forX(vertices_normals,p) if (vertices_normals(p,2)>0) {
27868  vertices_normals(p,0) = -vertices_normals(p,0);
27869  vertices_normals(p,1) = -vertices_normals(p,1);
27870  vertices_normals(p,2) = -vertices_normals(p,2);
27871  }
27872 
27873  if (render_type==4) {
27874  lightprops.assign(vertices.width);
27875  cimg_forX(lightprops,ll) {
27876  const float
27877  nx = vertices_normals(ll,0),
27878  ny = vertices_normals(ll,1),
27879  nz = vertices_normals(ll,2),
27880  norm = (float)std::sqrt(1e-5f + nx*nx + ny*ny + nz*nz),
27881  lx = (float)(X + vertices(ll,0) - lightx),
27882  ly = (float)(Y + vertices(ll,1) - lighty),
27883  lz = (float)(Z + vertices(ll,2) - lightz),
27884  nl = (float)std::sqrt(1e-5f + lx*lx + ly*ly + lz*lz),
27885  factor = cimg::max((-lx*nx-ly*ny-lz*nz)/(norm*nl),0);
27886  lightprops[ll] = factor<=nspec?factor:(nsl1*factor*factor + nsl2*factor + nsl3);
27887  }
27888  } else {
27889  const unsigned int
27890  lw2 = light_texture.width/2 - 1,
27891  lh2 = light_texture.height/2 - 1;
27892  lightprops.assign(vertices.width,2);
27893  cimg_forX(lightprops,ll) {
27894  const float
27895  nx = vertices_normals(ll,0),
27896  ny = vertices_normals(ll,1),
27897  nz = vertices_normals(ll,2),
27898  norm = (float)std::sqrt(1e-5f + nx*nx + ny*ny + nz*nz),
27899  nnx = nx/norm,
27900  nny = ny/norm;
27901  lightprops(ll,0) = lw2*(1 + nnx);
27902  lightprops(ll,1) = lh2*(1 + nny);
27903  }
27904  }
27905  } break;
27906  }
27907 
27908  // Draw visible primitives
27909  const CImg<tc> default_color(1,dim,1,1,(tc)200);
27910  for (unsigned int l = 0; l<nb_visibles; ++l) {
27911  const unsigned int n_primitive = visibles(permutations(l));
27912  const CImg<tf>& primitive = primitives[n_primitive];
27913  const CImg<tc>& color = n_primitive<colors.width?colors[n_primitive]:default_color;
27914  const float opac = n_primitive<nb_opacities?opacities(n_primitive,0):1.0f;
27915 #ifdef cimg_use_board
27916  LibBoard::Board &board = *(LibBoard::Board*)pboard;
27917 #endif
27918 
27919  switch (primitive.size()) {
27920  case 1 : { // Colored point or sprite
27921  const unsigned int n0 = (unsigned int)primitive[0];
27922  const int x0 = (int)projections(n0,0), y0 = (int)projections(n0,1);
27923  if (color.size()==dim) { // Colored point.
27924  draw_point(x0,y0,color,opac);
27925 #ifdef cimg_use_board
27926  if (pboard) {
27927  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
27928  board.fillCircle((float)x0,dimy()-(float)y0,0);
27929  }
27930 #endif
27931  } else { // Colored sprite.
27932  const float z = Z + vertices(n0,2);
27933  const int
27934  factor = (int)(focale*100/(z+focale)),
27935  sw = color.width*factor/200,
27936  sh = color.height*factor/200,
27937  nx0 = x0 - sw, ny0 = y0 - sh;
27938  if (x0+sw>=0 && nx0<dimx() && y0+sh>=0 && ny0<dimy()) {
27939  const CImg<T> sprite = color.get_resize(-factor,-factor,1,-100,render_type<=3?1:3);
27940  __draw_object3d(n_primitive,nb_opacities,opacities,color,nx0,ny0,sprite,opac);
27941 #ifdef cimg_use_board
27942  if (pboard) {
27943  board.setPenColorRGBi(128,128,128);
27944  board.setFillColor(LibBoard::Color::None);
27945  board.drawRectangle((float)nx0,dimy()-(float)ny0,sw,sh);
27946  }
27947 #endif
27948  }
27949  }
27950  } break;
27951  case 2 : { // Colored line
27952  const unsigned int
27953  n0 = (unsigned int)primitive[0],
27954  n1 = (unsigned int)primitive[1];
27955  const int
27956  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
27957  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1);
27958  const float
27959  z0 = vertices(n0,2) + Z + focale,
27960  z1 = vertices(n1,2) + Z + focale;
27961  if (render_type) {
27962  if (zbuffer) draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac);
27963  else draw_line(x0,y0,x1,y1,color,opac);
27964 #ifdef cimg_use_board
27965  if (pboard) {
27966  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
27967  board.drawLine((float)x0,dimy()-(float)y0,x1,dimy()-(float)y1);
27968  }
27969 #endif
27970  } else {
27971  draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac);
27972 #ifdef cimg_use_board
27973  if (pboard) {
27974  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
27975  board.drawCircle((float)x0,dimy()-(float)y0,0);
27976  board.drawCircle((float)x1,dimy()-(float)y1,0);
27977  }
27978 #endif
27979  }
27980  } break;
27981  case 5 : { // Colored sphere
27982  const unsigned int
27983  n0 = (unsigned int)primitive[0],
27984  n1 = (unsigned int)primitive[1],
27985  n2 = (unsigned int)primitive[2];
27986  const int
27987  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1);
27988  int radius;
27989  if (n2) radius = (int)(n2*focale/(Z + vertices(n0,2) + focale));
27990  else {
27991  const int
27992  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
27993  deltax = x1-x0, deltay = y1-y0;
27994  radius = (int)std::sqrt((float)(deltax*deltax + deltay*deltay));
27995  }
27996  switch (render_type) {
27997  case 0 :
27998  draw_point(x0,y0,color,opac);
27999 #ifdef cimg_use_board
28000  if (pboard) {
28001  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28002  board.fillCircle((float)x0,dimy()-(float)y0,0);
28003  }
28004 #endif
28005  break;
28006  case 1 :
28007  draw_circle(x0,y0,radius,color,opac,~0U);
28008 #ifdef cimg_use_board
28009  if (pboard) {
28010  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28011  board.setFillColor(LibBoard::Color::None);
28012  board.drawCircle((float)x0,dimy()-(float)y0,(float)radius);
28013  }
28014 #endif
28015  break;
28016  default :
28017  draw_circle(x0,y0,radius,color,opac);
28018 #ifdef cimg_use_board
28019  if (pboard) {
28020  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28021  board.fillCircle((float)x0,dimy()-(float)y0,(float)radius);
28022  }
28023 #endif
28024  break;
28025  }
28026  } break;
28027  case 6 : { // Textured line
28028  const unsigned int
28029  n0 = (unsigned int)primitive[0],
28030  n1 = (unsigned int)primitive[1],
28031  tx0 = (unsigned int)primitive[2],
28032  ty0 = (unsigned int)primitive[3],
28033  tx1 = (unsigned int)primitive[4],
28034  ty1 = (unsigned int)primitive[5];
28035  const int
28036  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28037  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1);
28038  const float
28039  z0 = vertices(n0,2) + Z + focale,
28040  z1 = vertices(n1,2) + Z + focale;
28041  if (render_type) {
28042  if (zbuffer) draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac);
28043  else draw_line(x0,y0,x1,y1,color,tx0,ty0,tx1,ty1,opac);
28044 #ifdef cimg_use_board
28045  if (pboard) {
28046  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28047  board.drawLine((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1);
28048  }
28049 #endif
28050  } else {
28051  draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28052  draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac);
28053 #ifdef cimg_use_board
28054  if (pboard) {
28055  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28056  board.drawCircle((float)x0,dimy()-(float)y0,0);
28057  board.drawCircle((float)x1,dimy()-(float)y1,0);
28058  }
28059 #endif
28060  }
28061  } break;
28062  case 3 : { // Colored triangle
28063  const unsigned int
28064  n0 = (unsigned int)primitive[0],
28065  n1 = (unsigned int)primitive[1],
28066  n2 = (unsigned int)primitive[2];
28067  const int
28068  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28069  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28070  x2 = (int)projections(n2,0), y2 = (int)projections(n2,1);
28071  const float
28072  z0 = vertices(n0,2) + Z + focale,
28073  z1 = vertices(n1,2) + Z + focale,
28074  z2 = vertices(n2,2) + Z + focale;
28075  switch (render_type) {
28076  case 0 :
28077  draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac).draw_point(x2,y2,color,opac);
28078 #ifdef cimg_use_board
28079  if (pboard) {
28080  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28081  board.drawCircle((float)x0,dimy()-(float)y0,0);
28082  board.drawCircle((float)x1,dimy()-(float)y1,0);
28083  board.drawCircle((float)x2,dimy()-(float)y2,0);
28084  }
28085 #endif
28086  break;
28087  case 1 :
28088  if (zbuffer)
28089  draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac).draw_line(zbuffer,x0,y0,z0,x2,y2,z2,color,opac).
28090  draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,opac);
28091  else
28092  draw_line(x0,y0,x1,y1,color,opac).draw_line(x0,y0,x2,y2,color,opac).
28093  draw_line(x1,y1,x2,y2,color,opac);
28094 #ifdef cimg_use_board
28095  if (pboard) {
28096  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28097  board.drawLine((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1);
28098  board.drawLine((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2);
28099  board.drawLine((float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28100  }
28101 #endif
28102  break;
28103  case 2 :
28104  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,opac);
28105  else draw_triangle(x0,y0,x1,y1,x2,y2,color,opac);
28106 #ifdef cimg_use_board
28107  if (pboard) {
28108  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28109  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28110  }
28111 #endif
28112  break;
28113  case 3 :
28114  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opac,lightprops(l));
28115  else _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l));
28116 #ifdef cimg_use_board
28117  if (pboard) {
28118  const float lp = cimg::min(lightprops(l),1);
28119  board.setPenColorRGBi((unsigned char)(color[0]*lp),
28120  (unsigned char)(color[1]*lp),
28121  (unsigned char)(color[2]*lp),
28122  (unsigned char)(opac*255));
28123  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28124  }
28125 #endif
28126  break;
28127  case 4 :
28128  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28129  else draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28130 #ifdef cimg_use_board
28131  if (pboard) {
28132  board.setPenColorRGBi((unsigned char)(color[0]),
28133  (unsigned char)(color[1]),
28134  (unsigned char)(color[2]),
28135  (unsigned char)(opac*255));
28136  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprops(n0),
28137  (float)x1,dimy()-(float)y1,lightprops(n1),
28138  (float)x2,dimy()-(float)y2,lightprops(n2));
28139  }
28140 #endif
28141  break;
28142  case 5 : {
28143  const unsigned int
28144  lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1),
28145  lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1),
28146  lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1);
28147  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac);
28148  else draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac);
28149 #ifdef cimg_use_board
28150  if (pboard) {
28151  const float
28152  l0 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n0,0))), (int)(light_texture.dimy()/2*(1+lightprops(n0,1)))),
28153  l1 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n1,0))), (int)(light_texture.dimy()/2*(1+lightprops(n1,1)))),
28154  l2 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n2,0))), (int)(light_texture.dimy()/2*(1+lightprops(n2,1))));
28155  board.setPenColorRGBi((unsigned char)(color[0]),
28156  (unsigned char)(color[1]),
28157  (unsigned char)(color[2]),
28158  (unsigned char)(opac*255));
28159  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,
28160  (float)x1,dimy()-(float)y1,l1,
28161  (float)x2,dimy()-(float)y2,l2);
28162  }
28163 #endif
28164  } break;
28165  }
28166  } break;
28167  case 4 : { // Colored rectangle
28168  const unsigned int
28169  n0 = (unsigned int)primitive[0],
28170  n1 = (unsigned int)primitive[1],
28171  n2 = (unsigned int)primitive[2],
28172  n3 = (unsigned int)primitive[3];
28173  const int
28174  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28175  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28176  x2 = (int)projections(n2,0), y2 = (int)projections(n2,1),
28177  x3 = (int)projections(n3,0), y3 = (int)projections(n3,1);
28178  const float
28179  z0 = vertices(n0,2) + Z + focale,
28180  z1 = vertices(n1,2) + Z + focale,
28181  z2 = vertices(n2,2) + Z + focale,
28182  z3 = vertices(n3,2) + Z + focale;
28183  switch (render_type) {
28184  case 0 :
28185  draw_point(x0,y0,color,opac).draw_point(x1,y1,color,opac).
28186  draw_point(x2,y2,color,opac).draw_point(x3,y3,color,opac);
28187 #ifdef cimg_use_board
28188  if (pboard) {
28189  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28190  board.drawCircle((float)x0,dimy()-(float)y0,0);
28191  board.drawCircle((float)x1,dimy()-(float)y1,0);
28192  board.drawCircle((float)x2,dimy()-(float)y2,0);
28193  board.drawCircle((float)x3,dimy()-(float)y3,0);
28194  }
28195 #endif
28196  break;
28197  case 1 :
28198  if (zbuffer)
28199  draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,opac).draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,opac).
28200  draw_line(zbuffer,x2,y2,z2,x3,y3,z3,color,opac).draw_line(zbuffer,x3,y3,z3,x0,y0,z0,color,opac);
28201  else
28202  draw_line(x0,y0,x1,y1,color,opac).draw_line(x1,y1,x2,y2,color,opac).
28203  draw_line(x2,y2,x3,y3,color,opac).draw_line(x3,y3,x0,y0,color,opac);
28204 #ifdef cimg_use_board
28205  if (pboard) {
28206  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28207  board.drawLine((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1);
28208  board.drawLine((float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28209  board.drawLine((float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28210  board.drawLine((float)x3,dimy()-(float)y3,(float)x0,dimy()-(float)y0);
28211  }
28212 #endif
28213  break;
28214  case 2 :
28215  if (zbuffer)
28216  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,opac).draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,opac);
28217  else
28218  draw_triangle(x0,y0,x1,y1,x2,y2,color,opac).draw_triangle(x0,y0,x2,y2,x3,y3,color,opac);
28219 #ifdef cimg_use_board
28220  if (pboard) {
28221  board.setPenColorRGBi(color[0],color[1],color[2],(unsigned char)(opac*255));
28222  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28223  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28224  }
28225 #endif
28226  break;
28227  case 3 :
28228  if (zbuffer)
28229  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opac,lightprops(l)).
28230  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color.data,opac,lightprops(l));
28231  else
28232  _draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opac,lightprops(l)).
28233  _draw_triangle(x0,y0,x2,y2,x3,y3,color.data,opac,lightprops(l));
28234 #ifdef cimg_use_board
28235  if (pboard) {
28236  const float lp = cimg::min(lightprops(l),1);
28237  board.setPenColorRGBi((unsigned char)(color[0]*lp),
28238  (unsigned char)(color[1]*lp),
28239  (unsigned char)(color[2]*lp),(unsigned char)(opac*255));
28240  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28241  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28242  }
28243 #endif
28244  break;
28245  case 4 : {
28246  const float
28247  lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
28248  lightprop2 = lightprops(n2), lightprop3 = lightprops(n3);
28249  if (zbuffer)
28250  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,lightprop0,lightprop1,lightprop2,opac).
28251  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,lightprop0,lightprop2,lightprop3,opac);
28252  else
28253  draw_triangle(x0,y0,x1,y1,x2,y2,color,lightprop0,lightprop1,lightprop2,opac).
28254  draw_triangle(x0,y0,x2,y2,x3,y3,color,lightprop0,lightprop2,lightprop3,opac);
28255 #ifdef cimg_use_board
28256  if (pboard) {
28257  board.setPenColorRGBi((unsigned char)(color[0]),
28258  (unsigned char)(color[1]),
28259  (unsigned char)(color[2]),
28260  (unsigned char)(opac*255));
28261  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprop0,
28262  (float)x1,dimy()-(float)y1,lightprop1,
28263  (float)x2,dimy()-(float)y2,lightprop2);
28264  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprop0,
28265  (float)x2,dimy()-(float)y2,lightprop2,
28266  (float)x3,dimy()-(float)y3,lightprop3);
28267  }
28268 #endif
28269  } break;
28270  case 5 : {
28271  const unsigned int
28272  lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1),
28273  lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1),
28274  lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1),
28275  lx3 = (unsigned int)lightprops(n3,0), ly3 = (unsigned int)lightprops(n3,1);
28276  if (zbuffer)
28277  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28278  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28279  else
28280  draw_triangle(x0,y0,x1,y1,x2,y2,color,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28281  draw_triangle(x0,y0,x2,y2,x3,y3,color,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28282 #ifdef cimg_use_board
28283  if (pboard) {
28284  const float
28285  l0 = light_texture((int)(light_texture.dimx()/2*(1+lx0)), (int)(light_texture.dimy()/2*(1+ly0))),
28286  l1 = light_texture((int)(light_texture.dimx()/2*(1+lx1)), (int)(light_texture.dimy()/2*(1+ly1))),
28287  l2 = light_texture((int)(light_texture.dimx()/2*(1+lx2)), (int)(light_texture.dimy()/2*(1+ly2))),
28288  l3 = light_texture((int)(light_texture.dimx()/2*(1+lx3)), (int)(light_texture.dimy()/2*(1+ly3)));
28289  board.setPenColorRGBi((unsigned char)(color[0]),
28290  (unsigned char)(color[1]),
28291  (unsigned char)(color[2]),
28292  (unsigned char)(opac*255));
28293  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,
28294  (float)x1,dimy()-(float)y1,l1,
28295  (float)x2,dimy()-(float)y2,l2);
28296  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,
28297  (float)x2,dimy()-(float)y2,l2,
28298  (float)x3,dimy()-(float)y3,l3);
28299  }
28300 #endif
28301  } break;
28302  }
28303  } break;
28304  case 9 : { // Textured triangle
28305  const unsigned int
28306  n0 = (unsigned int)primitive[0],
28307  n1 = (unsigned int)primitive[1],
28308  n2 = (unsigned int)primitive[2],
28309  tx0 = (unsigned int)primitive[3],
28310  ty0 = (unsigned int)primitive[4],
28311  tx1 = (unsigned int)primitive[5],
28312  ty1 = (unsigned int)primitive[6],
28313  tx2 = (unsigned int)primitive[7],
28314  ty2 = (unsigned int)primitive[8];
28315  const int
28316  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28317  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28318  x2 = (int)projections(n2,0), y2 = (int)projections(n2,1);
28319  const float
28320  z0 = vertices(n0,2) + Z + focale,
28321  z1 = vertices(n1,2) + Z + focale,
28322  z2 = vertices(n2,2) + Z + focale;
28323  switch (render_type) {
28324  case 0 :
28325  draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28326  draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac).
28327  draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac);
28328 #ifdef cimg_use_board
28329  if (pboard) {
28330  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28331  board.drawCircle((float)x0,dimy()-(float)y0,0);
28332  board.drawCircle((float)x1,dimy()-(float)y1,0);
28333  board.drawCircle((float)x2,dimy()-(float)y2,0);
28334  }
28335 #endif
28336  break;
28337  case 1 :
28338  if (zbuffer)
28339  draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28340  draw_line(zbuffer,x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opac).
28341  draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac);
28342  else
28343  draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28344  draw_line(x0,y0,z0,x2,y2,z2,color,tx0,ty0,tx2,ty2,opac).
28345  draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac);
28346 #ifdef cimg_use_board
28347  if (pboard) {
28348  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28349  board.drawLine((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1);
28350  board.drawLine((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2);
28351  board.drawLine((float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28352  }
28353 #endif
28354  break;
28355  case 2 :
28356  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac);
28357  else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac);
28358 #ifdef cimg_use_board
28359  if (pboard) {
28360  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28361  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28362  }
28363 #endif
28364  break;
28365  case 3 :
28366  if (zbuffer) draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l));
28367  else draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l));
28368 #ifdef cimg_use_board
28369  if (pboard) {
28370  const float lp = cimg::min(lightprops(l),1);
28371  board.setPenColorRGBi((unsigned char)(128*lp),
28372  (unsigned char)(128*lp),
28373  (unsigned char)(128*lp),
28374  (unsigned char)(opac*255));
28375  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28376  }
28377 #endif
28378  break;
28379  case 4 :
28380  if (zbuffer)
28381  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28382  else
28383  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprops(n0),lightprops(n1),lightprops(n2),opac);
28384 #ifdef cimg_use_board
28385  if (pboard) {
28386  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28387  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprops(n0),
28388  (float)x1,dimy()-(float)y1,lightprops(n1),
28389  (float)x2,dimy()-(float)y2,lightprops(n2));
28390  }
28391 #endif
28392  break;
28393  case 5 :
28394  if (zbuffer)
28395  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
28396  (unsigned int)lightprops(n0,0), (unsigned int)lightprops(n0,1),
28397  (unsigned int)lightprops(n1,0), (unsigned int)lightprops(n1,1),
28398  (unsigned int)lightprops(n2,0), (unsigned int)lightprops(n2,1),
28399  opac);
28400  else
28401  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,
28402  (unsigned int)lightprops(n0,0), (unsigned int)lightprops(n0,1),
28403  (unsigned int)lightprops(n1,0), (unsigned int)lightprops(n1,1),
28404  (unsigned int)lightprops(n2,0), (unsigned int)lightprops(n2,1),
28405  opac);
28406 #ifdef cimg_use_board
28407  if (pboard) {
28408  const float
28409  l0 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n0,0))), (int)(light_texture.dimy()/2*(1+lightprops(n0,1)))),
28410  l1 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n1,0))), (int)(light_texture.dimy()/2*(1+lightprops(n1,1)))),
28411  l2 = light_texture((int)(light_texture.dimx()/2*(1+lightprops(n2,0))), (int)(light_texture.dimy()/2*(1+lightprops(n2,1))));
28412  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28413  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,(float)x1,dimy()-(float)y1,l1,(float)x2,dimy()-(float)y2,l2);
28414  }
28415 #endif
28416  break;
28417  }
28418  } break;
28419  case 12 : { // Textured rectangle
28420  const unsigned int
28421  n0 = (unsigned int)primitive[0],
28422  n1 = (unsigned int)primitive[1],
28423  n2 = (unsigned int)primitive[2],
28424  n3 = (unsigned int)primitive[3],
28425  tx0 = (unsigned int)primitive[4],
28426  ty0 = (unsigned int)primitive[5],
28427  tx1 = (unsigned int)primitive[6],
28428  ty1 = (unsigned int)primitive[7],
28429  tx2 = (unsigned int)primitive[8],
28430  ty2 = (unsigned int)primitive[9],
28431  tx3 = (unsigned int)primitive[10],
28432  ty3 = (unsigned int)primitive[11];
28433  const int
28434  x0 = (int)projections(n0,0), y0 = (int)projections(n0,1),
28435  x1 = (int)projections(n1,0), y1 = (int)projections(n1,1),
28436  x2 = (int)projections(n2,0), y2 = (int)projections(n2,1),
28437  x3 = (int)projections(n3,0), y3 = (int)projections(n3,1);
28438  const float
28439  z0 = vertices(n0,2) + Z + focale,
28440  z1 = vertices(n1,2) + Z + focale,
28441  z2 = vertices(n2,2) + Z + focale,
28442  z3 = vertices(n3,2) + Z + focale;
28443 
28444  switch (render_type) {
28445  case 0 :
28446  draw_point(x0,y0,color.get_vector_at(tx0,ty0),opac).
28447  draw_point(x1,y1,color.get_vector_at(tx1,ty1),opac).
28448  draw_point(x2,y2,color.get_vector_at(tx2,ty2),opac).
28449  draw_point(x3,y3,color.get_vector_at(tx3,ty3),opac);
28450 #ifdef cimg_use_board
28451  if (pboard) {
28452  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28453  board.drawCircle((float)x0,dimy()-(float)y0,0);
28454  board.drawCircle((float)x1,dimy()-(float)y1,0);
28455  board.drawCircle((float)x2,dimy()-(float)y2,0);
28456  board.drawCircle((float)x3,dimy()-(float)y3,0);
28457  }
28458 #endif
28459  break;
28460  case 1 :
28461  if (zbuffer)
28462  draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28463  draw_line(zbuffer,x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac).
28464  draw_line(zbuffer,x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opac).
28465  draw_line(zbuffer,x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opac);
28466  else
28467  draw_line(x0,y0,z0,x1,y1,z1,color,tx0,ty0,tx1,ty1,opac).
28468  draw_line(x1,y1,z1,x2,y2,z2,color,tx1,ty1,tx2,ty2,opac).
28469  draw_line(x2,y2,z2,x3,y3,z3,color,tx2,ty2,tx3,ty3,opac).
28470  draw_line(x3,y3,z3,x0,y0,z0,color,tx3,ty3,tx0,ty0,opac);
28471 #ifdef cimg_use_board
28472  if (pboard) {
28473  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28474  board.drawLine((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1);
28475  board.drawLine((float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28476  board.drawLine((float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28477  board.drawLine((float)x3,dimy()-(float)y3,(float)x0,dimy()-(float)y0);
28478  }
28479 #endif
28480  break;
28481  case 2 :
28482  if (zbuffer)
28483  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac).
28484  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac);
28485  else
28486  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac).
28487  draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac);
28488 #ifdef cimg_use_board
28489  if (pboard) {
28490  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28491  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28492  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28493  }
28494 #endif
28495  break;
28496  case 3 :
28497  if (zbuffer)
28498  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)).
28499  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac,lightprops(l));
28500  else
28501  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,opac,lightprops(l)).
28502  draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,opac,lightprops(l));
28503 #ifdef cimg_use_board
28504  if (pboard) {
28505  const float lp = cimg::min(lightprops(l),1);
28506  board.setPenColorRGBi((unsigned char)(128*lp),
28507  (unsigned char)(128*lp),
28508  (unsigned char)(128*lp),
28509  (unsigned char)(opac*255));
28510  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x1,dimy()-(float)y1,(float)x2,dimy()-(float)y2);
28511  board.fillTriangle((float)x0,dimy()-(float)y0,(float)x2,dimy()-(float)y2,(float)x3,dimy()-(float)y3);
28512  }
28513 #endif
28514  break;
28515  case 4 : {
28516  const float
28517  lightprop0 = lightprops(n0), lightprop1 = lightprops(n1),
28518  lightprop2 = lightprops(n2), lightprop3 = lightprops(n3);
28519  if (zbuffer)
28520  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprop0,lightprop1,lightprop2,opac).
28521  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,lightprop0,lightprop2,lightprop3,opac);
28522  else
28523  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,lightprop0,lightprop1,lightprop2,opac).
28524  draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,lightprop0,lightprop2,lightprop3,opac);
28525 #ifdef cimg_use_board
28526  if (pboard) {
28527  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28528  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprop0,
28529  (float)x1,dimy()-(float)y1,lightprop1,
28530  (float)x2,dimy()-(float)y2,lightprop2);
28531  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,lightprop0,
28532  (float)x2,dimy()-(float)y2,lightprop2,
28533  (float)x3,dimy()-(float)y3,lightprop3);
28534  }
28535 #endif
28536  } break;
28537  case 5 : {
28538  const unsigned int
28539  lx0 = (unsigned int)lightprops(n0,0), ly0 = (unsigned int)lightprops(n0,1),
28540  lx1 = (unsigned int)lightprops(n1,0), ly1 = (unsigned int)lightprops(n1,1),
28541  lx2 = (unsigned int)lightprops(n2,0), ly2 = (unsigned int)lightprops(n2,1),
28542  lx3 = (unsigned int)lightprops(n3,0), ly3 = (unsigned int)lightprops(n3,1);
28543  if (zbuffer)
28544  draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28545  draw_triangle(zbuffer,x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28546  else
28547  draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,color,tx0,ty0,tx1,ty1,tx2,ty2,light_texture,lx0,ly0,lx1,ly1,lx2,ly2,opac).
28548  draw_triangle(x0,y0,z0,x2,y2,z2,x3,y3,z3,color,tx0,ty0,tx2,ty2,tx3,ty3,light_texture,lx0,ly0,lx2,ly2,lx3,ly3,opac);
28549 #ifdef cimg_use_board
28550  if (pboard) {
28551  const float
28552  l0 = light_texture((int)(light_texture.dimx()/2*(1+lx0)), (int)(light_texture.dimy()/2*(1+ly0))),
28553  l1 = light_texture((int)(light_texture.dimx()/2*(1+lx1)), (int)(light_texture.dimy()/2*(1+ly1))),
28554  l2 = light_texture((int)(light_texture.dimx()/2*(1+lx2)), (int)(light_texture.dimy()/2*(1+ly2))),
28555  l3 = light_texture((int)(light_texture.dimx()/2*(1+lx3)), (int)(light_texture.dimy()/2*(1+ly3)));
28556  board.setPenColorRGBi(128,128,128,(unsigned char)(opac*255));
28557  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,
28558  (float)x1,dimy()-(float)y1,l1,
28559  (float)x2,dimy()-(float)y2,l2);
28560  board.fillGouraudTriangle((float)x0,dimy()-(float)y0,l0,
28561  (float)x2,dimy()-(float)y2,l2,
28562  (float)x3,dimy()-(float)y3,l3);
28563  }
28564 #endif
28565  } break;
28566  }
28567  } break;
28568  }
28569  }
28570  return *this;
28571  }
if(dy > dx)
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_forX(img, x)
Definition: CImg.h:593
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
const NT & d
void int int REAL REAL * y
Definition: read.cpp:74
double sqrt(double d)
Definition: double.h:73
CImg< T > & norm(const int norm_type=2)
Compute L2-norm of each multi-valued pixel of the instance image.
Definition: CImg.h:15127
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
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.
Definition: CImg.h:23796
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
Draw a filled circle.
Definition: CImg.h:25869
CImg< T > & sort(CImg< t > &permutations, const bool increasing=true)
Sort values of a vector and get permutations.
Definition: CImg.h:13768
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 float brightness)
Definition: CImg.h:23774
T sqr(const T val)
Return the square of a number.
Definition: CImg.h:4717
void __draw_object3d(const unsigned int n_primitive, const unsigned int nb_opacities, const CImgList< to > &opacities, const CImg< tc > &color, const int nx0, const int ny0, const CImg< T > &sprite, const float opac)
Definition: CImg.h:27611
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& _draw_point ( const t &  points,
const unsigned int  W,
const unsigned int  H,
const tc *const  color,
const float  opacity 
)
inline

Definition at line 22232 of file CImg.h.

Referenced by CImg< uintT >::draw_point().

22233  {
22234  if (is_empty() || !points || !W) return *this;
22235  switch (H) {
22236  case 0 : case 1 :
22237  throw CImgArgumentException("CImg<%s>::draw_point() : Given list of points is not valid.",
22238  pixel_type());
22239  case 2 : {
22240  for (unsigned int i = 0; i<W; ++i) {
22241  const int x = (int)points(i,0), y = (int)points(i,1);
22242  draw_point(x,y,color,opacity);
22243  }
22244  } break;
22245  default : {
22246  for (unsigned int i = 0; i<W; ++i) {
22247  const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2);
22248  draw_point(x,y,z,color,opacity);
22249  }
22250  }
22251  }
22252  return *this;
22253  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
void int int REAL REAL * y
Definition: read.cpp:74
Definition: points.h:30
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

CImg<T>& _draw_polygon ( const t &  points,
const unsigned int  N,
const tc *const  color,
const float  opacity 
)
inline

Definition at line 25699 of file CImg.h.

Referenced by CImg< uintT >::draw_polygon().

25700  {
25701  if (is_empty() || !points || N<3) return *this;
25702  if (!color)
25703  throw CImgArgumentException("CImg<%s>::draw_polygon() : Specified color is (null).",
25704  pixel_type());
25705  _draw_scanline(color,opacity);
25706  int xmin = (int)(~0U>>1), xmax = 0, ymin = (int)(~0U>>1), ymax = 0;
25707  for (unsigned int p = 0; p<N; ++p) {
25708  const int x = (int)points(p,0), y = (int)points(p,1);
25709  if (x<xmin) xmin = x;
25710  if (x>xmax) xmax = x;
25711  if (y<ymin) ymin = y;
25712  if (y>ymax) ymax = y;
25713  }
25714  if (xmax<0 || xmin>=dimx() || ymax<0 || ymin>=dimy()) return *this;
25715  const unsigned int
25716  nymin = ymin<0?0:(unsigned int)ymin,
25717  nymax = ymax>=dimy()?height-1:(unsigned int)ymax,
25718  dy = 1 + nymax - nymin;
25719  CImg<intT> X(1+2*N,dy,1,1,0), tmp;
25720  int cx = (int)points(0,0), cy = (int)points(0,1);
25721  for (unsigned int cp = 0, p = 0; p<N; ++p) {
25722  const unsigned int np = (p!=N-1)?p+1:0, ap = (np!=N-1)?np+1:0;
25723  const int
25724  nx = (int)points(np,0), ny = (int)points(np,1), ay = (int)points(ap,1),
25725  y0 = cy - nymin, y1 = ny - nymin;
25726  if (y0!=y1) {
25727  const int countermin = ((ny<ay && cy<ny) || (ny>ay && cy>ny))?1:0;
25728  for (int x = cx, y = y0, _sx = 1, _sy = 1,
25729  _dx = nx>cx?nx-cx:((_sx=-1),cx-nx),
25730  _dy = y1>y0?y1-y0:((_sy=-1),y0-y1),
25731  _counter = ((_dx-=_dy?_dy*(_dx/_dy):0),_dy),
25732  _err = _dx>>1,
25733  _rx = _dy?(nx-cx)/_dy:0;
25734  _counter>=countermin;
25735  --_counter, y+=_sy, x+=_rx + ((_err-=_dx)<0?_err+=_dy,_sx:0))
25736  if (y>=0 && y<(int)dy) X(++X(0,y),y) = x;
25737  cp = np; cx = nx; cy = ny;
25738  } else {
25739  const int pp = (cp?cp-1:N-1), py = (int)points(pp,1);
25740  if ((cy>py && ay>cy) || (cy<py && ay<cy)) X(++X(0,y0),y0) = nx;
25741  if (cy!=ay) { cp = np; cx = nx; cy = ny; }
25742  }
25743  }
25744  for (int y = 0; y<(int)dy; ++y) {
25745  tmp.assign(X.ptr(1,y),X(0,y),1,1,1,true).sort();
25746  for (int i = 1; i<=X(0,y); ) {
25747  const int xb = X(i++,y), xe = X(i++,y);
25748  _draw_scanline(xb,xe,nymin+y,color,opacity);
25749  }
25750  }
25751  return *this;
25752  }
void int int REAL REAL * y
Definition: read.cpp:74
Definition: points.h:30
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
Definition: CImg.h:22095
CImg< T > & sort(CImg< t > &permutations, const bool increasing=true)
Sort values of a vector and get permutations.
Definition: CImg.h:13768
NT dy

Here is the caller graph for this function:

CImg<T>& _draw_polygon ( const t &  points,
const unsigned int  W,
const unsigned int  H,
const tc *const  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Definition at line 25790 of file CImg.h.

25792  {
25793  if (is_empty() || !points || W<3) return *this;
25794  bool ninit_hatch = true;
25795  switch (H) {
25796  case 0 : case 1 :
25797  throw CImgArgumentException("CImg<%s>::draw_polygon() : Given list of points is not valid.",
25798  pixel_type());
25799  case 2 : {
25800  const int x0 = (int)points(0,0), y0 = (int)points(0,1);
25801  int ox = x0, oy = y0;
25802  for (unsigned int i = 1; i<W; ++i) {
25803  const int x = (int)points(i,0), y = (int)points(i,1);
25804  draw_line(ox,oy,x,y,color,opacity,pattern,ninit_hatch);
25805  ninit_hatch = false;
25806  ox = x; oy = y;
25807  }
25808  draw_line(ox,oy,x0,y0,color,opacity,pattern,false);
25809  } break;
25810  default : {
25811  const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
25812  int ox = x0, oy = y0, oz = z0;
25813  for (unsigned int i = 1; i<W; ++i) {
25814  const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2);
25815  draw_line(ox,oy,oz,x,y,z,color,opacity,pattern,ninit_hatch);
25816  ninit_hatch = false;
25817  ox = x; oy = y; oz = z;
25818  }
25819  draw_line(ox,oy,oz,x0,y0,z0,color,opacity,pattern,false);
25820  }
25821  }
25822  return *this;
25823  }
void int int REAL REAL * y
Definition: read.cpp:74
Definition: points.h:30
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:22330
CImg<T>& _draw_scanline ( const int  x0,
const int  x1,
const int  y,
const tc *const  color,
const float  opacity = 1,
const float  brightness = 1,
const bool  init = false 
)
inline

Definition at line 22095 of file CImg.h.

Referenced by CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_scanline(), CImg< uintT >::_draw_triangle(), and CImg< uintT >::draw_circle().

22097  {
22098  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
22099  static float nopacity = 0, copacity = 0;
22100  static unsigned int whz = 0;
22101  static const tc *col = 0;
22102  if (init) {
22103  nopacity = cimg::abs(opacity);
22104  copacity = 1 - cimg::max(opacity,0);
22105  whz = width*height*depth;
22106  } else {
22107  const int nx0 = x0>0?x0:0, nx1 = x1<dimx()?x1:dimx()-1, dx = nx1 - nx0;
22108  if (dx>=0) {
22109  col = color;
22110  const unsigned int off = whz-dx-1;
22111  T *ptrd = ptr(nx0,y);
22112  if (opacity>=1) { // ** Opaque drawing **
22113  if (brightness==1) { // Brightness==1
22114  if (sizeof(T)!=1) cimg_forV(*this,k) {
22115  const T val = (T)*(col++);
22116  for (int x = dx; x>=0; --x) *(ptrd++) = val;
22117  ptrd+=off;
22118  } else cimg_forV(*this,k) {
22119  const T val = (T)*(col++);
22120  std::memset(ptrd,(int)val,dx+1);
22121  ptrd+=whz;
22122  }
22123  } else if (brightness<1) { // Brightness<1
22124  if (sizeof(T)!=1) cimg_forV(*this,k) {
22125  const T val = (T)(*(col++)*brightness);
22126  for (int x = dx; x>=0; --x) *(ptrd++) = val;
22127  ptrd+=off;
22128  } else cimg_forV(*this,k) {
22129  const T val = (T)(*(col++)*brightness);
22130  std::memset(ptrd,(int)val,dx+1);
22131  ptrd+=whz;
22132  }
22133  } else { // Brightness>1
22134  if (sizeof(T)!=1) cimg_forV(*this,k) {
22135  const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22136  for (int x = dx; x>=0; --x) *(ptrd++) = val;
22137  ptrd+=off;
22138  } else cimg_forV(*this,k) {
22139  const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22140  std::memset(ptrd,(int)val,dx+1);
22141  ptrd+=whz;
22142  }
22143  }
22144  } else { // ** Transparent drawing **
22145  if (brightness==1) { // Brightness==1
22146  cimg_forV(*this,k) {
22147  const T val = (T)*(col++);
22148  for (int x = dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22149  ptrd+=off;
22150  }
22151  } else if (brightness<=1) { // Brightness<1
22152  cimg_forV(*this,k) {
22153  const T val = (T)(*(col++)*brightness);
22154  for (int x = dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22155  ptrd+=off;
22156  }
22157  } else { // Brightness>1
22158  cimg_forV(*this,k) {
22159  const T val = (T)((2-brightness)**(col++) + (brightness-1)*maxval);
22160  for (int x = dx; x>=0; --x) { *ptrd = (T)(val*nopacity + *ptrd*copacity); ++ptrd; }
22161  ptrd+=off;
22162  }
22163  }
22164  }
22165  }
22166  }
22167  return *this;
22168  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

CImg<T>& _draw_scanline ( const tc *const  color,
const float  opacity = 1 
)
inline

Definition at line 22171 of file CImg.h.

22171  {
22172  return _draw_scanline(0,0,0,color,opacity,0,true);
22173  }
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
Definition: CImg.h:22095
CImg<T>& _draw_spline ( const tp &  points,
const tt &  tangents,
const unsigned int  W,
const unsigned int  H,
const tc *const  color,
const float  opacity,
const bool  close_set,
const float  precision,
const unsigned int  pattern,
const bool  init_hatch 
)
inline

Definition at line 23285 of file CImg.h.

Referenced by CImg< uintT >::_draw_spline(), and CImg< uintT >::draw_spline().

23288  {
23289  if (is_empty() || !points || !tangents || W<2) return *this;
23290  bool ninit_hatch = init_hatch;
23291  switch (H) {
23292  case 0 : case 1 :
23293  throw CImgArgumentException("CImg<%s>::draw_spline() : Given list of points or tangents is not valid.",
23294  pixel_type());
23295  case 2 : {
23296  const int x0 = (int)points(0,0), y0 = (int)points(0,1);
23297  const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1);
23298  int ox = x0, oy = y0;
23299  float ou = u0, ov = v0;
23300  for (unsigned int i = 1; i<W; ++i) {
23301  const int x = (int)points(i,0), y = (int)points(i,1);
23302  const float u = (float)tangents(i,0), v = (float)tangents(i,1);
23303  draw_spline(ox,oy,ou,ov,x,y,u,v,color,precision,opacity,pattern,ninit_hatch);
23304  ninit_hatch = false;
23305  ox = x; oy = y; ou = u; ov = v;
23306  }
23307  if (close_set) draw_spline(ox,oy,ou,ov,x0,y0,u0,v0,color,precision,opacity,pattern,false);
23308  } break;
23309  default : {
23310  const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2);
23311  const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1), w0 = (float)tangents(0,2);
23312  int ox = x0, oy = y0, oz = z0;
23313  float ou = u0, ov = v0, ow = w0;
23314  for (unsigned int i = 1; i<W; ++i) {
23315  const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2);
23316  const float u = (float)tangents(i,0), v = (float)tangents(i,1), w = (float)tangents(i,2);
23317  draw_spline(ox,oy,oz,ou,ov,ow,x,y,z,u,v,w,color,opacity,pattern,ninit_hatch);
23318  ninit_hatch = false;
23319  ox = x; oy = y; oz = z; ou = u; ov = v; ow = w;
23320  }
23321  if (close_set) draw_spline(ox,oy,oz,ou,ov,ow,x0,y0,z0,u0,v0,w0,color,precision,opacity,pattern,false);
23322  }
23323  }
23324  return *this;
23325  }
void int int REAL REAL * y
Definition: read.cpp:74
Definition: points.h:30
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

CImg<T>& _draw_spline ( const tp &  points,
const unsigned int  W,
const unsigned int  H,
const tc *const  color,
const float  opacity,
const bool  close_set,
const float  precision,
const unsigned int  pattern,
const bool  init_hatch 
)
inline

Definition at line 23329 of file CImg.h.

23332  {
23333  if (is_empty() || !points || W<2) return *this;
23334  CImg<Tfloat> tangents;
23335  switch (H) {
23336  case 0 : case 1 :
23337  throw CImgArgumentException("CImg<%s>::draw_spline() : Given list of points or tangents is not valid.",
23338  pixel_type());
23339  case 2 : {
23340  tangents.assign(W,H);
23341  for (unsigned int p = 0; p<W; ++p) {
23342  const unsigned int
23343  p0 = close_set?(p+W-1)%W:(p?p-1:0),
23344  p1 = close_set?(p+1)%W:(p+1<W?p+1:p);
23345  const float
23346  x = (float)points(p,0),
23347  y = (float)points(p,1),
23348  x0 = (float)points(p0,0),
23349  y0 = (float)points(p0,1),
23350  x1 = (float)points(p1,0),
23351  y1 = (float)points(p1,1),
23352  u0 = x - x0,
23353  v0 = y - y0,
23354  n0 = 1e-8f + (float)std::sqrt(u0*u0 + v0*v0),
23355  u1 = x1 - x,
23356  v1 = y1 - y,
23357  n1 = 1e-8f + (float)std::sqrt(u1*u1 + v1*v1),
23358  u = u0/n0 + u1/n1,
23359  v = v0/n0 + v1/n1,
23360  n = 1e-8f + (float)std::sqrt(u*u + v*v),
23361  fact = 0.5f*(n0 + n1);
23362  tangents(p,0) = (Tfloat)(fact*u/n);
23363  tangents(p,1) = (Tfloat)(fact*v/n);
23364  }
23365  } break;
23366  default : {
23367  tangents.assign(W,H);
23368  for (unsigned int p = 0; p<W; ++p) {
23369  const unsigned int
23370  p0 = close_set?(p+W-1)%W:(p?p-1:0),
23371  p1 = close_set?(p+1)%W:(p+1<W?p+1:p);
23372  const float
23373  x = (float)points(p,0),
23374  y = (float)points(p,1),
23375  z = (float)points(p,2),
23376  x0 = (float)points(p0,0),
23377  y0 = (float)points(p0,1),
23378  z0 = (float)points(p0,2),
23379  x1 = (float)points(p1,0),
23380  y1 = (float)points(p1,1),
23381  z1 = (float)points(p1,2),
23382  u0 = x - x0,
23383  v0 = y - y0,
23384  w0 = z - z0,
23385  n0 = 1e-8f + (float)std::sqrt(u0*u0 + v0*v0 + w0*w0),
23386  u1 = x1 - x,
23387  v1 = y1 - y,
23388  w1 = z1 - z,
23389  n1 = 1e-8f + (float)std::sqrt(u1*u1 + v1*v1 + w1*w1),
23390  u = u0/n0 + u1/n1,
23391  v = v0/n0 + v1/n1,
23392  w = w0/n0 + w1/n1,
23393  n = 1e-8f + (float)std::sqrt(u*u + v*v + w*w),
23394  fact = 0.5f*(n0 + n1);
23395  tangents(p,0) = (Tfloat)(fact*u/n);
23396  tangents(p,1) = (Tfloat)(fact*v/n);
23397  tangents(p,2) = (Tfloat)(fact*w/n);
23398  }
23399  }
23400  }
23401  return _draw_spline(points,tangents,W,H,color,opacity,close_set,precision,pattern,init_hatch);
23402  }
void int int REAL REAL * y
Definition: read.cpp:74
NT p1
Definition: points.h:30
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
NT p0
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
const NT & n
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:23285
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 
)
inline

Definition at line 26435 of file CImg.h.

Referenced by CImg< uintT >::draw_text().

26437  {
26438  if (!text) return *this;
26439  if (!font)
26440  throw CImgArgumentException("CImg<%s>::draw_text() : Specified font (%u,%p) is empty.",
26441  pixel_type(),font.width,font.data);
26442  const unsigned int text_length = std::strlen(text);
26443 
26444  if (is_empty()) {
26445  // If needed, pre-compute necessary size of the image
26446  int x = 0, y = 0, w = 0;
26447  unsigned char c = 0;
26448  for (unsigned int i = 0; i<text_length; ++i) {
26449  c = text[i];
26450  switch (c) {
26451  case '\n' : y+=font[' '].height; if (x>w) w = x; x = 0; break;
26452  case '\t' : x+=4*font[' '].width; break;
26453  default : if (c<font.width) x+=font[c].width;
26454  }
26455  }
26456  if (x!=0 || c=='\n') {
26457  if (x>w) w=x;
26458  y+=font[' '].height;
26459  }
26460  assign(x0+w,y0+y,1,font[' '].dim,0);
26461  if (background_color) cimg_forV(*this,k) get_shared_channel(k).fill((T)background_color[k]);
26462  }
26463 
26464  int x = x0, y = y0;
26465  CImg<T> letter;
26466  for (unsigned int i = 0; i<text_length; ++i) {
26467  const unsigned char c = text[i];
26468  switch (c) {
26469  case '\n' : y+=font[' '].height; x = x0; break;
26470  case '\t' : x+=4*font[' '].width; break;
26471  default : if (c<font.width) {
26472  letter = font[c];
26473  const CImg<T>& mask = (c+256)<(int)font.width?font[c+256]:font[c];
26474  if (foreground_color) for (unsigned int p = 0; p<letter.width*letter.height; ++p)
26475  if (mask(p)) cimg_forV(*this,k) letter(p,0,0,k) = (T)(letter(p,0,0,k)*foreground_color[k]);
26476  if (background_color) for (unsigned int p = 0; p<letter.width*letter.height; ++p)
26477  if (!mask(p)) cimg_forV(*this,k) letter(p,0,0,k) = (T)background_color[k];
26478  if (!background_color && font.width>=512) draw_image(x,y,letter,mask,opacity,(T)1);
26479  else draw_image(x,y,letter,opacity);
26480  x+=letter.width;
26481  }
26482  }
26483  }
26484  return *this;
26485  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
CImg()
Default constructor.
Definition: CImg.h:9857
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
for(;;)
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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 float  brightness 
)
inline

Definition at line 23774 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), and CImg< uintT >::draw_triangle().

23778  {
23779  _draw_scanline(color,opacity);
23780  const float nbrightness = brightness<0?0:(brightness>2?2:brightness);
23781  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
23782  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1);
23783  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2);
23784  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2);
23785  if (ny0<dimy() && ny2>=0) {
23786  if ((nx1 - nx0)*(ny2 - ny0) - (nx2 - nx0)*(ny1 - ny0)<0)
23787  _cimg_for_triangle1(*this,xl,xr,y,nx0,ny0,nx1,ny1,nx2,ny2) _draw_scanline(xl,xr,y,color,opacity,nbrightness);
23788  else
23789  _cimg_for_triangle1(*this,xl,xr,y,nx0,ny0,nx1,ny1,nx2,ny2) _draw_scanline(xr,xl,y,color,opacity,nbrightness);
23790  }
23791  return *this;
23792  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
Definition: CImg.h:22095
#define _cimg_for_triangle1(img, xl, xr, y, x0, y0, x1, y1, x2, y2)
Definition: CImg.h:23480

Here is the caller graph for this function:

CImg<t> _get_permute_axes ( const char *  permut,
const t &   
) const
inline

Definition at line 17431 of file CImg.h.

Referenced by CImg< uintT >::get_permute_axes().

17431  {
17432  if (is_empty() || !permut) return CImg<t>(*this,false);
17433  CImg<t> res;
17434  const T* ptrs = data;
17435  if (!cimg::strncasecmp(permut,"xyzv",4)) return (+*this);
17436  if (!cimg::strncasecmp(permut,"xyvz",4)) {
17437  res.assign(width,height,dim,depth);
17438  cimg_forXYZV(*this,x,y,z,v) res(x,y,v,z) = (t)*(ptrs++);
17439  }
17440  if (!cimg::strncasecmp(permut,"xzyv",4)) {
17441  res.assign(width,depth,height,dim);
17442  cimg_forXYZV(*this,x,y,z,v) res(x,z,y,v) = (t)*(ptrs++);
17443  }
17444  if (!cimg::strncasecmp(permut,"xzvy",4)) {
17445  res.assign(width,depth,dim,height);
17446  cimg_forXYZV(*this,x,y,z,v) res(x,z,v,y) = (t)*(ptrs++);
17447  }
17448  if (!cimg::strncasecmp(permut,"xvyz",4)) {
17449  res.assign(width,dim,height,depth);
17450  cimg_forXYZV(*this,x,y,z,v) res(x,v,y,z) = (t)*(ptrs++);
17451  }
17452  if (!cimg::strncasecmp(permut,"xvzy",4)) {
17453  res.assign(width,dim,depth,height);
17454  cimg_forXYZV(*this,x,y,z,v) res(x,v,z,y) = (t)*(ptrs++);
17455  }
17456  if (!cimg::strncasecmp(permut,"yxzv",4)) {
17457  res.assign(height,width,depth,dim);
17458  cimg_forXYZV(*this,x,y,z,v) res(y,x,z,v) = (t)*(ptrs++);
17459  }
17460  if (!cimg::strncasecmp(permut,"yxvz",4)) {
17461  res.assign(height,width,dim,depth);
17462  cimg_forXYZV(*this,x,y,z,v) res(y,x,v,z) = (t)*(ptrs++);
17463  }
17464  if (!cimg::strncasecmp(permut,"yzxv",4)) {
17465  res.assign(height,depth,width,dim);
17466  cimg_forXYZV(*this,x,y,z,v) res(y,z,x,v) = (t)*(ptrs++);
17467  }
17468  if (!cimg::strncasecmp(permut,"yzvx",4)) {
17469  res.assign(height,depth,dim,width);
17470  switch (width) {
17471  case 1 : {
17472  t *ptrR = res.ptr(0,0,0,0);
17473  for (unsigned int siz = height*depth*dim; siz; --siz) {
17474  *(ptrR++) = (t)*(ptrs++);
17475  }
17476  } break;
17477  case 2 : {
17478  t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1);
17479  for (unsigned int siz = height*depth*dim; siz; --siz) {
17480  *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++);
17481  }
17482  } break;
17483  case 3 : { // Optimization for the classical conversion from interleaved RGB to planar RGB
17484  t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1), *ptrB = res.ptr(0,0,0,2);
17485  for (unsigned int siz = height*depth*dim; siz; --siz) {
17486  *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++); *(ptrB++) = (t)*(ptrs++);
17487  }
17488  } break;
17489  case 4 : { // Optimization for the classical conversion from interleaved RGBA to planar RGBA
17490  t *ptrR = res.ptr(0,0,0,0), *ptrG = res.ptr(0,0,0,1), *ptrB = res.ptr(0,0,0,2), *ptrA = res.ptr(0,0,0,3);
17491  for (unsigned int siz = height*depth*dim; siz; --siz) {
17492  *(ptrR++) = (t)*(ptrs++); *(ptrG++) = (t)*(ptrs++); *(ptrB++) = (t)*(ptrs++); *(ptrA++) = (t)*(ptrs++);
17493  }
17494  } break;
17495  default : {
17496  cimg_forXYZV(*this,x,y,z,v) res(y,z,v,x) = *(ptrs++);
17497  return res;
17498  }
17499  }
17500  }
17501  if (!cimg::strncasecmp(permut,"yvxz",4)) {
17502  res.assign(height,dim,width,depth);
17503  cimg_forXYZV(*this,x,y,z,v) res(y,v,x,z) = (t)*(ptrs++);
17504  }
17505  if (!cimg::strncasecmp(permut,"yvzx",4)) {
17506  res.assign(height,dim,depth,width);
17507  cimg_forXYZV(*this,x,y,z,v) res(y,v,z,x) = (t)*(ptrs++);
17508  }
17509  if (!cimg::strncasecmp(permut,"zxyv",4)) {
17510  res.assign(depth,width,height,dim);
17511  cimg_forXYZV(*this,x,y,z,v) res(z,x,y,v) = (t)*(ptrs++);
17512  }
17513  if (!cimg::strncasecmp(permut,"zxvy",4)) {
17514  res.assign(depth,width,dim,height);
17515  cimg_forXYZV(*this,x,y,z,v) res(z,x,v,y) = (t)*(ptrs++);
17516  }
17517  if (!cimg::strncasecmp(permut,"zyxv",4)) {
17518  res.assign(depth,height,width,dim);
17519  cimg_forXYZV(*this,x,y,z,v) res(z,y,x,v) = (t)*(ptrs++);
17520  }
17521  if (!cimg::strncasecmp(permut,"zyvx",4)) {
17522  res.assign(depth,height,dim,width);
17523  cimg_forXYZV(*this,x,y,z,v) res(z,y,v,x) = (t)*(ptrs++);
17524  }
17525  if (!cimg::strncasecmp(permut,"zvxy",4)) {
17526  res.assign(depth,dim,width,height);
17527  cimg_forXYZV(*this,x,y,z,v) res(z,v,x,y) = (t)*(ptrs++);
17528  }
17529  if (!cimg::strncasecmp(permut,"zvyx",4)) {
17530  res.assign(depth,dim,height,width);
17531  cimg_forXYZV(*this,x,y,z,v) res(z,v,y,x) = (t)*(ptrs++);
17532  }
17533  if (!cimg::strncasecmp(permut,"vxyz",4)) {
17534  res.assign(dim,width,height,depth);
17535  switch (dim) {
17536  case 1 : {
17537  const T *ptrR = ptr(0,0,0,0);
17538  t *ptrd = res.ptr();
17539  for (unsigned int siz = width*height*depth; siz; --siz) {
17540  *(ptrd++) = (t)*(ptrR++);
17541  }
17542  } break;
17543  case 2 : {
17544  const T *ptrR = ptr(0,0,0,0), *ptrG = ptr(0,0,0,1);
17545  t *ptrd = res.ptr();
17546  for (unsigned int siz = width*height*depth; siz; --siz) {
17547  *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++);
17548  }
17549  } break;
17550  case 3 : { // Optimization for the classical conversion from planar RGB to interleaved RGB
17551  const T *ptrR = ptr(0,0,0,0), *ptrG = ptr(0,0,0,1), *ptrB = ptr(0,0,0,2);
17552  t *ptrd = res.ptr();
17553  for (unsigned int siz = width*height*depth; siz; --siz) {
17554  *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++); *(ptrd++) = (t)*(ptrB++);
17555  }
17556  } break;
17557  case 4 : { // Optimization for the classical conversion from planar RGBA to interleaved RGBA
17558  const T *ptrR = ptr(0,0,0,0), *ptrG = ptr(0,0,0,1), *ptrB = ptr(0,0,0,2), *ptrA = ptr(0,0,0,3);
17559  t *ptrd = res.ptr();
17560  for (unsigned int siz = width*height*depth; siz; --siz) {
17561  *(ptrd++) = (t)*(ptrR++); *(ptrd++) = (t)*(ptrG++); *(ptrd++) = (t)*(ptrB++); *(ptrd++) = (t)*(ptrA++);
17562  }
17563  } break;
17564  default : {
17565  cimg_forXYZV(*this,x,y,z,v) res(v,x,y,z) = (t)*(ptrs++);
17566  }
17567  }
17568  }
17569  if (!cimg::strncasecmp(permut,"vxzy",4)) {
17570  res.assign(dim,width,depth,height);
17571  cimg_forXYZV(*this,x,y,z,v) res(v,x,z,y) = (t)*(ptrs++);
17572  }
17573  if (!cimg::strncasecmp(permut,"vyxz",4)) {
17574  res.assign(dim,height,width,depth);
17575  cimg_forXYZV(*this,x,y,z,v) res(v,y,x,z) = (t)*(ptrs++);
17576  }
17577  if (!cimg::strncasecmp(permut,"vyzx",4)) {
17578  res.assign(dim,height,depth,width);
17579  cimg_forXYZV(*this,x,y,z,v) res(v,y,z,x) = (t)*(ptrs++);
17580  }
17581  if (!cimg::strncasecmp(permut,"vzxy",4)) {
17582  res.assign(dim,depth,width,height);
17583  cimg_forXYZV(*this,x,y,z,v) res(v,z,x,y) = (t)*(ptrs++);
17584  }
17585  if (!cimg::strncasecmp(permut,"vzyx",4)) {
17586  res.assign(dim,depth,height,width);
17587  cimg_forXYZV(*this,x,y,z,v) res(v,z,y,x) = (t)*(ptrs++);
17588  }
17589  if (!res)
17590  throw CImgArgumentException("CImg<%s>::permute_axes() : Invalid permutation '%s'.",
17591  pixel_type(),permut);
17592  return res;
17593  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & permute_axes(const char *order)
Permute axes order.
Definition: CImg.h:17600
void int int REAL * x
Definition: read.cpp:74
CImg()
Default constructor.
Definition: CImg.h:9857
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<intT> _get_select ( CImgDisplay disp,
const char *const  title,
const int  coords_type,
unsigned int *const  XYZ,
const unsigned char *const  color,
const int  origX,
const int  origY,
const int  origZ 
) const
inline

Definition at line 28616 of file CImg.h.

Referenced by CImg< uintT >::get_select().

28619  {
28620  if (is_empty())
28621  throw CImgInstanceException("CImg<%s>::select() : Instance image (%u,%u,%u,%u,%p) is empty.",
28623  if (!disp) {
28624  char ntitle[64] = { 0 }; if (!title) { std::sprintf(ntitle,"CImg<%s>",pixel_type()); }
28625  disp.assign(cimg_fitscreen(width,height,depth),title?title:ntitle,1);
28626  }
28627 
28628  const unsigned int
28629  old_normalization = disp.normalization,
28630  hatch = 0x55555555;
28631 
28632  bool old_is_resized = disp.is_resized;
28633  disp.normalization = 0;
28634  disp.show().key = 0;
28635 
28636  unsigned char foreground_color[] = { 255,255,105 }, background_color[] = { 0,0,0 };
28637  if (color) std::memcpy(foreground_color,color,sizeof(unsigned char)*cimg::min(3,dimv()));
28638 
28639  int area = 0, clicked_area = 0, phase = 0,
28640  X0 = (int)((XYZ?XYZ[0]:width/2)%width), Y0 = (int)((XYZ?XYZ[1]:height/2)%height), Z0 = (int)((XYZ?XYZ[2]:depth/2)%depth),
28641  X1 =-1, Y1 = -1, Z1 = -1,
28642  X = -1, Y = -1, Z = -1,
28643  oX = X, oY = Y, oZ = Z;
28644  unsigned int old_button = 0, key = 0;
28645 
28646  bool shape_selected = false, text_down = false;
28647  CImg<ucharT> visu, visu0;
28648  char text[1024] = { 0 };
28649 
28650  while (!key && !disp.is_closed && !shape_selected) {
28651 
28652  // Handle mouse motion and selection
28653  oX = X; oY = Y; oZ = Z;
28654  int mx = disp.mouse_x, my = disp.mouse_y;
28655  const int mX = mx*(width+(depth>1?depth:0))/disp.width, mY = my*(height+(depth>1?depth:0))/disp.height;
28656 
28657  area = 0;
28658  if (mX<dimx() && mY<dimy()) { area = 1; X = mX; Y = mY; Z = phase?Z1:Z0; }
28659  if (mX<dimx() && mY>=dimy()) { area = 2; X = mX; Z = mY-height; Y = phase?Y1:Y0; }
28660  if (mX>=dimx() && mY<dimy()) { area = 3; Y = mY; Z = mX-width; X = phase?X1:X0; }
28661 
28662  switch (key = disp.key) {
28663  case 0 : case cimg::keyCTRLLEFT : disp.key = key = 0; break;
28664  case cimg::keyPAGEUP : if (disp.is_keyCTRLLEFT) { ++disp.wheel; key = 0; } break;
28665  case cimg::keyPAGEDOWN : if (disp.is_keyCTRLLEFT) { --disp.wheel; key = 0; } break;
28666  case cimg::keyD : if (disp.is_keyCTRLLEFT) {
28667  disp.normalscreen().resize(CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,false),
28668  CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,true),false).is_resized = true;
28669  disp.key = key = 0;
28670  } break;
28671  case cimg::keyC : if (disp.is_keyCTRLLEFT) {
28672  disp.normalscreen().resize(cimg_fitscreen(2*disp.width/3,2*disp.height/3,1),false).is_resized = true;
28673  disp.key = key = 0; visu0.assign();
28674  } break;
28675  case cimg::keyR : if (disp.is_keyCTRLLEFT) {
28676  disp.normalscreen().resize(cimg_fitscreen(width,height,depth),false).is_resized = true;
28677  disp.key = key = 0; visu0.assign();
28678  } break;
28679  case cimg::keyF : if (disp.is_keyCTRLLEFT) {
28680  disp.resize(disp.screen_dimx(),disp.screen_dimy(),false).toggle_fullscreen().is_resized = true;
28681  disp.key = key = 0; visu0.assign();
28682  } break;
28683  case cimg::keyS : if (disp.is_keyCTRLLEFT) {
28684  static unsigned int snap_number = 0;
28685  char filename[32] = { 0 };
28686  std::FILE *file;
28687  do {
28688  std::sprintf(filename,"CImg_%.4u.bmp",snap_number++);
28689  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
28690  } while (file);
28691  if (visu0) {
28692  visu.draw_text(2,2,"Saving snapshot...",foreground_color,background_color,0.8f,11).display(disp);
28693  visu0.save(filename);
28694  visu.draw_text(2,2,"Snapshot '%s' saved.",foreground_color,background_color,0.8f,11,filename).display(disp);
28695  }
28696  disp.key = key = 0;
28697  } break;
28698  case cimg::keyO : if (disp.is_keyCTRLLEFT) {
28699  static unsigned int snap_number = 0;
28700  char filename[32] = { 0 };
28701  std::FILE *file;
28702  do {
28703  std::sprintf(filename,"CImg_%.4u.cimg",snap_number++);
28704  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
28705  } while (file);
28706  visu.draw_text(2,2,"Saving instance...",foreground_color,background_color,0.8f,11).display(disp);
28707  save(filename);
28708  visu.draw_text(2,2,"Instance '%s' saved.",foreground_color,background_color,0.8f,11,filename).display(disp);
28709  disp.key = key = 0;
28710  } break;
28711  }
28712 
28713  if (!area) mx = my = X = Y = Z = -1;
28714  else {
28715  if (disp.button&1 && phase<2) { X1 = X; Y1 = Y; Z1 = Z; }
28716  if (!(disp.button&1) && phase>=2) {
28717  switch (clicked_area) {
28718  case 1 : Z1 = Z; break;
28719  case 2 : Y1 = Y; break;
28720  case 3 : X1 = X; break;
28721  }
28722  }
28723  if (disp.button&2) { if (phase) { X1 = X; Y1 = Y; Z1 = Z; } else { X0 = X; Y0 = Y; Z0 = Z; } }
28724  if (disp.button&4) { oX = X = X0; oY = Y = Y0; oZ = Z = Z0; phase = 0; visu.assign(); }
28725  if (disp.wheel) {
28726  if (depth>1 && !disp.is_keyCTRLLEFT && !disp.is_keySHIFTLEFT && !disp.is_keyALT) {
28727  switch (area) {
28728  case 1 : if (phase) Z = (Z1+=disp.wheel); else Z = (Z0+=disp.wheel); break;
28729  case 2 : if (phase) Y = (Y1+=disp.wheel); else Y = (Y0+=disp.wheel); break;
28730  case 3 : if (phase) X = (X1+=disp.wheel); else X = (X0+=disp.wheel); break;
28731  }
28732  disp.wheel = 0;
28733  } else key = ~0U;
28734  }
28735  if ((disp.button&1)!=old_button) {
28736  switch (phase++) {
28737  case 0 : X0 = X1 = X; Y0 = Y1 = Y; Z0 = Z1 = Z; clicked_area = area; break;
28738  case 1 : X1 = X; Y1 = Y; Z1 = Z; break;
28739  }
28740  old_button = disp.button&1;
28741  }
28742  if (depth>1 && (X!=oX || Y!=oY || Z!=oZ)) visu0.assign();
28743  }
28744 
28745  if (phase) {
28746  if (!coords_type) shape_selected = phase?true:false;
28747  else {
28748  if (depth>1) shape_selected = (phase==3)?true:false;
28749  else shape_selected = (phase==2)?true:false;
28750  }
28751  }
28752 
28753  if (X0<0) X0 = 0; if (X0>=dimx()) X0 = dimx()-1; if (Y0<0) Y0 = 0; if (Y0>=dimy()) Y0 = dimy()-1;
28754  if (Z0<0) Z0 = 0; if (Z0>=dimz()) Z0 = dimz()-1;
28755  if (X1<1) X1 = 0; if (X1>=dimx()) X1 = dimx()-1; if (Y1<0) Y1 = 0; if (Y1>=dimy()) Y1 = dimy()-1;
28756  if (Z1<0) Z1 = 0; if (Z1>=dimz()) Z1 = dimz()-1;
28757 
28758  // Draw visualization image on the display
28759  if (oX!=X || oY!=Y || oZ!=Z || !visu0) {
28760  if (!visu0) {
28761  CImg<Tuchar> tmp, tmp0;
28762  if (depth!=1) {
28763  tmp0 = (!phase)?get_projections2d(X0,Y0,Z0):get_projections2d(X1,Y1,Z1);
28764  tmp = tmp0.get_channels(0,cimg::min(2U,dim-1));
28765  } else tmp = get_channels(0,cimg::min(2U,dim-1));
28766  switch (old_normalization) {
28767  case 0 : visu0 = tmp; break;
28768  case 3 :
28769  if (cimg::type<T>::is_float()) visu0 = tmp.normalize(0,(T)255);
28770  else {
28771  const float m = (float)cimg::type<T>::min(), M = (float)cimg::type<T>::max();
28772  visu0.assign(tmp.width,tmp.height,1,tmp.dim);
28773  unsigned char *ptrd = visu0.end();
28774  cimg_for(tmp,ptrs,Tuchar) *(--ptrd) = (unsigned char)((*ptrs-m)*255.0f/(M-m));
28775  } break;
28776  default : visu0 = tmp.normalize(0,255);
28777  }
28778  visu0.resize(disp);
28779  }
28780  visu = visu0;
28781  if (!color) {
28782  if (visu.mean()<200) {
28783  foreground_color[0] = foreground_color[1] = foreground_color[2] = 255;
28784  background_color[0] = background_color[1] = background_color[2] = 0;
28785  } else {
28786  foreground_color[0] = foreground_color[1] = foreground_color[2] = 0;
28787  background_color[0] = background_color[1] = background_color[2] = 255;
28788  }
28789  }
28790 
28791  const int d = (depth>1)?depth:0;
28792  if (phase) switch (coords_type) {
28793  case 1 : {
28794  const int
28795  x0 = (int)((X0+0.5f)*disp.width/(width+d)),
28796  y0 = (int)((Y0+0.5f)*disp.height/(height+d)),
28797  x1 = (int)((X1+0.5f)*disp.width/(width+d)),
28798  y1 = (int)((Y1+0.5f)*disp.height/(height+d));
28799  visu.draw_arrow(x0,y0,x1,y1,foreground_color,0.6f,30,5,hatch);
28800  if (d) {
28801  const int
28802  zx0 = (int)((width+Z0+0.5f)*disp.width/(width+d)),
28803  zx1 = (int)((width+Z1+0.5f)*disp.width/(width+d)),
28804  zy0 = (int)((height+Z0+0.5f)*disp.height/(height+d)),
28805  zy1 = (int)((height+Z1+0.5f)*disp.height/(height+d));
28806  visu.draw_arrow(zx0,y0,zx1,y1,foreground_color,0.6f,30,5,hatch).
28807  draw_arrow(x0,zy0,x1,zy1,foreground_color,0.6f,30,5,hatch);
28808  }
28809  } break;
28810  case 2 : {
28811  const int
28812  x0 = (X0<X1?X0:X1)*disp.width/(width+d), y0 = (Y0<Y1?Y0:Y1)*disp.height/(height+d),
28813  x1 = ((X0<X1?X1:X0)+1)*disp.width/(width+d)-1, y1 = ((Y0<Y1?Y1:Y0)+1)*disp.height/(height+d)-1;
28814  visu.draw_rectangle(x0,y0,x1,y1,foreground_color,0.2f).draw_rectangle(x0,y0,x1,y1,foreground_color,0.6f,hatch);
28815  if (d) {
28816  const int
28817  zx0 = (int)((width+(Z0<Z1?Z0:Z1))*disp.width/(width+d)),
28818  zy0 = (int)((height+(Z0<Z1?Z0:Z1))*disp.height/(height+d)),
28819  zx1 = (int)((width+(Z0<Z1?Z1:Z0)+1)*disp.width/(width+d))-1,
28820  zy1 = (int)((height+(Z0<Z1?Z1:Z0)+1)*disp.height/(height+d))-1;
28821  visu.draw_rectangle(zx0,y0,zx1,y1,foreground_color,0.2f).draw_rectangle(zx0,y0,zx1,y1,foreground_color,0.6f,hatch);
28822  visu.draw_rectangle(x0,zy0,x1,zy1,foreground_color,0.2f).draw_rectangle(x0,zy0,x1,zy1,foreground_color,0.6f,hatch);
28823  }
28824  } break;
28825  case 3 : {
28826  const int
28827  x0 = X0*disp.width/(width+d),
28828  y0 = Y0*disp.height/(height+d),
28829  x1 = X1*disp.width/(width+d)-1,
28830  y1 = Y1*disp.height/(height+d)-1;
28831  visu.draw_ellipse(x0,y0,(float)(x1-x0),(float)(y1-y0),0,foreground_color,0.2f).
28832  draw_ellipse(x0,y0,(float)(x1-x0),(float)(y1-y0),0,foreground_color,0.6f,hatch);
28833  if (d) {
28834  const int
28835  zx0 = (int)((width+Z0)*disp.width/(width+d)),
28836  zy0 = (int)((height+Z0)*disp.height/(height+d)),
28837  zx1 = (int)((width+Z1+1)*disp.width/(width+d))-1,
28838  zy1 = (int)((height+Z1+1)*disp.height/(height+d))-1;
28839  visu.draw_ellipse(zx0,y0,(float)(zx1-zx0),(float)(y1-y0),0,foreground_color,0.2f).
28840  draw_ellipse(zx0,y0,(float)(zx1-zx0),(float)(y1-y0),0,foreground_color,0.6f,hatch).
28841  draw_ellipse(x0,zy0,(float)(x1-x0),(float)(zy1-zy0),0,foreground_color,0.2f).
28842  draw_ellipse(x0,zy0,(float)(x1-x0),(float)(zy1-zy0),0,foreground_color,0.6f,hatch);
28843  }
28844  } break;
28845  } else {
28846  const int
28847  x0 = X*disp.width/(width+d),
28848  y0 = Y*disp.height/(height+d),
28849  x1 = (X+1)*disp.width/(width+d)-1,
28850  y1 = (Y+1)*disp.height/(height+d)-1;
28851  if (x1-x0>=4 && y1-y0>=4) visu.draw_rectangle(x0,y0,x1,y1,foreground_color,0.4f,~0U);
28852  }
28853 
28854  if (my<12) text_down = true;
28855  if (my>=visu.dimy()-11) text_down = false;
28856  if (!coords_type || !phase) {
28857  if (X>=0 && Y>=0 && Z>=0 && X<dimx() && Y<dimy() && Z<dimz()) {
28858  if (depth>1) std::sprintf(text,"Point (%d,%d,%d) = [ ",origX+X,origY+Y,origZ+Z);
28859  else std::sprintf(text,"Point (%d,%d) = [ ",origX+X,origY+Y);
28860  char *ctext = text + std::strlen(text), *const ltext = text + 512;
28861  for (unsigned int k = 0; k<dim && ctext<ltext; ++k) {
28862  std::sprintf(ctext,cimg::type<T>::format(),cimg::type<T>::format((*this)(X,Y,Z,k)));
28863  ctext = text + std::strlen(text);
28864  *(ctext++) = ' '; *ctext = 0;
28865  }
28866  std::sprintf(text + std::strlen(text),"]");
28867  }
28868  } else switch (coords_type) {
28869  case 1 : {
28870  const double dX = (double)(X0 - X1), dY = (double)(Y0 - Y1), dZ = (double)(Z0 - Z1), norm = std::sqrt(dX*dX+dY*dY+dZ*dZ);
28871  if (depth>1) std::sprintf(text,"Vect (%d,%d,%d)-(%d,%d,%d), Norm = %g",
28872  origX+X0,origY+Y0,origZ+Z0,origX+X1,origY+Y1,origZ+Z1,norm);
28873  else std::sprintf(text,"Vect (%d,%d)-(%d,%d), Norm = %g",
28874  origX+X0,origY+Y0,origX+X1,origY+Y1,norm);
28875  } break;
28876  case 2 :
28877  if (depth>1) std::sprintf(text,"Box (%d,%d,%d)-(%d,%d,%d), Size = (%d,%d,%d)",
28878  origX+(X0<X1?X0:X1),origY+(Y0<Y1?Y0:Y1),origZ+(Z0<Z1?Z0:Z1),
28879  origX+(X0<X1?X1:X0),origY+(Y0<Y1?Y1:Y0),origZ+(Z0<Z1?Z1:Z0),
28880  1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1),1+cimg::abs(Z0-Z1));
28881  else std::sprintf(text,"Box (%d,%d)-(%d,%d), Size = (%d,%d)",
28882  origX+(X0<X1?X0:X1),origY+(Y0<Y1?Y0:Y1),origX+(X0<X1?X1:X0),origY+(Y0<Y1?Y1:Y0),
28883  1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1));
28884  break;
28885  default :
28886  if (depth>1) std::sprintf(text,"Ellipse (%d,%d,%d)-(%d,%d,%d), Radii = (%d,%d,%d)",
28887  origX+X0,origY+Y0,origZ+Z0,origX+X1,origY+Y1,origZ+Z1,
28888  1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1),1+cimg::abs(Z0-Z1));
28889  else std::sprintf(text,"Ellipse (%d,%d)-(%d,%d), Radii = (%d,%d)",
28890  origX+X0,origY+Y0,origX+X1,origY+Y1,1+cimg::abs(X0-X1),1+cimg::abs(Y0-Y1));
28891 
28892  }
28893  if (phase || (mx>=0 && my>=0)) visu.draw_text(0,text_down?visu.dimy()-11:0,text,foreground_color,background_color,0.7f,11);
28894  disp.display(visu).wait(25);
28895  } else if (!shape_selected) disp.wait();
28896  if (disp.is_resized) { disp.resize(false).is_resized = false; old_is_resized = true; visu0.assign(); }
28897  }
28898 
28899  // Return result
28900  CImg<intT> res(1,6,1,1,-1);
28901  if (XYZ) { XYZ[0] = (unsigned int)X0; XYZ[1] = (unsigned int)Y0; XYZ[2] = (unsigned int)Z0; }
28902  if (shape_selected) {
28903  if (coords_type==2) {
28904  if (X0>X1) cimg::swap(X0,X1);
28905  if (Y0>Y1) cimg::swap(Y0,Y1);
28906  if (Z0>Z1) cimg::swap(Z0,Z1);
28907  }
28908  if (X1<0 || Y1<0 || Z1<0) X0 = Y0 = Z0 = X1 = Y1 = Z1 = -1;
28909  switch (coords_type) {
28910  case 1 :
28911  case 2 : res[3] = X1; res[4] = Y1; res[5] = Z1;
28912  default : res[0] = X0; res[1] = Y0; res[2] = Z0;
28913  }
28914  }
28915  disp.button = 0;
28916  disp.normalization = old_normalization;
28917  disp.is_resized = old_is_resized;
28918  if (key!=~0U) disp.key = key;
28919  return res;
28920  }
cimg::superset< T, unsigned char >::type Tuchar
Definition: CImg.h:9773
static unsigned int _fitscreen(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const int dmin=128, const int dmax=-85, const bool return_last=false)
Definition: CImg.h:6437
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
CImg< T > get_channels(const unsigned int v0, const unsigned int v1) const
Definition: CImg.h:18470
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const unsigned int keyPAGEUP
Definition: CImg.h:2698
const NT & d
j indices k indices k
Definition: Indexing.h:6
const unsigned int keyCTRLLEFT
Definition: CImg.h:2734
#define cimg_fitscreen(dx, dy, dz)
Definition: CImg.h:6436
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
const unsigned int keyC
Definition: CImg.h:2727
double sqrt(double d)
Definition: double.h:73
CImg< T > & norm(const int norm_type=2)
Compute L2-norm of each multi-valued pixel of the instance image.
Definition: CImg.h:15127
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const unsigned int keyO
Definition: CImg.h:2708
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
const unsigned int keyPAGEDOWN
Definition: CImg.h:2712
const unsigned int keyF
Definition: CImg.h:2717
Const_pointer end() const
Definition: Vector_n.h:122
const CImg< T > & save(const char *const filename, const int number=-1) const
Save the image as a file.
Definition: CImg.h:32256
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
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.
Definition: CImg.h:26017
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
const unsigned int keyR
Definition: CImg.h:2703
CImg< T > get_projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, const int dx=-100, const int dy=-100, const int dz=-100) const
Definition: CImg.h:18151
const unsigned int keyS
Definition: CImg.h:2715
const unsigned int keyD
Definition: CImg.h:2716
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 instance image.
Definition: CImg.h:23057
static T_Key key
Definition: vinci_lass.c:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

Tfloat _linear_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11575 of file CImg.h.

Referenced by CImg< uintT >::get_warp(), and CImg< uintT >::linear_atX().

11575  {
11576  const float
11577  nfx = fx<0?0:(fx>width-1?width-1:fx);
11578  const unsigned int
11579  x = (unsigned int)nfx;
11580  const float
11581  dx = nfx-x;
11582  const unsigned int
11583  nx = dx>0?x+1:x;
11584  const Tfloat
11585  Ic = (Tfloat)(*this)(x,y,z,v), In = (Tfloat)(*this)(nx,y,z,v);
11586  return Ic + dx*(In-Ic);
11587  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781

Here is the caller graph for this function:

Tfloat _linear_atXY ( const float  fx,
const float  fy,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11537 of file CImg.h.

Referenced by CImg< uintT >::blur_anisotropic(), CImg< uintT >::get_warp(), and CImg< uintT >::linear_atXY().

11537  {
11538  const float
11539  nfx = fx<0?0:(fx>width-1?width-1:fx),
11540  nfy = fy<0?0:(fy>height-1?height-1:fy);
11541  const unsigned int
11542  x = (unsigned int)nfx,
11543  y = (unsigned int)nfy;
11544  const float
11545  dx = nfx-x,
11546  dy = nfy-y;
11547  const unsigned int
11548  nx = dx>0?x+1:x,
11549  ny = dy>0?y+1:y;
11550  const Tfloat
11551  Icc = (Tfloat)(*this)(x,y,z,v), Inc = (Tfloat)(*this)(nx,y,z,v),
11552  Icn = (Tfloat)(*this)(x,ny,z,v), Inn = (Tfloat)(*this)(nx,ny,z,v);
11553  return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc);
11554  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy

Here is the caller graph for this function:

Tfloat _linear_atXYZ ( const float  fx,
const float  fy = 0,
const float  fz = 0,
const int  v = 0 
) const
inline

Definition at line 11483 of file CImg.h.

Referenced by CImg< uintT >::blur_anisotropic(), CImg< uintT >::get_warp(), and CImg< uintT >::linear_atXYZ().

11483  {
11484  const float
11485  nfx = fx<0?0:(fx>width-1?width-1:fx),
11486  nfy = fy<0?0:(fy>height-1?height-1:fy),
11487  nfz = fz<0?0:(fz>depth-1?depth-1:fz);
11488  const unsigned int
11489  x = (unsigned int)nfx,
11490  y = (unsigned int)nfy,
11491  z = (unsigned int)nfz;
11492  const float
11493  dx = nfx-x,
11494  dy = nfy-y,
11495  dz = nfz-z;
11496  const unsigned int
11497  nx = dx>0?x+1:x,
11498  ny = dy>0?y+1:y,
11499  nz = dz>0?z+1:z;
11500  const Tfloat
11501  Iccc = (Tfloat)(*this)(x,y,z,v), Incc = (Tfloat)(*this)(nx,y,z,v),
11502  Icnc = (Tfloat)(*this)(x,ny,z,v), Innc = (Tfloat)(*this)(nx,ny,z,v),
11503  Iccn = (Tfloat)(*this)(x,y,nz,v), Incn = (Tfloat)(*this)(nx,y,nz,v),
11504  Icnn = (Tfloat)(*this)(x,ny,nz,v), Innn = (Tfloat)(*this)(nx,ny,nz,v);
11505  return Iccc +
11506  dx*(Incc-Iccc +
11507  dy*(Iccc+Innc-Icnc-Incc +
11508  dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) +
11509  dz*(Iccc+Incn-Iccn-Incc)) +
11510  dy*(Icnc-Iccc +
11511  dz*(Iccc+Icnn-Iccn-Icnc)) +
11512  dz*(Iccn-Iccc);
11513  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

Tfloat _linear_atXYZV ( const float  fx,
const float  fy = 0,
const float  fz = 0,
const float  fv = 0 
) const
inline

Definition at line 11402 of file CImg.h.

Referenced by CImg< uintT >::get_warp(), and CImg< uintT >::linear_atXYZV().

11402  {
11403  const float
11404  nfx = fx<0?0:(fx>width-1?width-1:fx),
11405  nfy = fy<0?0:(fy>height-1?height-1:fy),
11406  nfz = fz<0?0:(fz>depth-1?depth-1:fz),
11407  nfv = fv<0?0:(fv>dim-1?dim-1:fv);
11408  const unsigned int
11409  x = (unsigned int)nfx,
11410  y = (unsigned int)nfy,
11411  z = (unsigned int)nfz,
11412  v = (unsigned int)nfv;
11413  const float
11414  dx = nfx-x,
11415  dy = nfy-y,
11416  dz = nfz-z,
11417  dv = nfv-v;
11418  const unsigned int
11419  nx = dx>0?x+1:x,
11420  ny = dy>0?y+1:y,
11421  nz = dz>0?z+1:z,
11422  nv = dv>0?v+1:v;
11423  const Tfloat
11424  Icccc = (Tfloat)(*this)(x,y,z,v), Inccc = (Tfloat)(*this)(nx,y,z,v),
11425  Icncc = (Tfloat)(*this)(x,ny,z,v), Inncc = (Tfloat)(*this)(nx,ny,z,v),
11426  Iccnc = (Tfloat)(*this)(x,y,nz,v), Incnc = (Tfloat)(*this)(nx,y,nz,v),
11427  Icnnc = (Tfloat)(*this)(x,ny,nz,v), Innnc = (Tfloat)(*this)(nx,ny,nz,v),
11428  Icccn = (Tfloat)(*this)(x,y,z,nv), Inccn = (Tfloat)(*this)(nx,y,z,nv),
11429  Icncn = (Tfloat)(*this)(x,ny,z,nv), Inncn = (Tfloat)(*this)(nx,ny,z,nv),
11430  Iccnn = (Tfloat)(*this)(x,y,nz,nv), Incnn = (Tfloat)(*this)(nx,y,nz,nv),
11431  Icnnn = (Tfloat)(*this)(x,ny,nz,nv), Innnn = (Tfloat)(*this)(nx,ny,nz,nv);
11432  return Icccc +
11433  dx*(Inccc-Icccc +
11434  dy*(Icccc+Inncc-Icncc-Inccc +
11435  dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc +
11436  dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) +
11437  dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) +
11438  dz*(Icccc+Incnc-Iccnc-Inccc +
11439  dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) +
11440  dv*(Icccc+Inccn-Inccc-Icccn)) +
11441  dy*(Icncc-Icccc +
11442  dz*(Icccc+Icnnc-Iccnc-Icncc +
11443  dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) +
11444  dv*(Icccc+Icncn-Icncc-Icccn)) +
11445  dz*(Iccnc-Icccc +
11446  dv*(Icccc+Iccnn-Iccnc-Icccn)) +
11447  dv*(Icccn-Icccc);
11448  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& _load_analyze ( std::FILE *const  file,
const char *const  filename,
float *const  voxsize = 0 
)
inline

Definition at line 30425 of file CImg.h.

Referenced by CImg< uintT >::load_analyze().

30425  {
30426  if (!filename && !file)
30427  throw CImgArgumentException("CImg<%s>::load_analyze() : Cannot load (null) filename.",
30428  pixel_type());
30429  std::FILE *nfile_header = 0, *nfile = 0;
30430  if (!file) {
30431  char body[1024] = { 0 };
30432  const char *ext = cimg::split_filename(filename,body);
30433  if (!cimg::strcasecmp(ext,"hdr")) { // File is an Analyze header file.
30434  nfile_header = cimg::fopen(filename,"rb");
30435  std::sprintf(body+std::strlen(body),".img");
30436  nfile = cimg::fopen(body,"rb");
30437  } else if (!cimg::strcasecmp(ext,"img")) { // File is an Analyze data file.
30438  nfile = cimg::fopen(filename,"rb");
30439  std::sprintf(body+std::strlen(body),".hdr");
30440  nfile_header = cimg::fopen(body,"rb");
30441  } else nfile_header = nfile = cimg::fopen(filename,"rb"); // File is a Niftii file.
30442  } else nfile_header = nfile = file; // File is a Niftii file.
30443  if (!nfile || !nfile_header)
30444  throw CImgIOException("CImg<%s>::load_analyze() : File '%s', not recognized as an Analyze7.5 or NIFTI file.",
30445  pixel_type(),filename?filename:"(FILE*)");
30446 
30447  // Read header.
30448  bool endian = false;
30449  unsigned int header_size;
30450  cimg::fread(&header_size,1,nfile_header);
30451  if (!header_size)
30452  throw CImgIOException("CImg<%s>::load_analyze() : File '%s', zero-sized header found.",
30453  pixel_type(),filename?filename:"(FILE*)");
30454  if (header_size>=4096) { endian = true; cimg::invert_endianness(header_size); }
30455  unsigned char *header = new unsigned char[header_size];
30456  cimg::fread(header+4,header_size-4,nfile_header);
30457  if (!file && nfile_header!=nfile) cimg::fclose(nfile_header);
30458  if (endian) {
30459  cimg::invert_endianness((short*)(header+40),5);
30460  cimg::invert_endianness((short*)(header+70),1);
30461  cimg::invert_endianness((short*)(header+72),1);
30462  cimg::invert_endianness((float*)(header+76),4);
30463  cimg::invert_endianness((float*)(header+112),1);
30464  }
30465  unsigned short *dim = (unsigned short*)(header+40), dimx = 1, dimy = 1, dimz = 1, dimv = 1;
30466  if (!dim[0])
30467  cimg::warn("CImg<%s>::load_analyze() : File '%s', tells that image has zero dimensions.",
30468  pixel_type(),filename?filename:"(FILE*)");
30469  if (dim[0]>4)
30470  cimg::warn("CImg<%s>::load_analyze() : File '%s', number of image dimension is %u, reading only the 4 first dimensions",
30471  pixel_type(),filename?filename:"(FILE*)",dim[0]);
30472  if (dim[0]>=1) dimx = dim[1];
30473  if (dim[0]>=2) dimy = dim[2];
30474  if (dim[0]>=3) dimz = dim[3];
30475  if (dim[0]>=4) dimv = dim[4];
30476  float scalefactor = *(float*)(header+112); if (scalefactor==0) scalefactor=1;
30477  const unsigned short datatype = *(short*)(header+70);
30478  if (voxsize) {
30479  const float *vsize = (float*)(header+76);
30480  voxsize[0] = vsize[1]; voxsize[1] = vsize[2]; voxsize[2] = vsize[3];
30481  }
30482  delete[] header;
30483 
30484  // Read pixel data.
30486  switch (datatype) {
30487  case 2 : {
30488  unsigned char *buffer = new unsigned char[dimx*dimy*dimz*dimv];
30489  cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
30490  cimg_foroff(*this,off) data[off] = (T)(buffer[off]*scalefactor);
30491  delete[] buffer;
30492  } break;
30493  case 4 : {
30494  short *buffer = new short[dimx*dimy*dimz*dimv];
30495  cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
30496  if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
30497  cimg_foroff(*this,off) data[off] = (T)(buffer[off]*scalefactor);
30498  delete[] buffer;
30499  } break;
30500  case 8 : {
30501  int *buffer = new int[dimx*dimy*dimz*dimv];
30502  cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
30503  if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
30504  cimg_foroff(*this,off) data[off] = (T)(buffer[off]*scalefactor);
30505  delete[] buffer;
30506  } break;
30507  case 16 : {
30508  float *buffer = new float[dimx*dimy*dimz*dimv];
30509  cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
30510  if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
30511  cimg_foroff(*this,off) data[off] = (T)(buffer[off]*scalefactor);
30512  delete[] buffer;
30513  } break;
30514  case 64 : {
30515  double *buffer = new double[dimx*dimy*dimz*dimv];
30516  cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
30517  if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
30518  cimg_foroff(*this,off) data[off] = (T)(buffer[off]*scalefactor);
30519  delete[] buffer;
30520  } break;
30521  default :
30522  if (!file) cimg::fclose(nfile);
30523  throw CImgIOException("CImg<%s>::load_analyze() : File '%s', cannot read images with 'datatype = %d'",
30524  pixel_type(),filename?filename:"(FILE*)",datatype);
30525  }
30526  if (!file) cimg::fclose(nfile);
30527  return *this;
30528  }
if(dy > dx)
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
const NT & d
double s
Definition: blastest.C:80
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
Definition: CImg.h:30408
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
systems whose!Fortran compilers support!instead of just C or *for comments can!globally replace a C in the first column with
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
#define cimg_foroff(img, off)
Definition: CImg.h:590
CImg()
Default constructor.
Definition: CImg.h:9857
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<T>& _load_ascii ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29283 of file CImg.h.

Referenced by CImg< uintT >::load_ascii().

29283  {
29284  if (!filename && !file)
29285  throw CImgArgumentException("CImg<%s>::load_ascii() : Cannot load (null) filename.",
29286  pixel_type());
29287  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
29288  char line[256] = { 0 };
29289  int err = std::fscanf(nfile,"%255[^\n]",line);
29290  unsigned int off, dx = 0, dy = 1, dz = 1, dv = 1;
29291  std::sscanf(line,"%u%*c%u%*c%u%*c%u",&dx,&dy,&dz,&dv);
29292  err = std::fscanf(nfile,"%*[^0-9.eE+-]");
29293  if (!dx || !dy || !dz || !dv) {
29294  if (!file) cimg::fclose(nfile);
29295  throw CImgIOException("CImg<%s>::load_ascii() : File '%s', invalid .ASC header, specified image dimensions are (%u,%u,%u,%u).",
29296  pixel_type(),filename?filename:"(FILE*)",dx,dy,dz,dv);
29297  }
29298  assign(dx,dy,dz,dv);
29299  const unsigned int siz = size();
29300  double val;
29301  T *ptr = data;
29302  for (err = 1, off = 0; off<siz && err==1; ++off) {
29303  err = std::fscanf(nfile,"%lf%*[^0-9.eE+-]",&val);
29304  *(ptr++) = (T)val;
29305  }
29306  if (err!=1)
29307  cimg::warn("CImg<%s>::load_ascii() : File '%s', only %u/%u values read.",
29308  pixel_type(),filename?filename:"(FILE*)",off-1,siz);
29309  if (!file) cimg::fclose(nfile);
29310  return *this;
29311  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
NT dx
CImg< T > & line(const unsigned int y0)
Get a line.
Definition: CImg.h:18421
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_bmp ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29379 of file CImg.h.

Referenced by CImg< uintT >::load_bmp().

29379  {
29380  if (!filename && !file)
29381  throw CImgArgumentException("CImg<%s>::load_bmp() : Cannot load (null) filename.",
29382  pixel_type());
29383  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
29384  unsigned char header[64] = { 0 };
29385  cimg::fread(header,54,nfile);
29386  if (header[0]!='B' || header[1]!='M') {
29387  if (!file) cimg::fclose(nfile);
29388  throw CImgIOException("CImg<%s>::load_bmp() : Invalid valid BMP file (filename '%s').",
29389  pixel_type(),filename?filename:"(FILE*)");
29390  }
29391  assign();
29392 
29393  // Read header and pixel buffer
29394  int
29395  file_size = header[0x02] + (header[0x03]<<8) + (header[0x04]<<16) + (header[0x05]<<24),
29396  offset = header[0x0A] + (header[0x0B]<<8) + (header[0x0C]<<16) + (header[0x0D]<<24),
29397  dx = header[0x12] + (header[0x13]<<8) + (header[0x14]<<16) + (header[0x15]<<24),
29398  dy = header[0x16] + (header[0x17]<<8) + (header[0x18]<<16) + (header[0x19]<<24),
29399  compression = header[0x1E] + (header[0x1F]<<8) + (header[0x20]<<16) + (header[0x21]<<24),
29400  nb_colors = header[0x2E] + (header[0x2F]<<8) + (header[0x30]<<16) + (header[0x31]<<24),
29401  bpp = header[0x1C] + (header[0x1D]<<8),
29402  *palette = 0;
29403  const int
29404  dx_bytes = (bpp==1)?(dx/8+(dx%8?1:0)):((bpp==4)?(dx/2+(dx%2?1:0)):(dx*bpp/8)),
29405  align = (4-dx_bytes%4)%4,
29406  buf_size = cimg::min(cimg::abs(dy)*(dx_bytes+align),file_size-offset);
29407 
29408  if (bpp<16) { if (!nb_colors) nb_colors=1<<bpp; } else nb_colors = 0;
29409  if (nb_colors) { palette = new int[nb_colors]; cimg::fread(palette,nb_colors,nfile); }
29410  const int xoffset = offset-54-4*nb_colors;
29411  if (xoffset>0) std::fseek(nfile,xoffset,SEEK_CUR);
29412  unsigned char *buffer = new unsigned char[buf_size], *ptrs = buffer;
29413  cimg::fread(buffer,buf_size,nfile);
29414  if (!file) cimg::fclose(nfile);
29415 
29416  // Decompress buffer (if necessary)
29417  if (compression) {
29418  delete[] buffer;
29419  if (file) {
29420  throw CImgIOException("CImg<%s>::load_bmp() : Not able to read a compressed BMP file using a *FILE input",
29421  pixel_type());
29422  } else return load_other(filename);
29423  }
29424 
29425  // Read pixel data
29426  assign(dx,cimg::abs(dy),1,3);
29427  switch (bpp) {
29428  case 1 : { // Monochrome
29429  for (int y = dimy()-1; y>=0; --y) {
29430  unsigned char mask = 0x80, val = 0;
29431  cimg_forX(*this,x) {
29432  if (mask==0x80) val = *(ptrs++);
29433  const unsigned char *col = (unsigned char*)(palette+(val&mask?1:0));
29434  (*this)(x,y,2) = (T)*(col++);
29435  (*this)(x,y,1) = (T)*(col++);
29436  (*this)(x,y,0) = (T)*(col++);
29437  mask = cimg::ror(mask);
29438  } ptrs+=align; }
29439  } break;
29440  case 4 : { // 16 colors
29441  for (int y = dimy()-1; y>=0; --y) {
29442  unsigned char mask = 0xF0, val = 0;
29443  cimg_forX(*this,x) {
29444  if (mask==0xF0) val = *(ptrs++);
29445  const unsigned char color = (unsigned char)((mask<16)?(val&mask):((val&mask)>>4));
29446  unsigned char *col = (unsigned char*)(palette+color);
29447  (*this)(x,y,2) = (T)*(col++);
29448  (*this)(x,y,1) = (T)*(col++);
29449  (*this)(x,y,0) = (T)*(col++);
29450  mask = cimg::ror(mask,4);
29451  } ptrs+=align; }
29452  } break;
29453  case 8 : { // 256 colors
29454  for (int y = dimy()-1; y>=0; --y) { cimg_forX(*this,x) {
29455  const unsigned char *col = (unsigned char*)(palette+*(ptrs++));
29456  (*this)(x,y,2) = (T)*(col++);
29457  (*this)(x,y,1) = (T)*(col++);
29458  (*this)(x,y,0) = (T)*(col++);
29459  } ptrs+=align; }
29460  } break;
29461  case 16 : { // 16 bits colors
29462  for (int y = dimy()-1; y>=0; --y) { cimg_forX(*this,x) {
29463  const unsigned char c1 = *(ptrs++), c2 = *(ptrs++);
29464  const unsigned short col = (unsigned short)(c1|(c2<<8));
29465  (*this)(x,y,2) = (T)(col&0x1F);
29466  (*this)(x,y,1) = (T)((col>>5)&0x1F);
29467  (*this)(x,y,0) = (T)((col>>10)&0x1F);
29468  } ptrs+=align; }
29469  } break;
29470  case 24 : { // 24 bits colors
29471  for (int y = dimy()-1; y>=0; --y) { cimg_forX(*this,x) {
29472  (*this)(x,y,2) = (T)*(ptrs++);
29473  (*this)(x,y,1) = (T)*(ptrs++);
29474  (*this)(x,y,0) = (T)*(ptrs++);
29475  } ptrs+=align; }
29476  } break;
29477  case 32 : { // 32 bits colors
29478  for (int y = dimy()-1; y>=0; --y) { cimg_forX(*this,x) {
29479  (*this)(x,y,2) = (T)*(ptrs++);
29480  (*this)(x,y,1) = (T)*(ptrs++);
29481  (*this)(x,y,0) = (T)*(ptrs++);
29482  ++ptrs;
29483  } ptrs+=align; }
29484  } break;
29485  }
29486  if (palette) delete[] palette;
29487  delete[] buffer;
29488  if (dy<0) mirror('y');
29489  return *this;
29490  }
CImg< T > & mirror(const char axis)
Mirror an image along the specified axis.
Definition: CImg.h:17147
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_forX(img, x)
Definition: CImg.h:593
const T ror(const T a, const unsigned int n=1)
Return a right bitwise-rotated number.
Definition: CImg.h:4677
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
NT dy
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_dlm ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29331 of file CImg.h.

Referenced by CImg< uintT >::load_dlm().

29331  {
29332  if (!filename && !file)
29333  throw CImgArgumentException("CImg<%s>::load_dlm() : Cannot load (null) filename.",
29334  pixel_type());
29335  std::FILE *const nfile = file?file:cimg::fopen(filename,"r");
29336  char delimiter[256] = { 0 }, tmp[256] = { 0 };
29337  unsigned int cdx = 0, dx = 0, dy = 0;
29338  int err = 0;
29339  double val;
29340  assign(256,256);
29341  while ((err = std::fscanf(nfile,"%lf%255[^0-9.+-]",&val,delimiter))>0) {
29342  if (err>0) (*this)(cdx++,dy) = (T)val;
29343  if (cdx>=width) resize(3*width/2,1,1,1,0);
29344  char c = 0;
29345  if (!std::sscanf(delimiter,"%255[^\n]%c",tmp,&c) || c=='\n') {
29346  dx = cimg::max(cdx,dx);
29347  if (++dy>=height) resize(width,3*height/2,1,1,0);
29348  cdx = 0;
29349  }
29350  }
29351  if (cdx && err==1) { dx = cdx; ++dy; }
29352  if (!dx || !dy) {
29353  if (!file) cimg::fclose(nfile);
29354  throw CImgIOException("CImg<%s>::load_dlm() : File '%s', invalid DLM file.",pixel_type(),filename?filename:"(FILE*)");
29355  }
29356  resize(dx,dy,1,1,0);
29357  if (!file) cimg::fclose(nfile);
29358  return *this;
29359  }
if(dy > dx)
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
Definition: CImg.h:16630
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
const NT & n
NT dy
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_inr ( std::FILE *const  file,
const char *const  filename,
float *const  voxsize 
)
inline

Definition at line 30659 of file CImg.h.

Referenced by CImg< uintT >::load_inr().

30659  {
30660 #define _cimg_load_inr_case(Tf,sign,pixsize,Ts) \
30661  if (!loaded && fopt[6]==pixsize && fopt[4]==Tf && fopt[5]==sign) { \
30662  Ts *xval, *val = new Ts[fopt[0]*fopt[3]]; \
30663  cimg_forYZ(*this,y,z) { \
30664  cimg::fread(val,fopt[0]*fopt[3],nfile); \
30665  if (fopt[7]!=endian) cimg::invert_endianness(val,fopt[0]*fopt[3]); \
30666  xval = val; cimg_forX(*this,x) cimg_forV(*this,k) (*this)(x,y,z,k) = (T)*(xval++); \
30667  } \
30668  delete[] val; \
30669  loaded = true; \
30670  }
30671 
30672  if (!filename && !file)
30673  throw CImgArgumentException("CImg<%s>::load_inr() : Cannot load (null) filename.",
30674  pixel_type());
30675  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
30676  int fopt[8], endian=cimg::endianness()?1:0;
30677  bool loaded = false;
30678  if (voxsize) voxsize[0]=voxsize[1]=voxsize[2]=1;
30679  _load_inr_header(nfile,fopt,voxsize);
30680  assign(fopt[0],fopt[1],fopt[2],fopt[3]);
30681  _cimg_load_inr_case(0,0,8, unsigned char);
30682  _cimg_load_inr_case(0,1,8, char);
30683  _cimg_load_inr_case(0,0,16,unsigned short);
30684  _cimg_load_inr_case(0,1,16,short);
30685  _cimg_load_inr_case(0,0,32,unsigned int);
30686  _cimg_load_inr_case(0,1,32,int);
30687  _cimg_load_inr_case(1,0,32,float);
30688  _cimg_load_inr_case(1,1,32,float);
30689  _cimg_load_inr_case(1,0,64,double);
30690  _cimg_load_inr_case(1,1,64,double);
30691  if (!loaded) {
30692  if (!file) cimg::fclose(nfile);
30693  throw CImgIOException("CImg<%s>::load_inr() : File '%s', cannot read images of the type specified in the file",
30694  pixel_type(),filename?filename:"(FILE*)");
30695  }
30696  if (!file) cimg::fclose(nfile);
30697  return *this;
30698  }
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
static void _load_inr_header(std::FILE *file, int out[8], float *const voxsize)
Definition: CImg.h:30613
#define _cimg_load_inr_case(Tf, sign, pixsize, Ts)
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

static void _load_inr_header ( std::FILE *  file,
int  out[8],
float *const  voxsize 
)
inlinestatic

Definition at line 30613 of file CImg.h.

Referenced by CImg< uintT >::_load_inr().

30613  {
30614  char item[1024] = { 0 }, tmp1[64] = { 0 }, tmp2[64] = { 0 };
30615  out[0] = std::fscanf(file,"%63s",item);
30616  out[0] = out[1] = out[2] = out[3] = out[5] = 1; out[4] = out[6] = out[7] = -1;
30617  if(cimg::strncasecmp(item,"#INRIMAGE-4#{",13)!=0)
30618  throw CImgIOException("CImg<%s>::load_inr() : File does not appear to be a valid INR file.\n"
30619  "(INRIMAGE-4 identifier not found)",
30620  pixel_type());
30621  while (std::fscanf(file," %63[^\n]%*c",item)!=EOF && std::strncmp(item,"##}",3)) {
30622  std::sscanf(item," XDIM%*[^0-9]%d",out);
30623  std::sscanf(item," YDIM%*[^0-9]%d",out+1);
30624  std::sscanf(item," ZDIM%*[^0-9]%d",out+2);
30625  std::sscanf(item," VDIM%*[^0-9]%d",out+3);
30626  std::sscanf(item," PIXSIZE%*[^0-9]%d",out+6);
30627  if (voxsize) {
30628  std::sscanf(item," VX%*[^0-9.+-]%f",voxsize);
30629  std::sscanf(item," VY%*[^0-9.+-]%f",voxsize+1);
30630  std::sscanf(item," VZ%*[^0-9.+-]%f",voxsize+2);
30631  }
30632  if (std::sscanf(item," CPU%*[ =]%s",tmp1)) out[7]=cimg::strncasecmp(tmp1,"sun",3)?0:1;
30633  switch (std::sscanf(item," TYPE%*[ =]%s %s",tmp1,tmp2)) {
30634  case 0 : break;
30635  case 2 : out[5] = cimg::strncasecmp(tmp1,"unsigned",8)?1:0; std::strcpy(tmp1,tmp2);
30636  case 1 :
30637  if (!cimg::strncasecmp(tmp1,"int",3) || !cimg::strncasecmp(tmp1,"fixed",5)) out[4] = 0;
30638  if (!cimg::strncasecmp(tmp1,"float",5) || !cimg::strncasecmp(tmp1,"double",6)) out[4] = 1;
30639  if (!cimg::strncasecmp(tmp1,"packed",6)) out[4] = 2;
30640  if (out[4]>=0) break;
30641  default :
30642  throw CImgIOException("cimg::inr_header_read() : Invalid TYPE '%s'",tmp2);
30643  }
30644  }
30645  if(out[0]<0 || out[1]<0 || out[2]<0 || out[3]<0)
30646  throw CImgIOException("CImg<%s>::load_inr() : Bad dimensions in .inr file = ( %d , %d , %d , %d )",
30647  pixel_type(),out[0],out[1],out[2],out[3]);
30648  if(out[4]<0 || out[5]<0)
30649  throw CImgIOException("CImg<%s>::load_inr() : TYPE is not fully defined",
30650  pixel_type());
30651  if(out[6]<0)
30652  throw CImgIOException("CImg<%s>::load_inr() : PIXSIZE is not fully defined",
30653  pixel_type());
30654  if(out[7]<0)
30655  throw CImgIOException("CImg<%s>::load_inr() : Big/Little Endian coding type is not defined",
30656  pixel_type());
30657  }
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041

Here is the caller graph for this function:

CImg<T>& _load_jpeg ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29510 of file CImg.h.

Referenced by CImg< uintT >::load_jpeg().

29510  {
29511  if (!filename && !file)
29512  throw CImgArgumentException("CImg<%s>::load_jpeg() : Cannot load (null) filename.",
29513  pixel_type());
29514 #ifndef cimg_use_jpeg
29515  if (file)
29516  throw CImgIOException("CImg<%s>::load_jpeg() : File '(FILE*)' cannot be read without using libjpeg.",
29517  pixel_type());
29518  else return load_other(filename);
29519 #else
29520  struct jpeg_decompress_struct cinfo;
29521  struct jpeg_error_mgr jerr;
29522  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
29523 
29524  cinfo.err = jpeg_std_error(&jerr);
29525  jpeg_create_decompress(&cinfo);
29526  jpeg_stdio_src(&cinfo,nfile);
29527  jpeg_read_header(&cinfo,TRUE);
29528  jpeg_start_decompress(&cinfo);
29529 
29530  if (cinfo.output_components!=1 && cinfo.output_components!=3 && cinfo.output_components!=4) {
29531  cimg::warn("CImg<%s>::load_jpeg() : Don't know how to read image '%s' with libpeg, trying ImageMagick's convert",
29532  pixel_type(),filename?filename:"(FILE*)");
29533  if (!file) return load_other(filename);
29534  else {
29535  if (!file) cimg::fclose(nfile);
29536  throw CImgIOException("CImg<%s>::load_jpeg() : Cannot read JPEG image '%s' using a *FILE input.",
29537  pixel_type(),filename?filename:"(FILE*)");
29538  }
29539  }
29540 
29541  const unsigned int row_stride = cinfo.output_width * cinfo.output_components;
29542  unsigned char *buf = new unsigned char[cinfo.output_width*cinfo.output_height*cinfo.output_components], *buf2 = buf;
29543  JSAMPROW row_pointer[1];
29544  while (cinfo.output_scanline < cinfo.output_height) {
29545  row_pointer[0] = &buf[cinfo.output_scanline*row_stride];
29546  jpeg_read_scanlines(&cinfo,row_pointer,1);
29547  }
29548  jpeg_finish_decompress(&cinfo);
29549  jpeg_destroy_decompress(&cinfo);
29550  if (!file) cimg::fclose(nfile);
29551 
29552  assign(cinfo.output_width,cinfo.output_height,1,cinfo.output_components);
29553  switch (dim) {
29554  case 1 : {
29555  T *ptr_g = data;
29556  cimg_forXY(*this,x,y) *(ptr_g++) = (T)*(buf2++);
29557  } break;
29558  case 3 : {
29559  T *ptr_r = ptr(0,0,0,0), *ptr_g = ptr(0,0,0,1), *ptr_b = ptr(0,0,0,2);
29560  cimg_forXY(*this,x,y) {
29561  *(ptr_r++) = (T)*(buf2++);
29562  *(ptr_g++) = (T)*(buf2++);
29563  *(ptr_b++) = (T)*(buf2++);
29564  }
29565  } break;
29566  case 4 : {
29567  T *ptr_r = ptr(0,0,0,0), *ptr_g = ptr(0,0,0,1),
29568  *ptr_b = ptr(0,0,0,2), *ptr_a = ptr(0,0,0,3);
29569  cimg_forXY(*this,x,y) {
29570  *(ptr_r++) = (T)*(buf2++);
29571  *(ptr_g++) = (T)*(buf2++);
29572  *(ptr_b++) = (T)*(buf2++);
29573  *(ptr_a++) = (T)*(buf2++);
29574  }
29575  } break;
29576  }
29577  delete[] buf;
29578  return *this;
29579 #endif
29580  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
void int int REAL REAL * y
Definition: read.cpp:74
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
#define TRUE
Definition: vinci.h:134
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& _load_off ( std::FILE *const  file,
const char *const  filename,
CImgList< tf > &  primitives,
CImgList< tc > &  colors 
)
inline

Definition at line 31050 of file CImg.h.

Referenced by CImg< uintT >::load_off().

31051  {
31052  if (!filename && !file)
31053  throw CImgArgumentException("CImg<%s>::load_off() : Cannot load (null) filename.",
31054  pixel_type());
31055  std::FILE *const nfile = file?file:cimg::fopen(filename,"r");
31056  unsigned int nb_points = 0, nb_primitives = 0, nb_read = 0;
31057  char line[256] = { 0 };
31058  int err;
31059 
31060  // Skip comments, and read magic string OFF
31061  do { err = std::fscanf(nfile,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#'));
31062  if (cimg::strncasecmp(line,"OFF",3) && cimg::strncasecmp(line,"COFF",4)) {
31063  if (!file) cimg::fclose(nfile);
31064  throw CImgIOException("CImg<%s>::load_off() : File '%s', keyword 'OFF' not found.",
31065  pixel_type(),filename?filename:"(FILE*)");
31066  }
31067  do { err = std::fscanf(nfile,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#'));
31068  if ((err = std::sscanf(line,"%u%u%*[^\n] ",&nb_points,&nb_primitives))!=2) {
31069  if (!file) cimg::fclose(nfile);
31070  throw CImgIOException("CImg<%s>::load_off() : File '%s', invalid vertices/primitives numbers.",
31071  pixel_type(),filename?filename:"(FILE*)");
31072  }
31073 
31074  // Read points data
31075  assign(nb_points,3);
31076  float X = 0, Y = 0, Z = 0;
31077  cimg_forX(*this,l) {
31078  do { err = std::fscanf(nfile,"%255[^\n] ",line); } while (!err || (err==1 && line[0]=='#'));
31079  if ((err = std::sscanf(line,"%f%f%f%*[^\n] ",&X,&Y,&Z))!=3) {
31080  if (!file) cimg::fclose(nfile);
31081  throw CImgIOException("CImg<%s>::load_off() : File '%s', cannot read point %u/%u.\n",
31082  pixel_type(),filename?filename:"(FILE*)",l+1,nb_points);
31083  }
31084  (*this)(l,0) = (T)X; (*this)(l,1) = (T)Y; (*this)(l,2) = (T)Z;
31085  }
31086 
31087  // Read primitive data
31088  primitives.assign();
31089  colors.assign();
31090  bool stopflag = false;
31091  while (!stopflag) {
31092  float c0 = 0.7f, c1 = 0.7f, c2 = 0.7f;
31093  unsigned int prim = 0, i0 = 0, i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0;
31094  line[0] = 0;
31095  if ((err = std::fscanf(nfile,"%u",&prim))!=1) stopflag=true;
31096  else {
31097  ++nb_read;
31098  switch (prim) {
31099  case 1 : {
31100  if ((err = std::fscanf(nfile,"%u%255[^\n] ",&i0,line))<2) {
31101  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31102  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31103  err = std::fscanf(nfile,"%*[^\n] ");
31104  } else {
31105  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31106  CImg<tf>::vector(i0).transfer_to(primitives);
31107  CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31108  }
31109  } break;
31110  case 2 : {
31111  if ((err = std::fscanf(nfile,"%u%u%255[^\n] ",&i0,&i1,line))<2) {
31112  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31113  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31114  err = std::fscanf(nfile,"%*[^\n] ");
31115  } else {
31116  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31117  CImg<tf>::vector(i0,i1).transfer_to(primitives);
31118  CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31119  }
31120  } break;
31121  case 3 : {
31122  if ((err = std::fscanf(nfile,"%u%u%u%255[^\n] ",&i0,&i1,&i2,line))<3) {
31123  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31124  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31125  err = std::fscanf(nfile,"%*[^\n] ");
31126  } else {
31127  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31128  CImg<tf>::vector(i0,i2,i1).transfer_to(primitives);
31129  CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)).transfer_to(colors);
31130  }
31131  } break;
31132  case 4 : {
31133  if ((err = std::fscanf(nfile,"%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,line))<4) {
31134  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31135  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31136  err = std::fscanf(nfile,"%*[^\n] ");
31137  } else {
31138  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31139  CImg<tf>::vector(i0,i3,i2,i1).transfer_to(primitives);
31140  CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)).transfer_to(colors);
31141  }
31142  } break;
31143  case 5 : {
31144  if ((err = std::fscanf(nfile,"%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,line))<5) {
31145  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31146  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31147  err = std::fscanf(nfile,"%*[^\n] ");
31148  } else {
31149  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31150  CImg<tf>::vector(i0,i3,i2,i1).transfer_to(primitives);
31151  CImg<tf>::vector(i0,i4,i3).transfer_to(primitives);
31152  colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)));
31153  ++nb_primitives;
31154  }
31155  } break;
31156  case 6 : {
31157  if ((err = std::fscanf(nfile,"%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,line))<6) {
31158  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31159  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31160  err = std::fscanf(nfile,"%*[^\n] ");
31161  } else {
31162  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31163  CImg<tf>::vector(i0,i3,i2,i1).transfer_to(primitives);
31164  CImg<tf>::vector(i0,i5,i4,i3).transfer_to(primitives);
31165  colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)));
31166  ++nb_primitives;
31167  }
31168  } break;
31169  case 7 : {
31170  if ((err = std::fscanf(nfile,"%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,line))<7) {
31171  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31172  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31173  err = std::fscanf(nfile,"%*[^\n] ");
31174  } else {
31175  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31176  CImg<tf>::vector(i0,i4,i3,i1).transfer_to(primitives);
31177  CImg<tf>::vector(i0,i6,i5,i4).transfer_to(primitives);
31178  CImg<tf>::vector(i3,i2,i1).transfer_to(primitives);
31179  colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)));
31180  ++(++nb_primitives);
31181  }
31182  } break;
31183  case 8 : {
31184  if ((err = std::fscanf(nfile,"%u%u%u%u%u%u%u%u%255[^\n] ",&i0,&i1,&i2,&i3,&i4,&i5,&i6,&i7,line))<7) {
31185  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u.",
31186  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives);
31187  err = std::fscanf(nfile,"%*[^\n] ");
31188  } else {
31189  err = std::sscanf(line,"%f%f%f",&c0,&c1,&c2);
31190  CImg<tf>::vector(i0,i3,i2,i1).transfer_to(primitives);
31191  CImg<tf>::vector(i0,i5,i4,i3).transfer_to(primitives);
31192  CImg<tf>::vector(i0,i7,i6,i5).transfer_to(primitives);
31193  colors.insert(2,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255),(tc)(c2*255)));
31194  ++(++nb_primitives);
31195  }
31196  } break;
31197  default :
31198  cimg::warn("CImg<%s>::load_off() : File '%s', invalid primitive %u/%u (%u vertices).",
31199  pixel_type(),filename?filename:"(FILE*)",nb_read,nb_primitives,prim);
31200  err = std::fscanf(nfile,"%*[^\n] ");
31201  }
31202  }
31203  }
31204  if (!file) cimg::fclose(nfile);
31205  if (primitives.width!=nb_primitives)
31206  cimg::warn("CImg<%s>::load_off() : File '%s', read only %u primitives instead of %u as claimed in the header.",
31207  pixel_type(),filename?filename:"(FILE*)",primitives.width,nb_primitives);
31208  return *this;
31209  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
CImg< T > & line(const unsigned int y0)
Get a line.
Definition: CImg.h:18421
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_pandore ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 30718 of file CImg.h.

Referenced by CImg< uintT >::load_pandore().

30718  {
30719 #define __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,ndim,stype) \
30720  cimg::fread(dims,nbdim,nfile); \
30721  if (endian) cimg::invert_endianness(dims,nbdim); \
30722  assign(nwidth,nheight,ndepth,ndim); \
30723  const unsigned int siz = size(); \
30724  stype *buffer = new stype[siz]; \
30725  cimg::fread(buffer,siz,nfile); \
30726  if (endian) cimg::invert_endianness(buffer,siz); \
30727  T *ptrd = data; \
30728  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++); \
30729  buffer-=siz; \
30730  delete[] buffer
30731 
30732 #define _cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1,stype2,stype3,ltype) { \
30733  if (sizeof(stype1)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype1); } \
30734  else if (sizeof(stype2)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype2); } \
30735  else if (sizeof(stype3)==ltype) { __cimg_load_pandore_case(nbdim,nwidth,nheight,ndepth,dim,stype3); } \
30736  else throw CImgIOException("CImg<%s>::load_pandore() : File '%s' cannot be read, datatype not supported on this architecture.", \
30737  pixel_type(),filename?filename:"(FILE*)"); }
30738 
30739  if (!filename && !file)
30740  throw CImgArgumentException("CImg<%s>::load_pandore() : Cannot load (null) filename.",
30741  pixel_type());
30742  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
30743  typedef unsigned char uchar;
30744  typedef unsigned short ushort;
30745  typedef unsigned int uint;
30746  typedef unsigned long ulong;
30747  char header[32] = { 0 };
30748  cimg::fread(header,12,nfile);
30749  if (cimg::strncasecmp("PANDORE",header,7)) {
30750  if (!file) cimg::fclose(nfile);
30751  throw CImgIOException("CImg<%s>::load_pandore() : File '%s' is not a valid PANDORE file, "
30752  "(PANDORE identifier not found).",
30753  pixel_type(),filename?filename:"(FILE*)");
30754  }
30755  unsigned int imageid, dims[8] = { 0 };
30756  cimg::fread(&imageid,1,nfile);
30757  const bool endian = (imageid>255);
30758  if (endian) cimg::invert_endianness(imageid);
30759  cimg::fread(header,20,nfile);
30760 
30761  switch (imageid) {
30762  case 2: _cimg_load_pandore_case(2,dims[1],1,1,1,uchar,uchar,uchar,1); break;
30763  case 3: _cimg_load_pandore_case(2,dims[1],1,1,1,long,int,short,4); break;
30764  case 4: _cimg_load_pandore_case(2,dims[1],1,1,1,double,float,float,4); break;
30765  case 5: _cimg_load_pandore_case(3,dims[2],dims[1],1,1,uchar,uchar,uchar,1); break;
30766  case 6: _cimg_load_pandore_case(3,dims[2],dims[1],1,1,long,int,short,4); break;
30767  case 7: _cimg_load_pandore_case(3,dims[2],dims[1],1,1,double,float,float,4); break;
30768  case 8: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,uchar,uchar,uchar,1); break;
30769  case 9: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,long,int,short,4); break;
30770  case 10: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],1,double,float,float,4); break;
30771  case 11 : { // Region 1D
30772  cimg::fread(dims,3,nfile);
30773  if (endian) cimg::invert_endianness(dims,3);
30774  assign(dims[1],1,1,1);
30775  const unsigned siz = size();
30776  if (dims[2]<256) {
30777  unsigned char *buffer = new unsigned char[siz];
30778  cimg::fread(buffer,siz,nfile);
30779  T *ptrd = data;
30780  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30781  buffer-=siz;
30782  delete[] buffer;
30783  } else {
30784  if (dims[2]<65536) {
30785  unsigned short *buffer = new unsigned short[siz];
30786  cimg::fread(buffer,siz,nfile);
30787  if (endian) cimg::invert_endianness(buffer,siz);
30788  T *ptrd = data;
30789  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30790  buffer-=siz;
30791  delete[] buffer;
30792  } else {
30793  unsigned int *buffer = new unsigned int[siz];
30794  cimg::fread(buffer,siz,nfile);
30795  if (endian) cimg::invert_endianness(buffer,siz);
30796  T *ptrd = data;
30797  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30798  buffer-=siz;
30799  delete[] buffer;
30800  }
30801  }
30802  }
30803  break;
30804  case 12 : { // Region 2D
30805  cimg::fread(dims,4,nfile);
30806  if (endian) cimg::invert_endianness(dims,4);
30807  assign(dims[2],dims[1],1,1);
30808  const unsigned int siz = size();
30809  if (dims[3]<256) {
30810  unsigned char *buffer = new unsigned char[siz];
30811  cimg::fread(buffer,siz,nfile);
30812  T *ptrd = data;
30813  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30814  buffer-=siz;
30815  delete[] buffer;
30816  } else {
30817  if (dims[3]<65536) {
30818  unsigned short *buffer = new unsigned short[siz];
30819  cimg::fread(buffer,siz,nfile);
30820  if (endian) cimg::invert_endianness(buffer,siz);
30821  T *ptrd = data;
30822  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30823  buffer-=siz;
30824  delete[] buffer;
30825  } else {
30826  unsigned long *buffer = new unsigned long[siz];
30827  cimg::fread(buffer,siz,nfile);
30828  if (endian) cimg::invert_endianness(buffer,siz);
30829  T *ptrd = data;
30830  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30831  buffer-=siz;
30832  delete[] buffer;
30833  }
30834  }
30835  }
30836  break;
30837  case 13 : { // Region 3D
30838  cimg::fread(dims,5,nfile);
30839  if (endian) cimg::invert_endianness(dims,5);
30840  assign(dims[3],dims[2],dims[1],1);
30841  const unsigned int siz = size();
30842  if (dims[4]<256) {
30843  unsigned char *buffer = new unsigned char[siz];
30844  cimg::fread(buffer,siz,nfile);
30845  T *ptrd = data;
30846  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30847  buffer-=siz;
30848  delete[] buffer;
30849  } else {
30850  if (dims[4]<65536) {
30851  unsigned short *buffer = new unsigned short[siz];
30852  cimg::fread(buffer,siz,nfile);
30853  if (endian) cimg::invert_endianness(buffer,siz);
30854  T *ptrd = data;
30855  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30856  buffer-=siz;
30857  delete[] buffer;
30858  } else {
30859  unsigned int *buffer = new unsigned int[siz];
30860  cimg::fread(buffer,siz,nfile);
30861  if (endian) cimg::invert_endianness(buffer,siz);
30862  T *ptrd = data;
30863  cimg_foroff(*this,off) *(ptrd++) = (T)*(buffer++);
30864  buffer-=siz;
30865  delete[] buffer;
30866  }
30867  }
30868  }
30869  break;
30870  case 16: _cimg_load_pandore_case(4,dims[2],dims[1],1,3,uchar,uchar,uchar,1); break;
30871  case 17: _cimg_load_pandore_case(4,dims[2],dims[1],1,3,long,int,short,4); break;
30872  case 18: _cimg_load_pandore_case(4,dims[2],dims[1],1,3,double,float,float,4); break;
30873  case 19: _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,uchar,uchar,uchar,1); break;
30874  case 20: _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,long,int,short,4); break;
30875  case 21: _cimg_load_pandore_case(5,dims[3],dims[2],dims[1],3,double,float,float,4); break;
30876  case 22: _cimg_load_pandore_case(2,dims[1],1,1,dims[0],uchar,uchar,uchar,1); break;
30877  case 23: _cimg_load_pandore_case(2,dims[1],1,1,dims[0],long,int,short,4);
30878  case 24: _cimg_load_pandore_case(2,dims[1],1,1,dims[0],ulong,uint,ushort,4); break;
30879  case 25: _cimg_load_pandore_case(2,dims[1],1,1,dims[0],double,float,float,4); break;
30880  case 26: _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],uchar,uchar,uchar,1); break;
30881  case 27: _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],long,int,short,4); break;
30882  case 28: _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],ulong,uint,ushort,4); break;
30883  case 29: _cimg_load_pandore_case(3,dims[2],dims[1],1,dims[0],double,float,float,4); break;
30884  case 30: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],uchar,uchar,uchar,1); break;
30885  case 31: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],long,int,short,4); break;
30886  case 32: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],ulong,uint,ushort,4); break;
30887  case 33: _cimg_load_pandore_case(4,dims[3],dims[2],dims[1],dims[0],double,float,float,4); break;
30888  case 34 : { // Points 1D
30889  int ptbuf[4] = { 0 };
30890  cimg::fread(ptbuf,1,nfile);
30891  if (endian) cimg::invert_endianness(ptbuf,1);
30892  assign(1); (*this)(0) = (T)ptbuf[0];
30893  } break;
30894  case 35 : { // Points 2D
30895  int ptbuf[4] = { 0 };
30896  cimg::fread(ptbuf,2,nfile);
30897  if (endian) cimg::invert_endianness(ptbuf,2);
30898  assign(2); (*this)(0) = (T)ptbuf[1]; (*this)(1) = (T)ptbuf[0];
30899  } break;
30900  case 36 : { // Points 3D
30901  int ptbuf[4] = { 0 };
30902  cimg::fread(ptbuf,3,nfile);
30903  if (endian) cimg::invert_endianness(ptbuf,3);
30904  assign(3); (*this)(0) = (T)ptbuf[2]; (*this)(1) = (T)ptbuf[1]; (*this)(2) = (T)ptbuf[0];
30905  } break;
30906  default :
30907  if (!file) cimg::fclose(nfile);
30908  throw CImgIOException("CImg<%s>::load_pandore() : File '%s', cannot read images with ID_type = %u",
30909  pixel_type(),filename?filename:"(FILE*)",imageid);
30910  }
30911  if (!file) cimg::fclose(nfile);
30912  return *this;
30913  }
if(dy > dx)
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
double s
Definition: blastest.C:80
#define _cimg_load_pandore_case(nbdim, nwidth, nheight, ndepth, dim, stype1, stype2, stype3, ltype)
CImg< T > & load_pandore(const char *const filename)
Load an image from a PANDORE file.
Definition: CImg.h:30701
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
systems whose!Fortran compilers support!instead of just C or *for comments can!globally replace a C in the first column with
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define cimg_foroff(img, off)
Definition: CImg.h:590
CImg()
Default constructor.
Definition: CImg.h:9857
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_png ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29669 of file CImg.h.

Referenced by CImg< uintT >::load_png().

29669  {
29670  if (!filename && !file)
29671  throw CImgArgumentException("CImg<%s>::load_png() : Cannot load (null) filename.",
29672  pixel_type());
29673 #ifndef cimg_use_png
29674  if (file)
29675  throw CImgIOException("CImg<%s>::load_png() : File '(FILE*)' cannot be read without using libpng.",
29676  pixel_type());
29677  else return load_other(filename);
29678 #else
29679  // Open file and check for PNG validity
29680  const char *volatile nfilename = filename; // two 'volatile' here to remove a g++ warning due to 'setjmp'.
29681  std::FILE *volatile nfile = file?file:cimg::fopen(nfilename,"rb");
29682 
29683  unsigned char pngCheck[8] = { 0 };
29684  cimg::fread(pngCheck,8,(std::FILE*)nfile);
29685  if (png_sig_cmp(pngCheck,0,8)) {
29686  if (!file) cimg::fclose(nfile);
29687  throw CImgIOException("CImg<%s>::load_png() : File '%s' is not a valid PNG file.",
29688  pixel_type(),nfilename?nfilename:"(FILE*)");
29689  }
29690 
29691  // Setup PNG structures for read
29692  png_voidp user_error_ptr = 0;
29693  png_error_ptr user_error_fn = 0, user_warning_fn = 0;
29694  png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,user_error_ptr,user_error_fn,user_warning_fn);
29695  if (!png_ptr) {
29696  if (!file) cimg::fclose(nfile);
29697  throw CImgIOException("CImg<%s>::load_png() : File '%s', trouble initializing 'png_ptr' data structure.",
29698  pixel_type(),nfilename?nfilename:"(FILE*)");
29699  }
29700  png_infop info_ptr = png_create_info_struct(png_ptr);
29701  if (!info_ptr) {
29702  if (!file) cimg::fclose(nfile);
29703  png_destroy_read_struct(&png_ptr,(png_infopp)0,(png_infopp)0);
29704  throw CImgIOException("CImg<%s>::load_png() : File '%s', trouble initializing 'info_ptr' data structure.",
29705  pixel_type(),nfilename?nfilename:"(FILE*)");
29706  }
29707  png_infop end_info = png_create_info_struct(png_ptr);
29708  if (!end_info) {
29709  if (!file) cimg::fclose(nfile);
29710  png_destroy_read_struct(&png_ptr,&info_ptr,(png_infopp)0);
29711  throw CImgIOException("CImg<%s>::load_png() : File '%s', trouble initializing 'end_info' data structure.",
29712  pixel_type(),nfilename?nfilename:"(FILE*)");
29713  }
29714 
29715  // Error handling callback for png file reading
29716  if (setjmp(png_jmpbuf(png_ptr))) {
29717  if (!file) cimg::fclose((std::FILE*)nfile);
29718  png_destroy_read_struct(&png_ptr, &end_info, (png_infopp)0);
29719  throw CImgIOException("CImg<%s>::load_png() : File '%s', unknown fatal error.",
29720  pixel_type(),nfilename?nfilename:"(FILE*)");
29721  }
29722  png_init_io(png_ptr, nfile);
29723  png_set_sig_bytes(png_ptr, 8);
29724 
29725  // Get PNG Header Info up to data block
29726  png_read_info(png_ptr,info_ptr);
29727  png_uint_32 W, H;
29728  int bit_depth, color_type, interlace_type;
29729  png_get_IHDR(png_ptr,info_ptr,&W,&H,&bit_depth,&color_type,&interlace_type,int_p_NULL,int_p_NULL);
29730  int new_bit_depth = bit_depth;
29731  int new_color_type = color_type;
29732 
29733  // Transforms to unify image data
29734  if (new_color_type == PNG_COLOR_TYPE_PALETTE){
29735  png_set_palette_to_rgb(png_ptr);
29736  new_color_type -= PNG_COLOR_MASK_PALETTE;
29737  new_bit_depth = 8;
29738  }
29739  if (new_color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8){
29740  png_set_gray_1_2_4_to_8(png_ptr);
29741  new_bit_depth = 8;
29742  }
29743  if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
29744  png_set_tRNS_to_alpha(png_ptr);
29745  if (new_color_type == PNG_COLOR_TYPE_GRAY || new_color_type == PNG_COLOR_TYPE_GRAY_ALPHA){
29746  png_set_gray_to_rgb(png_ptr);
29747  new_color_type |= PNG_COLOR_MASK_COLOR;
29748  }
29749  if (new_color_type == PNG_COLOR_TYPE_RGB)
29750  png_set_filler(png_ptr, 0xffffU, PNG_FILLER_AFTER);
29751  png_read_update_info(png_ptr,info_ptr);
29752  if (!(new_bit_depth==8 || new_bit_depth==16)) {
29753  if (!file) cimg::fclose(nfile);
29754  png_destroy_read_struct(&png_ptr, &end_info, (png_infopp)0);
29755  throw CImgIOException("CImg<%s>::load_png() : File '%s', wrong bit coding (bit_depth=%u)",
29756  pixel_type(),nfilename?nfilename:"(FILE*)",new_bit_depth);
29757  }
29758  const int byte_depth = new_bit_depth>>3;
29759 
29760  // Allocate Memory for Image Read
29761  png_bytep *imgData = new png_bytep[H];
29762  for (unsigned int row = 0; row<H; ++row) imgData[row] = new png_byte[byte_depth*4*W];
29763  png_read_image(png_ptr,imgData);
29764  png_read_end(png_ptr,end_info);
29765 
29766  // Read pixel data
29767  if (!(new_color_type==PNG_COLOR_TYPE_RGB || new_color_type==PNG_COLOR_TYPE_RGB_ALPHA)) {
29768  if (!file) cimg::fclose(nfile);
29769  png_destroy_read_struct(&png_ptr,&end_info,(png_infopp)0);
29770  throw CImgIOException("CImg<%s>::load_png() : File '%s', wrong color coding (new_color_type=%u)",
29771  pixel_type(),nfilename?nfilename:"(FILE*)",new_color_type);
29772  }
29773  const bool no_alpha_channel = (new_color_type==PNG_COLOR_TYPE_RGB);
29774  assign(W,H,1,no_alpha_channel?3:4);
29775  T *ptr1 = ptr(0,0,0,0), *ptr2 = ptr(0,0,0,1), *ptr3 = ptr(0,0,0,2), *ptr4 = ptr(0,0,0,3);
29776  switch (new_bit_depth) {
29777  case 8 : {
29778  cimg_forY(*this,y){
29779  const unsigned char *ptrs = (unsigned char*)imgData[y];
29780  cimg_forX(*this,x){
29781  *(ptr1++) = (T)*(ptrs++);
29782  *(ptr2++) = (T)*(ptrs++);
29783  *(ptr3++) = (T)*(ptrs++);
29784  if (no_alpha_channel) ++ptrs; else *(ptr4++) = (T)*(ptrs++);
29785  }
29786  }
29787  } break;
29788  case 16 : {
29789  cimg_forY(*this,y){
29790  const unsigned short *ptrs = (unsigned short*)(imgData[y]);
29792  cimg_forX(*this,x){
29793  *(ptr1++) = (T)*(ptrs++);
29794  *(ptr2++) = (T)*(ptrs++);
29795  *(ptr3++) = (T)*(ptrs++);
29796  if (no_alpha_channel) ++ptrs; else *(ptr4++) = (T)*(ptrs++);
29797  }
29798  }
29799  } break;
29800  }
29801  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
29802 
29803  // Deallocate Image Read Memory
29804  cimg_forY(*this,n) delete[] imgData[n];
29805  delete[] imgData;
29806  if (!file) cimg::fclose(nfile);
29807  return *this;
29808 #endif
29809  }
if(dy > dx)
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
const NT & n
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_pnm ( std::FILE *const  file,
const char *const  filename 
)
inline

Definition at line 29829 of file CImg.h.

Referenced by CImg< uintT >::load_pnm().

29829  {
29830  if (!filename && !file)
29831  throw CImgArgumentException("CImg<%s>::load_pnm() : Cannot load (null) filename.",
29832  pixel_type());
29833  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
29834  unsigned int ppm_type, W, H, colormax = 255;
29835  char item[1024] = { 0 };
29836  int err, rval, gval, bval;
29837  const int cimg_iobuffer = 12*1024*1024;
29838  while ((err=std::fscanf(nfile,"%1023[^\n]",item))!=EOF && (item[0]=='#' || !err)) std::fgetc(nfile);
29839  if (std::sscanf(item," P%u",&ppm_type)!=1) {
29840  if (!file) cimg::fclose(nfile);
29841  throw CImgIOException("CImg<%s>::load_pnm() : File '%s', PNM header 'P?' not found.",
29842  pixel_type(),filename?filename:"(FILE*)");
29843  }
29844  while ((err=std::fscanf(nfile," %1023[^\n]",item))!=EOF && (item[0]=='#' || !err)) std::fgetc(nfile);
29845  if ((err=std::sscanf(item," %u %u %u",&W,&H,&colormax))<2) {
29846  if (!file) cimg::fclose(nfile);
29847  throw CImgIOException("CImg<%s>::load_pnm() : File '%s', WIDTH and HEIGHT fields are not defined in PNM header.",
29848  pixel_type(),filename?filename:"(FILE*)");
29849  }
29850  if (err==2) {
29851  while ((err=std::fscanf(nfile," %1023[^\n]",item))!=EOF && (item[0]=='#' || !err)) std::fgetc(nfile);
29852  if (std::sscanf(item,"%u",&colormax)!=1)
29853  cimg::warn("CImg<%s>::load_pnm() : File '%s', COLORMAX field is not defined in PNM header.",
29854  pixel_type(),filename?filename:"(FILE*)");
29855  }
29856  std::fgetc(nfile);
29857  assign();
29858 
29859  switch (ppm_type) {
29860  case 2 : { // Grey Ascii
29861  assign(W,H,1,1);
29862  T* rdata = data;
29863  cimg_foroff(*this,off) { if (std::fscanf(nfile,"%d",&rval)>0) *(rdata++) = (T)rval; else break; }
29864  } break;
29865  case 3 : { // Color Ascii
29866  assign(W,H,1,3);
29867  T *rdata = ptr(0,0,0,0), *gdata = ptr(0,0,0,1), *bdata = ptr(0,0,0,2);
29868  cimg_forXY(*this,x,y) {
29869  if (std::fscanf(nfile,"%d %d %d",&rval,&gval,&bval)==3) { *(rdata++) = (T)rval; *(gdata++) = (T)gval; *(bdata++) = (T)bval; }
29870  else break;
29871  }
29872  } break;
29873  case 5 : { // Grey Binary
29874  if (colormax<256) { // 8 bits
29875  CImg<ucharT> raw;
29876  assign(W,H,1,1);
29877  T *ptrd = ptr(0,0,0,0);
29878  for (int toread = (int)size(); toread>0; ) {
29879  raw.assign(cimg::min(toread,cimg_iobuffer));
29880  cimg::fread(raw.data,raw.width,nfile);
29881  toread-=raw.width;
29882  const unsigned char *ptrs = raw.data;
29883  for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++);
29884  }
29885  } else { // 16 bits
29886  CImg<ushortT> raw;
29887  assign(W,H,1,1);
29888  T *ptrd = ptr(0,0,0,0);
29889  for (int toread = (int)size(); toread>0; ) {
29890  raw.assign(cimg::min(toread,cimg_iobuffer/2));
29891  cimg::fread(raw.data,raw.width,nfile);
29892  if (!cimg::endianness()) cimg::invert_endianness(raw.data,raw.width);
29893  toread-=raw.width;
29894  const unsigned short *ptrs = raw.data;
29895  for (unsigned int off = raw.width; off; --off) *(ptrd++) = (T)*(ptrs++);
29896  }
29897  }
29898  } break;
29899  case 6 : { // Color Binary
29900  if (colormax<256) { // 8 bits
29901  CImg<ucharT> raw;
29902  assign(W,H,1,3);
29903  T
29904  *ptr_r = ptr(0,0,0,0),
29905  *ptr_g = ptr(0,0,0,1),
29906  *ptr_b = ptr(0,0,0,2);
29907  for (int toread = (int)size(); toread>0; ) {
29908  raw.assign(cimg::min(toread,cimg_iobuffer));
29909  cimg::fread(raw.data,raw.width,nfile);
29910  toread-=raw.width;
29911  const unsigned char *ptrs = raw.data;
29912  for (unsigned int off = raw.width/3; off; --off) {
29913  *(ptr_r++) = (T)*(ptrs++);
29914  *(ptr_g++) = (T)*(ptrs++);
29915  *(ptr_b++) = (T)*(ptrs++);
29916  }
29917  }
29918  } else { // 16 bits
29919  CImg<ushortT> raw;
29920  assign(W,H,1,3);
29921  T
29922  *ptr_r = ptr(0,0,0,0),
29923  *ptr_g = ptr(0,0,0,1),
29924  *ptr_b = ptr(0,0,0,2);
29925  for (int toread = (int)size(); toread>0; ) {
29926  raw.assign(cimg::min(toread,cimg_iobuffer/2));
29927  cimg::fread(raw.data,raw.width,nfile);
29928  if (!cimg::endianness()) cimg::invert_endianness(raw.data,raw.width);
29929  toread-=raw.width;
29930  const unsigned short *ptrs = raw.data;
29931  for (unsigned int off = raw.width/3; off; --off) {
29932  *(ptr_r++) = (T)*(ptrs++);
29933  *(ptr_g++) = (T)*(ptrs++);
29934  *(ptr_b++) = (T)*(ptrs++);
29935  }
29936  }
29937  }
29938  } break;
29939  default :
29940  if (!file) cimg::fclose(nfile);
29941  throw CImgIOException("CImg<%s>::load_pnm() : File '%s', PPM type 'P%d' not supported.",
29942  pixel_type(),filename?filename:"(FILE*)",ppm_type);
29943  }
29944  if (!file) cimg::fclose(nfile);
29945  return *this;
29946  }
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
void int int REAL REAL * y
Definition: read.cpp:74
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_raw ( std::FILE *const  file,
const char *const  filename,
const unsigned int  sizex,
const unsigned int  sizey,
const unsigned int  sizez,
const unsigned int  sizev,
const bool  multiplexed,
const bool  invert_endianness 
)
inline

Definition at line 30957 of file CImg.h.

Referenced by CImg< uintT >::load_raw().

30960  {
30961  if (!filename && !file)
30962  throw CImgArgumentException("CImg<%s>::load_raw() : Cannot load (null) filename.",
30963  pixel_type());
30964  assign(sizex,sizey,sizez,sizev,0);
30965  const unsigned int siz = size();
30966  if (siz) {
30967  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
30968  if (!multiplexed) {
30969  cimg::fread(data,siz,nfile);
30971  }
30972  else {
30973  CImg<T> buf(1,1,1,sizev);
30974  cimg_forXYZ(*this,x,y,z) {
30975  cimg::fread(buf.data,sizev,nfile);
30976  if (invert_endianness) cimg::invert_endianness(buf.data,sizev);
30977  set_vector_at(buf,x,y,z); }
30978  }
30979  if (!file) cimg::fclose(nfile);
30980  }
30981  return *this;
30982  }
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
Definition: CImg.h:14951
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
void int int REAL REAL * y
Definition: read.cpp:74
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
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...
Definition: CImg.h:13298
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_rgb ( std::FILE *const  file,
const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh 
)
inline

Definition at line 29966 of file CImg.h.

Referenced by CImg< uintT >::load_rgb().

29966  {
29967  if (!filename && !file)
29968  throw CImgArgumentException("CImg<%s>::load_rgb() : Cannot load (null) filename.",
29969  pixel_type());
29970  if (!dimw || !dimh) return assign();
29971  const int cimg_iobuffer = 12*1024*1024;
29972  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
29973  CImg<ucharT> raw;
29974  assign(dimw,dimh,1,3);
29975  T
29976  *ptr_r = ptr(0,0,0,0),
29977  *ptr_g = ptr(0,0,0,1),
29978  *ptr_b = ptr(0,0,0,2);
29979  for (int toread = (int)size(); toread>0; ) {
29980  raw.assign(cimg::min(toread,cimg_iobuffer));
29981  cimg::fread(raw.data,raw.width,nfile);
29982  toread-=raw.width;
29983  const unsigned char *ptrs = raw.data;
29984  for (unsigned int off = raw.width/3; off; --off) {
29985  *(ptr_r++) = (T)*(ptrs++);
29986  *(ptr_g++) = (T)*(ptrs++);
29987  *(ptr_b++) = (T)*(ptrs++);
29988  }
29989  }
29990  if (!file) cimg::fclose(nfile);
29991  return *this;
29992  }
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _load_rgba ( std::FILE *const  file,
const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh 
)
inline

Definition at line 30012 of file CImg.h.

Referenced by CImg< uintT >::load_rgba().

30012  {
30013  if (!filename && !file)
30014  throw CImgArgumentException("CImg<%s>::load_rgba() : Cannot load (null) filename.",
30015  pixel_type());
30016  if (!dimw || !dimh) return assign();
30017  const int cimg_iobuffer = 12*1024*1024;
30018  std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
30019  CImg<ucharT> raw;
30020  assign(dimw,dimh,1,4);
30021  T
30022  *ptr_r = ptr(0,0,0,0),
30023  *ptr_g = ptr(0,0,0,1),
30024  *ptr_b = ptr(0,0,0,2),
30025  *ptr_a = ptr(0,0,0,3);
30026  for (int toread = (int)size(); toread>0; ) {
30027  raw.assign(cimg::min(toread,cimg_iobuffer));
30028  cimg::fread(raw.data,raw.width,nfile);
30029  toread-=raw.width;
30030  const unsigned char *ptrs = raw.data;
30031  for (unsigned int off = raw.width/4; off; --off) {
30032  *(ptr_r++) = (T)*(ptrs++);
30033  *(ptr_g++) = (T)*(ptrs++);
30034  *(ptr_b++) = (T)*(ptrs++);
30035  *(ptr_a++) = (T)*(ptrs++);
30036  }
30037  }
30038  if (!file) cimg::fclose(nfile);
30039  return *this;
30040  }
int fread(T *const ptr, const unsigned int nmemb, std::FILE *stream)
Read file data, and check for possible errors.
Definition: CImg.h:5569
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& _LU ( CImg< t > &  indx,
bool &  d 
)
inline

Definition at line 13994 of file CImg.h.

13994  {
13995  const int N = dimx();
13996  int imax = 0;
13997  CImg<Tfloat> vv(N);
13998  indx.assign(N);
13999  d = true;
14000  cimg_forX(*this,i) {
14001  Tfloat vmax = 0;
14002  cimg_forX(*this,j) {
14003  const Tfloat tmp = cimg::abs((*this)(j,i));
14004  if (tmp>vmax) vmax = tmp;
14005  }
14006  if (vmax==0) { indx.fill(0); return fill(0); }
14007  vv[i] = 1/vmax;
14008  }
14009  cimg_forX(*this,j) {
14010  for (int i = 0; i<j; ++i) {
14011  Tfloat sum=(*this)(j,i);
14012  for (int k = 0; k<i; ++k) sum-=(*this)(k,i)*(*this)(j,k);
14013  (*this)(j,i) = (T)sum;
14014  }
14015  Tfloat vmax = 0;
14016  for (int i = j; i<dimx(); ++i) {
14017  Tfloat sum=(*this)(j,i);
14018  for (int k = 0; k<j; ++k) sum-=(*this)(k,i)*(*this)(j,k);
14019  (*this)(j,i) = (T)sum;
14020  const Tfloat tmp = vv[i]*cimg::abs(sum);
14021  if (tmp>=vmax) { vmax=tmp; imax=i; }
14022  }
14023  if (j!=imax) {
14024  cimg_forX(*this,k) cimg::swap((*this)(k,imax),(*this)(k,j));
14025  d =!d;
14026  vv[imax] = vv[j];
14027  }
14028  indx[j] = (t)imax;
14029  if ((*this)(j,j)==0) (*this)(j,j) = (T)1e-20;
14030  if (j<N) {
14031  const Tfloat tmp = 1/(Tfloat)(*this)(j,j);
14032  for (int i=j+1; i<N; ++i) (*this)(j,i) = (T)((*this)(j,i)*tmp);
14033  }
14034  }
14035  return *this;
14036  }
if(dy > dx)
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
#define cimg_forX(img, x)
Definition: CImg.h:593
const NT & d
j indices k indices k
Definition: Indexing.h:6
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
blockLoc i
Definition: read.cpp:79
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
j indices j
Definition: Indexing.h:6
for(;;)
CImg< T > & swap(CImg< T > &img)
Swap all fields of two images. Use with care !
Definition: CImg.h:10357
static int _marching2d_indice ( const unsigned int  edge,
const CImg< t > &  indices1,
const CImg< t > &  indices2,
const unsigned int  x,
const unsigned int  nx 
)
inlinestatic

Definition at line 21418 of file CImg.h.

Referenced by CImg< uintT >::isocurve3d().

21419  {
21420  switch (edge) {
21421  case 0 : return (int)indices1(x,0);
21422  case 1 : return (int)indices1(nx,1);
21423  case 2 : return (int)indices2(x,0);
21424  case 3 : return (int)indices1(x,1);
21425  }
21426  return 0;
21427  }
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

static int _marching3d_indice ( const unsigned int  edge,
const CImg< t > &  indices1,
const CImg< t > &  indices2,
const unsigned int  x,
const unsigned int  y,
const unsigned int  nx,
const unsigned int  ny 
)
inlinestatic

Definition at line 21754 of file CImg.h.

Referenced by CImg< uintT >::isosurface3d().

21755  {
21756  switch (edge) {
21757  case 0 : return indices1(x,y,0);
21758  case 1 : return indices1(nx,y,1);
21759  case 2 : return indices1(x,ny,0);
21760  case 3 : return indices1(x,y,1);
21761  case 4 : return indices2(x,y,0);
21762  case 5 : return indices2(nx,y,1);
21763  case 6 : return indices2(x,ny,0);
21764  case 7 : return indices2(x,y,1);
21765  case 8 : return indices1(x,y,2);
21766  case 9 : return indices1(nx,y,2);
21767  case 10 : return indices1(nx,ny,2);
21768  case 11 : return indices1(x,ny,2);
21769  }
21770  return 0;
21771  }
void int int REAL REAL * y
Definition: read.cpp:74
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

CImg<T>& _quicksort ( const int  min,
const int  max,
CImg< t > &  permutations,
const bool  increasing 
)
inline

Definition at line 13794 of file CImg.h.

Referenced by CImg< uintT >::_quicksort(), and CImg< uintT >::sort().

13794  {
13795  if (min<max) {
13796  const int mid = (min+max)/2;
13797  if (increasing) {
13798  if ((*this)[min]>(*this)[mid]) {
13799  cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); }
13800  if ((*this)[mid]>(*this)[max]) {
13801  cimg::swap((*this)[max],(*this)[mid]); cimg::swap(permutations[max],permutations[mid]); }
13802  if ((*this)[min]>(*this)[mid]) {
13803  cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); }
13804  } else {
13805  if ((*this)[min]<(*this)[mid]) {
13806  cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); }
13807  if ((*this)[mid]<(*this)[max]) {
13808  cimg::swap((*this)[max],(*this)[mid]); cimg::swap(permutations[max],permutations[mid]); }
13809  if ((*this)[min]<(*this)[mid]) {
13810  cimg::swap((*this)[min],(*this)[mid]); cimg::swap(permutations[min],permutations[mid]); }
13811  }
13812  if (max-min>=3) {
13813  const T pivot = (*this)[mid];
13814  int i = min, j = max;
13815  if (increasing) {
13816  do {
13817  while ((*this)[i]<pivot) ++i;
13818  while ((*this)[j]>pivot) --j;
13819  if (i<=j) {
13820  cimg::swap((*this)[i],(*this)[j]);
13821  cimg::swap(permutations[i++],permutations[j--]);
13822  }
13823  } while (i<=j);
13824  } else {
13825  do {
13826  while ((*this)[i]>pivot) ++i;
13827  while ((*this)[j]<pivot) --j;
13828  if (i<=j) {
13829  cimg::swap((*this)[i],(*this)[j]);
13830  cimg::swap(permutations[i++],permutations[j--]);
13831  }
13832  } while (i<=j);
13833  }
13834  if (min<j) _quicksort(min,j,permutations,increasing);
13835  if (i<max) _quicksort(i,max,permutations,increasing);
13836  }
13837  }
13838  return *this;
13839  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
CImg< T > & _quicksort(const int min, const int max, CImg< t > &permutations, const bool increasing)
Definition: CImg.h:13794
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6

Here is the caller graph for this function:

const CImg<T>& _save_ascii ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 32357 of file CImg.h.

Referenced by CImg< uintT >::save_ascii().

32357  {
32358  if (is_empty())
32359  throw CImgInstanceException("CImg<%s>::save_ascii() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32360  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32361  if (!file && !filename)
32362  throw CImgArgumentException("CImg<%s>::save_ascii() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32364  std::FILE *const nfile = file?file:cimg::fopen(filename,"w");
32365  std::fprintf(nfile,"%u %u %u %u\n",width,height,depth,dim);
32366  const T* ptrs = data;
32367  cimg_forYZV(*this,y,z,v) {
32368  cimg_forX(*this,x) std::fprintf(nfile,"%g ",(double)*(ptrs++));
32369  std::fputc('\n',nfile);
32370  }
32371  if (!file) cimg::fclose(nfile);
32372  return *this;
32373  }
if(dy > dx)
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
const NT & n
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

const CImg<T>& _save_bmp ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 32458 of file CImg.h.

Referenced by CImg< uintT >::save_bmp().

32458  {
32459  if (is_empty())
32460  throw CImgInstanceException("CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32461  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32462  if (!file && !filename)
32463  throw CImgArgumentException("CImg<%s>::save_bmp() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32465  if (depth>1)
32466  cimg::warn("CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32467  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32468  if (dim>3)
32469  cimg::warn("CImg<%s>::save_bmp() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32470  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32471 
32472  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
32473  unsigned char header[54] = { 0 }, align_buf[4] = { 0 };
32474  const unsigned int
32475  align = (4 - (3*width)%4)%4,
32476  buf_size = (3*width+align)*dimy(),
32477  file_size = 54 + buf_size;
32478  header[0] = 'B'; header[1] = 'M';
32479  header[0x02] = file_size&0xFF;
32480  header[0x03] = (file_size>>8)&0xFF;
32481  header[0x04] = (file_size>>16)&0xFF;
32482  header[0x05] = (file_size>>24)&0xFF;
32483  header[0x0A] = 0x36;
32484  header[0x0E] = 0x28;
32485  header[0x12] = width&0xFF;
32486  header[0x13] = (width>>8)&0xFF;
32487  header[0x14] = (width>>16)&0xFF;
32488  header[0x15] = (width>>24)&0xFF;
32489  header[0x16] = height&0xFF;
32490  header[0x17] = (height>>8)&0xFF;
32491  header[0x18] = (height>>16)&0xFF;
32492  header[0x19] = (height>>24)&0xFF;
32493  header[0x1A] = 1;
32494  header[0x1B] = 0;
32495  header[0x1C] = 24;
32496  header[0x1D] = 0;
32497  header[0x22] = buf_size&0xFF;
32498  header[0x23] = (buf_size>>8)&0xFF;
32499  header[0x24] = (buf_size>>16)&0xFF;
32500  header[0x25] = (buf_size>>24)&0xFF;
32501  header[0x27] = 0x1;
32502  header[0x2B] = 0x1;
32503  cimg::fwrite(header,54,nfile);
32504 
32505  const T
32506  *pR = ptr(0,height-1,0,0),
32507  *pG = (dim>=2)?ptr(0,height-1,0,1):0,
32508  *pB = (dim>=3)?ptr(0,height-1,0,2):0;
32509 
32510  switch (dim) {
32511  case 1 : {
32512  cimg_forY(*this,y) { cimg_forX(*this,x) {
32513  const unsigned char val = (unsigned char)*(pR++);
32514  std::fputc(val,nfile); std::fputc(val,nfile); std::fputc(val,nfile);
32515  }
32516  cimg::fwrite(align_buf,align,nfile);
32517  pR-=2*width;
32518  }} break;
32519  case 2 : {
32520  cimg_forY(*this,y) { cimg_forX(*this,x) {
32521  std::fputc(0,nfile);
32522  std::fputc((unsigned char)(*(pG++)),nfile);
32523  std::fputc((unsigned char)(*(pR++)),nfile);
32524  }
32525  cimg::fwrite(align_buf,align,nfile);
32526  pR-=2*width; pG-=2*width;
32527  }} break;
32528  default : {
32529  cimg_forY(*this,y) { cimg_forX(*this,x) {
32530  std::fputc((unsigned char)(*(pB++)),nfile);
32531  std::fputc((unsigned char)(*(pG++)),nfile);
32532  std::fputc((unsigned char)(*(pR++)),nfile);
32533  }
32534  cimg::fwrite(align_buf,align,nfile);
32535  pR-=2*width; pG-=2*width; pB-=2*width;
32536  }
32537  }
32538  }
32539  if (!file) cimg::fclose(nfile);
32540  return *this;
32541  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int REAL * x
Definition: read.cpp:74
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_cpp ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 32386 of file CImg.h.

Referenced by CImg< uintT >::save_cpp().

32386  {
32387  if (!file && !filename)
32388  throw CImgArgumentException("CImg<%s>::save_cpp() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32390  if (is_empty())
32391  throw CImgInstanceException("CImg<%s>::save_cpp() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32392  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32393  std::FILE *const nfile = file?file:cimg::fopen(filename,"w");
32394  char varname[1024] = { 0 };
32395  if (filename) std::sscanf(cimg::basename(filename),"%1023[a-zA-Z0-9_]",varname);
32396  if (!*varname) std::sprintf(varname,"unnamed");
32397  std::fprintf(nfile,
32398  "/* Define image '%s' of size %ux%ux%ux%u and type '%s' */\n"
32399  "%s data_%s[] = { \n ",
32400  varname,width,height,depth,dim,pixel_type(),pixel_type(),varname);
32401  for (unsigned int off = 0, siz = size()-1; off<=siz; ++off) {
32402  std::fprintf(nfile,cimg::type<T>::format(),cimg::type<T>::format((*this)[off]));
32403  if (off==siz) std::fprintf(nfile," };\n");
32404  else if (!((off+1)%16)) std::fprintf(nfile,",\n ");
32405  else std::fprintf(nfile,", ");
32406  }
32407  if (!file) cimg::fclose(nfile);
32408  return *this;
32409  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
const char * basename(const char *const s)
Compute the basename of a filename.
Definition: CImg.h:4989
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_dlm ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 32422 of file CImg.h.

Referenced by CImg< uintT >::save_dlm().

32422  {
32423  if (is_empty())
32424  throw CImgInstanceException("CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32425  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32426  if (!file && !filename)
32427  throw CImgArgumentException("CImg<%s>::save_dlm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32429  if (depth>1)
32430  cimg::warn("CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Pixel values along Z will be unrolled.",
32431  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32432  if (dim>1)
32433  cimg::warn("CImg<%s>::save_dlm() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. "
32434  "Pixel values along V will be unrolled.",
32435  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32436 
32437  std::FILE *const nfile = file?file:cimg::fopen(filename,"w");
32438  const T* ptrs = data;
32439  cimg_forYZV(*this,y,z,v) {
32440  cimg_forX(*this,x) std::fprintf(nfile,"%g%s",(double)*(ptrs++),(x==dimx()-1)?"":",");
32441  std::fputc('\n',nfile);
32442  }
32443  if (!file) cimg::fclose(nfile);
32444  return *this;
32445  }
if(dy > dx)
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
const NT & n
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

const CImg<T>& _save_inr ( std::FILE *const  file,
const char *const  filename,
const float *const  voxsize 
) const
inline

Definition at line 33328 of file CImg.h.

Referenced by CImg< uintT >::save_inr().

33328  {
33329  if (is_empty())
33330  throw CImgInstanceException("CImg<%s>::save_inr() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33331  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33332  if (!filename)
33333  throw CImgArgumentException("CImg<%s>::save_inr() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33335  int inrpixsize=-1;
33336  const char *inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0";
33337  if (!cimg::strcasecmp(pixel_type(),"unsigned char")) { inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; }
33338  if (!cimg::strcasecmp(pixel_type(),"char")) { inrtype = "fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; }
33339  if (!cimg::strcasecmp(pixel_type(),"unsigned short")) { inrtype = "unsigned fixed\nPIXSIZE=16 bits\nSCALE=2**0";inrpixsize = 2; }
33340  if (!cimg::strcasecmp(pixel_type(),"short")) { inrtype = "fixed\nPIXSIZE=16 bits\nSCALE=2**0"; inrpixsize = 2; }
33341  if (!cimg::strcasecmp(pixel_type(),"unsigned int")) { inrtype = "unsigned fixed\nPIXSIZE=32 bits\nSCALE=2**0";inrpixsize = 4; }
33342  if (!cimg::strcasecmp(pixel_type(),"int")) { inrtype = "fixed\nPIXSIZE=32 bits\nSCALE=2**0"; inrpixsize = 4; }
33343  if (!cimg::strcasecmp(pixel_type(),"float")) { inrtype = "float\nPIXSIZE=32 bits"; inrpixsize = 4; }
33344  if (!cimg::strcasecmp(pixel_type(),"double")) { inrtype = "float\nPIXSIZE=64 bits"; inrpixsize = 8; }
33345  if (inrpixsize<=0)
33346  throw CImgIOException("CImg<%s>::save_inr() : Don't know how to save images of '%s'",
33347  pixel_type(),pixel_type());
33348  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
33349  char header[257] = { 0 };
33350  int err = std::sprintf(header,"#INRIMAGE-4#{\nXDIM=%u\nYDIM=%u\nZDIM=%u\nVDIM=%u\n",width,height,depth,dim);
33351  if (voxsize) err += std::sprintf(header+err,"VX=%g\nVY=%g\nVZ=%g\n",voxsize[0],voxsize[1],voxsize[2]);
33352  err += std::sprintf(header+err,"TYPE=%s\nCPU=%s\n",inrtype,cimg::endianness()?"sun":"decm");
33353  std::memset(header+err,'\n',252-err);
33354  std::memcpy(header+252,"##}\n",4);
33355  cimg::fwrite(header,256,nfile);
33356  cimg_forXYZ(*this,x,y,z) cimg_forV(*this,k) cimg::fwrite(&((*this)(x,y,z,k)),1,nfile);
33357  if (!file) cimg::fclose(nfile);
33358  return *this;
33359  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_jpeg ( std::FILE *const  file,
const char *const  filename,
const unsigned int  quality 
) const
inline

Definition at line 32554 of file CImg.h.

Referenced by CImg< uintT >::save_jpeg().

32554  {
32555  if (is_empty())
32556  throw CImgInstanceException("CImg<%s>::save_jpeg() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32557  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32558  if (!file && !filename)
32559  throw CImgArgumentException("CImg<%s>::save_jpeg() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
32561  if (depth>1)
32562  cimg::warn("CImg<%s>::save_jpeg() : File '%s, instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32563  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32564 #ifndef cimg_use_jpeg
32565  if (!file) return save_other(filename,quality);
32566  else throw CImgIOException("CImg<%s>::save_jpeg() : Cannot save a JPEG image in a *FILE output. Use libjpeg instead.",
32567  pixel_type());
32568 #else
32569  // Fill pixel buffer
32570  unsigned char *buf;
32571  unsigned int dimbuf = 0;
32572  J_COLOR_SPACE colortype = JCS_RGB;
32573  switch (dim) {
32574  case 1 : { // Greyscale images
32575  unsigned char *buf2 = buf = new unsigned char[width*height*(dimbuf=1)];
32576  colortype = JCS_GRAYSCALE;
32577  const T *ptr_g = data;
32578  cimg_forXY(*this,x,y) *(buf2++) = (unsigned char)*(ptr_g++);
32579  } break;
32580  case 2 : { // RG images
32581  unsigned char *buf2 = buf = new unsigned char[width*height*(dimbuf=3)];
32582  const T *ptr_r = ptr(0,0,0,0), *ptr_g = ptr(0,0,0,1);
32583  colortype = JCS_RGB;
32584  cimg_forXY(*this,x,y) {
32585  *(buf2++) = (unsigned char)*(ptr_r++);
32586  *(buf2++) = (unsigned char)*(ptr_g++);
32587  *(buf2++) = 0;
32588  }
32589  } break;
32590  case 3 : { // RGB images
32591  unsigned char *buf2 = buf = new unsigned char[width*height*(dimbuf=3)];
32592  const T *ptr_r = ptr(0,0,0,0), *ptr_g = ptr(0,0,0,1), *ptr_b = ptr(0,0,0,2);
32593  colortype = JCS_RGB;
32594  cimg_forXY(*this,x,y) {
32595  *(buf2++) = (unsigned char)*(ptr_r++);
32596  *(buf2++) = (unsigned char)*(ptr_g++);
32597  *(buf2++) = (unsigned char)*(ptr_b++);
32598  }
32599  } break;
32600  default : { // CMYK images
32601  unsigned char *buf2 = buf = new unsigned char[width*height*(dimbuf=4)];
32602  const T *ptr_r = ptr(0,0,0,0), *ptr_g = ptr(0,0,0,1), *ptr_b = ptr(0,0,0,2), *ptr_a = ptr(0,0,0,3);
32603  colortype = JCS_CMYK;
32604  cimg_forXY(*this,x,y) {
32605  *(buf2++) = (unsigned char)*(ptr_r++);
32606  *(buf2++) = (unsigned char)*(ptr_g++);
32607  *(buf2++) = (unsigned char)*(ptr_b++);
32608  *(buf2++) = (unsigned char)*(ptr_a++);
32609  }
32610  }
32611  }
32612 
32613  // Call libjpeg functions
32614  struct jpeg_compress_struct cinfo;
32615  struct jpeg_error_mgr jerr;
32616  cinfo.err = jpeg_std_error(&jerr);
32617  jpeg_create_compress(&cinfo);
32618  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
32619  jpeg_stdio_dest(&cinfo,nfile);
32620  cinfo.image_width = width;
32621  cinfo.image_height = height;
32622  cinfo.input_components = dimbuf;
32623  cinfo.in_color_space = colortype;
32624  jpeg_set_defaults(&cinfo);
32625  jpeg_set_quality(&cinfo,quality<100?quality:100,TRUE);
32626  jpeg_start_compress(&cinfo,TRUE);
32627 
32628  const unsigned int row_stride = width*dimbuf;
32629  JSAMPROW row_pointer[1];
32630  while (cinfo.next_scanline < cinfo.image_height) {
32631  row_pointer[0] = &buf[cinfo.next_scanline*row_stride];
32632  jpeg_write_scanlines(&cinfo,row_pointer,1);
32633  }
32634  jpeg_finish_compress(&cinfo);
32635 
32636  delete[] buf;
32637  if (!file) cimg::fclose(nfile);
32638  jpeg_destroy_compress(&cinfo);
32639  return *this;
32640 #endif
32641  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
const CImg< T > & save_other(const char *const filename, const unsigned int quality=100) const
Definition: CImg.h:33819
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int REAL * x
Definition: read.cpp:74
#define TRUE
Definition: vinci.h:134
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_off ( std::FILE *const  file,
const char *const  filename,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors 
) const
inline

Definition at line 33607 of file CImg.h.

Referenced by CImg< uintT >::save_off().

33608  {
33609  if (is_empty())
33610  throw CImgInstanceException("CImg<%s>::save_off() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33611  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33612  if (!file && !filename)
33613  throw CImgArgumentException("CImg<%s>::save_off() : Specified filename is (null).",
33614  pixel_type());
33615  if (height<3) return get_resize(-100,3,1,1,0)._save_off(file,filename,primitives,colors);
33616  CImgList<tc> _colors;
33617  if (!colors) _colors.insert(primitives.width,CImg<tc>::vector(200,200,200));
33618  const CImgList<tc>& ncolors = colors?colors:_colors;
33619 
33620  std::FILE *const nfile = file?file:cimg::fopen(filename,"w");
33621  std::fprintf(nfile,"OFF\n%u %u %u\n",width,primitives.width,3*primitives.width);
33622  cimg_forX(*this,i) std::fprintf(nfile,"%f %f %f\n",(float)((*this)(i,0)),(float)((*this)(i,1)),(float)((*this)(i,2)));
33623  cimglist_for(primitives,l) {
33624  const unsigned int prim = primitives[l].size();
33625  const bool textured = (prim>4);
33626  const CImg<tc>& color = ncolors[l];
33627  const unsigned int s = textured?color.dimv():color.size();
33628  const float
33629  r = textured?(s>0?(float)(color.get_shared_channel(0).mean()/255.0f):1.0f):(s>0?(float)(color(0)/255.0f):1.0f),
33630  g = textured?(s>1?(float)(color.get_shared_channel(1).mean()/255.0f):r) :(s>1?(float)(color(1)/255.0f):r),
33631  b = textured?(s>2?(float)(color.get_shared_channel(2).mean()/255.0f):r) :(s>2?(float)(color(2)/255.0f):r);
33632 
33633  switch (prim) {
33634  case 1 :
33635  std::fprintf(nfile,"1 %u %f %f %f\n",(unsigned int)primitives(l,0),r,g,b);
33636  break;
33637  case 2 : case 6 :
33638  std::fprintf(nfile,"2 %u %u %f %f %f\n",(unsigned int)primitives(l,0),(unsigned int)primitives(l,1),r,g,b);
33639  break;
33640  case 3 : case 9 :
33641  std::fprintf(nfile,"3 %u %u %u %f %f %f\n",(unsigned int)primitives(l,0),(unsigned int)primitives(l,2),
33642  (unsigned int)primitives(l,1),r,g,b);
33643  break;
33644  case 4 : case 12 :
33645  std::fprintf(nfile,"4 %u %u %u %u %f %f %f\n",
33646  (unsigned int)primitives(l,0),(unsigned int)primitives(l,3),(unsigned int)primitives(l,2),
33647  (unsigned int)primitives(l,1),r,g,b);
33648  break;
33649  }
33650  }
33651  if (!file) cimg::fclose(nfile);
33652  return *this;
33653  }
#define cimg_forX(img, x)
Definition: CImg.h:593
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Tfloat mean() const
Return the mean pixel value of the instance image.
Definition: CImg.h:13032
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
blockLoc i
Definition: read.cpp:79
const NT & n
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_pandore ( std::FILE *const  file,
const char *const  filename,
const unsigned int  colorspace 
) const
inline

Definition at line 33385 of file CImg.h.

Referenced by CImg< uintT >::save_pandore().

33385  {
33386  typedef unsigned char uchar;
33387  typedef unsigned short ushort;
33388  typedef unsigned int uint;
33389  typedef unsigned long ulong;
33390 
33391 #define __cimg_save_pandore_case(dtype) \
33392  dtype *buffer = new dtype[size()]; \
33393  const T *ptrs = data; \
33394  cimg_foroff(*this,off) *(buffer++) = (dtype)(*(ptrs++)); \
33395  buffer-=size(); \
33396  cimg::fwrite(buffer,size(),nfile); \
33397  delete[] buffer
33398 
33399 #define _cimg_save_pandore_case(sy,sz,sv,stype,id) \
33400  if (!saved && (sy?(sy==height):true) && (sz?(sz==depth):true) && (sv?(sv==dim):true) && !std::strcmp(stype,pixel_type())) { \
33401  unsigned int *iheader = (unsigned int*)(header+12); \
33402  nbdims = _save_pandore_header_length((*iheader=id),dims,colorspace); \
33403  cimg::fwrite(header,36,nfile); \
33404  if (sizeof(ulong)==4) { ulong ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (ulong)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33405  else if (sizeof(uint)==4) { uint ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (uint)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33406  else if (sizeof(ushort)==4) { ushort ndims[5] = { 0 }; for (int d = 0; d<5; ++d) ndims[d] = (ushort)dims[d]; cimg::fwrite(ndims,nbdims,nfile); } \
33407  else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33408  "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33409  depth,dim,data); \
33410  if (id==2 || id==5 || id==8 || id==16 || id==19 || id==22 || id==26 || id==30) { \
33411  __cimg_save_pandore_case(uchar); \
33412  } else if (id==3 || id==6 || id==9 || id==17 || id==20 || id==23 || id==27 || id==31) { \
33413  if (sizeof(ulong)==4) { __cimg_save_pandore_case(ulong); } \
33414  else if (sizeof(uint)==4) { __cimg_save_pandore_case(uint); } \
33415  else if (sizeof(ushort)==4) { __cimg_save_pandore_case(ushort); } \
33416  else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33417  "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33418  depth,dim,data); \
33419  } else if (id==4 || id==7 || id==10 || id==18 || id==21 || id==25 || id==29 || id==33) { \
33420  if (sizeof(double)==4) { __cimg_save_pandore_case(double); } \
33421  else if (sizeof(float)==4) { __cimg_save_pandore_case(float); } \
33422  else throw CImgIOException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p), output type is not" \
33423  "supported on this architecture.",pixel_type(),filename?filename:"(FILE*)",width,height, \
33424  depth,dim,data); \
33425  } \
33426  saved = true; \
33427  }
33428 
33429  if (is_empty())
33430  throw CImgInstanceException("CImg<%s>::save_pandore() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33431  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33432  if (!file && !filename)
33433  throw CImgArgumentException("CImg<%s>::save_pandore() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33435  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
33436  unsigned char header[36] = { 'P','A','N','D','O','R','E','0','4',0,0,0,
33437  0,0,0,0,'C','I','m','g',0,0,0,0,0,'N','o',' ','d','a','t','e',0,0,0,0 };
33438  unsigned int nbdims, dims[5] = { 0 };
33439  bool saved = false;
33440  _cimg_save_pandore_case(1,1,1,"unsigned char",2);
33441  _cimg_save_pandore_case(1,1,1,"char",3);
33442  _cimg_save_pandore_case(1,1,1,"short",3);
33443  _cimg_save_pandore_case(1,1,1,"unsigned short",3);
33444  _cimg_save_pandore_case(1,1,1,"unsigned int",3);
33445  _cimg_save_pandore_case(1,1,1,"int",3);
33446  _cimg_save_pandore_case(1,1,1,"unsigned long",4);
33447  _cimg_save_pandore_case(1,1,1,"long",3);
33448  _cimg_save_pandore_case(1,1,1,"float",4);
33449  _cimg_save_pandore_case(1,1,1,"double",4);
33450 
33451  _cimg_save_pandore_case(0,1,1,"unsigned char",5);
33452  _cimg_save_pandore_case(0,1,1,"char",6);
33453  _cimg_save_pandore_case(0,1,1,"short",6);
33454  _cimg_save_pandore_case(0,1,1,"unsigned short",6);
33455  _cimg_save_pandore_case(0,1,1,"unsigned int",6);
33456  _cimg_save_pandore_case(0,1,1,"int",6);
33457  _cimg_save_pandore_case(0,1,1,"unsigned long",7);
33458  _cimg_save_pandore_case(0,1,1,"long",6);
33459  _cimg_save_pandore_case(0,1,1,"float",7);
33460  _cimg_save_pandore_case(0,1,1,"double",7);
33461 
33462  _cimg_save_pandore_case(0,0,1,"unsigned char",8);
33463  _cimg_save_pandore_case(0,0,1,"char",9);
33464  _cimg_save_pandore_case(0,0,1,"short",9);
33465  _cimg_save_pandore_case(0,0,1,"unsigned short",9);
33466  _cimg_save_pandore_case(0,0,1,"unsigned int",9);
33467  _cimg_save_pandore_case(0,0,1,"int",9);
33468  _cimg_save_pandore_case(0,0,1,"unsigned long",10);
33469  _cimg_save_pandore_case(0,0,1,"long",9);
33470  _cimg_save_pandore_case(0,0,1,"float",10);
33471  _cimg_save_pandore_case(0,0,1,"double",10);
33472 
33473  _cimg_save_pandore_case(0,1,3,"unsigned char",16);
33474  _cimg_save_pandore_case(0,1,3,"char",17);
33475  _cimg_save_pandore_case(0,1,3,"short",17);
33476  _cimg_save_pandore_case(0,1,3,"unsigned short",17);
33477  _cimg_save_pandore_case(0,1,3,"unsigned int",17);
33478  _cimg_save_pandore_case(0,1,3,"int",17);
33479  _cimg_save_pandore_case(0,1,3,"unsigned long",18);
33480  _cimg_save_pandore_case(0,1,3,"long",17);
33481  _cimg_save_pandore_case(0,1,3,"float",18);
33482  _cimg_save_pandore_case(0,1,3,"double",18);
33483 
33484  _cimg_save_pandore_case(0,0,3,"unsigned char",19);
33485  _cimg_save_pandore_case(0,0,3,"char",20);
33486  _cimg_save_pandore_case(0,0,3,"short",20);
33487  _cimg_save_pandore_case(0,0,3,"unsigned short",20);
33488  _cimg_save_pandore_case(0,0,3,"unsigned int",20);
33489  _cimg_save_pandore_case(0,0,3,"int",20);
33490  _cimg_save_pandore_case(0,0,3,"unsigned long",21);
33491  _cimg_save_pandore_case(0,0,3,"long",20);
33492  _cimg_save_pandore_case(0,0,3,"float",21);
33493  _cimg_save_pandore_case(0,0,3,"double",21);
33494 
33495  _cimg_save_pandore_case(1,1,0,"unsigned char",22);
33496  _cimg_save_pandore_case(1,1,0,"char",23);
33497  _cimg_save_pandore_case(1,1,0,"short",23);
33498  _cimg_save_pandore_case(1,1,0,"unsigned short",23);
33499  _cimg_save_pandore_case(1,1,0,"unsigned int",23);
33500  _cimg_save_pandore_case(1,1,0,"int",23);
33501  _cimg_save_pandore_case(1,1,0,"unsigned long",25);
33502  _cimg_save_pandore_case(1,1,0,"long",23);
33503  _cimg_save_pandore_case(1,1,0,"float",25);
33504  _cimg_save_pandore_case(1,1,0,"double",25);
33505 
33506  _cimg_save_pandore_case(0,1,0,"unsigned char",26);
33507  _cimg_save_pandore_case(0,1,0,"char",27);
33508  _cimg_save_pandore_case(0,1,0,"short",27);
33509  _cimg_save_pandore_case(0,1,0,"unsigned short",27);
33510  _cimg_save_pandore_case(0,1,0,"unsigned int",27);
33511  _cimg_save_pandore_case(0,1,0,"int",27);
33512  _cimg_save_pandore_case(0,1,0,"unsigned long",29);
33513  _cimg_save_pandore_case(0,1,0,"long",27);
33514  _cimg_save_pandore_case(0,1,0,"float",29);
33515  _cimg_save_pandore_case(0,1,0,"double",29);
33516 
33517  _cimg_save_pandore_case(0,0,0,"unsigned char",30);
33518  _cimg_save_pandore_case(0,0,0,"char",31);
33519  _cimg_save_pandore_case(0,0,0,"short",31);
33520  _cimg_save_pandore_case(0,0,0,"unsigned short",31);
33521  _cimg_save_pandore_case(0,0,0,"unsigned int",31);
33522  _cimg_save_pandore_case(0,0,0,"int",31);
33523  _cimg_save_pandore_case(0,0,0,"unsigned long",33);
33524  _cimg_save_pandore_case(0,0,0,"long",31);
33525  _cimg_save_pandore_case(0,0,0,"float",33);
33526  _cimg_save_pandore_case(0,0,0,"double",33);
33527 
33528  if (!file) cimg::fclose(nfile);
33529  return *this;
33530  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define _cimg_save_pandore_case(sy, sz, sv, stype, id)
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

unsigned int _save_pandore_header_length ( unsigned int  id,
unsigned int *  dims,
const unsigned int  colorspace 
) const
inline

Definition at line 33372 of file CImg.h.

33372  {
33373  unsigned int nbdims = 0;
33374  if (id==2 || id==3 || id==4) { dims[0] = 1; dims[1] = width; nbdims = 2; }
33375  if (id==5 || id==6 || id==7) { dims[0] = 1; dims[1] = height; dims[2] = width; nbdims=3; }
33376  if (id==8 || id==9 || id==10) { dims[0] = dim; dims[1] = depth; dims[2] = height; dims[3] = width; nbdims = 4; }
33377  if (id==16 || id==17 || id==18) { dims[0] = 3; dims[1] = height; dims[2] = width; dims[3] = colorspace; nbdims = 4; }
33378  if (id==19 || id==20 || id==21) { dims[0] = 3; dims[1] = depth; dims[2] = height; dims[3] = width; dims[4] = colorspace; nbdims = 5; }
33379  if (id==22 || id==23 || id==25) { dims[0] = dim; dims[1] = width; nbdims = 2; }
33380  if (id==26 || id==27 || id==29) { dims[0] = dim; dims[1] = height; dims[2] = width; nbdims=3; }
33381  if (id==30 || id==31 || id==33) { dims[0] = dim; dims[1] = depth; dims[2] = height; dims[3] = width; nbdims = 4; }
33382  return nbdims;
33383  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
const CImg<T>& _save_png ( std::FILE *const  file,
const char *const  filename,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Definition at line 32714 of file CImg.h.

Referenced by CImg< uintT >::save_png().

32714  {
32715  if (is_empty())
32716  throw CImgInstanceException("CImg<%s>::save_png() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32717  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32718  if (!filename)
32719  throw CImgArgumentException("CImg<%s>::save_png() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
32721  if (depth>1)
32722  cimg::warn("CImg<%s>::save_png() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32723  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32724  unsigned int foo = bytes_per_pixel; foo = 0;
32725 #ifndef cimg_use_png
32726  if (!file) return save_other(filename);
32727  else throw CImgIOException("CImg<%s>::save_png() : Cannot save a PNG image in a *FILE output. You must use 'libpng' to do this instead.",
32728  pixel_type());
32729 #else
32730  const char *volatile nfilename = filename; // two 'volatile' here to remove a g++ warning due to 'setjmp'.
32731  std::FILE *volatile nfile = file?file:cimg::fopen(nfilename,"wb");
32732 
32733  double stmin, stmax = (double)maxmin(stmin);
32734  if (depth>1)
32735  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32736  pixel_type(),filename,width,height,depth,dim,data);
32737  if (dim>3)
32738  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32739  pixel_type(),filename,width,height,depth,dim,data);
32740  if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32741  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32742  pixel_type(),filename,width,height,depth,dim,data,stmin,stmax);
32743 
32744  // Setup PNG structures for write
32745  png_voidp user_error_ptr = 0;
32746  png_error_ptr user_error_fn = 0, user_warning_fn = 0;
32747  png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,user_error_ptr, user_error_fn, user_warning_fn);
32748  if(!png_ptr){
32749  if (!file) cimg::fclose(nfile);
32750  throw CImgIOException("CImg<%s>::save_png() : File '%s', error when initializing 'png_ptr' data structure.",
32751  pixel_type(),nfilename?nfilename:"(FILE*)");
32752  }
32753  png_infop info_ptr = png_create_info_struct(png_ptr);
32754  if (!info_ptr) {
32755  png_destroy_write_struct(&png_ptr,(png_infopp)0);
32756  if (!file) cimg::fclose(nfile);
32757  throw CImgIOException("CImg<%s>::save_png() : File '%s', error when initializing 'info_ptr' data structure.",
32758  pixel_type(),nfilename?nfilename:"(FILE*)");
32759  }
32760  if (setjmp(png_jmpbuf(png_ptr))) {
32761  png_destroy_write_struct(&png_ptr, &info_ptr);
32762  if (!file) cimg::fclose(nfile);
32763  throw CImgIOException("CImg<%s>::save_png() : File '%s', unknown fatal error.",
32764  pixel_type(),nfilename?nfilename:"(FILE*)");
32765  }
32766  png_init_io(png_ptr, nfile);
32767  png_uint_32 width = dimx(), height = dimy();
32768  const int bit_depth = bytes_per_pixel?(bytes_per_pixel*8):(stmax>=256?16:8);
32769  int color_type;
32770  switch (dimv()) {
32771  case 1 : color_type = PNG_COLOR_TYPE_GRAY; break;
32772  case 2 : color_type = PNG_COLOR_TYPE_GRAY_ALPHA; break;
32773  case 3 : color_type = PNG_COLOR_TYPE_RGB; break;
32774  default : color_type = PNG_COLOR_TYPE_RGB_ALPHA;
32775  }
32776  const int interlace_type = PNG_INTERLACE_NONE;
32777  const int compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
32778  const int filter_method = PNG_FILTER_TYPE_DEFAULT;
32779  png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type,compression_type, filter_method);
32780  png_write_info(png_ptr, info_ptr);
32781  const int byte_depth = bit_depth>>3;
32782  const int numChan = dimv()>4?4:dimv();
32783  const int pixel_bit_depth_flag = numChan * (bit_depth-1);
32784 
32785  // Allocate Memory for Image Save and Fill pixel data
32786  png_bytep *imgData = new png_byte*[height];
32787  for (unsigned int row = 0; row<height; ++row) imgData[row] = new png_byte[byte_depth*numChan*width];
32788  const T *pC0 = ptr(0,0,0,0);
32789  switch (pixel_bit_depth_flag) {
32790  case 7 : { // Gray 8-bit
32791  cimg_forY(*this,y) {
32792  unsigned char *ptrd = imgData[y];
32793  cimg_forX(*this,x) *(ptrd++) = (unsigned char)*(pC0++);
32794  }
32795  } break;
32796  case 14 : { // Gray w/ Alpha 8-bit
32797  const T *pC1 = ptr(0,0,0,1);
32798  cimg_forY(*this,y) {
32799  unsigned char *ptrd = imgData[y];
32800  cimg_forX(*this,x) {
32801  *(ptrd++) = (unsigned char)*(pC0++);
32802  *(ptrd++) = (unsigned char)*(pC1++);
32803  }
32804  }
32805  } break;
32806  case 21 : { // RGB 8-bit
32807  const T *pC1 = ptr(0,0,0,1), *pC2 = ptr(0,0,0,2);
32808  cimg_forY(*this,y) {
32809  unsigned char *ptrd = imgData[y];
32810  cimg_forX(*this,x) {
32811  *(ptrd++) = (unsigned char)*(pC0++);
32812  *(ptrd++) = (unsigned char)*(pC1++);
32813  *(ptrd++) = (unsigned char)*(pC2++);
32814  }
32815  }
32816  } break;
32817  case 28 : { // RGB x/ Alpha 8-bit
32818  const T *pC1 = ptr(0,0,0,1), *pC2 = ptr(0,0,0,2), *pC3 = ptr(0,0,0,3);
32819  cimg_forY(*this,y){
32820  unsigned char *ptrd = imgData[y];
32821  cimg_forX(*this,x){
32822  *(ptrd++) = (unsigned char)*(pC0++);
32823  *(ptrd++) = (unsigned char)*(pC1++);
32824  *(ptrd++) = (unsigned char)*(pC2++);
32825  *(ptrd++) = (unsigned char)*(pC3++);
32826  }
32827  }
32828  } break;
32829  case 15 : { // Gray 16-bit
32830  cimg_forY(*this,y){
32831  unsigned short *ptrd = (unsigned short*)(imgData[y]);
32832  cimg_forX(*this,x) *(ptrd++) = (unsigned short)*(pC0++);
32833  if (!cimg::endianness()) cimg::invert_endianness((unsigned short*)imgData[y],width);
32834  }
32835  } break;
32836  case 30 : { // Gray w/ Alpha 16-bit
32837  const T *pC1 = ptr(0,0,0,1);
32838  cimg_forY(*this,y){
32839  unsigned short *ptrd = (unsigned short*)(imgData[y]);
32840  cimg_forX(*this,x) {
32841  *(ptrd++) = (unsigned short)*(pC0++);
32842  *(ptrd++) = (unsigned short)*(pC1++);
32843  }
32844  if (!cimg::endianness()) cimg::invert_endianness((unsigned short*)imgData[y],2*width);
32845  }
32846  } break;
32847  case 45 : { // RGB 16-bit
32848  const T *pC1 = ptr(0,0,0,1), *pC2 = ptr(0,0,0,2);
32849  cimg_forY(*this,y) {
32850  unsigned short *ptrd = (unsigned short*)(imgData[y]);
32851  cimg_forX(*this,x) {
32852  *(ptrd++) = (unsigned short)*(pC0++);
32853  *(ptrd++) = (unsigned short)*(pC1++);
32854  *(ptrd++) = (unsigned short)*(pC2++);
32855  }
32856  if (!cimg::endianness()) cimg::invert_endianness((unsigned short*)imgData[y],3*width);
32857  }
32858  } break;
32859  case 60 : { // RGB w/ Alpha 16-bit
32860  const T *pC1 = ptr(0,0,0,1), *pC2 = ptr(0,0,0,2), *pC3 = ptr(0,0,0,3);
32861  cimg_forY(*this,y) {
32862  unsigned short *ptrd = (unsigned short*)(imgData[y]);
32863  cimg_forX(*this,x) {
32864  *(ptrd++) = (unsigned short)*(pC0++);
32865  *(ptrd++) = (unsigned short)*(pC1++);
32866  *(ptrd++) = (unsigned short)*(pC2++);
32867  *(ptrd++) = (unsigned short)*(pC3++);
32868  }
32869  if (!cimg::endianness()) cimg::invert_endianness((unsigned short*)imgData[y],4*width);
32870  }
32871  } break;
32872  default :
32873  if (!file) cimg::fclose(nfile);
32874  throw CImgIOException("CImg<%s>::save_png() : File '%s', unknown fatal error.",
32875  pixel_type(),nfilename?nfilename:"(FILE*)");
32876  }
32877  png_write_image(png_ptr, imgData);
32878  png_write_end(png_ptr, info_ptr);
32879  png_destroy_write_struct(&png_ptr, &info_ptr);
32880 
32881  // Deallocate Image Write Memory
32882  cimg_forY(*this,n) delete[] imgData[n];
32883  delete[] imgData;
32884  if (!file) cimg::fclose(nfile);
32885  return *this;
32886 #endif
32887  }
if(dy > dx)
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
const CImg< T > & save_other(const char *const filename, const unsigned int quality=100) const
Definition: CImg.h:33819
void int int REAL REAL * y
Definition: read.cpp:74
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
const NT & n
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

const CImg<T>& _save_pnm ( std::FILE *const  file,
const char *const  filename,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Definition at line 32900 of file CImg.h.

Referenced by CImg< uintT >::save_pnm().

32900  {
32901  if (!file && !filename)
32902  throw CImgArgumentException("CImg<%s>::save_pnm() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32904  if (is_empty())
32905  throw CImgInstanceException("CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32906  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32907  double stmin, stmax = (double)maxmin(stmin);
32908  if (depth>1)
32909  cimg::warn("CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32910  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32911  if (dim>3)
32912  cimg::warn("CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32913  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
32914  if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32915  cimg::warn("CImg<%s>::save_pnm() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32916  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data,stmin,stmax);
32917  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
32918  const T
32919  *ptrR = ptr(0,0,0,0),
32920  *ptrG = (dim>=2)?ptr(0,0,0,1):0,
32921  *ptrB = (dim>=3)?ptr(0,0,0,2):0;
32922  const unsigned int buf_size = width*height*(dim==1?1:3);
32923 
32924  std::fprintf(nfile,"P%c\n# CREATOR: CImg Library (original size = %ux%ux%ux%u)\n%u %u\n%u\n",
32925  (dim==1?'5':'6'),width,height,depth,dim,width,height,stmax<256?255:(stmax<4096?4095:65535));
32926 
32927  switch (dim) {
32928  case 1 : { // Scalar image
32929  if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PGM 8 bits
32930  unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd;
32931  cimg_forXY(*this,x,y) *(xptrd++) = (unsigned char)*(ptrR++);
32932  cimg::fwrite(ptrd,buf_size,nfile);
32933  delete[] ptrd;
32934  } else { // Binary PGM 16 bits
32935  unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd;
32936  cimg_forXY(*this,x,y) *(xptrd++) = (unsigned short)*(ptrR++);
32937  if (!cimg::endianness()) cimg::invert_endianness(ptrd,buf_size);
32938  cimg::fwrite(ptrd,buf_size,nfile);
32939  delete[] ptrd;
32940  }
32941  } break;
32942  case 2 : { // RG image
32943  if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PPM 8 bits
32944  unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd;
32945  cimg_forXY(*this,x,y) {
32946  *(xptrd++) = (unsigned char)*(ptrR++);
32947  *(xptrd++) = (unsigned char)*(ptrG++);
32948  *(xptrd++) = 0;
32949  }
32950  cimg::fwrite(ptrd,buf_size,nfile);
32951  delete[] ptrd;
32952  } else { // Binary PPM 16 bits
32953  unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd;
32954  cimg_forXY(*this,x,y) {
32955  *(xptrd++) = (unsigned short)*(ptrR++);
32956  *(xptrd++) = (unsigned short)*(ptrG++);
32957  *(xptrd++) = 0;
32958  }
32959  if (!cimg::endianness()) cimg::invert_endianness(ptrd,buf_size);
32960  cimg::fwrite(ptrd,buf_size,nfile);
32961  delete[] ptrd;
32962  }
32963  } break;
32964  default : { // RGB image
32965  if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PPM 8 bits
32966  unsigned char *ptrd = new unsigned char[buf_size], *xptrd = ptrd;
32967  cimg_forXY(*this,x,y) {
32968  *(xptrd++) = (unsigned char)*(ptrR++);
32969  *(xptrd++) = (unsigned char)*(ptrG++);
32970  *(xptrd++) = (unsigned char)*(ptrB++);
32971  }
32972  cimg::fwrite(ptrd,buf_size,nfile);
32973  delete[] ptrd;
32974  } else { // Binary PPM 16 bits
32975  unsigned short *ptrd = new unsigned short[buf_size], *xptrd = ptrd;
32976  cimg_forXY(*this,x,y) {
32977  *(xptrd++) = (unsigned short)*(ptrR++);
32978  *(xptrd++) = (unsigned short)*(ptrG++);
32979  *(xptrd++) = (unsigned short)*(ptrB++);
32980  }
32981  if (!cimg::endianness()) cimg::invert_endianness(ptrd,buf_size);
32982  cimg::fwrite(ptrd,buf_size,nfile);
32983  delete[] ptrd;
32984  }
32985  }
32986  }
32987  if (!file) cimg::fclose(nfile);
32988  return *this;
32989  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
void int int REAL REAL * y
Definition: read.cpp:74
bool endianness()
Return the current endianness of the CPU.
Definition: CImg.h:4572
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_raw ( std::FILE *const  file,
const char *const  filename,
const bool  multiplexed 
) const
inline

Definition at line 33543 of file CImg.h.

Referenced by CImg< uintT >::save_raw().

33543  {
33544  if (is_empty())
33545  throw CImgInstanceException("CImg<%s>::save_raw() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33546  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33547  if (!file && !filename)
33548  throw CImgArgumentException("CImg<%s>::save_raw() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33550  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
33551  if (!multiplexed) cimg::fwrite(data,size(),nfile);
33552  else {
33553  CImg<T> buf(dim);
33554  cimg_forXYZ(*this,x,y,z) {
33555  cimg_forV(*this,k) buf[k] = (*this)(x,y,z,k);
33556  cimg::fwrite(buf.data,dim,nfile);
33557  }
33558  }
33559  if (!file) cimg::fclose(nfile);
33560  return *this;
33561  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_rgb ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 33002 of file CImg.h.

Referenced by CImg< uintT >::save_rgb().

33002  {
33003  if (is_empty())
33004  throw CImgInstanceException("CImg<%s>::save_rgb() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33005  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33006  if (!file && !filename)
33007  throw CImgArgumentException("CImg<%s>::save_rgb() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33009  if (dim!=3)
33010  cimg::warn("CImg<%s>::save_rgb() : File '%s', instance image (%u,%u,%u,%u,%p) has not exactly 3 channels.",
33011  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33012  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
33013  const unsigned int wh = width*height;
33014  unsigned char *buffer = new unsigned char[3*wh], *nbuffer=buffer;
33015  const T
33016  *ptr1 = ptr(0,0,0,0),
33017  *ptr2 = dim>1?ptr(0,0,0,1):0,
33018  *ptr3 = dim>2?ptr(0,0,0,2):0;
33019  switch (dim) {
33020  case 1 : { // Scalar image
33021  for (unsigned int k = 0; k<wh; ++k) {
33022  const unsigned char val = (unsigned char)*(ptr1++);
33023  *(nbuffer++) = val;
33024  *(nbuffer++) = val;
33025  *(nbuffer++) = val;
33026  }} break;
33027  case 2 : { // RG image
33028  for (unsigned int k = 0; k<wh; ++k) {
33029  *(nbuffer++) = (unsigned char)(*(ptr1++));
33030  *(nbuffer++) = (unsigned char)(*(ptr2++));
33031  *(nbuffer++) = 0;
33032  }} break;
33033  default : { // RGB image
33034  for (unsigned int k = 0; k<wh; ++k) {
33035  *(nbuffer++) = (unsigned char)(*(ptr1++));
33036  *(nbuffer++) = (unsigned char)(*(ptr2++));
33037  *(nbuffer++) = (unsigned char)(*(ptr3++));
33038  }
33039  }
33040  }
33041  cimg::fwrite(buffer,3*wh,nfile);
33042  if (!file) cimg::fclose(nfile);
33043  delete[] buffer;
33044  return *this;
33045  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& _save_rgba ( std::FILE *const  file,
const char *const  filename 
) const
inline

Definition at line 33058 of file CImg.h.

Referenced by CImg< uintT >::save_rgba().

33058  {
33059  if (is_empty())
33060  throw CImgInstanceException("CImg<%s>::save_rgba() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33061  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33062  if (!file && !filename)
33063  throw CImgArgumentException("CImg<%s>::save_rgba() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
33065  if (dim!=4)
33066  cimg::warn("CImg<%s>::save_rgba() : File '%s, instance image (%u,%u,%u,%u,%p) has not exactly 4 channels.",
33067  pixel_type(),filename?filename:"(FILE*)",width,height,depth,dim,data);
33068  std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
33069  const unsigned int wh = width*height;
33070  unsigned char *buffer = new unsigned char[4*wh], *nbuffer=buffer;
33071  const T
33072  *ptr1 = ptr(0,0,0,0),
33073  *ptr2 = dim>1?ptr(0,0,0,1):0,
33074  *ptr3 = dim>2?ptr(0,0,0,2):0,
33075  *ptr4 = dim>3?ptr(0,0,0,3):0;
33076  switch (dim) {
33077  case 1 : { // Scalar images
33078  for (unsigned int k = 0; k<wh; ++k) {
33079  const unsigned char val = (unsigned char)*(ptr1++);
33080  *(nbuffer++) = val;
33081  *(nbuffer++) = val;
33082  *(nbuffer++) = val;
33083  *(nbuffer++) = 255;
33084  }} break;
33085  case 2 : { // RG images
33086  for (unsigned int k = 0; k<wh; ++k) {
33087  *(nbuffer++) = (unsigned char)(*(ptr1++));
33088  *(nbuffer++) = (unsigned char)(*(ptr2++));
33089  *(nbuffer++) = 0;
33090  *(nbuffer++) = 255;
33091  }} break;
33092  case 3 : { // RGB images
33093  for (unsigned int k = 0; k<wh; ++k) {
33094  *(nbuffer++) = (unsigned char)(*(ptr1++));
33095  *(nbuffer++) = (unsigned char)(*(ptr2++));
33096  *(nbuffer++) = (unsigned char)(*(ptr3++));
33097  *(nbuffer++) = 255;
33098  }} break;
33099  default : { // RGBA images
33100  for (unsigned int k = 0; k<wh; ++k) {
33101  *(nbuffer++) = (unsigned char)(*(ptr1++));
33102  *(nbuffer++) = (unsigned char)(*(ptr2++));
33103  *(nbuffer++) = (unsigned char)(*(ptr3++));
33104  *(nbuffer++) = (unsigned char)(*(ptr4++));
33105  }
33106  }
33107  }
33108  cimg::fwrite(buffer,4*wh,nfile);
33109  if (!file) cimg::fclose(nfile);
33110  delete[] buffer;
33111  return *this;
33112  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& _solve ( const CImg< t > &  A,
const CImg< ti > &  indx 
)
inline

Definition at line 13605 of file CImg.h.

Referenced by CImg< uintT >::solve().

13605  {
13606  typedef _cimg_Ttfloat Ttfloat;
13607  const int N = size();
13608  int ii = -1;
13609  Ttfloat sum;
13610  for (int i = 0; i<N; ++i) {
13611  const int ip = (int)indx[i];
13612  Ttfloat sum = (*this)(ip);
13613  (*this)(ip) = (*this)(i);
13614  if (ii>=0) for (int j = ii; j<=i-1; ++j) sum-=A(j,i)*(*this)(j);
13615  else if (sum!=0) ii=i;
13616  (*this)(i) = (T)sum;
13617  }
13618  for (int i = N-1; i>=0; --i) {
13619  sum = (*this)(i);
13620  for (int j = i+1; j<N; ++j) sum-=A(j,i)*(*this)(j);
13621  (*this)(i) = (T)(sum/A(i,i));
13622  }
13623  return *this;
13624  }
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
#define _cimg_Ttfloat
Definition: CImg.h:2302
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
rational * A
Definition: vinci_lass.c:67
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
for(;;)

Here is the caller graph for this function:

CImg<T>& abs ( )
inline

Compute the absolute value of each pixel value.

Definition at line 12570 of file CImg.h.

Referenced by CImg< uintT >::get_abs().

12570  {
12571  cimg_for(*this,ptr,T) (*ptr) = cimg::abs(*ptr);
12572  return *this;
12573  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& acos ( )
inline

Compute the arc-cosine of each pixel value.

Definition at line 12640 of file CImg.h.

Referenced by CImg< uintT >::get_acos().

12640  {
12641  cimg_for(*this,ptr,T) (*ptr) = (T)std::acos((double)(*ptr));
12642  return *this;
12643  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051

Here is the caller graph for this function:

CImg<T>& append ( const CImg< t > &  img,
const char  axis = 'x',
const char  align = 'p' 
)
inline

Append an image.

Definition at line 18642 of file CImg.h.

Referenced by CImg< uintT >::append_object3d().

18642  {
18643  if (is_empty()) return assign(img,false);
18644  if (!img) return *this;
18645  return CImgList<T>(*this,img).get_append(axis,align).transfer_to(*this);
18646  }
CImg< _cimg_Tt > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
Definition: CImg.h:18655
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103

Here is the caller graph for this function:

CImg<T>& append ( const CImg< T > &  img,
const char  axis = 'x',
const char  align = 'p' 
)
inline

Definition at line 18648 of file CImg.h.

18648  {
18649  if (is_empty()) return assign(img,false);
18650  if (!img) return *this;
18651  return CImgList<T>(*this,img,true).get_append(axis,align).transfer_to(*this);
18652  }
CImg< _cimg_Tt > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
Definition: CImg.h:18655
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& append_object3d ( CImgList< tf > &  primitives,
const CImg< tp > &  obj_vertices,
const CImgList< tff > &  obj_primitives 
)
inline

Append a 3D object to another one.

Definition at line 21143 of file CImg.h.

21143  {
21144  if (!obj_vertices || !obj_primitives) return *this;
21145  if (obj_vertices.height!=3 || obj_vertices.depth>1 || obj_vertices.dim>1)
21146  throw CImgInstanceException("CImg<%s>::append_object3d() : Vertice image argument (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21147  pixel_type(),obj_vertices.width,obj_vertices.height,obj_vertices.depth,obj_vertices.dim,obj_vertices.data);
21148  if (is_empty()) { primitives.assign(obj_primitives); return assign(obj_vertices); }
21149  if (height!=3 || depth>1 || dim>1)
21150  throw CImgInstanceException("CImg<%s>::append_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21152  const unsigned int P = width;
21153  append(obj_vertices,'x');
21154  const unsigned int N = primitives.width;
21155  primitives.insert(obj_primitives);
21156  for (unsigned int i = N; i<primitives.width; ++i) {
21157  CImg<tf> &p = primitives[i];
21158  switch (p.size()) {
21159  case 1 : p[0]+=P; break; // Point.
21160  case 5 : p[0]+=P; if (!p[2]) p[1]+=P; break; // Sphere.
21161  case 2 : case 6 : p[0]+=P; p[1]+=P; break; // Segment.
21162  case 3 : case 9 : p[0]+=P; p[1]+=P; p[2]+=P; break; // Triangle.
21163  case 4 : case 12 : p[0]+=P; p[1]+=P; p[2]+=P; p[3]+=P; break; // Rectangle.
21164  }
21165  }
21166  return *this;
21167  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
blockLoc i
Definition: read.cpp:79
CImg< T > & append(const CImg< t > &img, const char axis='x', const char align='p')
Append an image.
Definition: CImg.h:18642
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& asin ( )
inline

Compute the arc-sinus of each pixel value.

Definition at line 12650 of file CImg.h.

Referenced by CImg< uintT >::get_asin().

12650  {
12651  cimg_for(*this,ptr,T) (*ptr) = (T)std::asin((double)(*ptr));
12652  return *this;
12653  }
CImg< _cimg_Tfloat > asin(const CImg< T > &instance)
Definition: CImg.h:6056
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& assign ( )
inline

In-place version of the default constructor/destructor.

This function replaces the instance image by an empty image.

Remarks
  • Memory used by the previous content of the instance image is freed if necessary.
  • If the instance image was initially shared, it is replaced by a (non-shared) empty image.
  • This function is useful to free memory used by an image that is not of use, but which has been created in the current code scope (i.e. not destroyed yet).

Definition at line 10103 of file CImg.h.

Referenced by CImg< T >::_cimg_math_parser::_cimg_math_parser(), CImg< uintT >::_draw_text(), CImg< uintT >::_load_analyze(), CImg< uintT >::_load_ascii(), CImg< uintT >::_load_bmp(), CImg< uintT >::_load_dlm(), CImg< uintT >::_load_inr(), CImg< uintT >::_load_jpeg(), CImg< uintT >::_load_off(), CImg< uintT >::_load_pandore(), CImg< uintT >::_load_png(), CImg< uintT >::_load_pnm(), CImg< uintT >::_load_raw(), CImg< uintT >::_load_rgb(), CImg< uintT >::_load_rgba(), CImg< uintT >::append(), CImg< uintT >::append_object3d(), CImg< uintT >::assign(), CImg< uintT >::CImg(), CImg< uintT >::clear(), CImg< uintT >::load(), CImg< uintT >::load_cimg(), CImg< uintT >::load_magick(), CImg< uintT >::load_other(), CImg< uintT >::load_parrec(), CImg< uintT >::load_tiff(), CImg< uintT >::operator=(), CImg< uintT >::resize(), CImgDisplay::snapshot(), CImg< uintT >::solve(), and CImg< uintT >::transfer_to().

10103  {
10104  if (data && !is_shared) delete[] data;
10105  width = height = depth = dim = 0; is_shared = false; data = 0;
10106  return *this;
10107  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& assign ( const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1 
)
inline

In-place version of the previous constructor.

This function replaces the instance image by a new image of size (dx,dy,dz,dv) with pixels of type T.

Parameters
dxDesired size along the X-axis, i.e. the width of the image.
dyDesired size along the Y-axis, i.e. the height of the image.
dzDesired size along the Z-axis, i.e. the depth of the image.
dvDesired size along the V-axis, i.e. the number of image channels dim.
  • If one of the input dimension dx,dy,dz or dv is set to 0, the instance image becomes empty and all has its dimensions set to 0. No memory for pixel data is then allocated.
  • Memory buffer used to store previous pixel values is freed if necessary.
  • If the instance image is shared, this constructor actually does nothing more than verifying that new and old image dimensions fit.
  • Image pixels allocated by this function are not initialized. Use the function assign(const unsigned int,const unsigned int,const unsigned int,const unsigned int,const T) to assign an image of desired size with pixels set to a particular value.

Definition at line 10125 of file CImg.h.

10125  {
10126  const unsigned int siz = dx*dy*dz*dv;
10127  if (!siz) return assign();
10128  const unsigned int curr_siz = size();
10129  if (siz!=curr_siz) {
10130  if (is_shared)
10131  throw CImgArgumentException("CImg<%s>::assign() : Cannot assign image (%u,%u,%u,%u) to shared instance image (%u,%u,%u,%u,%p).",
10132  pixel_type(),dx,dy,dz,dv,width,height,depth,dim,data);
10133  else { if (data) delete[] data; data = new T[siz]; }
10134  }
10135  width = dx; height = dy; depth = dz; dim = dv;
10136  return *this;
10137  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& assign ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const T  val 
)
inline

In-place version of the previous constructor.

This function replaces the instance image by a new image of size (dx,dy,dz,dv) with pixels of type T and sets all pixel values of the instance image to val.

Parameters
dxDesired size along the X-axis, i.e. the width of the image.
dyDesired size along the Y-axis, i.e. the height of the image.
dzDesired size along the Z-axis, i.e. the depth of the image.
dvDesired size along the V-axis, i.e. the number of image channels dim.
valDefault value for image pixels.
Remarks

Definition at line 10151 of file CImg.h.

10151  {
10152  return assign(dx,dy,dz,dv).fill(val);
10153  }
NT dx
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
CImg<T>& assign ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const int  val0,
const int  val1,
  ... 
)
inline

In-place version of the previous constructor.

Definition at line 10156 of file CImg.h.

10157  {
10158  assign(dx,dy,dz,dv);
10159  _CImg_stdarg(*this,val0,val1,dx*dy*dz*dv,int);
10160  return *this;
10161  }
NT dx
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define _CImg_stdarg(img, a0, a1, N, t)
NT dy
CImg<T>& assign ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const double  val0,
const double  val1,
  ... 
)
inline

In-place version of the previous constructor.

Definition at line 10164 of file CImg.h.

10165  {
10166  assign(dx,dy,dz,dv);
10167  _CImg_stdarg(*this,val0,val1,dx*dy*dz*dv,double);
10168  return *this;
10169  }
NT dx
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define _CImg_stdarg(img, a0, a1, N, t)
NT dy
CImg<T>& assign ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const char *const  values,
const bool  repeat_values 
)
inline

In-place version of the corresponding constructor.

Definition at line 10172 of file CImg.h.

10173  {
10174  return assign(dx,dy,dz,dv).fill(values,repeat_values);
10175  }
NT dx
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
CImg<T>& assign ( const t *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1 
)
inline

In-place version of the previous constructor.

Definition at line 10179 of file CImg.h.

10180  {
10181  const unsigned int siz = dx*dy*dz*dv;
10182  if (!data_buffer || !siz) return assign();
10183  assign(dx,dy,dz,dv);
10184  const t *ptrs = data_buffer + siz; cimg_for(*this,ptrd,T) *ptrd = (T)*(--ptrs);
10185  return *this;
10186  }
NT dx
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
NT dy
CImg<T>& assign ( const T *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy = 1,
const unsigned int  dz = 1,
const unsigned int  dv = 1 
)
inline

Definition at line 10188 of file CImg.h.

10189  {
10190  const unsigned int siz = dx*dy*dz*dv;
10191  if (!data_buffer || !siz) return assign();
10192  const unsigned int curr_siz = size();
10193  if (data_buffer==data && siz==curr_siz) return assign(dx,dy,dz,dv);
10194  if (is_shared || data_buffer+siz<data || data_buffer>=data+size()) {
10195  assign(dx,dy,dz,dv);
10196  if (is_shared) std::memmove(data,data_buffer,siz*sizeof(T));
10197  else std::memcpy(data,data_buffer,siz*sizeof(T));
10198  } else {
10199  T *new_data = new T[siz];
10200  std::memcpy(new_data,data_buffer,siz*sizeof(T));
10201  delete[] data; data = new_data; width = dx; height = dy; depth = dz; dim = dv;
10202  }
10203  return *this;
10204  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& assign ( const t *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const bool  shared 
)
inline

In-place version of the previous constructor, allowing to force the shared state of the instance image.

Definition at line 10208 of file CImg.h.

10209  {
10210  if (shared)
10211  throw CImgArgumentException("CImg<%s>::assign() : Cannot assign buffer (%s*) to shared instance image (%u,%u,%u,%u,%p)"
10212  "(different pixel types).",
10213  pixel_type(),CImg<t>::pixel_type(),width,height,depth,dim,data);
10214  return assign(data_buffer,dx,dy,dz,dv);
10215  }
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& assign ( const T *const  data_buffer,
const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv,
const bool  shared 
)
inline

Definition at line 10217 of file CImg.h.

10218  {
10219  const unsigned int siz = dx*dy*dz*dv;
10220  if (!data_buffer || !siz) return assign();
10221  if (!shared) { if (is_shared) assign(); assign(data_buffer,dx,dy,dz,dv); }
10222  else {
10223  if (!is_shared) {
10224  if (data_buffer+siz<data || data_buffer>=data+size()) assign();
10225  else cimg::warn("CImg<%s>::assign() : Shared instance image has overlapping memory !",
10226  pixel_type());
10227  }
10228  width = dx; height = dy; depth = dz; dim = dv; is_shared = true;
10229  data = const_cast<T*>(data_buffer);
10230  }
10231  return *this;
10232  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& assign ( const char *const  filename)
inline

In-place version of the previous constructor.

This function replaces the instance image by the one that have been read from the given file.

Parameters
filenameFilename of the image file.
  • The image format is deduced from the filename only by looking for the filename extension i.e. without analyzing the file itself.
  • Recognized image formats depend on the tools installed on your system or the external libraries you use to link your code with. More informations on this topic can be found in cimg_files_io.
  • If the filename is not found, a CImgIOException is thrown by this constructor.

Definition at line 10244 of file CImg.h.

10244  {
10245  return load(filename);
10246  }
CImg< T > & load(const char *const filename)
Load an image from a file.
Definition: CImg.h:29130
CImg<T>& assign ( const CImg< t > &  img)
inline

In-place version of the default copy constructor.

This function assigns a copy of the input image img to the current instance image.

Parameters
imgThe input image to copy.
Remarks
  • If the instance image is not shared, the content of the input image img is copied into a new buffer becoming the new pixel buffer of the instance image, while the old pixel buffer is freed if necessary.
  • If the instance image is shared, the content of the input image img is copied into the current (shared) pixel buffer of the instance image, modifying then the image referenced by the shared instance image. The instance image still remains shared.

Definition at line 10259 of file CImg.h.

10259  {
10260  return assign(img.data,img.width,img.height,img.depth,img.dim);
10261  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& assign ( const CImg< t > &  img,
const bool  shared 
)
inline

In-place version of the advanced constructor.

This function - as the simpler function assign(const CImg< t >&) - assigns a copy of the input image img to the current instance image. But it also decides if the copy is shared (if the input parameter shared is set to true) or non-shared (if the input parameter shared is set to false).

Parameters
imgThe input image to copy.
sharedBoolean flag that decides if the copy is shared or non-shared.
Remarks
  • It is not possible to assign a shared copy if the input image img is empty or has a different pixel type t != T.
  • If a non-shared copy of the input image img is assigned, a new memory buffer is allocated for pixel data.
  • If a shared copy of the input image img is assigned, no extra memory is allocated and the pixel buffer of the instance image is the same as the one used by the input image img.

Definition at line 10277 of file CImg.h.

10277  {
10278  return assign(img.data,img.width,img.height,img.depth,img.dim,shared);
10279  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& assign ( const CImg< t > &  img,
const char *const  dimensions 
)
inline

In-place version of the previous constructor.

Definition at line 10283 of file CImg.h.

10283  {
10284  if (!dimensions || !*dimensions) return assign(img.width,img.height,img.depth,img.dim);
10285  unsigned int siz[4] = { 0,1,1,1 }, k = 0;
10286  for (const char *s = dimensions; *s && k<4; ++k) {
10287  char item[256] = { 0 };
10288  if (std::sscanf(s,"%255[^0-9%xyzvwhdcXYZVWHDC]",item)>0) s+=std::strlen(item);
10289  if (*s) {
10290  unsigned int val = 0; char sep = 0;
10291  if (std::sscanf(s,"%u%c",&val,&sep)>0) {
10292  if (sep=='%') siz[k] = val*(k==0?width:k==1?height:k==2?depth:dim)/100;
10293  else siz[k] = val;
10294  while (*s>='0' && *s<='9') ++s; if (sep=='%') ++s;
10295  } else switch (cimg::uncase(*s)) {
10296  case 'x' : case 'w' : siz[k] = img.width; ++s; break;
10297  case 'y' : case 'h' : siz[k] = img.height; ++s; break;
10298  case 'z' : case 'd' : siz[k] = img.depth; ++s; break;
10299  case 'v' : case 'c' : siz[k] = img.dim; ++s; break;
10300  default :
10301  throw CImgArgumentException("CImg<%s>::assign() : Misplaced character '%c' in input dimension string '%s'.",
10302  pixel_type(),*s,dimensions);
10303  }
10304  }
10305  }
10306  return assign(siz[0],siz[1],siz[2],siz[3]);
10307  }
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& assign ( const CImg< t > &  img,
const char *const  dimensions,
const T  val 
)
inline

In-place version of the previous constructor.

Definition at line 10311 of file CImg.h.

10311  {
10312  return assign(img,dimensions).fill(val);
10313  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& assign ( const CImg< t > &  img,
const char *const  dimensions,
const char *const  values,
const bool  repeat_values 
)
inline

In-place version of the previous constructor.

Definition at line 10317 of file CImg.h.

10317  {
10318  return assign(img,dimensions).fill(values,repeat_values);
10319  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& assign ( const CImgDisplay disp)
inline

In-place version of the previous constructor.

Definition at line 10322 of file CImg.h.

10322  {
10323  disp.snapshot(*this);
10324  return *this;
10325  }
T& at ( const int  off,
const T  out_val 
)
inline

Read a pixel value with Dirichlet boundary conditions.

Definition at line 11188 of file CImg.h.

11188  {
11189  return (off<0 || off>=(int)size())?(cimg::temporary(out_val)=out_val):(*this)[off];
11190  }
T & temporary(const T &)
Return a reference to a temporary variable of type T.
Definition: CImg.h:4515
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T at ( const int  off,
const T  out_val 
) const
inline

Definition at line 11192 of file CImg.h.

11192  {
11193  return (off<0 || off>=(int)size())?out_val:(*this)[off];
11194  }
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T& at ( const int  off)
inline

Read a pixel value with Neumann boundary conditions.

Definition at line 11197 of file CImg.h.

11197  {
11198  if (!size())
11199  throw CImgInstanceException("CImg<%s>::at() : Instance image is empty.",
11200  pixel_type());
11201  return _at(off);
11202  }
T & _at(const int off)
Definition: CImg.h:11211
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T at ( const int  off) const
inline

Definition at line 11204 of file CImg.h.

11204  {
11205  if (!size())
11206  throw CImgInstanceException("CImg<%s>::at() : Instance image is empty.",
11207  pixel_type());
11208  return _at(off);
11209  }
T & _at(const int off)
Definition: CImg.h:11211
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T>& atan ( )
inline

Compute the arc-tangent of each pixel.

Definition at line 12660 of file CImg.h.

Referenced by CImg< uintT >::get_atan().

12660  {
12661  cimg_for(*this,ptr,T) (*ptr) = (T)std::atan((double)(*ptr));
12662  return *this;
12663  }
CImg< _cimg_Tfloat > atan(const CImg< T > &instance)
Definition: CImg.h:6061
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& atan2 ( const CImg< t > &  img)
inline

Compute the arc-tangent of each pixel.

Definition at line 12671 of file CImg.h.

Referenced by rflu_modrepair3d::angfnd(), rflu_modrepair3d::dihed(), CImg< uintT >::get_atan2(), rflu_modexactflow::rflu_computeexactflowculick(), rflu_modexactflow::rflu_computeexactflowpacoust(), rflu_initbcdatahardcode(), rflu_initflowhardcode(), rflu_modrindstates::rflu_setrindstatefarfieldperf(), and rflu_modrepair3d::snglar().

12671  {
12672  const unsigned int smin = cimg::min(size(),img.size());
12673  t *ptrs = img.data + smin;
12674  for (T *ptrd = data + smin; ptrd>data; --ptrd, *ptrd = (T)std::atan2((double)*ptrd,(double)*(--ptrs))) {}
12675  return *this;
12676  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075

Here is the caller graph for this function:

T& atX ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
)
inline

Read a pixel value with Dirichlet boundary conditions for the first coordinates (x).

Definition at line 11324 of file CImg.h.

Referenced by CImg< uintT >::cubic_atX(), CImg< uintT >::get_warp(), and CImg< uintT >::linear_atX().

11324  {
11325  return (x<0 || x>=dimx())?(cimg::temporary(out_val)=out_val):(*this)(x,y,z,v);
11326  }
void int int REAL REAL * y
Definition: read.cpp:74
T & temporary(const T &)
Return a reference to a temporary variable of type T.
Definition: CImg.h:4515
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T atX ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Definition at line 11328 of file CImg.h.

11328  {
11329  return (x<0 || x>=dimx())?out_val:(*this)(x,y,z,v);
11330  }
void int int REAL REAL * y
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& atX ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
)
inline

Read a pixel value with Neumann boundary conditions for the first coordinates (x).

Definition at line 11333 of file CImg.h.

11333  {
11334  if (is_empty())
11335  throw CImgInstanceException("CImg<%s>::atX() : Instance image is empty.",
11336  pixel_type());
11337  return _atX(x,y,z,v);
11338  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T & _atX(const int x, const int y=0, const int z=0, const int v=0)
Definition: CImg.h:11347
T atX ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11340 of file CImg.h.

11340  {
11341  if (is_empty())
11342  throw CImgInstanceException("CImg<%s>::atX() : Instance image is empty.",
11343  pixel_type());
11344  return _atX(x,y,z,v);
11345  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T & _atX(const int x, const int y=0, const int z=0, const int v=0)
Definition: CImg.h:11347
T& atXY ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
)
inline

Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x,y).

Definition at line 11292 of file CImg.h.

Referenced by CImg< uintT >::cubic_atXY(), CImg< uintT >::get_rotate(), CImg< uintT >::get_warp(), CImg< uintT >::linear_atX(), and CImg< uintT >::linear_atXY().

11292  {
11293  return (x<0 || y<0 || x>=dimx() || y>=dimy())?(cimg::temporary(out_val)=out_val):(*this)(x,y,z,v);
11294  }
void int int REAL REAL * y
Definition: read.cpp:74
T & temporary(const T &)
Return a reference to a temporary variable of type T.
Definition: CImg.h:4515
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T atXY ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Definition at line 11296 of file CImg.h.

11296  {
11297  return (x<0 || y<0 || x>=dimx() || y>=dimy())?out_val:(*this)(x,y,z,v);
11298  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& atXY ( const int  x,
const int  y,
const int  z = 0,
const int  v = 0 
)
inline

Read a pixel value with Neumann boundary conditions for the two first coordinates (x,y).

Definition at line 11301 of file CImg.h.

11301  {
11302  if (is_empty())
11303  throw CImgInstanceException("CImg<%s>::atXY() : Instance image is empty.",
11304  pixel_type());
11305  return _atXY(x,y,z,v);
11306  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & _atXY(const int x, const int y, const int z=0, const int v=0)
Definition: CImg.h:11315
void int int REAL * x
Definition: read.cpp:74
T atXY ( const int  x,
const int  y,
const int  z = 0,
const int  v = 0 
) const
inline

Definition at line 11308 of file CImg.h.

11308  {
11309  if (is_empty())
11310  throw CImgInstanceException("CImg<%s>::atXY() : Instance image is empty.",
11311  pixel_type());
11312  return _atXY(x,y,z,v);
11313  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & _atXY(const int x, const int y, const int z=0, const int v=0)
Definition: CImg.h:11315
void int int REAL * x
Definition: read.cpp:74
T& atXYZ ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
)
inline

Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x,y,z).

Definition at line 11257 of file CImg.h.

Referenced by CImg< uintT >::get_correlate(), CImg< uintT >::get_dilate(), CImg< uintT >::get_erode(), CImg< uintT >::get_warp(), and CImg< uintT >::linear_atXYZ().

11257  {
11258  return (x<0 || y<0 || z<0 || x>=dimx() || y>=dimy() || z>=dimz())?
11259  (cimg::temporary(out_val)=out_val):(*this)(x,y,z,v);
11260  }
void int int REAL REAL * y
Definition: read.cpp:74
T & temporary(const T &)
Return a reference to a temporary variable of type T.
Definition: CImg.h:4515
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

T atXYZ ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Definition at line 11262 of file CImg.h.

11262  {
11263  return (x<0 || y<0 || z<0 || x>=dimx() || y>=dimy() || z>=dimz())?out_val:(*this)(x,y,z,v);
11264  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T& atXYZ ( const int  x,
const int  y,
const int  z,
const int  v = 0 
)
inline

Read a pixel value with Neumann boundary conditions for the three first coordinates (x,y,z).

Definition at line 11267 of file CImg.h.

11267  {
11268  if (is_empty())
11269  throw CImgInstanceException("CImg<%s>::atXYZ() : Instance image is empty.",
11270  pixel_type());
11271  return _atXYZ(x,y,z,v);
11272  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
void int int REAL * x
Definition: read.cpp:74
T atXYZ ( const int  x,
const int  y,
const int  z,
const int  v = 0 
) const
inline

Definition at line 11274 of file CImg.h.

11274  {
11275  if (is_empty())
11276  throw CImgInstanceException("CImg<%s>::atXYZ() : Instance image is empty.",
11277  pixel_type());
11278  return _atXYZ(x,y,z,v);
11279  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
void int int REAL * x
Definition: read.cpp:74
T& atXYZV ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
)
inline

Read a pixel value with Dirichlet boundary conditions.

Definition at line 11222 of file CImg.h.

Referenced by CImg< uintT >::get_warp(), and CImg< uintT >::linear_atXYZV().

11222  {
11223  return (x<0 || y<0 || z<0 || v<0 || x>=dimx() || y>=dimy() || z>=dimz() || v>=dimv())?
11224  (cimg::temporary(out_val)=out_val):(*this)(x,y,z,v);
11225  }
void int int REAL REAL * y
Definition: read.cpp:74
T & temporary(const T &)
Return a reference to a temporary variable of type T.
Definition: CImg.h:4515
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

T atXYZV ( const int  x,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Definition at line 11227 of file CImg.h.

11227  {
11228  return (x<0 || y<0 || z<0 || v<0 || x>=dimx() || y>=dimy() || z>=dimz() || v>=dimv())?out_val:(*this)(x,y,z,v);
11229  }
void int int REAL REAL * y
Definition: read.cpp:74
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
T& atXYZV ( const int  x,
const int  y,
const int  z,
const int  v 
)
inline

Read a pixel value with Neumann boundary conditions.

Definition at line 11232 of file CImg.h.

11232  {
11233  if (is_empty())
11234  throw CImgInstanceException("CImg<%s>::atXYZV() : Instance image is empty.",
11235  pixel_type());
11236  return _atXYZV(x,y,z,v);
11237  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T & _atXYZV(const int x, const int y, const int z, const int v)
Definition: CImg.h:11246
T atXYZV ( const int  x,
const int  y,
const int  z,
const int  v 
) const
inline

Definition at line 11239 of file CImg.h.

11239  {
11240  if (is_empty())
11241  throw CImgInstanceException("CImg<%s>::atXYZV() : Instance image is empty.",
11242  pixel_type());
11243  return _atXYZV(x,y,z,v);
11244  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T & _atXYZV(const int x, const int y, const int z, const int v)
Definition: CImg.h:11246
CImg<T>& autocrop ( const T  value,
const char *const  axes = "vzyx" 
)
inline

Autocrop an image, regarding of the specified backround value.

Definition at line 18267 of file CImg.h.

Referenced by CImg< uintT >::get_autocrop().

18267  {
18268  if (is_empty()) return *this;
18269  for (const char *s = axes; *s; ++s) {
18270  const char axis = cimg::uncase(*s);
18271  const CImg<intT> coords = _autocrop(value,axis);
18272  switch (axis) {
18273  case 'x' : {
18274  const int x0 = coords[0], x1 = coords[1];
18275  if (x0>=0 && x1>=0) crop(x0,x1);
18276  } break;
18277  case 'y' : {
18278  const int y0 = coords[0], y1 = coords[1];
18279  if (y0>=0 && y1>=0) crop(0,y0,width-1,y1);
18280  } break;
18281  case 'z' : {
18282  const int z0 = coords[0], z1 = coords[1];
18283  if (z0>=0 && z1>=0) crop(0,0,z0,width-1,height-1,z1);
18284  } break;
18285  case 'v' : {
18286  const int v0 = coords[0], v1 = coords[1];
18287  if (v0>=0 && v1>=0) crop(0,0,0,v0,width-1,height-1,depth-1,v1);
18288  } break;
18289  default :
18290  throw CImgArgumentException("CImg<%s>::autocrop() : Invalid axis '%c' (should be 'x','y','z' or 'v').",
18291  pixel_type(),*s);
18292  }
18293  }
18294  return *this;
18295  }
CImg< intT > _autocrop(const T value, const char axis) const
Definition: CImg.h:18355
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
Definition: CImg.h:18184
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

CImg<T>& autocrop ( const T *const  color,
const char *const  axes = "zyx" 
)
inline

Autocrop an image, regarding of the specified backround color.

Definition at line 18302 of file CImg.h.

18302  {
18303  if (is_empty()) return *this;
18304  for (const char *s = axes; *s; ++s) {
18305  const char axis = cimg::uncase(*s);
18306  switch (axis) {
18307  case 'x' : {
18308  int x0 = width, x1 = -1;
18309  cimg_forV(*this,k) {
18310  const CImg<intT> coords = get_shared_channel(k)._autocrop(color[k],'x');
18311  const int nx0 = coords[0], nx1 = coords[1];
18312  if (nx0>=0 && nx1>=0) { x0 = cimg::min(x0,nx0); x1 = cimg::max(x1,nx1); }
18313  }
18314  if (x0<=x1) crop(x0,x1);
18315  } break;
18316  case 'y' : {
18317  int y0 = height, y1 = -1;
18318  cimg_forV(*this,k) {
18319  const CImg<intT> coords = get_shared_channel(k)._autocrop(color[k],'y');
18320  const int ny0 = coords[0], ny1 = coords[1];
18321  if (ny0>=0 && ny1>=0) { y0 = cimg::min(y0,ny0); y1 = cimg::max(y1,ny1); }
18322  }
18323  if (y0<=y1) crop(0,y0,width-1,y1);
18324  } break;
18325  case 'z' : {
18326  int z0 = depth, z1 = -1;
18327  cimg_forV(*this,k) {
18328  const CImg<intT> coords = get_shared_channel(k)._autocrop(color[k],'z');
18329  const int nz0 = coords[0], nz1 = coords[1];
18330  if (nz0>=0 && nz1>=0) { z0 = cimg::min(z0,nz0); z1 = cimg::max(z1,nz1); }
18331  }
18332  if (z0<=z1) crop(0,0,z0,width-1,height-1,z1);
18333  } break;
18334  default :
18335  throw CImgArgumentException("CImg<%s>::autocrop() : Invalid axis '%c' (should be 'x','y' or 'z').",
18336  pixel_type(),*s);
18337  }
18338  }
18339  return *this;
18340  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
Definition: CImg.h:18184
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
#define cimg_forV(img, v)
Definition: CImg.h:596
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& autocrop ( const CImg< t > &  color,
const char *const  axes = "zyx" 
)
inline

Autocrop an image, regarding of the specified backround color.

Definition at line 18347 of file CImg.h.

18347  {
18348  return get_autocrop(color,axes).transfer_to(*this);
18349  }
CImg< T > get_autocrop(const T value, const char *const axes="vzyx") const
Definition: CImg.h:18297
const T& back ( ) const
inline

Return a reference to the last image pixel (STL-compliant name).

Definition at line 11179 of file CImg.h.

11179  {
11180  return *(data + size() - 1);
11181  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T& back ( )
inline

Definition at line 11183 of file CImg.h.

11183  {
11184  return *(data + size() - 1);
11185  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T>& BayertoRGB ( const unsigned int  interpolation_type = 3)
inline

Convert a Bayer-coded image to a (R,G,B) color image.

Definition at line 16494 of file CImg.h.

16494  {
16495  return get_BayertoRGB(interpolation_type).transfer_to(*this);
16496  }
CImg< Tuchar > get_BayertoRGB(const unsigned int interpolation_type=3) const
Definition: CImg.h:16498
iterator begin ( )
inline

Return an iterator to the first image pixel.

Definition at line 11152 of file CImg.h.

Referenced by CImg< uintT >::print().

11152  {
11153  return data;
11154  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750

Here is the caller graph for this function:

const_iterator begin ( ) const
inline

Definition at line 11156 of file CImg.h.

11156  {
11157  return data;
11158  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
CImg<T>& blur ( const float  sigmax,
const float  sigmay,
const float  sigmaz,
const bool  cond = true 
)
inline

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

Definition at line 19211 of file CImg.h.

Referenced by CImg< uintT >::blur(), CImg< uintT >::edge_tensors(), and CImg< uintT >::get_blur().

19211  {
19212  if (!is_empty()) {
19213  if (width>1) deriche(sigmax,0,'x',cond);
19214  if (height>1) deriche(sigmay,0,'y',cond);
19215  if (depth>1) deriche(sigmaz,0,'z',cond);
19216  }
19217  return *this;
19218  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
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.
Definition: CImg.h:19118
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

CImg<T>& blur ( const float  sigma,
const bool  cond = true 
)
inline

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

Definition at line 19225 of file CImg.h.

19225  {
19226  const float nsigma = sigma>=0?sigma:-sigma*cimg::max(width,height,depth)/100;
19227  return blur(nsigma,nsigma,nsigma,cond);
19228  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
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.
Definition: CImg.h:19211
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
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 unsigned int  fast_approx = 1 
)
inline

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.
is_tensor= Tell if G is a tensor or a vector field.
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.

Definition at line 19246 of file CImg.h.

Referenced by CImg< uintT >::blur_anisotropic(), and CImg< uintT >::get_blur_anisotropic().

19249  {
19250 
19251  // Check arguments and init variables
19252  if (is_empty() || amplitude<=0 || dl<0) return *this;
19253  if (!is_sameXYZ(G) || (G.dim!=3 && G.dim!=6))
19254  throw CImgArgumentException("CImg<%s>::blur_anisotropic() : Invalid diffusion tensor field (%u,%u,%u,%u,%p) "
19255  "for instance image (%u,%u,%u,%u,%p).",
19256  pixel_type(),G.width,G.height,G.depth,G.dim,G.data,width,height,depth,dim,data);
19257  const bool threed = G.dim==6;
19258 
19259  if (da<=0) { // Iterated oriented Laplacians
19260  CImg<Tfloat> veloc(width,height,depth,dim);
19261  for (unsigned int iter = 0; iter<(unsigned int)amplitude; ++iter) {
19262  Tfloat *ptrd = veloc.fill(0).ptr(), betamax = 0;
19263  if (threed) { // 3D version
19264  CImg_3x3x3(I,T);
19265  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
19266  const Tfloat
19267  ixx = (Tfloat)(Incc + Ipcc - 2*Iccc),
19268  iyy = (Tfloat)(Icnc + Icpc - 2*Iccc),
19269  izz = (Tfloat)(Iccn + Iccp - 2*Iccc),
19270  ixy = (Tfloat)(0.25f*(Innc + Ippc - Inpc - Ipnc)),
19271  ixz = (Tfloat)(0.25f*(Incn + Ipcp - Incp - Ipcn)),
19272  iyz = (Tfloat)(0.25f*(Icnn + Icpp - Icnp - Icpn)),
19273  beta = (Tfloat)(G(x,y,z,0)*ixx + 2*G(x,y,z,1)*ixy + 2*G(x,y,z,2)*ixz + G(x,y,z,3)*iyy + 2*G(x,y,z,4)*iyz + G(x,y,z,5)*izz);
19274  *(ptrd++) = beta;
19275  betamax = beta>betamax?beta:(-beta>betamax?-beta:betamax);
19276  }
19277  } else { // 2D version
19278  CImg_3x3(I,T);
19279  Tfloat *ptrd = veloc.ptr();
19280  betamax = 0;
19281  if (G.dim==3) cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) { // Tensor field
19282  const Tfloat
19283  ixx = (Tfloat)(Inc + Ipc - 2*Icc),
19284  iyy = (Tfloat)(Icn + Icp - 2*Icc),
19285  ixy = (Tfloat)(0.25f*(Inn + Ipp - Inp - Ipn)),
19286  beta = (Tfloat)(G(x,y,0,0)*ixx + G(x,y,0,1)*ixy + G(x,y,0,2)*iyy);
19287  *(ptrd++) = beta;
19288  betamax = beta>betamax?beta:(-beta>betamax?-beta:betamax);
19289  }
19290  }
19291  if (betamax>0) (*this)+=(veloc*=dl/betamax);
19292  }
19293  } else { // LIC-based smoothing.
19294 #define _cimg_valign2d(i,j) { Tfloat &u = W(i,j,0,0), &v = W(i,j,0,1); if (u*curru + v*currv<0) { u=-u; v=-v; }}
19295 #define _cimg_valign3d(i,j,k) { Tfloat &u = W(i,j,k,0), &v = W(i,j,k,1), &w = W(i,j,k,2); if (u*curru + v*currv + w*currw<0) { u=-u; v=-v; w=-w; }}
19296 
19297  const float sqrt2amplitude = (float)std::sqrt(2*amplitude);
19298  const int dx1 = dimx()-1, dy1 = dimy()-1, dz1 = dimz()-1;
19299  CImg<Tfloat> dest(width,height,depth,dim,0), W(width,height,depth,threed?4:3), tmp(dim);
19300  int N = 0;
19301  if (threed) { // 3D version
19302  for (float phi = (180%(int)da)/2.0f; phi<=180; phi+=da) {
19303  const float phir = (float)(phi*cimg::valuePI/180), datmp = (float)(da/std::cos(phir)), da2 = datmp<1?360.0f:datmp;
19304  for (float theta = 0; theta<360; (theta+=da2),++N) {
19305  const float
19306  thetar = (float)(theta*cimg::valuePI/180),
19307  vx = (float)(std::cos(thetar)*std::cos(phir)),
19308  vy = (float)(std::sin(thetar)*std::cos(phir)),
19309  vz = (float)std::sin(phir);
19310  const t
19311  *pa = G.ptr(0,0,0,0), *pb = G.ptr(0,0,0,1), *pc = G.ptr(0,0,0,2),
19312  *pd = G.ptr(0,0,0,3), *pe = G.ptr(0,0,0,4), *pf = G.ptr(0,0,0,5);
19313  Tfloat *pd0 = W.ptr(0,0,0,0), *pd1 = W.ptr(0,0,0,1), *pd2 = W.ptr(0,0,0,2), *pd3 = W.ptr(0,0,0,3);
19314  cimg_forXYZ(G,xg,yg,zg) {
19315  const t a = *(pa++), b = *(pb++), c = *(pc++), d = *(pd++), e = *(pe++), f = *(pf++);
19316  const float u = (float)(a*vx + b*vy + c*vz), v = (float)(b*vx + d*vy + e*vz), w = (float)(c*vx + e*vy + f*vz),
19317  n = (float)std::sqrt(1e-5+u*u+v*v+w*w), dln = dl/n;
19318  *(pd0++) = (Tfloat)(u*dln);
19319  *(pd1++) = (Tfloat)(v*dln);
19320  *(pd2++) = (Tfloat)(w*dln);
19321  *(pd3++) = (Tfloat)n;
19322  }
19323 
19324  cimg_forXYZ(*this,x,y,z) {
19325  tmp.fill(0);
19326  const float cu = (float)W(x,y,z,0), cv = (float)W(x,y,z,1), cw = (float)W(x,y,z,2), n = (float)W(x,y,z,3),
19327  fsigma = (float)(n*sqrt2amplitude), length = gauss_prec*fsigma, fsigma2 = 2*fsigma*fsigma;
19328  float S = 0, pu = cu, pv = cv, pw = cw, X = (float)x, Y = (float)y, Z = (float)z;
19329  switch (interpolation_type) {
19330  case 0 : { // Nearest neighbor
19331  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19332  const int cx = (int)(X+0.5f), cy = (int)(Y+0.5f), cz = (int)(Z+0.5f);
19333  float u = (float)W(cx,cy,cz,0), v = (float)W(cx,cy,cz,1), w = (float)W(cx,cy,cz,2);
19334  if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; }
19335  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)(*this)(cx,cy,cz,k); ++S; }
19336  else {
19337  const float coef = (float)std::exp(-l*l/fsigma2);
19338  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*(*this)(cx,cy,cz,k));
19339  S+=coef;
19340  }
19341  X+=(pu=u); Y+=(pv=v); Z+=(pw=w);
19342  }
19343  } break;
19344  case 1 : { // Linear interpolation
19345  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19346  const int
19347  cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19348  cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1,
19349  cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1;
19350  const float curru = (float)W(cx,cy,cz,0), currv = (float)W(cx,cy,cz,1), currw = (float)W(cx,cy,cz,2);
19351  _cimg_valign3d(px,py,pz); _cimg_valign3d(cx,py,pz); _cimg_valign3d(nx,py,pz);
19352  _cimg_valign3d(px,cy,pz); _cimg_valign3d(cx,cy,pz); _cimg_valign3d(nx,cy,pz);
19353  _cimg_valign3d(px,ny,pz); _cimg_valign3d(cx,ny,pz); _cimg_valign3d(nx,ny,pz);
19354  _cimg_valign3d(px,py,cz); _cimg_valign3d(cx,py,cz); _cimg_valign3d(nx,py,cz);
19355  _cimg_valign3d(px,cy,cz); _cimg_valign3d(nx,cy,cz);
19356  _cimg_valign3d(px,ny,cz); _cimg_valign3d(cx,ny,cz); _cimg_valign3d(nx,ny,cz);
19357  _cimg_valign3d(px,py,nz); _cimg_valign3d(cx,py,nz); _cimg_valign3d(nx,py,nz);
19358  _cimg_valign3d(px,cy,nz); _cimg_valign3d(cx,cy,nz); _cimg_valign3d(nx,cy,nz);
19359  _cimg_valign3d(px,ny,nz); _cimg_valign3d(cx,ny,nz); _cimg_valign3d(nx,ny,nz);
19360  float u = (float)(W._linear_atXYZ(X,Y,Z,0)), v = (float)(W._linear_atXYZ(X,Y,Z,1)), w = (float)(W._linear_atXYZ(X,Y,Z,2));
19361  if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; }
19362  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)_linear_atXYZ(X,Y,Z,k); ++S; }
19363  else {
19364  const float coef = (float)std::exp(-l*l/fsigma2);
19365  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*_linear_atXYZ(X,Y,Z,k));
19366  S+=coef;
19367  }
19368  X+=(pu=u); Y+=(pv=v); Z+=(pw=w);
19369  }
19370  } break;
19371  default : { // 2nd order Runge Kutta
19372  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1 && Z>=0 && Z<=dz1; l+=dl) {
19373  const int
19374  cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19375  cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1,
19376  cz = (int)Z, pz = (cz-1<0)?0:cz-1, nz = (cz+1>dz1)?dz1:cz+1;
19377  const float curru = (float)W(cx,cy,cz,0), currv = (float)W(cx,cy,cz,1), currw = (float)W(cx,cy,cz,2);
19378  _cimg_valign3d(px,py,pz); _cimg_valign3d(cx,py,pz); _cimg_valign3d(nx,py,pz);
19379  _cimg_valign3d(px,cy,pz); _cimg_valign3d(cx,cy,pz); _cimg_valign3d(nx,cy,pz);
19380  _cimg_valign3d(px,ny,pz); _cimg_valign3d(cx,ny,pz); _cimg_valign3d(nx,ny,pz);
19381  _cimg_valign3d(px,py,cz); _cimg_valign3d(cx,py,cz); _cimg_valign3d(nx,py,cz);
19382  _cimg_valign3d(px,cy,cz); _cimg_valign3d(nx,cy,cz);
19383  _cimg_valign3d(px,ny,cz); _cimg_valign3d(cx,ny,cz); _cimg_valign3d(nx,ny,cz);
19384  _cimg_valign3d(px,py,nz); _cimg_valign3d(cx,py,nz); _cimg_valign3d(nx,py,nz);
19385  _cimg_valign3d(px,cy,nz); _cimg_valign3d(cx,cy,nz); _cimg_valign3d(nx,cy,nz);
19386  _cimg_valign3d(px,ny,nz); _cimg_valign3d(cx,ny,nz); _cimg_valign3d(nx,ny,nz);
19387  const float
19388  u0 = (float)(0.5f*W._linear_atXYZ(X,Y,Z,0)),
19389  v0 = (float)(0.5f*W._linear_atXYZ(X,Y,Z,1)),
19390  w0 = (float)(0.5f*W._linear_atXYZ(X,Y,Z,2));
19391  float
19392  u = (float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,0)),
19393  v = (float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,1)),
19394  w = (float)(W._linear_atXYZ(X+u0,Y+v0,Z+w0,2));
19395  if ((pu*u + pv*v + pw*w)<0) { u=-u; v=-v; w=-w; }
19396  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)_linear_atXYZ(X,Y,Z,k); ++S; }
19397  else {
19398  const float coef = (float)std::exp(-l*l/fsigma2);
19399  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*_linear_atXYZ(X,Y,Z,k));
19400  S+=coef;
19401  }
19402  X+=(pu=u); Y+=(pv=v); Z+=(pw=w);
19403  }
19404  } break;
19405  }
19406  if (S>0) cimg_forV(dest,k) dest(x,y,z,k)+=tmp[k]/S;
19407  else cimg_forV(dest,k) dest(x,y,z,k)+=(Tfloat)((*this)(x,y,z,k));
19408  }
19409  }
19410  }
19411  } else { // 2D LIC algorithm
19412  for (float theta = (360%(int)da)/2.0f; theta<360; (theta+=da),++N) {
19413  const float thetar = (float)(theta*cimg::valuePI/180), vx = (float)(std::cos(thetar)), vy = (float)(std::sin(thetar));
19414  const t *pa = G.ptr(0,0,0,0), *pb = G.ptr(0,0,0,1), *pc = G.ptr(0,0,0,2);
19415  Tfloat *pd0 = W.ptr(0,0,0,0), *pd1 = W.ptr(0,0,0,1), *pd2 = W.ptr(0,0,0,2);
19416  cimg_forXY(G,xg,yg) {
19417  const t a = *(pa++), b = *(pb++), c = *(pc++);
19418  const float u = (float)(a*vx + b*vy), v = (float)(b*vx + c*vy), n = (float)std::sqrt(1e-5+u*u+v*v), dln = dl/n;
19419  *(pd0++) = (Tfloat)(u*dln);
19420  *(pd1++) = (Tfloat)(v*dln);
19421  *(pd2++) = (Tfloat)n;
19422  }
19423  cimg_forXY(*this,x,y) {
19424  tmp.fill(0);
19425  const float
19426  cu = (float)W(x,y,0,0), cv = (float)W(x,y,0,1), n = (float)W(x,y,0,2),
19427  fsigma = (float)(n*sqrt2amplitude), length = gauss_prec*fsigma, fsigma2 = 2*fsigma*fsigma;
19428  float S = 0, pu = cu, pv = cv, X = (float)x, Y = (float)y;
19429 
19430  switch (interpolation_type) {
19431  case 0 : { // Nearest-neighbor
19432  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19433  const int cx = (int)(X+0.5f), cy = (int)(Y+0.5f);
19434  float u = (float)W(cx,cy,0,0), v = (float)W(cx,cy,0,1);
19435  if ((pu*u + pv*v)<0) { u=-u; v=-v; }
19436  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)(*this)(cx,cy,0,k); ++S; }
19437  else {
19438  const float coef = (float)std::exp(-l*l/fsigma2);
19439  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*(*this)(cx,cy,0,k));
19440  S+=coef;
19441  }
19442  X+=(pu=u); Y+=(pv=v);
19443  }
19444  } break;
19445  case 1 : { // Linear interpolation
19446  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19447  const int
19448  cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19449  cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1;
19450  const float curru = (float)W(cx,cy,0,0), currv = (float)W(cx,cy,0,1);
19451  _cimg_valign2d(px,py); _cimg_valign2d(cx,py); _cimg_valign2d(nx,py);
19452  _cimg_valign2d(px,cy); _cimg_valign2d(nx,cy);
19453  _cimg_valign2d(px,ny); _cimg_valign2d(cx,ny); _cimg_valign2d(nx,ny);
19454  float u = (float)(W._linear_atXY(X,Y,0,0)), v = (float)(W._linear_atXY(X,Y,0,1));
19455  if ((pu*u + pv*v)<0) { u=-u; v=-v; }
19456  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)_linear_atXY(X,Y,0,k); ++S; }
19457  else {
19458  const float coef = (float)std::exp(-l*l/fsigma2);
19459  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*_linear_atXY(X,Y,0,k));
19460  S+=coef;
19461  }
19462  X+=(pu=u); Y+=(pv=v);
19463  }
19464  } break;
19465  default : { // 2nd-order Runge-kutta interpolation
19466  for (float l = 0; l<length && X>=0 && X<=dx1 && Y>=0 && Y<=dy1; l+=dl) {
19467  const int
19468  cx = (int)X, px = (cx-1<0)?0:cx-1, nx = (cx+1>dx1)?dx1:cx+1,
19469  cy = (int)Y, py = (cy-1<0)?0:cy-1, ny = (cy+1>dy1)?dy1:cy+1;
19470  const float curru = (float)W(cx,cy,0,0), currv = (float)W(cx,cy,0,1);
19471  _cimg_valign2d(px,py); _cimg_valign2d(cx,py); _cimg_valign2d(nx,py);
19472  _cimg_valign2d(px,cy); _cimg_valign2d(nx,cy);
19473  _cimg_valign2d(px,ny); _cimg_valign2d(cx,ny); _cimg_valign2d(nx,ny);
19474  const float u0 = (float)(0.5f*W._linear_atXY(X,Y,0,0)), v0 = (float)(0.5f*W._linear_atXY(X,Y,0,1));
19475  float u = (float)(W._linear_atXY(X+u0,Y+v0,0,0)), v = (float)(W._linear_atXY(X+u0,Y+v0,0,1));
19476  if ((pu*u + pv*v)<0) { u=-u; v=-v; }
19477  if (fast_approx) { cimg_forV(*this,k) tmp[k]+=(Tfloat)_linear_atXY(X,Y,0,k); ++S; }
19478  else {
19479  const float coef = (float)std::exp(-l*l/fsigma2);
19480  cimg_forV(*this,k) tmp[k]+=(Tfloat)(coef*_linear_atXY(X,Y,0,k));
19481  S+=coef;
19482  }
19483  X+=(pu=u); Y+=(pv=v);
19484  }
19485  }
19486  }
19487  if (S>0) cimg_forV(dest,k) dest(x,y,0,k)+=tmp[k]/S;
19488  else cimg_forV(dest,k) dest(x,y,0,k)+=(Tfloat)((*this)(x,y,0,k));
19489  }
19490  }
19491  }
19492  const Tfloat *ptrs = dest.data + dest.size();
19493  const T m = cimg::type<T>::min(), M = cimg::type<T>::max();
19494  cimg_for(*this,ptrd,T) { const Tfloat val = *(--ptrs)/N; *ptrd = val<m?m:(val>M?M:(T)val); }
19495  }
19496  return *this;
19497  }
if(dy > dx)
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
const NT & d
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
#define _cimg_valign3d(i, j, k)
double sqrt(double d)
Definition: double.h:73
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
double length(Vector3D *const v, int n)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Tfloat _linear_atXYZ(const float fx, const float fy=0, const float fz=0, const int v=0) const
Definition: CImg.h:11483
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
NT & sin
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
Tfloat _linear_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Definition: CImg.h:11537
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
bool is_sameXYZ(const unsigned int dx, const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified width, height and depth.
Definition: CImg.h:11994
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define _cimg_valign2d(i, j)
#define CImg_3x3(I, T)
Definition: CImg.h:421
NT & cos
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& blur_anisotropic ( const float  amplitude,
const float  sharpness = 0.7f,
const float  anisotropy = 0.3f,
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 unsigned int  fast_approx = 1 
)
inline

Blur an image following in an anisotropic way.

Definition at line 19508 of file CImg.h.

19511  {
19512  return blur_anisotropic(get_edge_tensors(sharpness,anisotropy,alpha,sigma,interpolation_type!=3),
19513  amplitude,dl,da,gauss_prec,interpolation_type,fast_approx);
19514  }
CImg< T > get_edge_tensors(const float sharpness=0.7f, const float anisotropy=0.3f, const float alpha=0.6f, const float sigma=1.1f, const bool is_sqrt=false) const
Definition: CImg.h:20322
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 unsigned int fast_approx=1)
Blur the image anisotropically following a field of diffusion tensors.
Definition: CImg.h:19246
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 
)
inline

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

Definition at line 19537 of file CImg.h.

Referenced by CImg< uintT >::blur_bilateral(), and CImg< uintT >::get_blur_bilateral().

19539  {
19540  if (is_empty()) return *this;
19541  T m, M = maxmin(m);
19542  const float range = (float)(1.0f+M-m);
19543  const unsigned int
19544  bx0 = bgrid_x>=0?bgrid_x:width*(-bgrid_x)/100,
19545  by0 = bgrid_y>=0?bgrid_y:height*(-bgrid_y)/100,
19546  bz0 = bgrid_z>=0?bgrid_z:depth*(-bgrid_z)/100,
19547  br0 = bgrid_r>=0?bgrid_r:(int)(-range*bgrid_r/100),
19548  bx = bx0>0?bx0:1,
19549  by = by0>0?by0:1,
19550  bz = bz0>0?bz0:1,
19551  br = br0>0?br0:1;
19552  const float
19553  _sigma_x = sigma_x>=0?sigma_x:-sigma_x*width/100,
19554  _sigma_y = sigma_y>=0?sigma_y:-sigma_y*height/100,
19555  _sigma_z = sigma_z>=0?sigma_z:-sigma_z*depth/100,
19556  nsigma_x = _sigma_x*bx/width,
19557  nsigma_y = _sigma_y*by/height,
19558  nsigma_z = _sigma_z*bz/depth,
19559  nsigma_r = sigma_r*br/range;
19560  if (nsigma_x>0 || nsigma_y>0 || nsigma_z>0 || nsigma_r>0) {
19561  const bool threed = depth>1;
19562  if (threed) { // 3d version of the algorithm
19563  CImg<floatT> bgrid(bx,by,bz,br), bgridw(bx,by,bz,br);
19564  cimg_forV(*this,k) {
19565  bgrid.fill(0); bgridw.fill(0);
19566  cimg_forXYZ(*this,x,y,z) {
19567  const T val = (*this)(x,y,z,k);
19568  const int X = x*bx/width, Y = y*by/height, Z = z*bz/depth, R = (int)((val-m)*br/range);
19569  bgrid(X,Y,Z,R) = (float)val;
19570  bgridw(X,Y,Z,R) = 1;
19571  }
19572  bgrid.blur(nsigma_x,nsigma_y,nsigma_z,true).deriche(nsigma_r,0,'v',false);
19573  bgridw.blur(nsigma_x,nsigma_y,nsigma_z,true).deriche(nsigma_r,0,'v',false);
19574  if (interpolation_type) cimg_forXYZ(*this,x,y,z) {
19575  const T val = (*this)(x,y,z,k);
19576  const float X = (float)x*bx/width, Y = (float)y*by/height, Z = (float)z*bz/depth, R = (float)((val-m)*br/range),
19577  bval0 = bgrid._linear_atXYZV(X,Y,Z,R), bval1 = bgridw._linear_atXYZV(X,Y,Z,R);
19578  (*this)(x,y,z,k) = (T)(bval0/bval1);
19579  } else cimg_forXYZ(*this,x,y,z) {
19580  const T val = (*this)(x,y,z,k);
19581  const int X = x*bx/width, Y = y*by/height, Z = z*bz/depth, R = (int)((val-m)*br/range);
19582  const float bval0 = bgrid(X,Y,Z,R), bval1 = bgridw(X,Y,Z,R);
19583  (*this)(x,y,z,k) = (T)(bval0/bval1);
19584  }
19585  }
19586  } else { // 2d version of the algorithm
19587  CImg<floatT> bgrid(bx,by,br,2);
19588  cimg_forV(*this,k) {
19589  bgrid.fill(0);
19590  cimg_forXY(*this,x,y) {
19591  const T val = (*this)(x,y,k);
19592  const int X = x*bx/width, Y = y*by/height, R = (int)((val-m)*br/range);
19593  bgrid(X,Y,R,0) = (float)val;
19594  bgrid(X,Y,R,1) = 1;
19595  }
19596  bgrid.blur(nsigma_x,nsigma_y,0,true).blur(0,0,nsigma_r,false);
19597  if (interpolation_type) cimg_forXY(*this,x,y) {
19598  const T val = (*this)(x,y,k);
19599  const float X = (float)x*bx/width, Y = (float)y*by/height, R = (float)((val-m)*br/range),
19600  bval0 = bgrid._linear_atXYZ(X,Y,R,0), bval1 = bgrid._linear_atXYZ(X,Y,R,1);
19601  (*this)(x,y,k) = (T)(bval0/bval1);
19602  } else cimg_forXY(*this,x,y) {
19603  const T val = (*this)(x,y,k);
19604  const int X = x*bx/width, Y = y*by/height, R = (int)((val-m)*br/range);
19605  const float bval0 = bgrid(X,Y,R,0), bval1 = bgrid(X,Y,R,1);
19606  (*this)(x,y,k) = (T)(bval0/bval1);
19607  }
19608  }
19609  }
19610  }
19611  return *this;
19612  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

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

Blur an image using the bilateral filter.

Definition at line 19621 of file CImg.h.

19622  {
19623  const float nsigma_s = sigma_s>=0?sigma_s:-sigma_s*cimg::max(width,height,depth)/100;
19624  return blur_bilateral(nsigma_s,nsigma_s,nsigma_s,sigma_r,bgrid_s,bgrid_s,bgrid_s,bgrid_r,interpolation_type);
19625  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
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.
Definition: CImg.h:19537
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& blur_median ( const unsigned int  n)
inline

Apply a median filter.

Definition at line 19811 of file CImg.h.

19811  {
19812  return get_blur_median(n).transfer_to(*this);
19813  }
CImg< T > get_blur_median(const unsigned int n) const
Definition: CImg.h:19815
const NT & n
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 
)
inline

Blur an image in its patch-based space.

Definition at line 19633 of file CImg.h.

19634  {
19635  return get_blur_patch(sigma_s,sigma_p,patch_size,lookup_size,smoothness,fast_approx).transfer_to(*this);
19636  }
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
Definition: CImg.h:19638
static CImg<floatT> box3d ( CImgList< tf > &  primitives,
const float  size_x = 200,
const float  size_y = 100,
const float  size_z = 100 
)
inlinestatic

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(points3d,faces3d);
ref_box3d.jpg

Definition at line 21819 of file CImg.h.

21820  {
21821  primitives.assign(6,1,4,1,1, 0,3,2,1, 4,5,6,7, 0,1,5,4, 3,7,6,2, 0,4,7,3, 1,2,6,5);
21822  return CImg<floatT>(8,3,1,1,
21823  0.,size_x,size_x, 0., 0.,size_x,size_x, 0.,
21824  0., 0.,size_y,size_y, 0., 0.,size_y,size_y,
21825  0., 0., 0., 0.,size_z,size_z,size_z,size_z);
21826  }
CImg<T>& channel ( const unsigned int  v0)
inline

Get a channel.

Definition at line 18457 of file CImg.h.

18457  {
18458  return channels(v0,v0);
18459  }
CImg< T > & channels(const unsigned int v0, const unsigned int v1)
Get a set of channels.
Definition: CImg.h:18466
CImg<T>& channels ( const unsigned int  v0,
const unsigned int  v1 
)
inline

Get a set of channels.

Definition at line 18466 of file CImg.h.

Referenced by CImg< uintT >::channel().

18466  {
18467  return get_channels(v0,v1).transfer_to(*this);
18468  }
CImg< T > get_channels(const unsigned int v0, const unsigned int v1) const
Definition: CImg.h:18470

Here is the caller graph for this function:

CImg<T>& clear ( )
inline

In-place version of the default constructor (STL-compliant name).

This function is strictly equivalent to assign() and has been introduced for having a STL-compliant function name.

Definition at line 10090 of file CImg.h.

10090  {
10091  return assign();
10092  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& CMYKtoCMY ( )
inline

Convert (C,M,Y,K) pixels of a color image into the (C,M,Y) color space.

Definition at line 16211 of file CImg.h.

Referenced by CImg< uintT >::CMYKtoRGB().

16211  {
16212  return get_CMYKtoCMY().transfer_to(*this);
16213  }
CImg< Tfloat > get_CMYKtoCMY() const
Definition: CImg.h:16215

Here is the caller graph for this function:

CImg<T>& CMYKtoRGB ( )
inline

Convert a (C,M,Y,K) image to a (R,G,B) one.

Definition at line 16455 of file CImg.h.

Referenced by CImg< uintT >::get_CMYKtoRGB().

16455  {
16456  return CMYKtoCMY().CMYtoRGB();
16457  }
CImg< T > & CMYKtoCMY()
Convert (C,M,Y,K) pixels of a color image into the (C,M,Y) color space.
Definition: CImg.h:16211

Here is the caller graph for this function:

CImg<T>& CMYtoCMYK ( )
inline

Convert color pixels from (C,M,Y) to (C,M,Y,K).

Definition at line 16181 of file CImg.h.

16181  {
16182  return get_CMYtoCMYK().transfer_to(*this);
16183  }
CImg< Tfloat > get_CMYtoCMYK() const
Definition: CImg.h:16185
CImg<T>& CMYtoRGB ( )
inline

Convert (C,M,Y) pixels of a color image into the (R,G,B) color space.

Definition at line 16154 of file CImg.h.

Referenced by CImg< uintT >::get_CMYtoRGB().

16154  {
16155  if (is_empty()) return *this;
16156  if (dim!=3)
16157  throw CImgInstanceException("CImg<%s>::CMYtoRGB() : Input image dimension is dim=%u, "
16158  "should be a (C,M,Y) image (dim=3)",
16159  pixel_type(),dim);
16160  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16161  for (unsigned int N = width*height*depth; N; --N) {
16162  const Tfloat
16163  C = (Tfloat)*p1,
16164  M = (Tfloat)*p2,
16165  Y = (Tfloat)*p3,
16166  R = 255*(1 - C),
16167  G = 255*(1 - M),
16168  B = 255*(1 - Y);
16169  *(p1++) = (T)(R<0?0:(R>255?255:R));
16170  *(p2++) = (T)(G<0?0:(G>255?255:G));
16171  *(p3++) = (T)(B<0?0:(B>255?255:B));
16172  }
16173  return *this;
16174  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& column ( const unsigned int  x0)
inline

Get one column.

Definition at line 18403 of file CImg.h.

18403  {
18404  return columns(x0,x0);
18405  }
CImg< T > & columns(const unsigned int x0, const unsigned int x1)
Get a set of columns.
Definition: CImg.h:18412
CImg<T>& columns ( const unsigned int  x0,
const unsigned int  x1 
)
inline

Get a set of columns.

Definition at line 18412 of file CImg.h.

Referenced by CImg< uintT >::column().

18412  {
18413  return get_columns(x0,x1).transfer_to(*this);
18414  }
CImg< T > get_columns(const unsigned int x0, const unsigned int x1) const
Definition: CImg.h:18416

Here is the caller graph for this function:

static CImg<floatT> cone3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const float  size_z = 100,
const unsigned int  subdivisions = 24 
)
inlinestatic

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(points3d,faces3d);
ref_cone3d.jpg

Definition at line 21845 of file CImg.h.

21846  {
21847  primitives.assign();
21848  if (!subdivisions) return CImg<floatT>();
21849  CImgList<floatT> vertices(2,1,3,1,1,
21850  0.,0.,size_z,
21851  0.,0.,0.);
21852  for (float delta = 360.0f/subdivisions, angle = 0; angle<360; angle+=delta) {
21853  const float a = (float)(angle*cimg::valuePI/180);
21854  CImg<floatT>::vector((float)(radius*std::cos(a)),(float)(radius*std::sin(a)),0).transfer_to(vertices);
21855  }
21856  const unsigned int nbr = vertices.width - 2;
21857  for (unsigned int p = 0; p<nbr; ++p) {
21858  const unsigned int curr = 2 + p, next = 2 + ((p+1)%nbr);
21859  CImg<tf>::vector(1,next,curr).transfer_to(primitives);
21860  CImg<tf>::vector(0,curr,next).transfer_to(primitives);
21861  }
21862  return vertices>'x';
21863  }
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
NT & sin
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
NT & cos
bool contains ( const T &  pixel,
t &  x,
t &  y,
t &  z,
t &  v 
) const
inline

Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y,z,v).

Definition at line 12055 of file CImg.h.

Referenced by CImg< uintT >::get_stats().

12055  {
12056  const unsigned int wh = width*height, whz = wh*depth, siz = whz*dim;
12057  const T *const ppixel = &pixel;
12058  if (is_empty() || ppixel<data || ppixel>=data+siz) return false;
12059  unsigned int off = (unsigned int)(ppixel - data);
12060  const unsigned int nv = off/whz;
12061  off%=whz;
12062  const unsigned int nz = off/wh;
12063  off%=wh;
12064  const unsigned int ny = off/width, nx = off%width;
12065  x = (t)nx; y = (t)ny; z = (t)nz; v = (t)nv;
12066  return true;
12067  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y,z).

Definition at line 12071 of file CImg.h.

12071  {
12072  const unsigned int wh = width*height, whz = wh*depth, siz = whz*dim;
12073  const T *const ppixel = &pixel;
12074  if (is_empty() || ppixel<data || ppixel>=data+siz) return false;
12075  unsigned int off = ((unsigned int)(ppixel - data))%whz;
12076  const unsigned int nz = off/wh;
12077  off%=wh;
12078  const unsigned int ny = off/width, nx = off%width;
12079  x = (t)nx; y = (t)ny; z = (t)nz;
12080  return true;
12081  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
bool contains ( const T &  pixel,
t &  x,
t &  y 
) const
inline

Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x,y).

Definition at line 12085 of file CImg.h.

12085  {
12086  const unsigned int wh = width*height, siz = wh*depth*dim;
12087  const T *const ppixel = &pixel;
12088  if (is_empty() || ppixel<data || ppixel>=data+siz) return false;
12089  unsigned int off = ((unsigned int)(ppixel - data))%wh;
12090  const unsigned int ny = off/width, nx = off%width;
12091  x = (t)nx; y = (t)ny;
12092  return true;
12093  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
bool contains ( const T &  pixel,
t &  x 
) const
inline

Return true if specified referenced value is inside image boundaries. If true, returns pixel coordinates in (x).

Definition at line 12097 of file CImg.h.

12097  {
12098  const T *const ppixel = &pixel;
12099  if (is_empty() || ppixel<data || ppixel>=data+size()) return false;
12100  x = (t)(((unsigned int)(ppixel - data))%width);
12101  return true;
12102  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
void int int REAL * x
Definition: read.cpp:74
bool contains ( const T &  pixel) const
inline

Return true if specified referenced value is inside the image boundaries.

Definition at line 12105 of file CImg.h.

12105  {
12106  const T *const ppixel = &pixel;
12107  return !is_empty() && ppixel>=data && ppixel<data+size();
12108  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
bool containsXYZV ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Return true if pixel (x,y,z,v) is inside image boundaries.

Definition at line 12049 of file CImg.h.

12049  {
12050  return !is_empty() && x>=0 && x<dimx() && y>=0 && y<dimy() && z>=0 && z<dimz() && v>=0 && v<dimv();
12051  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int REAL * x
Definition: read.cpp:74
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
static CImg<Tuchar> contrast_LUT256 ( )
inlinestatic

Return a contrasted indexed color palette with 256 (R,G,B) entries.

Returns
An instance of a contrasted color palette with 256 (R,G,B) colors.
ref_contrast_LUT256.jpg

Definition at line 15756 of file CImg.h.

15756  {
15757  static const unsigned char pal[] = {
15758  217,62,88,75,1,237,240,12,56,160,165,116,1,1,204,2,15,248,148,185,133,141,46,246,222,116,16,5,207,226,
15759  17,114,247,1,214,53,238,0,95,55,233,235,109,0,17,54,33,0,90,30,3,0,94,27,19,0,68,212,166,130,0,15,7,119,
15760  238,2,246,198,0,3,16,10,13,2,25,28,12,6,2,99,18,141,30,4,3,140,12,4,30,233,7,10,0,136,35,160,168,184,20,
15761  233,0,1,242,83,90,56,180,44,41,0,6,19,207,5,31,214,4,35,153,180,75,21,76,16,202,218,22,17,2,136,71,74,
15762  81,251,244,148,222,17,0,234,24,0,200,16,239,15,225,102,230,186,58,230,110,12,0,7,129,249,22,241,37,219,
15763  1,3,254,210,3,212,113,131,197,162,123,252,90,96,209,60,0,17,0,180,249,12,112,165,43,27,229,77,40,195,12,
15764  87,1,210,148,47,80,5,9,1,137,2,40,57,205,244,40,8,252,98,0,40,43,206,31,187,0,180,1,69,70,227,131,108,0,
15765  223,94,228,35,248,243,4,16,0,34,24,2,9,35,73,91,12,199,51,1,249,12,103,131,20,224,2,70,32,
15766  233,1,165,3,8,154,246,233,196,5,0,6,183,227,247,195,208,36,0,0,226,160,210,198,69,153,210,1,23,8,192,2,4,
15767  137,1,0,52,2,249,241,129,0,0,234,7,238,71,7,32,15,157,157,252,158,2,250,6,13,30,11,162,0,199,21,11,27,224,
15768  4,157,20,181,111,187,218,3,0,11,158,230,196,34,223,22,248,135,254,210,157,219,0,117,239,3,255,4,227,5,247,
15769  11,4,3,188,111,11,105,195,2,0,14,1,21,219,192,0,183,191,113,241,1,12,17,248,0,48,7,19,1,254,212,0,239,246,
15770  0,23,0,250,165,194,194,17,3,253,0,24,6,0,141,167,221,24,212,2,235,243,0,0,205,1,251,133,204,28,4,6,1,10,
15771  141,21,74,12,236,254,228,19,1,0,214,1,186,13,13,6,13,16,27,209,6,216,11,207,251,59,32,9,155,23,19,235,143,
15772  116,6,213,6,75,159,23,6,0,228,4,10,245,249,1,7,44,234,4,102,174,0,19,239,103,16,15,18,8,214,22,4,47,244,
15773  255,8,0,251,173,1,212,252,250,251,252,6,0,29,29,222,233,246,5,149,0,182,180,13,151,0,203,183,0,35,149,0,
15774  235,246,254,78,9,17,203,73,11,195,0,3,5,44,0,0,237,5,106,6,130,16,214,20,168,247,168,4,207,11,5,1,232,251,
15775  129,210,116,231,217,223,214,27,45,38,4,177,186,249,7,215,172,16,214,27,249,230,236,2,34,216,217,0,175,30,
15776  243,225,244,182,20,212,2,226,21,255,20,0,2,13,62,13,191,14,76,64,20,121,4,118,0,216,1,147,0,2,210,1,215,
15777  95,210,236,225,184,46,0,248,24,11,1,9,141,250,243,9,221,233,160,11,147,2,55,8,23,12,253,9,0,54,0,231,6,3,
15778  141,8,2,246,9,180,5,11,8,227,8,43,110,242,1,130,5,97,36,10,6,219,86,133,11,108,6,1,5,244,67,19,28,0,174,
15779  154,16,127,149,252,188,196,196,228,244,9,249,0,0,0,37,170,32,250,0,73,255,23,3,224,234,38,195,198,0,255,87,
15780  33,221,174,31,3,0,189,228,6,153,14,144,14,108,197,0,9,206,245,254,3,16,253,178,248,0,95,125,8,0,3,168,21,
15781  23,168,19,50,240,244,185,0,1,144,10,168,31,82,1,13 };
15782  static const CImg<Tuchar> palette(pal,1,256,1,3,false);
15783  return palette;
15784  }
CImg<T>& convolve ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_convol = false 
)
inline

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.
cond= the border condition type (0=zero, 1=dirichlet)
weighted_convol= enable local normalization.

Definition at line 18899 of file CImg.h.

18899  {
18900  return get_convolve(mask,cond,weighted_convol).transfer_to(*this);
18901  }
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg< _cimg_Ttfloat > get_convolve(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_convol=false) const
Definition: CImg.h:18904
CImg<T>& correlate ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_correl = false 
)
inline

Compute the correlation of the instance image by a mask.

The correlation of the instance image *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.
cond= the border condition type (0=zero, 1=dirichlet)
weighted_correl= enable local normalization.

Definition at line 18685 of file CImg.h.

18685  {
18686  return get_correlate(mask,cond,weighted_correl).transfer_to(*this);
18687  }
CImg< _cimg_Ttfloat > get_correlate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false) const
Definition: CImg.h:18690
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg<T>& cos ( )
inline

Compute the cosinus of each pixel value.

Definition at line 12580 of file CImg.h.

Referenced by CImg< uintT >::get_cos().

12580  {
12581  cimg_for(*this,ptr,T) (*ptr) = (T)std::cos((double)(*ptr));
12582  return *this;
12583  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
NT & cos

Here is the caller graph for this function:

CImg<T>& cosh ( )
inline

Compute the hyperbolic cosine of each pixel value.

Definition at line 12610 of file CImg.h.

Referenced by CImg< uintT >::get_cosh().

12610  {
12611  cimg_for(*this,ptr,T) (*ptr) = (T)std::cosh((double)(*ptr));
12612  return *this;
12613  }
CImg< _cimg_Tfloat > cosh(const CImg< T > &instance)
Definition: CImg.h:6066
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& crop ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const int  x1,
const int  y1,
const int  z1,
const int  v1,
const bool  border_condition = false 
)
inline

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.
v0= V-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.
v1= V-coordinate of the lower-right crop rectangle corner.
border_condition= Dirichlet (false) or Neumann border conditions.

Definition at line 18184 of file CImg.h.

Referenced by CImg< uintT >::autocrop(), and CImg< uintT >::crop().

18186  {
18187  return get_crop(x0,y0,z0,v0,x1,y1,z1,v1,border_condition).transfer_to(*this);
18188  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190

Here is the caller graph for this function:

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

Get a rectangular part of the instance 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.
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.

Definition at line 18218 of file CImg.h.

18220  {
18221  return crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition);
18222  }
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
Definition: CImg.h:18184
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& crop ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const bool  border_condition = false 
)
inline

Get a rectangular part of the instance image.

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.

Definition at line 18239 of file CImg.h.

18241  {
18242  return crop(x0,y0,0,0,x1,y1,depth-1,dim-1,border_condition);
18243  }
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
Definition: CImg.h:18184
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& crop ( const int  x0,
const int  x1,
const bool  border_condition = false 
)
inline

Get a rectangular part of the instance image.

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.

Definition at line 18258 of file CImg.h.

18258  {
18259  return crop(x0,0,0,0,x1,height-1,depth-1,dim-1,border_condition);
18260  }
CImg< T > & crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false)
Get a square region of the image.
Definition: CImg.h:18184
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& cross ( const CImg< t > &  img)
inline

Compute the cross product between two 3d vectors.

Definition at line 13457 of file CImg.h.

Referenced by CImg< uintT >::get_cross().

13457  {
13458  if (width!=1 || height<3 || img.width!=1 || img.height<3)
13459  throw CImgInstanceException("CImg<%s>::cross() : Arguments (%u,%u,%u,%u,%p) and (%u,%u,%u,%u,%p) must be both 3d vectors.",
13460  pixel_type(),width,height,depth,dim,data,img.width,img.height,img.depth,img.dim,img.data);
13461  const T x = (*this)[0], y = (*this)[1], z = (*this)[2];
13462  (*this)[0] = (T)(y*img[2]-z*img[1]);
13463  (*this)[1] = (T)(z*img[0]-x*img[2]);
13464  (*this)[2] = (T)(x*img[1]-y*img[0]);
13465  return *this;
13466  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

Tfloat cubic_atX ( const float  fx,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Read a pixel value using cubic interpolation and Dirichlet boundary conditions (first coordinates).

Definition at line 11697 of file CImg.h.

11697  {
11698  const int
11699  x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2;
11700  const float
11701  dx = fx-x;
11702  const Tfloat
11703  Ip = (Tfloat)atX(px,y,z,v,out_val), Ic = (Tfloat)atX(x,y,z,v,out_val),
11704  In = (Tfloat)atX(nx,y,z,v,out_val), Ia = (Tfloat)atX(ax,y,z,v,out_val),
11705  valm = cimg::min(Ip,In,Ic,Ia), valM = cimg::max(Ip,In,Ic,Ia),
11706  u0 = Ic - Ip,
11707  u1 = Ia - In,
11708  a = 2*(Ic-In) + u0 + u1,
11709  b = 3*(In-Ic) - 2*u0 - u1,
11710  val = a*dx*dx*dx + b*dx*dx + u0*dx + Ic;
11711  return val<valm?valm:(val>valM?valM:val);
11712  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T & atX(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the first coordinates (x).
Definition: CImg.h:11324
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
Tfloat cubic_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Read a pixel value using cubic interpolation and Neumann boundary conditions (first coordinates).

Definition at line 11715 of file CImg.h.

11715  {
11716  if (is_empty())
11717  throw CImgInstanceException("CImg<%s>::cubic_atX() : Instance image is empty.",
11718  pixel_type());
11719  return _cubic_atX(fx,y,z,v);
11720  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
Tfloat _cubic_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Definition: CImg.h:11722
Tfloat cubic_atXY ( const float  fx,
const float  fy,
const int  z,
const int  v,
const T  out_val 
) const
inline

Read a pixel value using cubic interpolation and Dirichlet boundary conditions.

Definition at line 11590 of file CImg.h.

Referenced by CImg< uintT >::get_resize(), and CImg< uintT >::get_rotate().

11590  {
11591  const int
11592  x = (int)fx-(fx>=0?0:1), px = x-1, nx = x+1, ax = x+2,
11593  y = (int)fy-(fy>=0?0:1), py = y-1, ny = y+1, ay = y+2;
11594  const float
11595  dx = fx-x, dx2 = dx*dx, dx3 = dx2*dx,
11596  dy = fy-y;
11597  const Tfloat
11598  Ipp = (Tfloat)atXY(px,py,z,v,out_val), Icp = (Tfloat)atXY(x,py,z,v,out_val),
11599  Inp = (Tfloat)atXY(nx,py,z,v,out_val), Iap = (Tfloat)atXY(ax,py,z,v,out_val),
11600  Ipc = (Tfloat)atXY(px,y,z,v,out_val), Icc = (Tfloat)atXY(x,y,z,v,out_val),
11601  Inc = (Tfloat)atXY(nx,y,z,v,out_val), Iac = (Tfloat)atXY(ax,y,z,v,out_val),
11602  Ipn = (Tfloat)atXY(px,ny,z,v,out_val), Icn = (Tfloat)atXY(x,ny,z,v,out_val),
11603  Inn = (Tfloat)atXY(nx,ny,z,v,out_val), Ian = (Tfloat)atXY(ax,ny,z,v,out_val),
11604  Ipa = (Tfloat)atXY(px,ay,z,v,out_val), Ica = (Tfloat)atXY(x,ay,z,v,out_val),
11605  Ina = (Tfloat)atXY(nx,ay,z,v,out_val), Iaa = (Tfloat)atXY(ax,ay,z,v,out_val),
11606  valm = cimg::min(cimg::min(Ipp,Icp,Inp,Iap),cimg::min(Ipc,Icc,Inc,Iac),cimg::min(Ipn,Icn,Inn,Ian),cimg::min(Ipa,Ica,Ina,Iaa)),
11607  valM = cimg::max(cimg::max(Ipp,Icp,Inp,Iap),cimg::max(Ipc,Icc,Inc,Iac),cimg::max(Ipn,Icn,Inn,Ian),cimg::max(Ipa,Ica,Ina,Iaa)),
11608  u0p = Icp - Ipp,
11609  u1p = Iap - Inp,
11610  ap = 2*(Icp-Inp) + u0p + u1p,
11611  bp = 3*(Inp-Icp) - 2*u0p - u1p,
11612  u0c = Icc - Ipc,
11613  u1c = Iac - Inc,
11614  ac = 2*(Icc-Inc) + u0c + u1c,
11615  bc = 3*(Inc-Icc) - 2*u0c - u1c,
11616  u0n = Icn - Ipn,
11617  u1n = Ian - Inn,
11618  an = 2*(Icn-Inn) + u0n + u1n,
11619  bn = 3*(Inn-Icn) - 2*u0n - u1n,
11620  u0a = Ica - Ipa,
11621  u1a = Iaa - Ina,
11622  aa = 2*(Ica-Ina) + u0a + u1a,
11623  ba = 3*(Ina-Ica) - 2*u0a - u1a,
11624  valp = ap*dx3 + bp*dx2 + u0p*dx + Icp,
11625  valc = ac*dx3 + bc*dx2 + u0c*dx + Icc,
11626  valn = an*dx3 + bn*dx2 + u0n*dx + Icn,
11627  vala = aa*dx3 + ba*dx2 + u0a*dx + Ica,
11628  u0 = valc - valp,
11629  u1 = vala - valn,
11630  a = 2*(valc-valn) + u0 + u1,
11631  b = 3*(valn-valc) - 2*u0 - u1,
11632  val = a*dy*dy*dy + b*dy*dy + u0*dy + valc;
11633  return val<valm?valm:(val>valM?valM:val);
11634  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy

Here is the caller graph for this function:

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

Read a pixel value using cubic interpolation and Neumann boundary conditions.

Definition at line 11637 of file CImg.h.

11637  {
11638  if (is_empty())
11639  throw CImgInstanceException("CImg<%s>::cubic_atXY() : Instance image is empty.",
11640  pixel_type());
11641  return _cubic_atXY(fx,fy,z,v);
11642  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
Tfloat _cubic_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Definition: CImg.h:11644
CImg<T>& cut ( const T  value_min,
const T  value_max 
)
inline

Cut values of the instance image 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 instance image.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_cut(160,220);
(img,res).display();
ref_cut.jpg

Definition at line 15172 of file CImg.h.

Referenced by CImg< uintT >::get_cut(), and CImg< uintT >::sharpen().

15172  {
15173  if (is_empty()) return *this;
15174  const T a = value_min<value_max?value_min:value_max, b = value_min<value_max?value_max:value_min;
15175  cimg_for(*this,ptr,T) *ptr = (*ptr<a)?a:((*ptr>b)?b:*ptr);
15176  return *this;
15177  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

static CImg<floatT> cylinder3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const float  size_z = 100,
const unsigned int  subdivisions = 24 
)
inlinestatic

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(points3d,faces3d);
ref_cylinder3d.jpg

Definition at line 21882 of file CImg.h.

21883  {
21884  primitives.assign();
21885  if (!subdivisions) return CImg<floatT>();
21886  CImgList<floatT> vertices(2,1,3,1,1,
21887  0.,0.,0.,
21888  0.,0.,size_z);
21889  for (float delta = 360.0f/subdivisions, angle = 0; angle<360; angle+=delta) {
21890  const float a = (float)(angle*cimg::valuePI/180);
21891  CImg<floatT>::vector((float)(radius*std::cos(a)),(float)(radius*std::sin(a)),0.0f).transfer_to(vertices);
21892  CImg<floatT>::vector((float)(radius*std::cos(a)),(float)(radius*std::sin(a)),size_z).transfer_to(vertices);
21893  }
21894  const unsigned int nbr = (vertices.width - 2)/2;
21895  for (unsigned int p = 0; p<nbr; ++p) {
21896  const unsigned int curr = 2+2*p, next = 2+(2*((p+1)%nbr));
21897  CImg<tf>::vector(0,next,curr).transfer_to(primitives);
21898  CImg<tf>::vector(1,curr+1,next+1).transfer_to(primitives);
21899  CImg<tf>::vector(curr,next,next+1,curr+1).transfer_to(primitives);
21900  }
21901  return vertices>'x';
21902  }
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
NT & sin
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
NT & cos
static CImg<Tuchar> default_LUT256 ( )
inlinestatic

Return a default indexed color palette with 256 (R,G,B) entries.

Returns
An instance of a default color palette with 256 (R,G,B) colors.
Note
This color palette is particularly used by CImg when displaying images on 256 colors displays. It consists in the quantification of the (R,G,B) color space using 3:3:2 bits for color coding (i.e 8 levels for the Red and Green and 4 levels for the Blue).
ref_default_LUT256.jpg

Definition at line 15715 of file CImg.h.

15715  {
15716  static CImg<Tuchar> palette;
15717  if (!palette) {
15718  palette.assign(1,256,1,3);
15719  for (unsigned int index = 0, r = 16; r<256; r+=32)
15720  for (unsigned int g = 16; g<256; g+=32)
15721  for (unsigned int b = 32; b<256; b+=64) {
15722  palette(0,index,0) = (Tuchar)r;
15723  palette(0,index,1) = (Tuchar)g;
15724  palette(0,index++,2) = (Tuchar)b;
15725  }
15726  }
15727  return palette;
15728  }
cimg::superset< T, unsigned char >::type Tuchar
Definition: CImg.h:9773
CImg< T > & index(const CImg< t > &palette, const bool dithering=false, const bool map_indexes=false)
Index multi-valued pixels of the instance image, regarding to a predefined palette.
Definition: CImg.h:15343
CImg<T>& deriche ( const float  sigma,
const int  order = 0,
const char  axis = 'x',
const bool  cond = true 
)
inline

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.

Definition at line 19118 of file CImg.h.

Referenced by CImg< uintT >::blur(), and CImg< uintT >::get_deriche().

19118  {
19119 #define _cimg_deriche2_apply \
19120  Tfloat *ptrY = Y.data, yb = 0, yp = 0; \
19121  T xp = (T)0; \
19122  if (cond) { xp = *ptrX; yb = yp = (Tfloat)(coefp*xp); } \
19123  for (int m = 0; m<N; ++m) { \
19124  const T xc = *ptrX; ptrX+=off; \
19125  const Tfloat yc = *(ptrY++) = (Tfloat)(a0*xc + a1*xp - b1*yp - b2*yb); \
19126  xp = xc; yb = yp; yp = yc; \
19127  } \
19128  T xn = (T)0, xa = (T)0; \
19129  Tfloat yn = 0, ya = 0; \
19130  if (cond) { xn = xa = *(ptrX-off); yn = ya = (Tfloat)coefn*xn; } \
19131  for (int n = N-1; n>=0; --n) { \
19132  const T xc = *(ptrX-=off); \
19133  const Tfloat yc = (Tfloat)(a2*xn + a3*xa - b1*yn - b2*ya); \
19134  xa = xn; xn = xc; ya = yn; yn = yc; \
19135  *ptrX = (T)(*(--ptrY)+yc); \
19136  }
19137  const char naxis = cimg::uncase(axis);
19138  const float nsigma = sigma>=0?sigma:-sigma*(naxis=='x'?width:naxis=='y'?height:naxis=='z'?depth:dim)/100;
19139  if (is_empty() || (nsigma<0.1 && !order)) return *this;
19140  const float
19141  nnsigma = nsigma<0.1f?0.1f:nsigma,
19142  alpha = 1.695f/nnsigma,
19143  ema = (float)std::exp(-alpha),
19144  ema2 = (float)std::exp(-2*alpha),
19145  b1 = -2*ema,
19146  b2 = ema2;
19147  float a0 = 0, a1 = 0, a2 = 0, a3 = 0, coefp = 0, coefn = 0;
19148  switch (order) {
19149  case 0 : {
19150  const float k = (1-ema)*(1-ema)/(1+2*alpha*ema-ema2);
19151  a0 = k;
19152  a1 = k*(alpha-1)*ema;
19153  a2 = k*(alpha+1)*ema;
19154  a3 = -k*ema2;
19155  } break;
19156  case 1 : {
19157  const float k = (1-ema)*(1-ema)/ema;
19158  a0 = k*ema;
19159  a1 = a3 = 0;
19160  a2 = -a0;
19161  } break;
19162  case 2 : {
19163  const float
19164  ea = (float)std::exp(-alpha),
19165  k = -(ema2-1)/(2*alpha*ema),
19166  kn = (-2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea));
19167  a0 = kn;
19168  a1 = -kn*(1+k*alpha)*ema;
19169  a2 = kn*(1-k*alpha)*ema;
19170  a3 = -kn*ema2;
19171  } break;
19172  default :
19173  throw CImgArgumentException("CImg<%s>::deriche() : Given filter order (order = %u) must be 0,1 or 2",
19174  pixel_type(),order);
19175  }
19176  coefp = (a0+a1)/(1+b1+b2);
19177  coefn = (a2+a3)/(1+b1+b2);
19178  switch (naxis) {
19179  case 'x' : {
19180  const int N = width, off = 1;
19181  CImg<Tfloat> Y(N);
19182  cimg_forYZV(*this,y,z,v) { T *ptrX = ptr(0,y,z,v); _cimg_deriche2_apply; }
19183  } break;
19184  case 'y' : {
19185  const int N = height, off = width;
19186  CImg<Tfloat> Y(N);
19187  cimg_forXZV(*this,x,z,v) { T *ptrX = ptr(x,0,z,v); _cimg_deriche2_apply; }
19188  } break;
19189  case 'z' : {
19190  const int N = depth, off = width*height;
19191  CImg<Tfloat> Y(N);
19192  cimg_forXYV(*this,x,y,v) { T *ptrX = ptr(x,y,0,v); _cimg_deriche2_apply; }
19193  } break;
19194  case 'v' : {
19195  const int N = dim, off = width*height*depth;
19196  CImg<Tfloat> Y(N);
19197  cimg_forXYZ(*this,x,y,z) { T *ptrX = ptr(x,y,z,0); _cimg_deriche2_apply; }
19198  } break;
19199  }
19200  return *this;
19201  }
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define _cimg_deriche2_apply
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

Tfloat det ( ) const
inline

Return the determinant of the image, viewed as a matrix.

Definition at line 13227 of file CImg.h.

Referenced by CImg< uintT >::invert().

13227  {
13228  if (is_empty() || width!=height || depth!=1 || dim!=1)
13229  throw CImgInstanceException("CImg<%s>::det() : Instance matrix (%u,%u,%u,%u,%p) is not square or is empty.",
13231  switch (width) {
13232  case 1 : return (Tfloat)((*this)(0,0));
13233  case 2 : return (Tfloat)((*this)(0,0))*(Tfloat)((*this)(1,1)) - (Tfloat)((*this)(0,1))*(Tfloat)((*this)(1,0));
13234  case 3 : {
13235  const Tfloat
13236  a = (Tfloat)data[0], d = (Tfloat)data[1], g = (Tfloat)data[2],
13237  b = (Tfloat)data[3], e = (Tfloat)data[4], h = (Tfloat)data[5],
13238  c = (Tfloat)data[6], f = (Tfloat)data[7], i = (Tfloat)data[8];
13239  return i*a*e - a*h*f - i*b*d + b*g*f + c*d*h - c*g*e;
13240  }
13241  default : {
13242  CImg<Tfloat> lu(*this);
13243  CImg<uintT> indx;
13244  bool d;
13245  lu._LU(indx,d);
13246  Tfloat res = d?(Tfloat)1:(Tfloat)-1;
13247  cimg_forX(lu,i) res*=lu(i,i);
13248  return res;
13249  }
13250  }
13251  return 0;
13252  }
#define cimg_forX(img, x)
Definition: CImg.h:593
const NT & d
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
blockLoc i
Definition: read.cpp:79
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& diagonal ( )
inline

Get a diagonal matrix, whose diagonal coefficients are the coefficients of the input image.

Definition at line 13404 of file CImg.h.

13404  {
13405  return get_diagonal().transfer_to(*this);
13406  }
CImg< T > get_diagonal() const
Definition: CImg.h:13408
static CImg<T> diagonal ( const T &  a0)
inlinestatic

Return a 1x1 diagonal matrix with specified coefficients.

Definition at line 14357 of file CImg.h.

14357  {
14358  return matrix(a0);
14359  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> diagonal ( const T &  a0,
const T &  a1 
)
inlinestatic

Return a 2x2 diagonal matrix with specified coefficients.

Definition at line 14362 of file CImg.h.

14362  {
14363  return matrix(a0,0,0,a1);
14364  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> diagonal ( const T &  a0,
const T &  a1,
const T &  a2 
)
inlinestatic

Return a 3x3 diagonal matrix with specified coefficients.

Definition at line 14367 of file CImg.h.

14367  {
14368  return matrix(a0,0,0,0,a1,0,0,0,a2);
14369  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> diagonal ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3 
)
inlinestatic

Return a 4x4 diagonal matrix with specified coefficients.

Definition at line 14372 of file CImg.h.

14372  {
14373  return matrix(a0,0,0,0,0,a1,0,0,0,0,a2,0,0,0,0,a3);
14374  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> diagonal ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4 
)
inlinestatic

Return a 5x5 diagonal matrix with specified coefficients.

Definition at line 14377 of file CImg.h.

14377  {
14378  return matrix(a0,0,0,0,0,0,a1,0,0,0,0,0,a2,0,0,0,0,0,a3,0,0,0,0,0,a4);
14379  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
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 
)
inlinestatic

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.

Definition at line 14048 of file CImg.h.

Referenced by CImg< uintT >::dijkstra(), and CImg< uintT >::get_dijkstra().

14050  {
14051 
14052  CImg<T> dist(1,nb_nodes,1,1,cimg::type<T>::max());
14053  dist(starting_node) = 0;
14054  previous.assign(1,nb_nodes,1,1,(t)-1);
14055  previous(starting_node) = (t)starting_node;
14056  CImg<uintT> Q(nb_nodes);
14057  cimg_forX(Q,u) Q(u) = u;
14058  cimg::swap(Q(starting_node),Q(0));
14059  unsigned int sizeQ = nb_nodes;
14060  while (sizeQ) {
14061  // Update neighbors from minimal vertex
14062  const unsigned int umin = Q(0);
14063  if (umin==ending_node) sizeQ = 0;
14064  else {
14065  const T dmin = dist(umin);
14066  const T infty = cimg::type<T>::max();
14067  for (unsigned int q=1; q<sizeQ; ++q) {
14068  const unsigned int v = Q(q);
14069  const T d = (T)distance(v,umin);
14070  if (d<infty) {
14071  const T alt = dmin + d;
14072  if (alt<dist(v)) {
14073  dist(v) = alt;
14074  previous(v) = (t)umin;
14075  const T distpos = dist(Q(q));
14076  for (unsigned int pos = q, par = 0; pos && distpos<dist(Q(par=(pos+1)/2-1)); pos=par) cimg::swap(Q(pos),Q(par));
14077  }
14078  }
14079  }
14080  // Remove minimal vertex from queue
14081  Q(0) = Q(--sizeQ);
14082  const T distpos = dist(Q(0));
14083  for (unsigned int pos = 0, left = 0, right = 0;
14084  ((right=2*(pos+1),(left=right-1))<sizeQ && distpos>dist(Q(left))) || (right<sizeQ && distpos>dist(Q(right)));) {
14085  if (right<sizeQ) {
14086  if (dist(Q(left))<dist(Q(right))) { cimg::swap(Q(pos),Q(left)); pos = left; }
14087  else { cimg::swap(Q(pos),Q(right)); pos = right; }
14088  } else { cimg::swap(Q(pos),Q(left)); pos = left; }
14089  }
14090  }
14091  }
14092  return dist;
14093  }
#define cimg_forX(img, x)
Definition: CImg.h:593
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
NT q
CImg< T > & distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true)
Compute the Euclidean distance map to a shape of specified isovalue.
Definition: CImg.h:20441
long double dist(long double *coord1, long double *coord2, int size)
CImg< T > & swap(CImg< T > &img)
Swap all fields of two images. Use with care !
Definition: CImg.h:10357

Here is the caller graph for this function:

static CImg<T> dijkstra ( const tf &  distance,
const unsigned int  nb_nodes,
const unsigned int  starting_node,
const unsigned int  ending_node = ~0U 
)
inlinestatic

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

Definition at line 14097 of file CImg.h.

14098  {
14099  CImg<uintT> foo;
14100  return dijkstra(distance,nb_nodes,starting_node,ending_node,foo);
14101  }
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.
Definition: CImg.h:14048
CImg< T > & distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true)
Compute the Euclidean distance map to a shape of specified isovalue.
Definition: CImg.h:20441
CImg<T>& dijkstra ( const unsigned int  starting_node,
const unsigned int  ending_node,
CImg< t > &  previous 
)
inline

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

Instance image 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.

Definition at line 14111 of file CImg.h.

14111  {
14112  return get_dijkstra(starting_node,ending_node,previous).transfer_to(*this);
14113  }
CImg< T > get_dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous) const
Definition: CImg.h:14116
CImg<T>& dijkstra ( const unsigned int  starting_node,
const unsigned int  ending_node = ~0U 
)
inline

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

Definition at line 14124 of file CImg.h.

14124  {
14125  return get_dijkstra(starting_node,ending_node).transfer_to(*this);
14126  }
CImg< T > get_dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous) const
Definition: CImg.h:14116
CImg<T>& dilate ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_dilatation = false 
)
inline

Dilate the image by a structuring element.

Definition at line 19015 of file CImg.h.

19015  {
19016  return get_dilate(mask,cond,weighted_dilatation).transfer_to(*this);
19017  }
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg< _cimg_Tt > get_dilate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false) const
Definition: CImg.h:19020
CImg<T>& dilate ( const unsigned int  n,
const unsigned int  cond = 1 
)
inline

Dilate the image by a square structuring element of size n.

Definition at line 19099 of file CImg.h.

19099  {
19100  if (n<2) return *this;
19101  return get_dilate(n,cond).transfer_to(*this);
19102  }
const NT & n
CImg< _cimg_Tt > get_dilate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false) const
Definition: CImg.h:19020
int dimv ( ) const
inline

Return the number of vector channels of the instance image (size along the V-axis).

Definition at line 11061 of file CImg.h.

Referenced by CImg< uintT >::_atXYZV(), CImg< uintT >::_autocrop(), CImg< uintT >::_get_select(), CImg< uintT >::_load_analyze(), CImg< uintT >::_save_png(), CImg< uintT >::atXYZV(), CImg< uintT >::containsXYZV(), CImg< uintT >::display_graph(), CImg< uintT >::draw_image(), CImg< uintT >::draw_rectangle(), CImg< uintT >::get_columns(), CImg< uintT >::get_crop(), CImg< uintT >::get_lines(), CImg< uintT >::get_resize(), CImg< uintT >::get_slices(), CImg< uintT >::set_linear_atXY(), CImg< uintT >::set_linear_atXYZ(), and CImg< uintT >::translate().

11061  {
11062  return (int)dim;
11063  }
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

int dimx ( ) const
inline

Return the number of columns of the instance image (size along the X-axis, i.e image width).

Definition at line 11046 of file CImg.h.

Referenced by CImg< uintT >::_atX(), CImg< uintT >::_atXY(), CImg< uintT >::_atXYZ(), CImg< uintT >::_atXYZV(), CImg< uintT >::_autocrop(), CImg< uintT >::_cubic_atX(), CImg< uintT >::_cubic_atXY(), CImg< uintT >::_display(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_scanline(), CImg< uintT >::_get_select(), CImg< uintT >::_load_analyze(), CImg< uintT >::_LU(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_png(), CImg< uintT >::atX(), CImg< uintT >::atXY(), CImg< uintT >::atXYZ(), CImg< uintT >::atXYZV(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::display_graph(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_circle(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_plasma(), CImg< uintT >::draw_point(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_channels(), CImg< uintT >::get_correlate(), CImg< uintT >::get_crop(), CImg< uintT >::get_dilate(), CImg< uintT >::get_distance(), CImg< uintT >::get_erode(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_lines(), CImg< uintT >::get_resize(), CImg< uintT >::get_rotate(), CImg< uintT >::get_slices(), CImg< uintT >::set_linear_atXY(), CImg< uintT >::set_linear_atXYZ(), CImg< uintT >::SVD(), CImg< uintT >::translate(), and CImg< uintT >::transpose().

11046  {
11047  return (int)width;
11048  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int dimy ( ) const
inline

Return the number of rows of the instance image (size along the Y-axis, i.e image height).

Definition at line 11051 of file CImg.h.

Referenced by CImg< uintT >::_atXY(), CImg< uintT >::_atXYZ(), CImg< uintT >::_atXYZV(), CImg< uintT >::_autocrop(), CImg< uintT >::_cubic_atXY(), CImg< uintT >::_display(), CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_triangle(), CImg< uintT >::_get_select(), CImg< uintT >::_load_analyze(), CImg< uintT >::_load_bmp(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_png(), CImg< uintT >::atXY(), CImg< uintT >::atXYZ(), CImg< uintT >::atXYZV(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::display_graph(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_circle(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_plasma(), CImg< uintT >::draw_point(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_channels(), CImg< uintT >::get_columns(), CImg< uintT >::get_correlate(), CImg< uintT >::get_crop(), CImg< uintT >::get_dilate(), CImg< uintT >::get_distance(), CImg< uintT >::get_erode(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_resize(), CImg< uintT >::get_rotate(), CImg< uintT >::get_slices(), CImg< uintT >::set_linear_atXY(), CImg< uintT >::set_linear_atXYZ(), CImg< uintT >::SVD(), and CImg< uintT >::translate().

11051  {
11052  return (int)height;
11053  }
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg<T>& displacement_field ( const CImg< T > &  target,
const float  smooth = 0.1f,
const float  precision = 0.1f,
const unsigned int  nb_scales = 0,
const unsigned int  itermax = 1000,
const bool  backward = true 
)
inline

Estimate a displacement field between instance image and given target image.

Parameters
backward: if false, match I2(X+U(X)) = I1(X), else match I2(X) = I1(X-U(X)).

Definition at line 20331 of file CImg.h.

20333  {
20334  return get_displacement_field(target,smooth,precision,nb_scales,itermax,backward).transfer_to(*this);
20335  }
CImg< Tfloat > get_displacement_field(const CImg< T > &target, const float smoothness=0.1f, const float precision=0.1f, const unsigned int nb_scales=0, const unsigned int itermax=1000, const bool backward=true) const
Definition: CImg.h:20337
const CImg<T>& display ( CImgDisplay disp) const
inline

Display an image into a CImgDisplay window.

Definition at line 31463 of file CImg.h.

Referenced by cimg_library::cimg::dialog().

31463  {
31464  disp.display(*this);
31465  return *this;
31466  }

Here is the caller graph for this function:

const CImg<T>& display ( CImgDisplay disp,
const bool  display_info 
) const
inline

Display an image in a window with a title title, and wait a 'is_closed' or 'keyboard' event.
.

Definition at line 31469 of file CImg.h.

31469  {
31470  return _display(disp,0,display_info);
31471  }
const CImg< T > & _display(CImgDisplay &disp, const char *const title, const bool display_info) const
Definition: CImg.h:31479
const CImg<T>& display ( const char *const  title = 0,
const bool  display_info = true 
) const
inline

Display an image in a window with a title title, and wait a 'is_closed' or 'keyboard' event.
.

Definition at line 31474 of file CImg.h.

31474  {
31475  CImgDisplay disp;
31476  return _display(disp,title,display_info);
31477  }
const CImg< T > & _display(CImgDisplay &disp, const char *const title, const bool display_info) const
Definition: CImg.h:31479
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
inline

High-level interface for displaying a graph.

Definition at line 32133 of file CImg.h.

Referenced by CImg< uintT >::display_graph().

32136  {
32137  if (is_empty())
32138  throw CImgInstanceException("CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
32140  const unsigned int siz = width*height*depth, onormalization = disp.normalization;
32141  if (!disp) { char ntitle[64] = { 0 }; std::sprintf(ntitle,"CImg<%s>",pixel_type()); disp.assign(640,480,ntitle,0); }
32142  disp.show().flush().normalization = 0;
32143  double y0 = ymin, y1 = ymax, nxmin = xmin, nxmax = xmax;
32144  if (nxmin==nxmax) { nxmin = 0; nxmax = siz; }
32145  int x0 = 0, x1 = dimx()*dimy()*dimz()-1, key = 0;
32146 
32147  for (bool reset_view = true, resize_disp = false; !key && !disp.is_closed; ) {
32148  if (reset_view) { x0 = 0; x1 = dimx()*dimy()*dimz()-1; y0 = ymin; y1 = ymax; reset_view = false; }
32149  CImg<T> zoom(x1-x0+1,1,1,dimv());
32150  cimg_forV(*this,k) zoom.get_shared_channel(k) = CImg<T>(ptr(x0,0,0,k),x1-x0+1,1,1,1,true);
32151 
32152  if (y0==y1) y0 = zoom.minmax(y1);
32153  if (y0==y1) { --y0; ++y1; }
32154  const CImg<intT> selection = zoom.get_select_graph(disp,plot_type,vertex_type,
32155  labelx,nxmin + x0*(nxmax-nxmin)/siz,nxmin + (x1+1)*(nxmax-nxmin)/siz,
32156  labely,y0,y1);
32157 
32158  const int mouse_x = disp.mouse_x, mouse_y = disp.mouse_y;
32159  if (selection[0]>=0 && selection[2]>=0) {
32160  x1 = x0 + selection[2];
32161  x0 += selection[0];
32162  if (x0==x1) reset_view = true;
32163  if (selection[1]>=0 && selection[3]>=0) {
32164  y0 = y1 - selection[3]*(y1-y0)/(disp.dimy()-32);
32165  y1 -= selection[1]*(y1-y0)/(disp.dimy()-32);
32166  }
32167  } else {
32168  bool go_in = false, go_out = false, go_left = false, go_right = false, go_up = false, go_down = false;
32169  switch (key = disp.key) {
32170  case cimg::keyHOME : case cimg::keyBACKSPACE : reset_view = resize_disp = true; key = 0; break;
32171  case cimg::keyPADADD : go_in = true; key = 0; break;
32172  case cimg::keyPADSUB : go_out = true; key = 0; break;
32173  case cimg::keyARROWLEFT : case cimg::keyPAD4 : go_left = true; key = 0; break;
32174  case cimg::keyARROWRIGHT : case cimg::keyPAD6 : go_right = true; key = 0; break;
32175  case cimg::keyARROWUP : case cimg::keyPAD8 : go_up = true; key = 0; break;
32176  case cimg::keyARROWDOWN : case cimg::keyPAD2 : go_down = true; key = 0; break;
32177  case cimg::keyPAD7 : go_left = true; go_up = true; key = 0; break;
32178  case cimg::keyPAD9 : go_right = true; go_up = true; key = 0; break;
32179  case cimg::keyPAD1 : go_left = true; go_down = true; key = 0; break;
32180  case cimg::keyPAD3 : go_right = true; go_down = true; key = 0; break;
32181  }
32182  if (disp.wheel) go_out = !(go_in = disp.wheel>0);
32183 
32184  if (go_in) {
32185  const int
32186  xsiz = x1 - x0,
32187  mx = (mouse_x-16)*xsiz/(disp.dimx()-32),
32188  cx = x0 + (mx<0?0:(mx>=xsiz?xsiz:mx));
32189  if (x1-x0>4) {
32190  x0 = cx - 7*(cx-x0)/8; x1 = cx + 7*(x1-cx)/8;
32191  if (disp.is_keyCTRLLEFT) {
32192  const double
32193  ysiz = y1 - y0,
32194  my = (mouse_y-16)*ysiz/(disp.dimy()-32),
32195  cy = y1 - (my<0?0:(my>=ysiz?ysiz:my));
32196  y0 = cy - 7*(cy-y0)/8; y1 = cy + 7*(y1-cy)/8;
32197  } else y0 = y1 = 0;
32198  }
32199  }
32200  if (go_out) {
32201  const int deltax = (x1-x0)/8, ndeltax = deltax?deltax:(siz>1?1:0);
32202  x0-=ndeltax; x1+=ndeltax;
32203  if (x0<0) { x1-=x0; x0 = 0; if (x1>=(int)siz) x1 = (int)siz-1; }
32204  if (x1>=(int)siz) { x0-=(x1-siz+1); x1 = (int)siz-1; if (x0<0) x0 = 0; }
32205  if (disp.is_keyCTRLLEFT) {
32206  const double deltay = (y1-y0)/8, ndeltay = deltay?deltay:0.01;
32207  y0-=ndeltay; y1+=ndeltay;
32208  }
32209  }
32210  if (go_left) {
32211  const int delta = (x1-x0)/5, ndelta = delta?delta:1;
32212  if (x0-ndelta>=0) { x0-=ndelta; x1-=ndelta; }
32213  else { x1-=x0; x0 = 0; }
32214  go_left = false;
32215  }
32216  if (go_right) {
32217  const int delta = (x1-x0)/5, ndelta = delta?delta:1;
32218  if (x1+ndelta<(int)siz) { x0+=ndelta; x1+=ndelta; }
32219  else { x0+=(siz-1-x1); x1 = siz-1; }
32220  go_right = false;
32221  }
32222  if (go_up) {
32223  const double delta = (y1-y0)/10, ndelta = delta?delta:1;
32224  y0+=ndelta; y1+=ndelta;
32225  go_up = false;
32226  }
32227  if (go_down) {
32228  const double delta = (y1-y0)/10, ndelta = delta?delta:1;
32229  y0-=ndelta; y1-=ndelta;
32230  go_down = false;
32231  }
32232  }
32233  }
32234  disp.normalization = onormalization;
32235  return *this;
32236  }
const unsigned int keyPAD3
Definition: CImg.h:2748
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const unsigned int keyPADADD
Definition: CImg.h:2755
const unsigned int keyARROWLEFT
Definition: CImg.h:2742
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
const unsigned int keyPAD1
Definition: CImg.h:2746
const unsigned int keyPAD6
Definition: CImg.h:2751
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const unsigned int keyPAD9
Definition: CImg.h:2754
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
const unsigned int keyPAD2
Definition: CImg.h:2747
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
const unsigned int keyHOME
Definition: CImg.h:2697
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
Definition: CImg.h:12920
const unsigned int keyARROWUP
Definition: CImg.h:2733
const unsigned int keyARROWRIGHT
Definition: CImg.h:2744
CImg()
Default constructor.
Definition: CImg.h:9857
const unsigned int keyPAD7
Definition: CImg.h:2752
const unsigned int keyPAD4
Definition: CImg.h:2749
const unsigned int keyPADSUB
Definition: CImg.h:2756
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
const unsigned int keyBACKSPACE
Definition: CImg.h:2695
const unsigned int keyPAD8
Definition: CImg.h:2753
const unsigned int keyARROWDOWN
Definition: CImg.h:2743
static T_Key key
Definition: vinci_lass.c:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

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
inline

High-level interface for displaying a graph.

Definition at line 32239 of file CImg.h.

32242  {
32243  if (is_empty())
32244  throw CImgInstanceException("CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
32246  char ntitle[64] = { 0 }; if (!title) std::sprintf(ntitle,"CImg<%s>",pixel_type());
32247  CImgDisplay disp(cimg_fitscreen(640,480,1),title?title:ntitle,0);
32248  return display_graph(disp,plot_type,vertex_type,labelx,xmin,xmax,labely,ymin,ymax);
32249  }
#define cimg_fitscreen(dx, dy, dz)
Definition: CImg.h:6436
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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.
Definition: CImg.h:32133
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31664 of file CImg.h.

Referenced by CImg< uintT >::display_object3d().

31673  {
31674  return _display_object3d(disp,0,vertices,primitives,colors,opacities,centering,render_static,
31675  render_motion,double_sided,focale,specular_light,specular_shine,
31676  display_axes,pose_matrix);
31677  }
const CImg< T > & _display_object3d(CImgDisplay &disp, const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering, const int render_static, const int render_motion, const bool double_sided, const float focale, const float specular_light, const float specular_shine, const bool display_axes, float *const pose_matrix) const
Definition: CImg.h:31788

Here is the caller graph for this function:

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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31681 of file CImg.h.

31690  {
31691  CImgDisplay disp;
31692  return _display_object3d(disp,title,vertices,primitives,colors,opacities,centering,render_static,
31693  render_motion,double_sided,focale,specular_light,specular_shine,
31694  display_axes,pose_matrix);
31695  }
const CImg< T > & _display_object3d(CImgDisplay &disp, const char *const title, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const bool centering, const int render_static, const int render_motion, const bool double_sided, const float focale, const float specular_light, const float specular_shine, const bool display_axes, float *const pose_matrix) const
Definition: CImg.h:31788
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31699 of file CImg.h.

31707  {
31708  return display_object3d(disp,vertices,primitives,colors,CImgList<floatT>(),centering,
31709  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31710  display_axes,pose_matrix);
31711  }
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 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.
Definition: CImg.h:31664
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31715 of file CImg.h.

31723  {
31724  return display_object3d(title,vertices,primitives,colors,CImgList<floatT>(),centering,
31725  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31726  display_axes,pose_matrix);
31727  }
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 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.
Definition: CImg.h:31664
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31731 of file CImg.h.

31738  {
31739  return display_object3d(disp,vertices,primitives,CImgList<T>(),centering,
31740  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31741  display_axes,pose_matrix);
31742  }
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 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.
Definition: CImg.h:31664
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31746 of file CImg.h.

31753  {
31754  return display_object3d(title,vertices,primitives,CImgList<T>(),centering,
31755  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31756  display_axes,pose_matrix);
31757  }
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 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.
Definition: CImg.h:31664
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31761 of file CImg.h.

31767  {
31768  return display_object3d(disp,vertices,CImgList<uintT>(),centering,
31769  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31770  display_axes,pose_matrix);
31771  }
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 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.
Definition: CImg.h:31664
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  specular_light = 0.2f,
const float  specular_shine = 0.1f,
const bool  display_axes = true,
float *const  pose_matrix = 0 
) const
inline

High-level interface for displaying a 3d object.

Definition at line 31775 of file CImg.h.

31781  {
31782  return display_object3d(title,vertices,CImgList<uintT>(),centering,
31783  render_static,render_motion,double_sided,focale,specular_light,specular_shine,
31784  display_axes,pose_matrix);
31785  }
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 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.
Definition: CImg.h:31664
CImg<T>& distance ( const T  isovalue,
const float  sizex = 1,
const float  sizey = 1,
const float  sizez = 1,
const bool  compute_sqrt = true 
)
inline

Compute the Euclidean distance map to a shape of specified isovalue.

Definition at line 20441 of file CImg.h.

Referenced by CImg< uintT >::dijkstra(), rflu_modextractflowdata::rflu_extractflowdatalinefarf(), and turb_coranswalldistov().

20443  {
20444  return get_distance(isovalue,sizex,sizey,sizez,compute_sqrt).transfer_to(*this);
20445  }
CImg< floatT > get_distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true) const
Definition: CImg.h:20447

Here is the caller graph for this function:

CImg<T>& distance_hamilton ( const unsigned int  nb_iter,
const float  band_size = 0,
const float  precision = 0.5f 
)
inline

Compute distance function from 0-valued isophotes by the application of an Hamilton-Jacobi PDE.

Definition at line 20547 of file CImg.h.

Referenced by CImg< uintT >::get_distance_hamilton().

20547  {
20548  if (is_empty()) return *this;
20549  CImg<Tfloat> veloc(*this);
20550  for (unsigned int iter = 0; iter<nb_iter; ++iter) {
20551  veloc.fill(0);
20552  if (depth>1) { // 3D version
20553  CImg_3x3x3(I,T);
20554  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) if (band_size<=0 || cimg::abs(Iccc)<band_size) {
20555  const Tfloat
20556  gx = 0.5f*((Tfloat)Incc - Ipcc),
20557  gy = 0.5f*((Tfloat)Icnc - Icpc),
20558  gz = 0.5f*((Tfloat)Iccn - Iccp),
20559  sgn = -cimg::sign((Tfloat)Iccc),
20560  ix = gx*sgn>0?(Tfloat)Incc - Iccc:(Tfloat)Iccc - Ipcc,
20561  iy = gy*sgn>0?(Tfloat)Icnc - Iccc:(Tfloat)Iccc - Icpc,
20562  iz = gz*sgn>0?(Tfloat)Iccn - Iccc:(Tfloat)Iccc - Iccp,
20563  ng = 1e-5f + (Tfloat)std::sqrt(gx*gx + gy*gy + gz*gz),
20564  ngx = gx/ng,
20565  ngy = gy/ng,
20566  ngz = gz/ng;
20567  veloc(x,y,z,k) = sgn*(ngx*ix + ngy*iy + ngz*iz - 1);
20568  }
20569  } else { // 2D version
20570  CImg_3x3(I,T);
20571  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) if (band_size<=0 || cimg::abs(Icc)<band_size) {
20572  const Tfloat
20573  gx = 0.5f*((Tfloat)Inc - Ipc),
20574  gy = 0.5f*((Tfloat)Icn - Icp),
20575  sgn = -cimg::sign((Tfloat)Icc),
20576  ix = gx*sgn>0?(Tfloat)Inc - Icc:(Tfloat)Icc - Ipc,
20577  iy = gy*sgn>0?(Tfloat)Icn - Icc:(Tfloat)Icc - Icp,
20578  ng = 1e-5f + (Tfloat)std::sqrt(gx*gx + gy*gy),
20579  ngx = gx/ng,
20580  ngy = gy/ng;
20581  veloc(x,y,k) = sgn*(ngx*ix + ngy*iy - 1);
20582  }
20583  }
20584  float m, M = (float)veloc.maxmin(m), xdt = precision/(float)cimg::max(cimg::abs(m),cimg::abs(M));
20585  *this+=(veloc*=xdt);
20586  }
20587  return *this;
20588  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
T sign(const T x)
Return the sign of a number.
Definition: CImg.h:4770
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421

Here is the caller graph for this function:

CImg<T>& div ( const CImg< t > &  img)
inline

Pointwise division between two images.

Definition at line 12704 of file CImg.h.

Referenced by CImg< uintT >::div(), and CImg< uintT >::get_div().

12704  {
12705  const unsigned int siz = size(), isiz = img.size();
12706  if (siz && isiz) {
12707  if (is_overlapped(img)) return div(+img);
12708  T *ptrd = data, *const ptrd_end = data + siz;
12709  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
12710  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd / *(ptrs++));
12711  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd / *(ptrs++));
12712  }
12713  return *this;
12714  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
CImg< T > & div(const CImg< t > &img)
Pointwise division between two images.
Definition: CImg.h:12704
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n

Here is the caller graph for this function:

Tfloat dot ( const CImg< t > &  img) const
inline

Return the dot product of the current vector/matrix with the vector/matrix img.

Definition at line 13256 of file CImg.h.

Referenced by CImg< uintT >::magnitude().

13256  {
13257  if (is_empty())
13258  throw CImgInstanceException("CImg<%s>::dot() : Instance object (%u,%u,%u,%u,%p) is empty.",
13260  if (!img)
13261  throw CImgArgumentException("CImg<%s>::trace() : Specified argument (%u,%u,%u,%u,%p) is empty.",
13262  pixel_type(),img.width,img.height,img.depth,img.dim,img.data);
13263  const unsigned int nb = cimg::min(size(),img.size());
13264  Tfloat res = 0;
13265  for (unsigned int off = 0; off<nb; ++off) res+=(Tfloat)data[off]*(Tfloat)img[off];
13266  return res;
13267  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

Draw a colored arrow in the instance image.

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 dimv() 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.

Definition at line 23057 of file CImg.h.

Referenced by CImg< uintT >::_get_select(), CImg< uintT >::draw_arrow(), CImg< uintT >::draw_axis(), and CImg< uintT >::draw_quiver().

23061  {
23062  if (is_empty()) return *this;
23063  const float u = (float)(x0 - x1), v = (float)(y0 - y1), sq = u*u + v*v,
23064  deg = (float)(angle*cimg::valuePI/180), ang = (sq>0)?(float)std::atan2(v,u):0.0f,
23065  l = (length>=0)?length:-length*(float)std::sqrt(sq)/100;
23066  if (sq>0) {
23067  const float
23068  cl = (float)std::cos(ang - deg), sl = (float)std::sin(ang - deg),
23069  cr = (float)std::cos(ang + deg), sr = (float)std::sin(ang + deg);
23070  const int
23071  xl = x1 + (int)(l*cl), yl = y1 + (int)(l*sl),
23072  xr = x1 + (int)(l*cr), yr = y1 + (int)(l*sr),
23073  xc = x1 + (int)((l+1)*(cl+cr))/2, yc = y1 + (int)((l+1)*(sl+sr))/2;
23074  draw_line(x0,y0,xc,yc,color,opacity,pattern).draw_triangle(x1,y1,xl,yl,xr,yr,color,opacity);
23075  } else draw_point(x0,y0,color,opacity);
23076  return *this;
23077  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
double length(Vector3D *const v, int n)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
NT & sin
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
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.
Definition: CImg.h:22330
NT & cos

Here is the caller graph for this function:

CImg<T>& draw_arrow ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const CImg< tc > &  color,
const float  opacity = 1,
const float  angle = 30,
const float  length = -10,
const unsigned int  pattern = ~0U 
)
inline

Draw a colored arrow in the instance image.

Definition at line 23081 of file CImg.h.

23085  {
23086  return draw_arrow(x0,y0,x1,y1,color.data,opacity,angle,length,pattern);
23087  }
double length(Vector3D *const v, int n)
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
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 instance image.
Definition: CImg.h:23057
CImg<T>& draw_axis ( const CImg< t > &  xvalues,
const int  y,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U 
)
inline

Draw a labeled horizontal axis on the instance image.

Parameters
xvaluesLower bound of the x-range.
yY-coordinate of the horizontal axis in the instance image.
colorArray of dimv() 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.

Definition at line 26565 of file CImg.h.

Referenced by CImg< uintT >::draw_axis().

26567  {
26568  if (!is_empty()) {
26569  int siz = (int)xvalues.size()-1;
26570  if (siz<=0) draw_line(0,y,width-1,y,color,opacity,pattern);
26571  else {
26572  if (xvalues[0]<xvalues[siz]) draw_arrow(0,y,width-1,y,color,opacity,30,5,pattern);
26573  else draw_arrow(width-1,y,0,y,color,opacity,30,5,pattern);
26574  const int yt = (y+14)<dimy()?(y+3):(y-14);
26575  char txt[32] = { 0 };
26576  cimg_foroff(xvalues,x) {
26577  std::sprintf(txt,"%g",(double)xvalues(x));
26578  const int xi = (int)(x*(width-1)/siz), xt = xi-(int)std::strlen(txt)*3;
26579  draw_point(xi,y-1,color,opacity).draw_point(xi,y+1,color,opacity).
26580  draw_text(xt<0?0:xt,yt,txt,color,(tc*)0,opacity,11);
26581  }
26582  }
26583  }
26584  return *this;
26585  }
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.
Definition: CImg.h:26338
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
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 instance image.
Definition: CImg.h:23057
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.
Definition: CImg.h:22330

Here is the caller graph for this function:

CImg<T>& draw_axis ( const CImg< t > &  xvalues,
const int  y,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U 
)
inline

Draw a labeled horizontal axis on the instance image.

Definition at line 26589 of file CImg.h.

26591  {
26592  return draw_axis(xvalues,y,color.data,opacity,pattern);
26593  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26565
CImg<T>& draw_axis ( const int  x,
const CImg< t > &  yvalues,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U 
)
inline

Draw a labeled vertical axis on the instance image.

Definition at line 26597 of file CImg.h.

26599  {
26600  if (!is_empty()) {
26601  int siz = (int)yvalues.size()-1;
26602  if (siz<=0) draw_line(x,0,x,height-1,color,opacity,pattern);
26603  else {
26604  if (yvalues[0]<yvalues[siz]) draw_arrow(x,0,x,height-1,color,opacity,30,5,pattern);
26605  else draw_arrow(x,height-1,x,0,color,opacity,30,5,pattern);
26606  char txt[32] = { 0 };
26607  cimg_foroff(yvalues,y) {
26608  std::sprintf(txt,"%g",(double)yvalues(y));
26609  const int
26610  yi = (int)(y*(height-1)/siz),
26611  tmp = yi-5,
26612  nyi = tmp<0?0:(tmp>=dimy()-11?dimy()-11:tmp),
26613  xt = x-(int)std::strlen(txt)*7;
26614  draw_point(x-1,yi,color,opacity).draw_point(x+1,yi,color,opacity);
26615  if (xt>0) draw_text(xt,nyi,txt,color,(tc*)0,opacity,11);
26616  else draw_text(x+3,nyi,txt,color,(tc*)0,opacity,11);
26617  }
26618  }
26619  }
26620  return *this;
26621  }
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.
Definition: CImg.h:26338
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
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 instance image.
Definition: CImg.h:23057
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.
Definition: CImg.h:22330
CImg<T>& draw_axis ( const int  x,
const CImg< t > &  yvalues,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U 
)
inline

Draw a labeled vertical axis on the instance image.

Definition at line 26625 of file CImg.h.

26627  {
26628  return draw_axis(x,yvalues,color.data,opacity,pattern);
26629  }
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 instance image.
Definition: CImg.h:26565
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_axis ( 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 
)
inline

Draw a labeled horizontal+vertical axis on the instance image.

Definition at line 26633 of file CImg.h.

26635  {
26636  if (!is_empty()) {
26637  const CImg<tx> nxvalues(xvalues.data,xvalues.size(),1,1,1,true);
26638  const int sizx = (int)xvalues.size()-1, wm1 = (int)(width)-1;
26639  if (sizx>0) {
26640  float ox = (float)nxvalues[0];
26641  for (unsigned int x = 1; x<width; ++x) {
26642  const float nx = (float)nxvalues._linear_atX((float)x*sizx/wm1);
26643  if (nx*ox<=0) { draw_axis(nx==0?x:x-1,yvalues,color,opacity,patterny); break; }
26644  ox = nx;
26645  }
26646  }
26647  const CImg<ty> nyvalues(yvalues.data,yvalues.size(),1,1,1,true);
26648  const int sizy = (int)yvalues.size()-1, hm1 = (int)(height)-1;
26649  if (sizy>0) {
26650  float oy = (float)nyvalues[0];
26651  for (unsigned int y = 1; y<height; ++y) {
26652  const float ny = (float)nyvalues._linear_atX((float)y*sizy/hm1);
26653  if (ny*oy<=0) { draw_axis(xvalues,ny==0?y:y-1,color,opacity,patternx); break; }
26654  oy = ny;
26655  }
26656  }
26657  }
26658  return *this;
26659  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
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 instance image.
Definition: CImg.h:26565
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_axis ( const CImg< tx > &  xvalues,
const CImg< ty > &  yvalues,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  patternx = ~0U,
const unsigned int  patterny = ~0U 
)
inline

Draw a labeled horizontal+vertical axis on the instance image.

Definition at line 26663 of file CImg.h.

26665  {
26666  return draw_axis(xvalues,yvalues,color.data,opacity,patternx,patterny);
26667  }
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 instance image.
Definition: CImg.h:26565
CImg<T>& draw_axis ( 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 
)
inline

Draw a labeled horizontal+vertical axis on the instance image.

Definition at line 26671 of file CImg.h.

26675  {
26676  if (!is_empty()) {
26677  const float
26678  dx = cimg::abs(x1-x0), dy = cimg::abs(y1-y0),
26679  px = (precisionx==0)?(float)std::pow(10.0,(int)std::log10(dx)-2.0):precisionx,
26680  py = (precisiony==0)?(float)std::pow(10.0,(int)std::log10(dy)-2.0):precisiony;
26681  draw_axis(CImg<floatT>::sequence(subdivisionx>0?subdivisionx:1-dimx()/subdivisionx,x0,x1).round(px),
26682  CImg<floatT>::sequence(subdivisiony>0?subdivisiony:1-dimy()/subdivisiony,y0,y1).round(py),
26683  color,opacity,patternx,patterny);
26684  }
26685  return *this;
26686  }
CImg< T > & log10()
Compute the log10 of each each pixel value.
Definition: CImg.h:12560
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
NT dx
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
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 instance image.
Definition: CImg.h:26565
CImg< _cimg_Tfloat > log10(const CImg< T > &instance)
Definition: CImg.h:6026
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
CImg< T > & round(const float x, const int rounding_type=0)
Compute image with rounded pixel values.
Definition: CImg.h:14976
NT dy
double pow(double value, const Exponent &exp)
CImg<T>& draw_axis ( const float  x0,
const float  x1,
const float  y0,
const float  y1,
const CImg< tc > &  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 
)
inline

Draw a labeled horizontal+vertical axis on the instance image.

Definition at line 26690 of file CImg.h.

26694  {
26695  return draw_axis(x0,x1,y0,y1,color.data,opacity,subdivisionx,subdivisiony,precisionx,precisiony,patternx,patterny);
26696  }
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 instance image.
Definition: CImg.h:26565
CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a filled circle.

Parameters
x0X-coordinate of the circle center.
y0Y-coordinate of the circle center.
radiusCircle radius.
colorArray of dimv() values of type T, defining the drawing color.
opacityDrawing opacity.
Note
  • Circle version of the Bresenham's algorithm is used.

Definition at line 25869 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), CImg< uintT >::draw_circle(), and CImg< uintT >::draw_graph().

25870  {
25871  if (!is_empty()) {
25872  if (!color)
25873  throw CImgArgumentException("CImg<%s>::draw_circle : Specified color is (null).",
25874  pixel_type());
25875  _draw_scanline(color,opacity);
25876  if (radius<0 || x0-radius>=dimx() || y0+radius<0 || y0-radius>=dimy()) return *this;
25877  if (y0>=0 && y0<dimy()) _draw_scanline(x0-radius,x0+radius,y0,color,opacity);
25878  for (int f = 1-radius, ddFx = 0, ddFy = -(radius<<1), x = 0, y = radius; x<y; ) {
25879  if (f>=0) {
25880  const int x1 = x0-x, x2 = x0+x, y1 = y0-y, y2 = y0+y;
25881  if (y1>=0 && y1<dimy()) _draw_scanline(x1,x2,y1,color,opacity);
25882  if (y2>=0 && y2<dimy()) _draw_scanline(x1,x2,y2,color,opacity);
25883  f+=(ddFy+=2); --y;
25884  }
25885  const bool no_diag = y!=(x++);
25886  ++(f+=(ddFx+=2));
25887  const int x1 = x0-y, x2 = x0+y, y1 = y0-x, y2 = y0+x;
25888  if (no_diag) {
25889  if (y1>=0 && y1<dimy()) _draw_scanline(x1,x2,y1,color,opacity);
25890  if (y2>=0 && y2<dimy()) _draw_scanline(x1,x2,y2,color,opacity);
25891  }
25892  }
25893  }
25894  return *this;
25895  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
CImg< T > & _draw_scanline(const int x0, const int x1, const int y, const tc *const color, const float opacity=1, const float brightness=1, const bool init=false)
Definition: CImg.h:22095

Here is the caller graph for this function:

CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a filled circle.

Definition at line 25899 of file CImg.h.

25900  {
25901  return draw_circle(x0,y0,radius,color.data,opacity);
25902  }
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
Draw a filled circle.
Definition: CImg.h:25869
CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const tc *const  color,
const float  opacity,
const unsigned  int 
)
inline

Draw an outlined circle.

Parameters
x0X-coordinate of the circle center.
y0Y-coordinate of the circle center.
radiusCircle radius.
colorArray of dimv() values of type T, defining the drawing color.
opacityDrawing opacity.

Definition at line 25913 of file CImg.h.

25915  {
25916  if (!is_empty()) {
25917  if (!color)
25918  throw CImgArgumentException("CImg<%s>::draw_circle : Specified color is (null).",
25919  pixel_type());
25920  if (radius<0 || x0-radius>=dimx() || y0+radius<0 || y0-radius>=dimy()) return *this;
25921  if (!radius) return draw_point(x0,y0,color,opacity);
25922  draw_point(x0-radius,y0,color,opacity).draw_point(x0+radius,y0,color,opacity).
25923  draw_point(x0,y0-radius,color,opacity).draw_point(x0,y0+radius,color,opacity);
25924  if (radius==1) return *this;
25925  for (int f = 1-radius, ddFx = 0, ddFy = -(radius<<1), x = 0, y = radius; x<y; ) {
25926  if (f>=0) { f+=(ddFy+=2); --y; }
25927  ++x; ++(f+=(ddFx+=2));
25928  if (x!=y+1) {
25929  const int x1 = x0-y, x2 = x0+y, y1 = y0-x, y2 = y0+x, x3 = x0-x, x4 = x0+x, y3 = y0-y, y4 = y0+y;
25930  draw_point(x1,y1,color,opacity).draw_point(x1,y2,color,opacity).
25931  draw_point(x2,y1,color,opacity).draw_point(x2,y2,color,opacity);
25932  if (x!=y)
25933  draw_point(x3,y3,color,opacity).draw_point(x4,y4,color,opacity).
25934  draw_point(x4,y3,color,opacity).draw_point(x3,y4,color,opacity);
25935  }
25936  }
25937  }
25938  return *this;
25939  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_circle ( const int  x0,
const int  y0,
int  radius,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw an outlined circle.

Definition at line 25943 of file CImg.h.

25945  {
25946  return draw_circle(x0,y0,radius,color.data,opacity,pattern);
25947  }
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
Draw a filled circle.
Definition: CImg.h:25869
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 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 26017 of file CImg.h.

Referenced by CImg< uintT >::_get_select(), and CImg< uintT >::draw_ellipse().

26018  {
26019  return _draw_ellipse(x0,y0,r1,r2,angle,color,opacity,0U);
26020  }
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)
Definition: CImg.h:25951
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61

Here is the caller graph for this function:

CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const float  r1,
const float  r2,
const float  angle,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a filled ellipse.

Definition at line 26024 of file CImg.h.

26025  {
26026  return draw_ellipse(x0,y0,r1,r2,angle,color.data,opacity);
26027  }
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
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.
Definition: CImg.h:26017
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity = 1 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 26038 of file CImg.h.

26039  {
26040  CImgList<t> eig = tensor.get_symmetric_eigen();
26041  const CImg<t> &val = eig[0], &vec = eig[1];
26042  return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity);
26043  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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.
Definition: CImg.h:26017
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const CImg< t > &  tensor,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a filled ellipse.

Definition at line 26047 of file CImg.h.

26048  {
26049  return draw_ellipse(x0,y0,tensor,color.data,opacity);
26050  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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.
Definition: CImg.h:26017
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 
)
inline

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 dimv() 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.

Definition at line 26065 of file CImg.h.

26066  {
26067  if (pattern) _draw_ellipse(x0,y0,r1,r2,angle,color,opacity,pattern);
26068  return *this;
26069  }
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)
Definition: CImg.h:25951
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const float  r1,
const float  r2,
const float  angle,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw an outlined ellipse.

Definition at line 26073 of file CImg.h.

26074  {
26075  return draw_ellipse(x0,y0,r1,r2,angle,color.data,opacity,pattern);
26076  }
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
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.
Definition: CImg.h:26017
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 
)
inline

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 dimv() 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.

Definition at line 26088 of file CImg.h.

26090  {
26091  CImgList<t> eig = tensor.get_symmetric_eigen();
26092  const CImg<t> &val = eig[0], &vec = eig[1];
26093  return draw_ellipse(x0,y0,val(0),val(1),vec(0,0),vec(0,1),color,opacity,pattern);
26094  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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.
Definition: CImg.h:26017
CImg<T>& draw_ellipse ( const int  x0,
const int  y0,
const CImg< t > &  tensor,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw an outlined ellipse.

Definition at line 26098 of file CImg.h.

26100  {
26101  return draw_ellipse(x0,y0,tensor,color.data,opacity,pattern);
26102  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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.
Definition: CImg.h:26017
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 
)
inline

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

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 dimv() 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.

Definition at line 26929 of file CImg.h.

Referenced by CImg< uintT >::draw_fill().

26932  {
26933 
26934 #define _cimg_draw_fill_test(x,y,z,res) if (region(x,y,z)) res = false; else { \
26935  res = true; \
26936  const T *reference_col = reference_color.ptr() + dim, *ptrs = ptr(x,y,z) + siz; \
26937  for (unsigned int i = dim; res && i; --i) { ptrs-=whz; res = (cimg::abs(*ptrs - *(--reference_col))<=sigma); } \
26938  region(x,y,z) = (t)(res?1:noregion); \
26939 }
26940 
26941 #define _cimg_draw_fill_set(x,y,z) { \
26942  const tc *col = color; \
26943  T *ptrd = ptr(x,y,z); \
26944  if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=whz; } \
26945  else cimg_forV(*this,k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; } \
26946 }
26947 
26948 #define _cimg_draw_fill_insert(x,y,z) { \
26949  if (posr1>=remaining.height) remaining.resize(3,remaining.height<<1,1,1,0); \
26950  unsigned int *ptrr = remaining.ptr(0,posr1); \
26951  *(ptrr++) = x; *(ptrr++) = y; *(ptrr++) = z; ++posr1; \
26952 }
26953 
26954 #define _cimg_draw_fill_test_neighbor(x,y,z,cond) if (cond) { \
26955  const unsigned int tx = x, ty = y, tz = z; \
26956  _cimg_draw_fill_test(tx,ty,tz,res); if (res) _cimg_draw_fill_insert(tx,ty,tz); \
26957 }
26958 
26959  if (!color)
26960  throw CImgArgumentException("CImg<%s>::draw_fill() : Specified color is (null).",
26961  pixel_type());
26962  region.assign(width,height,depth,1,(t)0);
26963  if (x>=0 && x<dimx() && y>=0 && y<dimy() && z>=0 && z<dimz()) {
26964  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
26965  const unsigned int whz = width*height*depth, siz = dim*whz, W1 = width-1, H1 = height-1, D1 = depth-1;
26966  const bool threed = depth>1;
26967  const CImg<T> reference_color = get_vector_at(x,y,z);
26968  CImg<uintT> remaining(3,512,1,1,0);
26969  remaining(0,0) = x; remaining(1,0) = y; remaining(2,0) = z;
26970  unsigned int posr0 = 0, posr1 = 1;
26971  region(x,y,z) = (t)1;
26972  const t noregion = ((t)1==(t)2)?(t)0:(t)(-1);
26973  if (threed) do { // 3D version of the filling algorithm
26974  const unsigned int *pcurr = remaining.ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++), zc = *(pcurr++);
26975  if (posr0>=512) { remaining.translate(0,-(int)posr0); posr1-=posr0; posr0 = 0; }
26976  bool cont, res;
26977  unsigned int nxc = xc;
26978  do { // X-backward
26979  _cimg_draw_fill_set(nxc,yc,zc);
26980  _cimg_draw_fill_test_neighbor(nxc,yc-1,zc,yc!=0);
26981  _cimg_draw_fill_test_neighbor(nxc,yc+1,zc,yc<H1);
26982  _cimg_draw_fill_test_neighbor(nxc,yc,zc-1,zc!=0);
26983  _cimg_draw_fill_test_neighbor(nxc,yc,zc+1,zc<D1);
26984  if (nxc) { --nxc; _cimg_draw_fill_test(nxc,yc,zc,cont); } else cont = false;
26985  } while (cont);
26986  nxc = xc;
26987  do { // X-forward
26988  if ((++nxc)<=W1) { _cimg_draw_fill_test(nxc,yc,zc,cont); } else cont = false;
26989  if (cont) {
26990  _cimg_draw_fill_set(nxc,yc,zc);
26991  _cimg_draw_fill_test_neighbor(nxc,yc-1,zc,yc!=0);
26992  _cimg_draw_fill_test_neighbor(nxc,yc+1,zc,yc<H1);
26993  _cimg_draw_fill_test_neighbor(nxc,yc,zc-1,zc!=0);
26994  _cimg_draw_fill_test_neighbor(nxc,yc,zc+1,zc<D1);
26995  }
26996  } while (cont);
26997  unsigned int nyc = yc;
26998  do { // Y-backward
26999  if (nyc) { --nyc; _cimg_draw_fill_test(xc,nyc,zc,cont); } else cont = false;
27000  if (cont) {
27001  _cimg_draw_fill_set(xc,nyc,zc);
27002  _cimg_draw_fill_test_neighbor(xc-1,nyc,zc,xc!=0);
27003  _cimg_draw_fill_test_neighbor(xc+1,nyc,zc,xc<W1);
27004  _cimg_draw_fill_test_neighbor(xc,nyc,zc-1,zc!=0);
27005  _cimg_draw_fill_test_neighbor(xc,nyc,zc+1,zc<D1);
27006  }
27007  } while (cont);
27008  nyc = yc;
27009  do { // Y-forward
27010  if ((++nyc)<=H1) { _cimg_draw_fill_test(xc,nyc,zc,cont); } else cont = false;
27011  if (cont) {
27012  _cimg_draw_fill_set(xc,nyc,zc);
27013  _cimg_draw_fill_test_neighbor(xc-1,nyc,zc,xc!=0);
27014  _cimg_draw_fill_test_neighbor(xc+1,nyc,zc,xc<W1);
27015  _cimg_draw_fill_test_neighbor(xc,nyc,zc-1,zc!=0);
27016  _cimg_draw_fill_test_neighbor(xc,nyc,zc+1,zc<D1);
27017  }
27018  } while (cont);
27019  unsigned int nzc = zc;
27020  do { // Z-backward
27021  if (nzc) { --nzc; _cimg_draw_fill_test(xc,yc,nzc,cont); } else cont = false;
27022  if (cont) {
27023  _cimg_draw_fill_set(xc,yc,nzc);
27024  _cimg_draw_fill_test_neighbor(xc-1,yc,nzc,xc!=0);
27025  _cimg_draw_fill_test_neighbor(xc+1,yc,nzc,xc<W1);
27026  _cimg_draw_fill_test_neighbor(xc,yc-1,nzc,yc!=0);
27027  _cimg_draw_fill_test_neighbor(xc,yc+1,nzc,yc<H1);
27028  }
27029  } while (cont);
27030  nzc = zc;
27031  do { // Z-forward
27032  if ((++nzc)<=D1) { _cimg_draw_fill_test(xc,yc,nzc,cont); } else cont = false;
27033  if (cont) {
27034  _cimg_draw_fill_set(xc,nyc,zc);
27035  _cimg_draw_fill_test_neighbor(xc-1,yc,nzc,xc!=0);
27036  _cimg_draw_fill_test_neighbor(xc+1,yc,nzc,xc<W1);
27037  _cimg_draw_fill_test_neighbor(xc,yc-1,nzc,yc!=0);
27038  _cimg_draw_fill_test_neighbor(xc,yc+1,nzc,yc<H1);
27039  }
27040  } while (cont);
27041  } while (posr1>posr0);
27042  else do { // 2D version of the filling algorithm
27043  const unsigned int *pcurr = remaining.ptr(0,posr0++), xc = *(pcurr++), yc = *(pcurr++);
27044  if (posr0>=512) { remaining.translate(0,-(int)posr0); posr1-=posr0; posr0 = 0; }
27045  bool cont, res;
27046  unsigned int nxc = xc;
27047  do { // X-backward
27048  _cimg_draw_fill_set(nxc,yc,0);
27049  _cimg_draw_fill_test_neighbor(nxc,yc-1,0,yc!=0);
27050  _cimg_draw_fill_test_neighbor(nxc,yc+1,0,yc<H1);
27051  if (high_connexity) {
27052  _cimg_draw_fill_test_neighbor(nxc-1,yc-1,0,(nxc!=0 && yc!=0));
27053  _cimg_draw_fill_test_neighbor(nxc+1,yc-1,0,(nxc<W1 && yc!=0));
27054  _cimg_draw_fill_test_neighbor(nxc-1,yc+1,0,(nxc!=0 && yc<H1));
27055  _cimg_draw_fill_test_neighbor(nxc+1,yc+1,0,(nxc<W1 && yc<H1));
27056  }
27057  if (nxc) { --nxc; _cimg_draw_fill_test(nxc,yc,0,cont); } else cont = false;
27058  } while (cont);
27059  nxc = xc;
27060  do { // X-forward
27061  if ((++nxc)<=W1) { _cimg_draw_fill_test(nxc,yc,0,cont); } else cont = false;
27062  if (cont) {
27063  _cimg_draw_fill_set(nxc,yc,0);
27064  _cimg_draw_fill_test_neighbor(nxc,yc-1,0,yc!=0);
27065  _cimg_draw_fill_test_neighbor(nxc,yc+1,0,yc<H1);
27066  if (high_connexity) {
27067  _cimg_draw_fill_test_neighbor(nxc-1,yc-1,0,(nxc!=0 && yc!=0));
27068  _cimg_draw_fill_test_neighbor(nxc+1,yc-1,0,(nxc<W1 && yc!=0));
27069  _cimg_draw_fill_test_neighbor(nxc-1,yc+1,0,(nxc!=0 && yc<H1));
27070  _cimg_draw_fill_test_neighbor(nxc+1,yc+1,0,(nxc<W1 && yc<H1));
27071  }
27072  }
27073  } while (cont);
27074  unsigned int nyc = yc;
27075  do { // Y-backward
27076  if (nyc) { --nyc; _cimg_draw_fill_test(xc,nyc,0,cont); } else cont = false;
27077  if (cont) {
27078  _cimg_draw_fill_set(xc,nyc,0);
27079  _cimg_draw_fill_test_neighbor(xc-1,nyc,0,xc!=0);
27080  _cimg_draw_fill_test_neighbor(xc+1,nyc,0,xc<W1);
27081  if (high_connexity) {
27082  _cimg_draw_fill_test_neighbor(xc-1,nyc-1,0,(xc!=0 && nyc!=0));
27083  _cimg_draw_fill_test_neighbor(xc+1,nyc-1,0,(xc<W1 && nyc!=0));
27084  _cimg_draw_fill_test_neighbor(xc-1,nyc+1,0,(xc!=0 && nyc<H1));
27085  _cimg_draw_fill_test_neighbor(xc+1,nyc+1,0,(xc<W1 && nyc<H1));
27086  }
27087  }
27088  } while (cont);
27089  nyc = yc;
27090  do { // Y-forward
27091  if ((++nyc)<=H1) { _cimg_draw_fill_test(xc,nyc,0,cont); } else cont = false;
27092  if (cont) {
27093  _cimg_draw_fill_set(xc,nyc,0);
27094  _cimg_draw_fill_test_neighbor(xc-1,nyc,0,xc!=0);
27095  _cimg_draw_fill_test_neighbor(xc+1,nyc,0,xc<W1);
27096  if (high_connexity) {
27097  _cimg_draw_fill_test_neighbor(xc-1,nyc-1,0,(xc!=0 && nyc!=0));
27098  _cimg_draw_fill_test_neighbor(xc+1,nyc-1,0,(xc<W1 && nyc!=0));
27099  _cimg_draw_fill_test_neighbor(xc-1,nyc+1,0,(xc!=0 && nyc<H1));
27100  _cimg_draw_fill_test_neighbor(xc+1,nyc+1,0,(xc<W1 && nyc<H1));
27101  }
27102  }
27103  } while (cont);
27104  } while (posr1>posr0);
27105  if (noregion) cimg_for(region,ptr,t) if (*ptr==noregion) *ptr = (t)0;
27106  }
27107  return *this;
27108  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define _cimg_draw_fill_test(x, y, z, res)
#define _cimg_draw_fill_set(x, y, z)
#define _cimg_draw_fill_test_neighbor(x, y, z, cond)
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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...
Definition: CImg.h:13270
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& draw_fill ( const int  x,
const int  y,
const int  z,
const CImg< tc > &  color,
const float  opacity,
CImg< t > &  region,
const float  sigma = 0,
const bool  high_connexity = false 
)
inline

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

Definition at line 27112 of file CImg.h.

27114  {
27115  return draw_fill(x,y,z,color.data,opacity,region,sigma,high_connexity);
27116  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26929
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
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 
)
inline

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

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 dimv() values of type T, defining the drawing color.
sigma= tolerance concerning neighborhood values.
opacity= opacity of the drawing.

Definition at line 27128 of file CImg.h.

27130  {
27131  CImg<boolT> tmp;
27132  return draw_fill(x,y,z,color,opacity,tmp,sigma,high_connexity);
27133  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26929
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_fill ( const int  x,
const int  y,
const int  z,
const CImg< tc > &  color,
const float  opacity = 1,
const float  sigma = 0,
const bool  high_connexity = false 
)
inline

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

Definition at line 27137 of file CImg.h.

27139  {
27140  return draw_fill(x,y,z,color.data,opacity,sigma,high_connexity);
27141  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26929
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
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 
)
inline

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

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 dimv() values of type T, defining the drawing color.
sigma= tolerance concerning neighborhood values.
opacity= opacity of the drawing.

Definition at line 27152 of file CImg.h.

27154  {
27155  CImg<boolT> tmp;
27156  return draw_fill(x,y,0,color,opacity,tmp,sigma,high_connexity);
27157  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26929
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_fill ( const int  x,
const int  y,
const CImg< tc > &  color,
const float  opacity = 1,
const float  sigma = 0,
const bool  high_connexity = false 
)
inline

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

Definition at line 27161 of file CImg.h.

27163  {
27164  return draw_fill(x,y,color.data,opacity,sigma,high_connexity);
27165  }
void int int REAL REAL * y
Definition: read.cpp:74
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 instance image.
Definition: CImg.h:26929
void int int REAL * x
Definition: read.cpp:74
CImg<T>& draw_gaussian ( const float  xc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a 1D gaussian function in the instance image.

Parameters
xc= X-coordinate of the gaussian center.
sigma= Standard variation of the gaussian distribution.
color= array of dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 27328 of file CImg.h.

Referenced by CImg< uintT >::draw_gaussian().

27329  {
27330  if (is_empty()) return *this;
27331  if (!color)
27332  throw CImgArgumentException("CImg<%s>::draw_gaussian() : Specified color is (null)",
27333  pixel_type());
27334  const float sigma2 = 2*sigma*sigma, nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
27335  const unsigned int whz = width*height*depth;
27336  const tc *col = color;
27337  cimg_forX(*this,x) {
27338  const float dx = (x - xc), val = (float)std::exp(-dx*dx/sigma2);
27339  T *ptrd = ptr(x,0,0,0);
27340  if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27341  else cimg_forV(*this,k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27342  col-=dim;
27343  }
27344  return *this;
27345  }
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
#define cimg_forX(img, x)
Definition: CImg.h:593
j indices k indices k
Definition: Indexing.h:6
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& draw_gaussian ( const float  xc,
const float  sigma,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a 1D gaussian function in the instance image.

Definition at line 27349 of file CImg.h.

27350  {
27351  return draw_gaussian(xc,sigma,color.data,opacity);
27352  }
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const CImg< t > &  tensor,
const tc *const  color,
const float  opacity = 1 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 27363 of file CImg.h.

27364  {
27365  if (is_empty()) return *this;
27366  typedef typename cimg::superset<t,float>::type tfloat;
27367  if (tensor.width!=2 || tensor.height!=2 || tensor.depth!=1 || tensor.dim!=1)
27368  throw CImgArgumentException("CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 2x2 matrix.",
27369  pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data);
27370  if (!color)
27371  throw CImgArgumentException("CImg<%s>::draw_gaussian() : Specified color is (null)",
27372  pixel_type());
27373  const CImg<tfloat> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0);
27374  const tfloat a = invT2(0,0), b = 2*invT2(1,0), c = invT2(1,1);
27375  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
27376  const unsigned int whz = width*height*depth;
27377  const tc *col = color;
27378  float dy = -yc;
27379  cimg_forY(*this,y) {
27380  float dx = -xc;
27381  cimg_forX(*this,x) {
27382  const float val = (float)std::exp(a*dx*dx + b*dx*dy + c*dy*dy);
27383  T *ptrd = ptr(x,y,0,0);
27384  if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27385  else cimg_forV(*this,k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27386  col-=dim;
27387  ++dx;
27388  }
27389  ++dy;
27390  }
27391  return *this;
27392  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
#define cimg_forX(img, x)
Definition: CImg.h:593
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const CImg< t > &  tensor,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw an anisotropic 2D gaussian function.

Definition at line 27396 of file CImg.h.

27397  {
27398  return draw_gaussian(xc,yc,tensor,color.data,opacity);
27399  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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 instance image.
Definition: CImg.h:27328
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 
)
inline

Draw an anisotropic 2D gaussian function.

Definition at line 27403 of file CImg.h.

27404  {
27405  const double
27406  a = r1*ru*ru + r2*rv*rv,
27407  b = (r1-r2)*ru*rv,
27408  c = r1*rv*rv + r2*ru*ru;
27409  const CImg<Tfloat> tensor(2,2,1,1, a,b,b,c);
27410  return draw_gaussian(xc,yc,tensor,color,opacity);
27411  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const int  xc,
const int  yc,
const float  r1,
const float  r2,
const float  ru,
const float  rv,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw an anisotropic 2D gaussian function.

Definition at line 27415 of file CImg.h.

27416  {
27417  return draw_gaussian(xc,yc,r1,r2,ru,rv,color.data,opacity);
27418  }
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 27429 of file CImg.h.

27430  {
27431  return draw_gaussian(xc,yc,CImg<floatT>::diagonal(sigma,sigma),color,opacity);
27432  }
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  sigma,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw an isotropic 2D gaussian function.

Definition at line 27436 of file CImg.h.

27437  {
27438  return draw_gaussian(xc,yc,sigma,color.data,opacity);
27439  }
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 instance image.
Definition: CImg.h:27328
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 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 27451 of file CImg.h.

27452  {
27453  if (is_empty()) return *this;
27454  typedef typename cimg::superset<t,float>::type tfloat;
27455  if (tensor.width!=3 || tensor.height!=3 || tensor.depth!=1 || tensor.dim!=1)
27456  throw CImgArgumentException("CImg<%s>::draw_gaussian() : Tensor parameter (%u,%u,%u,%u,%p) is not a 3x3 matrix.",
27457  pixel_type(),tensor.width,tensor.height,tensor.depth,tensor.dim,tensor.data);
27458  const CImg<tfloat> invT = tensor.get_invert(), invT2 = (invT*invT)/(-2.0);
27459  const tfloat a = invT(0,0), b = 2*invT(1,0), c = 2*invT(2,0), d = invT(1,1), e = 2*invT(2,1), f = invT(2,2);
27460  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
27461  const unsigned int whz = width*height*depth;
27462  const tc *col = color;
27463  cimg_forXYZ(*this,x,y,z) {
27464  const float
27465  dx = (x - xc), dy = (y - yc), dz = (z - zc),
27466  val = (float)std::exp(a*dx*dx + b*dx*dy + c*dx*dz + d*dy*dy + e*dy*dz + f*dz*dz);
27467  T *ptrd = ptr(x,y,z,0);
27468  if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)(val*(*col++)); ptrd+=whz; }
27469  else cimg_forV(*this,k) { *ptrd = (T)(nopacity*val*(*col++) + *ptrd*copacity); ptrd+=whz; }
27470  col-=dim;
27471  }
27472  return *this;
27473  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
const NT & d
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  zc,
const CImg< t > &  tensor,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw an anisotropic 3D gaussian function.

Definition at line 27477 of file CImg.h.

27478  {
27479  return draw_gaussian(xc,yc,zc,tensor,color.data,opacity);
27480  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  zc,
const float  sigma,
const tc *const  color,
const float  opacity = 1 
)
inline

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 dimv() values of type T, defining the drawing color.
opacity= opacity of the drawing.

Definition at line 27492 of file CImg.h.

27493  {
27494  return draw_gaussian(xc,yc,zc,CImg<floatT>::diagonal(sigma,sigma,sigma),color,opacity);
27495  }
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 instance image.
Definition: CImg.h:27328
CImg<T>& draw_gaussian ( const float  xc,
const float  yc,
const float  zc,
const float  sigma,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw an isotropic 3D gaussian function.

Definition at line 27499 of file CImg.h.

27500  {
27501  return draw_gaussian(xc,yc,zc,sigma,color.data,opacity);
27502  }
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 instance image.
Definition: CImg.h:27328
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 bool  expand = false,
const unsigned int  pattern = ~0U 
)
inline

Draw a 1D graph on the instance image.

Parameters
dataImage containing the graph values I = f(x).
colorArray of dimv() 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.
expandExpand plot along the X-axis.
patternDrawing pattern.
Note
  • if ymin==ymax==0, the y-range is computed automatically from the input samples.

Definition at line 26788 of file CImg.h.

Referenced by CImg< uintT >::draw_graph().

26792  {
26793  if (is_empty() || height<=1) return *this;
26794  const unsigned int siz = data.size();
26795  if (!color)
26796  throw CImgArgumentException("CImg<%s>::draw_graph() : Specified color is (null)",
26797  pixel_type());
26798  tc *color1 = 0, *color2 = 0;
26799  if (plot_type==3) {
26800  color1 = new tc[dim]; color2 = new tc[dim];
26801  cimg_forV(*this,k) { color1[k] = (tc)(color[k]*0.6f); color2[k] = (tc)(color[k]*0.3f); }
26802  }
26803 
26804  double m = ymin, M = ymax;
26805  if (ymin==ymax) m = (double)data.maxmin(M);
26806  if (m==M) { --m; ++M; }
26807  const float ca = (float)(M-m)/(height-1);
26808  bool init_hatch = true;
26809  const unsigned int xp = expand?1:0;
26810 
26811  // Draw graph edges
26812  switch (plot_type%4) {
26813  case 1 : { // Segments
26814  int oX = 0, oY = (int)((data[0]-m)/ca);
26815  for (unsigned int off = 1; off<siz; ++off) {
26816  const int
26817  X = (int)(off*width/(siz-xp)),
26818  Y = (int)((data[off]-m)/ca);
26819  draw_line(oX,oY,X,Y,color,opacity,pattern,init_hatch);
26820  oX = X; oY = Y;
26821  init_hatch = false;
26822  }
26823  } break;
26824  case 2 : { // Spline
26825  const CImg<t> ndata(data.data,siz,1,1,1,true);
26826  int oY = (int)((data[0]-m)/ca);
26827  cimg_forX(*this,x) {
26828  const int Y = (int)((ndata._cubic_atX((float)x*(ndata.width-xp)/width)-m)/ca);
26829  if (x>0) draw_line(x,oY,x+1,Y,color,opacity,pattern,init_hatch);
26830  init_hatch = false;
26831  oY = Y;
26832  }
26833  } break;
26834  case 3 : { // Bars
26835  const int Y0 = (int)(-m/ca);
26836  int oX = 0;
26837  cimg_foroff(data,off) {
26838  const int
26839  X = (off+1)*width/siz-1,
26840  Y = (int)((data[off]-m)/ca);
26841  draw_rectangle(oX,Y0,X,Y,color1,opacity).
26842  draw_line(oX,Y,oX,Y0,color2,opacity).
26843  draw_line(oX,Y0,X,Y0,Y<=Y0?color2:color,opacity).
26844  draw_line(X,Y,X,Y0,color,opacity).
26845  draw_line(oX,Y,X,Y,Y<=Y0?color:color2,opacity);
26846  oX = X+1;
26847  }
26848  } break;
26849  default : break; // No edges
26850  }
26851 
26852  // Draw graph points
26853  switch (vertex_type%8) {
26854  case 1 : { // Point
26855  cimg_foroff(data,off) {
26856  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26857  draw_point(X,Y,color,opacity);
26858  }
26859  } break;
26860  case 2 : { // Straight Cross
26861  cimg_foroff(data,off) {
26862  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26863  draw_line(X-3,Y,X+3,Y,color,opacity).draw_line(X,Y-3,X,Y+3,color,opacity);
26864  }
26865  } break;
26866  case 3 : { // Diagonal Cross
26867  cimg_foroff(data,off) {
26868  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26869  draw_line(X-3,Y-3,X+3,Y+3,color,opacity).draw_line(X-3,Y+3,X+3,Y-3,color,opacity);
26870  }
26871  } break;
26872  case 4 : { // Filled Circle
26873  cimg_foroff(data,off) {
26874  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26875  draw_circle(X,Y,3,color,opacity);
26876  }
26877  } break;
26878  case 5 : { // Outlined circle
26879  cimg_foroff(data,off) {
26880  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26881  draw_circle(X,Y,3,color,opacity,0U);
26882  }
26883  } break;
26884  case 6 : { // Square
26885  cimg_foroff(data,off) {
26886  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26887  draw_rectangle(X-3,Y-3,X+3,Y+3,color,opacity,~0U);
26888  }
26889  } break;
26890  case 7 : { // Diamond
26891  cimg_foroff(data,off) {
26892  const int X = off*width/(siz-xp), Y = (int)((data[off]-m)/ca);
26893  draw_line(X,Y-4,X+4,Y,color,opacity).
26894  draw_line(X+4,Y,X,Y+4,color,opacity).
26895  draw_line(X,Y+4,X-4,Y,color,opacity).
26896  draw_line(X-4,Y,X,Y-4,color,opacity);
26897  }
26898  } break;
26899  default : break; // No points
26900  }
26901 
26902  if (color1) delete[] color1; if (color2) delete[] color2;
26903  return *this;
26904  }
#define cimg_forX(img, x)
Definition: CImg.h:593
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
CImg< T > & draw_circle(const int x0, const int y0, int radius, const tc *const color, const float opacity=1)
Draw a filled circle.
Definition: CImg.h:25869
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& draw_graph ( const CImg< t > &  data,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  plot_type = 1,
const unsigned int  vertex_type = 1,
const double  ymin = 0,
const double  ymax = 0,
const bool  expand = false,
const unsigned int  pattern = ~0U 
)
inline

Draw a 1D graph on the instance image.

Definition at line 26908 of file CImg.h.

26912  {
26913  return draw_graph(data,color.data,opacity,plot_type,vertex_type,ymin,ymax,expand,pattern);
26914  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
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 bool expand=false, const unsigned int pattern=~0U)
Draw a 1D graph on the instance image.
Definition: CImg.h:26788
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 
)
inline

Draw grid.

Definition at line 26700 of file CImg.h.

Referenced by CImg< uintT >::draw_grid().

26702  {
26703  if (!is_empty()) {
26704  if (xvalues) cimg_foroff(xvalues,x) {
26705  const int xi = (int)xvalues[x];
26706  if (xi>=0 && xi<dimx()) draw_line(xi,0,xi,height-1,color,opacity,patternx);
26707  }
26708  if (yvalues) cimg_foroff(yvalues,y) {
26709  const int yi = (int)yvalues[y];
26710  if (yi>=0 && yi<dimy()) draw_line(0,yi,width-1,yi,color,opacity,patterny);
26711  }
26712  }
26713  return *this;
26714  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
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.
Definition: CImg.h:22330

Here is the caller graph for this function:

CImg<T>& draw_grid ( const CImg< tx > &  xvalues,
const CImg< ty > &  yvalues,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  patternx = ~0U,
const unsigned int  patterny = ~0U 
)
inline

Draw grid.

Definition at line 26718 of file CImg.h.

26720  {
26721  return draw_grid(xvalues,yvalues,color.data,opacity,patternx,patterny);
26722  }
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.
Definition: CImg.h:26700
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 
)
inline

Draw grid.

Definition at line 26726 of file CImg.h.

26730  {
26731  CImg<uintT> seqx, seqy;
26732  if (deltax!=0) {
26733  const float dx = deltax>0?deltax:width*-deltax/100;
26734  const unsigned int nx = (unsigned int)(width/dx);
26735  seqx = CImg<uintT>::sequence(1+nx,0,(unsigned int)(dx*nx));
26736  if (offsetx) cimg_foroff(seqx,x) seqx(x) = (unsigned int)cimg::mod(seqx(x)+offsetx,(float)width);
26737  if (invertx) cimg_foroff(seqx,x) seqx(x) = width-1-seqx(x);
26738  }
26739 
26740  if (deltay!=0) {
26741  const float dy = deltay>0?deltay:height*-deltay/100;
26742  const unsigned int ny = (unsigned int)(height/dy);
26743  seqy = CImg<uintT>::sequence(1+ny,0,(unsigned int)(dy*ny));
26744  if (offsety) cimg_foroff(seqy,y) seqy(y) = (unsigned int)cimg::mod(seqy(y)+offsety,(float)height);
26745  if (inverty) cimg_foroff(seqy,y) seqy(y) = height-1-seqy(y);
26746  }
26747  return draw_grid(seqx,seqy,color,opacity,patternx,patterny);
26748  }
if(dy > dx)
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
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.
Definition: CImg.h:26700
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
NT dy
CImg< T > & sequence(const T a0, const T a1)
Return a N-numbered sequence vector from a0 to a1.
Definition: CImg.h:13425
CImg<T>& draw_grid ( const float  deltax,
const float  deltay,
const float  offsetx,
const float  offsety,
const bool  invertx,
const bool  inverty,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  patternx = ~0U,
const unsigned int  patterny = ~0U 
)
inline

Draw grid.

Definition at line 26752 of file CImg.h.

26756  {
26757  return draw_grid(deltax,deltay,offsetx,offsety,invertx,inverty,color.data,opacity,patternx,patterny);
26758  }
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.
Definition: CImg.h:26700
CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const CImg< t > &  sprite,
const float  opacity = 1 
)
inline

Draw an image.

Parameters
spriteSprite image.
x0X-coordinate of the sprite position.
y0Y-coordinate of the sprite position.
z0Z-coordinate of the sprite position.
v0V-coordinate of the sprite position.
opacityDrawing opacity (optional).
Note
  • Clipping is supported.

Definition at line 26116 of file CImg.h.

Referenced by CImg< uintT >::__draw_object3d(), CImg< uintT >::_draw_text(), CImg< uintT >::draw_image(), CImg< uintT >::get_projections2d(), and CImg< uintT >::load_tiff().

26117  {
26118  if (is_empty()) return *this;
26119  if (!sprite)
26120  throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26121  pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26122  if (is_overlapped(sprite)) return draw_image(x0,y0,z0,v0,+sprite,opacity);
26123  const bool bx = (x0<0), by = (y0<0), bz = (z0<0), bv = (v0<0);
26124  const int
26125  lX = sprite.dimx() - (x0 + sprite.dimx()>dimx()?x0 + sprite.dimx() - dimx():0) + (bx?x0:0),
26126  lY = sprite.dimy() - (y0 + sprite.dimy()>dimy()?y0 + sprite.dimy() - dimy():0) + (by?y0:0),
26127  lZ = sprite.dimz() - (z0 + sprite.dimz()>dimz()?z0 + sprite.dimz() - dimz():0) + (bz?z0:0),
26128  lV = sprite.dimv() - (v0 + sprite.dimv()>dimv()?v0 + sprite.dimv() - dimv():0) + (bv?v0:0);
26129  const t
26130  *ptrs = sprite.data -
26131  (bx?x0:0) -
26132  (by?y0*sprite.dimx():0) -
26133  (bz?z0*sprite.dimx()*sprite.dimy():0) -
26134  (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0);
26135  const unsigned int
26136  offX = width - lX, soffX = sprite.width - lX,
26137  offY = width*(height - lY), soffY = sprite.width*(sprite.height - lY),
26138  offZ = width*height*(depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ);
26139  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
26140  if (lX>0 && lY>0 && lZ>0 && lV>0) {
26141  T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26142  for (int v = 0; v<lV; ++v) {
26143  for (int z = 0; z<lZ; ++z) {
26144  for (int y = 0; y<lY; ++y) {
26145  if (opacity>=1) for (int x = 0; x<lX; ++x) *(ptrd++) = (T)*(ptrs++);
26146  else for (int x = 0; x<lX; ++x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; }
26147  ptrd+=offX; ptrs+=soffX;
26148  }
26149  ptrd+=offY; ptrs+=soffY;
26150  }
26151  ptrd+=offZ; ptrs+=soffZ;
26152  }
26153  }
26154  return *this;
26155  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const CImg< T > &  sprite,
const float  opacity = 1 
)
inline

Definition at line 26158 of file CImg.h.

26159  {
26160  if (is_empty()) return *this;
26161  if (!sprite)
26162  throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26163  pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26164  if (is_overlapped(sprite)) return draw_image(x0,y0,z0,v0,+sprite,opacity);
26165  const bool bx = (x0<0), by = (y0<0), bz = (z0<0), bv = (v0<0);
26166  const int
26167  lX = sprite.dimx() - (x0 + sprite.dimx()>dimx()?x0 + sprite.dimx() - dimx():0) + (bx?x0:0),
26168  lY = sprite.dimy() - (y0 + sprite.dimy()>dimy()?y0 + sprite.dimy() - dimy():0) + (by?y0:0),
26169  lZ = sprite.dimz() - (z0 + sprite.dimz()>dimz()?z0 + sprite.dimz() - dimz():0) + (bz?z0:0),
26170  lV = sprite.dimv() - (v0 + sprite.dimv()>dimv()?v0 + sprite.dimv() - dimv():0) + (bv?v0:0);
26171  const T
26172  *ptrs = sprite.data -
26173  (bx?x0:0) -
26174  (by?y0*sprite.dimx():0) -
26175  (bz?z0*sprite.dimx()*sprite.dimy():0) -
26176  (bv?v0*sprite.dimx()*sprite.dimy()*sprite.dimz():0);
26177  const unsigned int
26178  offX = width - lX, soffX = sprite.width - lX,
26179  offY = width*(height - lY), soffY = sprite.width*(sprite.height - lY),
26180  offZ = width*height*(depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ),
26181  slX = lX*sizeof(T);
26182  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
26183  if (lX>0 && lY>0 && lZ>0 && lV>0) {
26184  T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26185  for (int v = 0; v<lV; ++v) {
26186  for (int z = 0; z<lZ; ++z) {
26187  if (opacity>=1) for (int y = 0; y<lY; ++y) { std::memcpy(ptrd,ptrs,slX); ptrd+=width; ptrs+=sprite.width; }
26188  else for (int y = 0; y<lY; ++y) {
26189  for (int x = 0; x<lX; ++x) { *ptrd = (T)(nopacity*(*(ptrs++)) + *ptrd*copacity); ++ptrd; }
26190  ptrd+=offX; ptrs+=soffX;
26191  }
26192  ptrd+=offY; ptrs+=soffY;
26193  }
26194  ptrd+=offZ; ptrs+=soffZ;
26195  }
26196  }
26197  return *this;
26198  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const CImg< t > &  sprite,
const float  opacity = 1 
)
inline

Draw an image.

Definition at line 26202 of file CImg.h.

26203  {
26204  return draw_image(x0,y0,z0,0,sprite,opacity);
26205  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
CImg<T>& draw_image ( const int  x0,
const int  y0,
const CImg< t > &  sprite,
const float  opacity = 1 
)
inline

Draw an image.

Definition at line 26209 of file CImg.h.

26210  {
26211  return draw_image(x0,y0,0,sprite,opacity);
26212  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
CImg<T>& draw_image ( const int  x0,
const CImg< t > &  sprite,
const float  opacity = 1 
)
inline

Draw an image.

Definition at line 26216 of file CImg.h.

26217  {
26218  return draw_image(x0,0,sprite,opacity);
26219  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
CImg<T>& draw_image ( const CImg< t > &  sprite,
const float  opacity = 1 
)
inline

Draw an image.

Definition at line 26223 of file CImg.h.

26223  {
26224  return draw_image(0,sprite,opacity);
26225  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
CImg<T>& draw_image ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const CImg< ti > &  sprite,
const CImg< tm > &  mask,
const float  opacity = 1,
const float  mask_valmax = 1 
)
inline

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

Parameters
spriteSprite image.
maskMask image.
x0X-coordinate of the sprite position in the instance image.
y0Y-coordinate of the sprite position in the instance image.
z0Z-coordinate of the sprite position in the instance image.
v0V-coordinate of the sprite position in the instance image.
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.

Definition at line 26243 of file CImg.h.

26245  {
26246  if (is_empty()) return *this;
26247  if (!sprite)
26248  throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
26249  pixel_type(),sprite.width,sprite.height,sprite.depth,sprite.dim,sprite.data);
26250  if (!mask)
26251  throw CImgArgumentException("CImg<%s>::draw_image() : Specified mask image (%u,%u,%u,%u,%p) is empty.",
26252  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
26253  if (is_overlapped(sprite)) return draw_image(x0,y0,z0,v0,+sprite,mask,opacity,mask_valmax);
26254  if (is_overlapped(mask)) return draw_image(x0,y0,z0,v0,sprite,+mask,opacity,mask_valmax);
26255  if (mask.width!=sprite.width || mask.height!=sprite.height || mask.depth!=sprite.depth)
26256  throw CImgArgumentException("CImg<%s>::draw_image() : Mask dimension is (%u,%u,%u,%u), while sprite is (%u,%u,%u,%u)",
26257  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,sprite.width,sprite.height,sprite.depth,sprite.dim);
26258  const bool bx = (x0<0), by = (y0<0), bz = (z0<0), bv = (v0<0);
26259  const int
26260  lX = sprite.dimx() - (x0 + sprite.dimx()>dimx()?x0 + sprite.dimx() - dimx():0) + (bx?x0:0),
26261  lY = sprite.dimy() - (y0 + sprite.dimy()>dimy()?y0 + sprite.dimy() - dimy():0) + (by?y0:0),
26262  lZ = sprite.dimz() - (z0 + sprite.dimz()>dimz()?z0 + sprite.dimz() - dimz():0) + (bz?z0:0),
26263  lV = sprite.dimv() - (v0 + sprite.dimv()>dimv()?v0 + sprite.dimv() - dimv():0) + (bv?v0:0);
26264  const int
26265  coff = -(bx?x0:0)-(by?y0*mask.dimx():0)-(bz?z0*mask.dimx()*mask.dimy():0)-(bv?v0*mask.dimx()*mask.dimy()*mask.dimz():0),
26266  ssize = mask.dimx()*mask.dimy()*mask.dimz();
26267  const ti *ptrs = sprite.data + coff;
26268  const tm *ptrm = mask.data + coff;
26269  const unsigned int
26270  offX = width - lX, soffX = sprite.width - lX,
26271  offY = width*(height - lY), soffY = sprite.width*(sprite.height - lY),
26272  offZ = width*height*(depth - lZ), soffZ = sprite.width*sprite.height*(sprite.depth - lZ);
26273  if (lX>0 && lY>0 && lZ>0 && lV>0) {
26274  T *ptrd = ptr(x0<0?0:x0,y0<0?0:y0,z0<0?0:z0,v0<0?0:v0);
26275  for (int v = 0; v<lV; ++v) {
26276  ptrm = mask.data + (ptrm - mask.data)%ssize;
26277  for (int z = 0; z<lZ; ++z) {
26278  for (int y = 0; y<lY; ++y) {
26279  for (int x = 0; x<lX; ++x) {
26280  const float mopacity = (float)(*(ptrm++)*opacity),
26281  nopacity = cimg::abs(mopacity), copacity = mask_valmax - cimg::max(mopacity,0);
26282  *ptrd = (T)((nopacity*(*(ptrs++)) + *ptrd*copacity)/mask_valmax);
26283  ++ptrd;
26284  }
26285  ptrd+=offX; ptrs+=soffX; ptrm+=soffX;
26286  }
26287  ptrd+=offY; ptrs+=soffY; ptrm+=soffY;
26288  }
26289  ptrd+=offZ; ptrs+=soffZ; ptrm+=soffZ;
26290  }
26291  }
26292  return *this;
26293  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
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 
)
inline

Draw an image.

Definition at line 26297 of file CImg.h.

26299  {
26300  return draw_image(x0,y0,z0,0,sprite,mask,opacity,mask_valmax);
26301  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
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 
)
inline

Draw an image.

Definition at line 26305 of file CImg.h.

26307  {
26308  return draw_image(x0,y0,0,sprite,mask,opacity,mask_valmax);
26309  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg<T>& draw_image ( const int  x0,
const CImg< ti > &  sprite,
const CImg< tm > &  mask,
const float  opacity = 1,
const float  mask_valmax = 1 
)
inline

Draw an image.

Definition at line 26313 of file CImg.h.

26315  {
26316  return draw_image(x0,0,sprite,mask,opacity,mask_valmax);
26317  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg<T>& draw_image ( const CImg< ti > &  sprite,
const CImg< tm > &  mask,
const float  opacity = 1,
const float  mask_valmax = 1 
)
inline

Draw an image.

Definition at line 26321 of file CImg.h.

26322  {
26323  return draw_image(0,sprite,mask,opacity,mask_valmax);
26324  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
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 
)
inline

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 dimv() 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);

Definition at line 22330 of file CImg.h.

Referenced by CImg< uintT >::_draw_line(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_polygon(), cimg_library::cimg::dialog(), CImg< uintT >::draw_arrow(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_line(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_spline(), CImg< uintT >::draw_triangle(), and CImg< uintT >::get_select_graph().

22333  {
22334  if (is_empty()) return *this;
22335  if (!color)
22336  throw CImgArgumentException("CImg<%s>::draw_line() : Specified color is (null)",
22337  pixel_type());
22338  static unsigned int hatch = ~0U - (~0U>>1);
22339  if (init_hatch) hatch = ~0U - (~0U>>1);
22340  const bool xdir = x0<x1, ydir = y0<y1;
22341  int
22342  nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22343  &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22344  &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22345  &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22346  &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22347  if (xright<0 || xleft>=dimx()) return *this;
22348  if (xleft<0) { yleft-=xleft*(yright - yleft)/(xright - xleft); xleft = 0; }
22349  if (xright>=dimx()) { yright-=(xright - dimx())*(yright - yleft)/(xright - xleft); xright = dimx()-1; }
22350  if (ydown<0 || yup>=dimy()) return *this;
22351  if (yup<0) { xup-=yup*(xdown - xup)/(ydown - yup); yup = 0; }
22352  if (ydown>=dimy()) { xdown-=(ydown - dimy())*(xdown - xup)/(ydown - yup); ydown = dimy()-1; }
22353  T *ptrd0 = ptr(nx0,ny0);
22354  int dx = xright - xleft, dy = ydown - yup;
22355  const bool steep = dy>dx;
22356  if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22357  const int
22358  offx = (nx0<nx1?1:-1)*(steep?width:1),
22359  offy = (ny0<ny1?1:-1)*(steep?1:width),
22360  wh = width*height;
22361  if (opacity>=1) {
22362  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22363  if (pattern&hatch) { T *ptrd = ptrd0; const tc* col = color; cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=wh; }}
22364  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22365  ptrd0+=offx;
22366  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22367  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22368  T *ptrd = ptrd0; const tc* col = color; cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=wh; }
22369  ptrd0+=offx;
22370  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22371  }
22372  } else {
22373  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22374  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22375  if (pattern&hatch) {
22376  T *ptrd = ptrd0; const tc* col = color;
22377  cimg_forV(*this,k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22378  }
22379  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22380  ptrd0+=offx;
22381  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22382  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22383  T *ptrd = ptrd0; const tc* col = color; cimg_forV(*this,k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22384  ptrd0+=offx;
22385  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22386  }
22387  }
22388  return *this;
22389  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& draw_line ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

Draw a 2D colored line.

Definition at line 22393 of file CImg.h.

22396  {
22397  return draw_line(x0,y0,x1,y1,color.data,opacity,pattern,init_hatch);
22398  }
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.
Definition: CImg.h:22330
CImg<T>& draw_line ( CImg< floatT > &  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 
)
inline

Draw a 2D colored line, with z-buffering.

Definition at line 22402 of file CImg.h.

22406  {
22407  if (is_empty() || z0<=0 || z1<=0) return *this;
22408  if (!color)
22409  throw CImgArgumentException("CImg<%s>::draw_line() : Specified color is (null).",
22410  pixel_type());
22411  if (!is_sameXY(zbuffer))
22412  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
22413  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
22414  static unsigned int hatch = ~0U - (~0U>>1);
22415  if (init_hatch) hatch = ~0U - (~0U>>1);
22416  const bool xdir = x0<x1, ydir = y0<y1;
22417  int
22418  nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22419  &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22420  &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22421  &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22422  &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22423  float
22424  Z0 = 1/z0, Z1 = 1/z1, nz0 = Z0, nz1 = Z1, dz = Z1 - Z0,
22425  &zleft = xdir?nz0:nz1,
22426  &zright = xdir?nz1:nz0,
22427  &zup = ydir?nz0:nz1,
22428  &zdown = ydir?nz1:nz0;
22429  if (xright<0 || xleft>=dimx()) return *this;
22430  if (xleft<0) {
22431  const int D = xright - xleft;
22432  yleft-=xleft*(yright - yleft)/D;
22433  zleft-=xleft*(zright - zleft)/D;
22434  xleft = 0;
22435  }
22436  if (xright>=dimx()) {
22437  const int d = xright - dimx(), D = xright - xleft;
22438  yright-=d*(yright - yleft)/D;
22439  zright-=d*(zright - zleft)/D;
22440  xright = dimx()-1;
22441  }
22442  if (ydown<0 || yup>=dimy()) return *this;
22443  if (yup<0) {
22444  const int D = ydown - yup;
22445  xup-=yup*(xdown - xup)/D;
22446  zup-=yup*(zdown - zup)/D;
22447  yup = 0;
22448  }
22449  if (ydown>=dimy()) {
22450  const int d = ydown - dimy(), D = ydown - yup;
22451  xdown-=d*(xdown - xup)/D;
22452  zdown-=d*(zdown - zup)/D;
22453  ydown = dimy()-1;
22454  }
22455  T *ptrd0 = ptr(nx0,ny0);
22456  float *ptrz = zbuffer.ptr(nx0,ny0);
22457  int dx = xright - xleft, dy = ydown - yup;
22458  const bool steep = dy>dx;
22459  if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22460  const int
22461  offx = (nx0<nx1?1:-1)*(steep?width:1),
22462  offy = (ny0<ny1?1:-1)*(steep?1:width),
22463  wh = width*height,
22464  ndx = dx>0?dx:1;
22465  if (opacity>=1) {
22466  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22467  const float z = Z0 + x*dz/ndx;
22468  if (z>*ptrz && pattern&hatch) {
22469  *ptrz = z;
22470  T *ptrd = ptrd0; const tc *col = color;
22471  cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=wh; }
22472  }
22473  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22474  ptrd0+=offx; ptrz+=offx;
22475  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22476  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22477  const float z = Z0 + x*dz/ndx;
22478  if (z>*ptrz) {
22479  *ptrz = z;
22480  T *ptrd = ptrd0; const tc *col = color;
22481  cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=wh; }
22482  }
22483  ptrd0+=offx; ptrz+=offx;
22484  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22485  }
22486  } else {
22487  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22488  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22489  const float z = Z0 + x*dz/ndx;
22490  if (z>*ptrz && pattern&hatch) {
22491  *ptrz = z;
22492  T *ptrd = ptrd0; const tc *col = color;
22493  cimg_forV(*this,k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22494  }
22495  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22496  ptrd0+=offx; ptrz+=offx;
22497  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22498  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22499  const float z = Z0 + x*dz/ndx;
22500  if (z>*ptrz) {
22501  *ptrz = z;
22502  T *ptrd = ptrd0; const tc *col = color;
22503  cimg_forV(*this,k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=wh; }
22504  }
22505  ptrd0+=offx; ptrz+=offx;
22506  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22507  }
22508  }
22509  return *this;
22510  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
j indices k indices k
Definition: Indexing.h:6
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_line ( CImg< floatT > &  zbuffer,
const int  x0,
const int  y0,
const float  z0,
const int  x1,
const int  y1,
const float  z1,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

Draw a 2D colored line, with z-buffering.

Definition at line 22514 of file CImg.h.

22518  {
22519  return draw_line(zbuffer,x0,y0,z0,x1,y1,z1,color.data,opacity,pattern,init_hatch);
22520  }
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.
Definition: CImg.h:22330
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 
)
inline

Draw a 3D colored line.

Definition at line 22524 of file CImg.h.

22527  {
22528  if (is_empty()) return *this;
22529  if (!color)
22530  throw CImgArgumentException("CImg<%s>::draw_line() : Specified color is (null)",
22531  pixel_type());
22532  static unsigned int hatch = ~0U - (~0U>>1);
22533  if (init_hatch) hatch = ~0U - (~0U>>1);
22534  int nx0 = x0, ny0 = y0, nz0 = z0, nx1 = x1, ny1 = y1, nz1 = z1;
22535  if (nx0>nx1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22536  if (nx1<0 || nx0>=dimx()) return *this;
22537  if (nx0<0) { const int D = 1 + nx1 - nx0; ny0-=nx0*(1 + ny1 - ny0)/D; nz0-=nx0*(1 + nz1 - nz0)/D; nx0 = 0; }
22538  if (nx1>=dimx()) { const int d = nx1-dimx(), D = 1 + nx1 - nx0; ny1+=d*(1 + ny0 - ny1)/D; nz1+=d*(1 + nz0 - nz1)/D; nx1 = dimx()-1; }
22539  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22540  if (ny1<0 || ny0>=dimy()) return *this;
22541  if (ny0<0) { const int D = 1 + ny1 - ny0; nx0-=ny0*(1 + nx1 - nx0)/D; nz0-=ny0*(1 + nz1 - nz0)/D; ny0 = 0; }
22542  if (ny1>=dimy()) { const int d = ny1-dimy(), D = 1 + ny1 - ny0; nx1+=d*(1 + nx0 - nx1)/D; nz1+=d*(1 + nz0 - nz1)/D; ny1 = dimy()-1; }
22543  if (nz0>nz1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
22544  if (nz1<0 || nz0>=dimz()) return *this;
22545  if (nz0<0) { const int D = 1 + nz1 - nz0; nx0-=nz0*(1 + nx1 - nx0)/D; ny0-=nz0*(1 + ny1 - ny0)/D; nz0 = 0; }
22546  if (nz1>=dimz()) { const int d = nz1-dimz(), D = 1 + nz1 - nz0; nx1+=d*(1 + nx0 - nx1)/D; ny1+=d*(1 + ny0 - ny1)/D; nz1 = dimz()-1; }
22547  const unsigned int dmax = cimg::max(cimg::abs(nx1 - nx0),cimg::abs(ny1 - ny0),nz1 - nz0), whz = width*height*depth;
22548  const float px = (nx1 - nx0)/(float)dmax, py = (ny1 - ny0)/(float)dmax, pz = (nz1 - nz0)/(float)dmax;
22549  float x = (float)nx0, y = (float)ny0, z = (float)nz0;
22550  if (opacity>=1) for (unsigned int t = 0; t<=dmax; ++t) {
22551  if (!(~pattern) || (~pattern && pattern&hatch)) {
22552  T* ptrd = ptr((unsigned int)x,(unsigned int)y,(unsigned int)z);
22553  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=whz; }
22554  }
22555  x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); }
22556  } else {
22557  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22558  for (unsigned int t = 0; t<=dmax; ++t) {
22559  if (!(~pattern) || (~pattern && pattern&hatch)) {
22560  T* ptrd = ptr((unsigned int)x,(unsigned int)y,(unsigned int)z);
22561  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; }
22562  }
22563  x+=px; y+=py; z+=pz; if (pattern) { hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1); }
22564  }
22565  }
22566  return *this;
22567  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& draw_line ( const int  x0,
const int  y0,
const int  z0,
const int  x1,
const int  y1,
const int  z1,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

Draw a 3D colored line.

Definition at line 22571 of file CImg.h.

22574  {
22575  return draw_line(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern,init_hatch);
22576  }
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.
Definition: CImg.h:22330
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 
)
inline

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

Definition at line 22603 of file CImg.h.

22609  {
22610  if (is_empty()) return *this;
22611  if (!texture || texture.dim<dim)
22612  throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22613  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22614  if (is_overlapped(texture)) return draw_line(x0,y0,x1,y1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22615  static unsigned int hatch = ~0U - (~0U>>1);
22616  if (init_hatch) hatch = ~0U - (~0U>>1);
22617  const bool xdir = x0<x1, ydir = y0<y1;
22618  int
22619  dtx = tx1-tx0, dty = ty1-ty0,
22620  nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22621  tnx0 = tx0, tnx1 = tx1, tny0 = ty0, tny1 = ty1,
22622  &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1, &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22623  &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22624  &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1, &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0,
22625  &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22626  if (xright<0 || xleft>=dimx()) return *this;
22627  if (xleft<0) {
22628  const int D = xright - xleft;
22629  yleft-=xleft*(yright - yleft)/D;
22630  txleft-=xleft*(txright - txleft)/D;
22631  tyleft-=xleft*(tyright - tyleft)/D;
22632  xleft = 0;
22633  }
22634  if (xright>=dimx()) {
22635  const int d = xright - dimx(), D = xright - xleft;
22636  yright-=d*(yright - yleft)/D;
22637  txright-=d*(txright - txleft)/D;
22638  tyright-=d*(tyright - tyleft)/D;
22639  xright = dimx()-1;
22640  }
22641  if (ydown<0 || yup>=dimy()) return *this;
22642  if (yup<0) {
22643  const int D = ydown - yup;
22644  xup-=yup*(xdown - xup)/D;
22645  txup-=yup*(txdown - txup)/D;
22646  tyup-=yup*(tydown - tyup)/D;
22647  yup = 0;
22648  }
22649  if (ydown>=dimy()) {
22650  const int d = ydown - dimy(), D = ydown - yup;
22651  xdown-=d*(xdown - xup)/D;
22652  txdown-=d*(txdown - txup)/D;
22653  tydown-=d*(tydown - tyup)/D;
22654  ydown = dimy()-1;
22655  }
22656  T *ptrd0 = ptr(nx0,ny0);
22657  int dx = xright - xleft, dy = ydown - yup;
22658  const bool steep = dy>dx;
22659  if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22660  const int
22661  offx = (nx0<nx1?1:-1)*(steep?width:1),
22662  offy = (ny0<ny1?1:-1)*(steep?1:width),
22663  wh = width*height,
22664  ndx = dx>0?dx:1;
22665  if (opacity>=1) {
22666  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22667  if (pattern&hatch) {
22668  T *ptrd = ptrd0;
22669  const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22670  cimg_forV(*this,k) { *ptrd = (T)texture(tx,ty,0,k); ptrd+=wh; }
22671  }
22672  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22673  ptrd0+=offx;
22674  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22675  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22676  T *ptrd = ptrd0;
22677  const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22678  cimg_forV(*this,k) { *ptrd = (T)texture(tx,ty,0,k); ptrd+=wh; }
22679  ptrd0+=offx;
22680  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22681  }
22682  } else {
22683  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22684  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22685  T *ptrd = ptrd0;
22686  if (pattern&hatch) {
22687  const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22688  cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture(tx,ty,0,k) + *ptrd*copacity); ptrd+=wh; }
22689  }
22690  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22691  ptrd0+=offx;
22692  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22693  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22694  T *ptrd = ptrd0;
22695  const int tx = tx0 + x*dtx/ndx, ty = ty0 + x*dty/ndx;
22696  cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture(tx,ty,0,k) + *ptrd*copacity); ptrd+=wh; }
22697  ptrd0+=offx;
22698  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22699  }
22700  }
22701  return *this;
22702  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
j indices k indices k
Definition: Indexing.h:6
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 
)
inline

Draw a 2D textured line, with perspective correction.

Definition at line 22706 of file CImg.h.

22712  {
22713  if (is_empty() && z0<=0 && z1<=0) return *this;
22714  if (!texture || texture.dim<dim)
22715  throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22716  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22717  if (is_overlapped(texture)) return draw_line(x0,y0,z0,x1,y1,z1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22718  static unsigned int hatch = ~0U - (~0U>>1);
22719  if (init_hatch) hatch = ~0U - (~0U>>1);
22720  const bool xdir = x0<x1, ydir = y0<y1;
22721  int
22722  nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22723  &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22724  &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22725  &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22726  &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22727  float
22728  Tx0 = tx0/z0, Tx1 = tx1/z1,
22729  Ty0 = ty0/z0, Ty1 = ty1/z1,
22730  Z0 = 1/z0, Z1 = 1/z1,
22731  dz = Z1 - Z0, dtx = Tx1 - Tx0, dty = Ty1 - Ty0,
22732  tnx0 = Tx0, tnx1 = Tx1, tny0 = Ty0, tny1 = Ty1, nz0 = Z0, nz1 = Z1,
22733  &zleft = xdir?nz0:nz1, &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1,
22734  &zright = xdir?nz1:nz0, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22735  &zup = ydir?nz0:nz1, &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1,
22736  &zdown = ydir?nz1:nz0, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22737  if (xright<0 || xleft>=dimx()) return *this;
22738  if (xleft<0) {
22739  const int D = xright - xleft;
22740  yleft-=xleft*(yright - yleft)/D;
22741  zleft-=xleft*(zright - zleft)/D;
22742  txleft-=xleft*(txright - txleft)/D;
22743  tyleft-=xleft*(tyright - tyleft)/D;
22744  xleft = 0;
22745  }
22746  if (xright>=dimx()) {
22747  const int d = xright - dimx(), D = xright - xleft;
22748  yright-=d*(yright - yleft)/D;
22749  zright-=d*(zright - zleft)/D;
22750  txright-=d*(txright - txleft)/D;
22751  tyright-=d*(tyright - tyleft)/D;
22752  xright = dimx()-1;
22753  }
22754  if (ydown<0 || yup>=dimy()) return *this;
22755  if (yup<0) {
22756  const int D = ydown - yup;
22757  xup-=yup*(xdown - xup)/D;
22758  zup-=yup*(zdown - zup)/D;
22759  txup-=yup*(txdown - txup)/D;
22760  tyup-=yup*(tydown - tyup)/D;
22761  yup = 0;
22762  }
22763  if (ydown>=dimy()) {
22764  const int d = ydown - dimy(), D = ydown - yup;
22765  xdown-=d*(xdown - xup)/D;
22766  zdown-=d*(zdown - zup)/D;
22767  txdown-=d*(txdown - txup)/D;
22768  tydown-=d*(tydown - tyup)/D;
22769  ydown = dimy()-1;
22770  }
22771  T *ptrd0 = ptr(nx0,ny0);
22772  int dx = xright - xleft, dy = ydown - yup;
22773  const bool steep = dy>dx;
22774  if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22775  const int
22776  offx = (nx0<nx1?1:-1)*(steep?width:1),
22777  offy = (ny0<ny1?1:-1)*(steep?1:width),
22778  wh = width*height,
22779  ndx = dx>0?dx:1;
22780  if (opacity>=1) {
22781  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22782  if (pattern&hatch) {
22783  const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22784  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; }
22785  }
22786  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22787  ptrd0+=offx;
22788  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22789  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22790  const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22791  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; }
22792  ptrd0+=offx;
22793  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22794  }
22795  } else {
22796  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22797  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22798  if (pattern&hatch) {
22799  const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22800  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture((int)(tx/z),(int)(ty/z),0,k) + *ptrd*copacity); ptrd+=wh; }
22801  }
22802  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22803  ptrd0+=offx;
22804  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22805  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22806  const float z = Z0 + x*dz/ndx, tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22807  T *ptrd = ptrd0;
22808  cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture((int)(tx/z),(int)(ty/z),0,k) + *ptrd*copacity); ptrd+=wh; }
22809  ptrd0+=offx;
22810  if ((error-=dy)<0) { ptrd0+=offy; error+=dx; }
22811  }
22812  }
22813  return *this;
22814  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
j indices k indices k
Definition: Indexing.h:6
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_line ( CImg< floatT > &  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 
)
inline

Draw a 2D textured line, with z-buffering and perspective correction.

Definition at line 22818 of file CImg.h.

22825  {
22826  if (is_empty() || z0<=0 || z1<=0) return *this;
22827  if (!is_sameXY(zbuffer))
22828  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
22829  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
22830  if (!texture || texture.dim<dim)
22831  throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
22832  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
22833  if (is_overlapped(texture)) return draw_line(zbuffer,x0,y0,z0,x1,y1,z1,+texture,tx0,ty0,tx1,ty1,opacity,pattern,init_hatch);
22834  static unsigned int hatch = ~0U - (~0U>>1);
22835  if (init_hatch) hatch = ~0U - (~0U>>1);
22836  const bool xdir = x0<x1, ydir = y0<y1;
22837  int
22838  nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1,
22839  &xleft = xdir?nx0:nx1, &yleft = xdir?ny0:ny1,
22840  &xright = xdir?nx1:nx0, &yright = xdir?ny1:ny0,
22841  &xup = ydir?nx0:nx1, &yup = ydir?ny0:ny1,
22842  &xdown = ydir?nx1:nx0, &ydown = ydir?ny1:ny0;
22843  float
22844  Tx0 = tx0/z0, Tx1 = tx1/z1,
22845  Ty0 = ty0/z0, Ty1 = ty1/z1,
22846  Z0 = 1/z0, Z1 = 1/z1,
22847  dz = Z1 - Z0, dtx = Tx1 - Tx0, dty = Ty1 - Ty0,
22848  tnx0 = Tx0, tnx1 = Tx1, tny0 = Ty0, tny1 = Ty1, nz0 = Z0, nz1 = Z1,
22849  &zleft = xdir?nz0:nz1, &txleft = xdir?tnx0:tnx1, &tyleft = xdir?tny0:tny1,
22850  &zright = xdir?nz1:nz0, &txright = xdir?tnx1:tnx0, &tyright = xdir?tny1:tny0,
22851  &zup = ydir?nz0:nz1, &txup = ydir?tnx0:tnx1, &tyup = ydir?tny0:tny1,
22852  &zdown = ydir?nz1:nz0, &txdown = ydir?tnx1:tnx0, &tydown = ydir?tny1:tny0;
22853  if (xright<0 || xleft>=dimx()) return *this;
22854  if (xleft<0) {
22855  const int D = xright - xleft;
22856  yleft-=xleft*(yright - yleft)/D;
22857  zleft-=xleft*(zright - zleft)/D;
22858  txleft-=xleft*(txright - txleft)/D;
22859  tyleft-=xleft*(tyright - tyleft)/D;
22860  xleft = 0;
22861  }
22862  if (xright>=dimx()) {
22863  const int d = xright - dimx(), D = xright - xleft;
22864  yright-=d*(yright - yleft)/D;
22865  zright-=d*(zright - zleft)/D;
22866  txright-=d*(txright - txleft)/D;
22867  tyright-=d*(tyright - tyleft)/D;
22868  xright = dimx()-1;
22869  }
22870  if (ydown<0 || yup>=dimy()) return *this;
22871  if (yup<0) {
22872  const int D = ydown - yup;
22873  xup-=yup*(xdown - xup)/D;
22874  zup-=yup*(zdown - zup)/D;
22875  txup-=yup*(txdown - txup)/D;
22876  tyup-=yup*(tydown - tyup)/D;
22877  yup = 0;
22878  }
22879  if (ydown>=dimy()) {
22880  const int d = ydown - dimy(), D = ydown - yup;
22881  xdown-=d*(xdown - xup)/D;
22882  zdown-=d*(zdown - zup)/D;
22883  txdown-=d*(txdown - txup)/D;
22884  tydown-=d*(tydown - tyup)/D;
22885  ydown = dimy()-1;
22886  }
22887  T *ptrd0 = ptr(nx0,ny0);
22888  float *ptrz = zbuffer.ptr(nx0,ny0);
22889  int dx = xright - xleft, dy = ydown - yup;
22890  const bool steep = dy>dx;
22891  if (steep) cimg::swap(nx0,ny0,nx1,ny1,dx,dy);
22892  const int
22893  offx = (nx0<nx1?1:-1)*(steep?width:1),
22894  offy = (ny0<ny1?1:-1)*(steep?1:width),
22895  wh = width*height,
22896  ndx = dx>0?dx:1;
22897  if (opacity>=1) {
22898  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22899  if (pattern&hatch) {
22900  const float z = Z0 + x*dz/ndx;
22901  if (z>*ptrz) {
22902  *ptrz = z;
22903  const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22904  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; }
22905  }
22906  }
22907  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22908  ptrd0+=offx; ptrz+=offx;
22909  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22910  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22911  const float z = Z0 + x*dz/ndx;
22912  if (z>*ptrz) {
22913  *ptrz = z;
22914  const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22915  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)texture((int)(tx/z),(int)(ty/z),0,k); ptrd+=wh; }
22916  }
22917  ptrd0+=offx; ptrz+=offx;
22918  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22919  }
22920  } else {
22921  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22922  if (~pattern) for (int error = dx>>1, x = 0; x<=dx; ++x) {
22923  if (pattern&hatch) {
22924  const float z = Z0 + x*dz/ndx;
22925  if (z>*ptrz) {
22926  *ptrz = z;
22927  const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22928  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture((int)(tx/z),(int)(ty/z),0,k) + *ptrd*copacity); ptrd+=wh; }
22929  }
22930  }
22931  hatch>>=1; if (!hatch) hatch = ~0U - (~0U>>1);
22932  ptrd0+=offx; ptrz+=offx;
22933  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offy; error+=dx; }
22934  } else for (int error = dx>>1, x = 0; x<=dx; ++x) {
22935  const float z = Z0 + x*dz/ndx;
22936  if (z>*ptrz) {
22937  *ptrz = z;
22938  const float tx = Tx0 + x*dtx/ndx, ty = Ty0 + x*dty/ndx;
22939  T *ptrd = ptrd0; cimg_forV(*this,k) { *ptrd = (T)(nopacity*texture((int)(tx/z),(int)(ty/z),0,k) + *ptrd*copacity); ptrd+=wh; }
22940  }
22941  ptrd0+=offx; ptrz+=offx;
22942  if ((error-=dy)<0) { ptrd0+=offy; ptrz+=offx; error+=dx; }
22943  }
22944  }
22945  return *this;
22946  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
const NT & d
j indices k indices k
Definition: Indexing.h:6
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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.
Definition: CImg.h:22330
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_line ( const CImgList< t > &  points,
const tc *const  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Parameters
pointsCoordinates of vertices, stored as a list of vectors.
colorPointer to dimv() 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);

Definition at line 23006 of file CImg.h.

23008  {
23009  unsigned int H = ~0U; cimglist_for(points,p) H = cimg::min(H,(unsigned int)(points[p].size()));
23010  return _draw_line(points,points.width,H,color,opacity,pattern,init_hatch);
23011  }
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Definition: points.h:30
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg< T > & _draw_line(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:22950
CImg<T>& draw_line ( const CImgList< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23015 of file CImg.h.

23017  {
23018  return draw_line(points,color.data,opacity,pattern,init_hatch);
23019  }
Definition: points.h:30
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.
Definition: CImg.h:22330
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 
)
inline

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

Note
  • Similar to the previous function, where the N vertex coordinates are stored as a Nx2 or Nx3 image (sequence of vectors aligned along the x-axis).

Definition at line 23028 of file CImg.h.

23030  {
23031  return _draw_line(points,points.width,points.height,color,opacity,pattern,init_hatch);
23032  }
Definition: points.h:30
CImg< T > & _draw_line(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:22950
CImg<T>& draw_line ( const CImg< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23036 of file CImg.h.

23038  {
23039  return draw_line(points,color.data,opacity,pattern,init_hatch);
23040  }
Definition: points.h:30
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.
Definition: CImg.h:22330
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  itermax = 255,
const bool  normalized_iteration = false,
const bool  julia_set = false,
const double  paramr = 0,
const double  parami = 0 
)
inline

Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.

Definition at line 27250 of file CImg.h.

Referenced by CImg< uintT >::draw_mandelbrot().

27256  {
27257  if (is_empty()) return *this;
27258  CImg<tc> palette;
27259  if (color_palette) palette.assign(color_palette.data,color_palette.size()/color_palette.dim,1,1,color_palette.dim,true);
27260  if (palette && palette.dim!=dim)
27261  throw CImgArgumentException("CImg<%s>::draw_mandelbrot() : Specified color palette (%u,%u,%u,%u,%p) is not \n"
27262  "compatible with instance image (%u,%u,%u,%u,%p).",
27263  pixel_type(),color_palette.width,color_palette.height,color_palette.depth,color_palette.dim,
27264  color_palette.data,width,height,depth,dim,data);
27265  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0), ln2 = (float)std::log(2.0);
27266  unsigned int iter = 0;
27267  cimg_for_inXY(*this,x0,y0,x1,y1,p,q) {
27268  const double x = z0r + p*(z1r-z0r)/width, y = z0i + q*(z1i-z0i)/height;
27269  double zr, zi, cr, ci;
27270  if (julia_set) { zr = x; zi = y; cr = paramr; ci = parami; }
27271  else { zr = paramr; zi = parami; cr = x; ci = y; }
27272  for (iter=1; zr*zr + zi*zi<=4 && iter<=itermax; ++iter) {
27273  const double temp = zr*zr - zi*zi + cr;
27274  zi = 2*zr*zi + ci;
27275  zr = temp;
27276  }
27277  if (iter>itermax) {
27278  if (palette) {
27279  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)palette(0,k);
27280  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)(palette(0,k)*nopacity + (*this)(p,q,0,k)*copacity);
27281  } else {
27282  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)0;
27283  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)((*this)(p,q,0,k)*copacity);
27284  }
27285  } else if (normalized_iteration) {
27286  const float
27287  normz = (float)cimg::abs(zr*zr+zi*zi),
27288  niter = (float)(iter + 1 - std::log(std::log(normz))/ln2);
27289  if (palette) {
27290  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)palette._linear_atX(niter,k);
27291  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)(palette._linear_atX(niter,k)*nopacity + (*this)(p,q,0,k)*copacity);
27292  } else {
27293  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)niter;
27294  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)(niter*nopacity + (*this)(p,q,0,k)*copacity);
27295  }
27296  } else {
27297  if (palette) {
27298  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)palette._atX(iter,k);
27299  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)(palette(iter,k)*nopacity + (*this)(p,q,0,k)*copacity);
27300  } else {
27301  if (opacity>=1) cimg_forV(*this,k) (*this)(p,q,0,k) = (T)iter;
27302  else cimg_forV(*this,k) (*this)(p,q,0,k) = (T)(iter*nopacity + (*this)(p,q,0,k)*copacity);
27303  }
27304  }
27305  }
27306  return *this;
27307  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< _cimg_Tfloat > log(const CImg< T > &instance)
Definition: CImg.h:6021
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T & _atX(const int x, const int y=0, const int z=0, const int v=0)
Definition: CImg.h:11347
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT q
Tfloat _linear_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Definition: CImg.h:11575
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_for_inXY(img, x0, y0, x1, y1, x, y)
Definition: CImg.h:615

Here is the caller graph for this function:

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  itermax = 255,
const bool  normalized_iteration = false,
const bool  julia_set = false,
const double  paramr = 0,
const double  parami = 0 
)
inline

Draw a quadratic Mandelbrot or Julia fractal set, computed using the Escape Time Algorithm.

Definition at line 27311 of file CImg.h.

27316  {
27317  return draw_mandelbrot(0,0,width-1,height-1,color_palette,opacity,z0r,z0i,z1r,z1i,itermax,normalized_iteration,julia_set,paramr,parami);
27318  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
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 itermax=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.
Definition: CImg.h:27250
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 = -5000,
const float  specular_light = 0.2f,
const float  specular_shine = 0.1f,
CImg< floatT > &  zbuffer = cimg_library::CImg<floatT>::empty() 
)
inline

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 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
lightx= X-coordinate of the light
lighty= Y-coordinate of the light
lightz= Z-coordinate of the light
specular_shine= Shininess of the object

Definition at line 27522 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d(), and CImg< uintT >::draw_object3d().

27529  {
27530  return _draw_object3d(0,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.width,
27531  render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27532  }
CImg< T > & _draw_object3d(void *const pboard, CImg< floatT > &zbuffer, const float X, const float Y, const float Z, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const unsigned int nb_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)
Definition: CImg.h:27625

Here is the caller graph for this function:

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 = -5000,
const float  specular_light = 0.2f,
const float  specular_shine = 0.1f,
CImg< floatT > &  zbuffer = cimg_library::CImg<floatT>::empty() 
)
inline

Definition at line 27550 of file CImg.h.

27557  {
27558  return _draw_object3d(0,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities,opacities.size(),
27559  render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine);
27560  }
CImg< T > & _draw_object3d(void *const pboard, CImg< floatT > &zbuffer, const float X, const float Y, const float Z, const CImg< tp > &vertices, const CImgList< tf > &primitives, const CImgList< tc > &colors, const to &opacities, const unsigned int nb_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)
Definition: CImg.h:27625
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 = -5000,
const float  specular_light = 0.2f,
const float  specular_shine = 0.1f,
CImg< floatT > &  zbuffer = cimg_library::CImg<floatT>::empty() 
)
inline

Draw a 3D object.

Definition at line 27580 of file CImg.h.

27587  {
27588  static const CImg<floatT> opacities;
27589  return draw_object3d(x0,y0,z0,vertices,primitives,colors,opacities,
27590  render_type,double_sided,focale,lightx,lighty,lightz,specular_light,specular_shine,zbuffer);
27591  }
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=-5000, const float specular_light=0.2f, const float specular_shine=0.1f, CImg< floatT > &zbuffer=cimg_library::CImg< floatT >::empty())
Draw a 3D object.
Definition: CImg.h:27522
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 
)
inline

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.

Definition at line 27177 of file CImg.h.

Referenced by CImg< uintT >::draw_plasma().

27179  {
27180  if (!is_empty()) {
27181  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
27182  int nx0 = x0, nx1 = x1, ny0 = y0, ny1 = y1;
27183  if (nx1<nx0) cimg::swap(nx0,nx1);
27184  if (ny1<ny0) cimg::swap(ny0,ny1);
27185  if (nx0<0) nx0 = 0;
27186  if (nx1>=dimx()) nx1 = width-1;
27187  if (ny0<0) ny0 = 0;
27188  if (ny1>=dimy()) ny1 = height-1;
27189  const int xc = (nx0+nx1)/2, yc = (ny0+ny1)/2, dx = (xc-nx0), dy = (yc-ny0);
27190  const Tfloat dc = (Tfloat)(std::sqrt((float)(dx*dx+dy*dy))*alpha + beta);
27191  Tfloat val = 0;
27192  cimg_forV(*this,k) {
27193  if (opacity>=1) {
27194  const Tfloat
27195  val0 = (Tfloat)((*this)(nx0,ny0,0,k)), val1 = (Tfloat)((*this)(nx1,ny0,0,k)),
27196  val2 = (Tfloat)((*this)(nx0,ny1,0,k)), val3 = (Tfloat)((*this)(nx1,ny1,0,k));
27197  (*this)(xc,ny0,0,k) = (T)((val0+val1)/2);
27198  (*this)(xc,ny1,0,k) = (T)((val2+val3)/2);
27199  (*this)(nx0,yc,0,k) = (T)((val0+val2)/2);
27200  (*this)(nx1,yc,0,k) = (T)((val1+val3)/2);
27201  do {
27202  val = (Tfloat)(0.25f*((Tfloat)((*this)(nx0,ny0,0,k)) +
27203  (Tfloat)((*this)(nx1,ny0,0,k)) +
27204  (Tfloat)((*this)(nx1,ny1,0,k)) +
27205  (Tfloat)((*this)(nx0,ny1,0,k))) +
27206  dc*cimg::grand());
27207  } while (val<(Tfloat)cimg::type<T>::min() || val>(Tfloat)cimg::type<T>::max());
27208  (*this)(xc,yc,0,k) = (T)val;
27209  } else {
27210  const Tfloat
27211  val0 = (Tfloat)((*this)(nx0,ny0,0,k)), val1 = (Tfloat)((*this)(nx1,ny0,0,k)),
27212  val2 = (Tfloat)((*this)(nx0,ny1,0,k)), val3 = (Tfloat)((*this)(nx1,ny1,0,k));
27213  (*this)(xc,ny0,0,k) = (T)(((val0+val1)*nopacity + copacity*(*this)(xc,ny0,0,k))/2);
27214  (*this)(xc,ny1,0,k) = (T)(((val2+val3)*nopacity + copacity*(*this)(xc,ny1,0,k))/2);
27215  (*this)(nx0,yc,0,k) = (T)(((val0+val2)*nopacity + copacity*(*this)(nx0,yc,0,k))/2);
27216  (*this)(nx1,yc,0,k) = (T)(((val1+val3)*nopacity + copacity*(*this)(nx1,yc,0,k))/2);
27217  do {
27218  val = (Tfloat)(0.25f*(((Tfloat)((*this)(nx0,ny0,0,k)) +
27219  (Tfloat)((*this)(nx1,ny0,0,k)) +
27220  (Tfloat)((*this)(nx1,ny1,0,k)) +
27221  (Tfloat)((*this)(nx0,ny1,0,k))) +
27222  dc*cimg::grand())*nopacity + copacity*(*this)(xc,yc,0,k));
27223  } while (val<(Tfloat)cimg::type<T>::min() || val>(Tfloat)cimg::type<T>::max());
27224  (*this)(xc,yc,0,k) = (T)val;
27225  }
27226  }
27227  if (xc!=nx0 || yc!=ny0) {
27228  draw_plasma(nx0,ny0,xc,yc,alpha,beta,opacity);
27229  draw_plasma(xc,ny0,nx1,yc,alpha,beta,opacity);
27230  draw_plasma(nx0,yc,xc,ny1,alpha,beta,opacity);
27231  draw_plasma(xc,yc,nx1,ny1,alpha,beta,opacity);
27232  }
27233  }
27234  return *this;
27235  }
if(dy > dx)
double grand()
Return a random variable following a gaussian distribution and a standard deviation of 1...
Definition: CImg.h:4845
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
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.
Definition: CImg.h:27177
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy

Here is the caller graph for this function:

CImg<T>& draw_plasma ( const float  alpha = 1,
const float  beta = 1,
const float  opacity = 1 
)
inline

Draw a plasma random texture.

Parameters
alpha= Alpha-parameter of the plasma.
beta= Beta-parameter of the plasma.
opacity= opacity of the drawing.

Definition at line 27243 of file CImg.h.

27244  {
27245  return draw_plasma(0,0,width-1,height-1,alpha,beta,opacity);
27246  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
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.
Definition: CImg.h:27177
CImg<T>& draw_point ( const int  x0,
const int  y0,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a 2D colored point (pixel).

Parameters
x0X-coordinate of the point.
y0Y-coordinate of the point.
colorPointer to dimv() 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);

Definition at line 22192 of file CImg.h.

Referenced by CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_point(), CImg< uintT >::draw_arrow(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_circle(), CImg< uintT >::draw_graph(), and CImg< uintT >::draw_point().

22193  {
22194  return draw_point(x0,y0,0,color,opacity);
22195  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192

Here is the caller graph for this function:

CImg<T>& draw_point ( const int  x0,
const int  y0,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a 2D colored point (pixel).

Definition at line 22199 of file CImg.h.

22200  {
22201  return draw_point(x0,y0,color.data,opacity);
22202  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
CImg<T>& draw_point ( const int  x0,
const int  y0,
const int  z0,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a 3D colored point (voxel).

Definition at line 22206 of file CImg.h.

22207  {
22208  if (is_empty()) return *this;
22209  if (!color)
22210  throw CImgArgumentException("CImg<%s>::draw_point() : Specified color is (null)",
22211  pixel_type());
22212  if (x0>=0 && y0>=0 && z0>=0 && x0<dimx() && y0<dimy() && z0<dimz()) {
22213  const unsigned int whz = width*height*depth;
22214  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
22215  T *ptrd = ptr(x0,y0,z0,0);
22216  const tc *col = color;
22217  if (opacity>=1) cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=whz; }
22218  else cimg_forV(*this,k) { *ptrd = (T)(*(col++)*nopacity + *ptrd*copacity); ptrd+=whz; }
22219  }
22220  return *this;
22221  }
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& draw_point ( const int  x0,
const int  y0,
const int  z0,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a 3D colored point (voxel).

Definition at line 22225 of file CImg.h.

22226  {
22227  return draw_point(x0,y0,z0,color.data,opacity);
22228  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
CImg<T>& draw_point ( const CImgList< t > &  points,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a cloud of colored points.

Parameters
pointsCoordinates of vertices, stored as a list of vectors.
colorPointer to dimv() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
Note
  • This function uses several call to the single CImg::draw_point() 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_point(points,color);

Definition at line 22276 of file CImg.h.

22277  {
22278  unsigned int H = ~0U; cimglist_for(points,p) H = cimg::min(H,(unsigned int)(points[p].size()));
22279  return _draw_point(points,points.width,H,color,opacity);
22280  }
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Definition: points.h:30
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & _draw_point(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity)
Definition: CImg.h:22232
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg<T>& draw_point ( const CImgList< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a cloud of colored points.

Definition at line 22284 of file CImg.h.

22285  {
22286  return draw_point(points,color.data,opacity);
22287  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
Definition: points.h:30
CImg<T>& draw_point ( const CImg< t > &  points,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a cloud of colored points.

Note
  • Similar to the previous function, where the N vertex coordinates are stored as a Nx2 or Nx3 image (sequence of vectors aligned along the x-axis).

Definition at line 22296 of file CImg.h.

22297  {
22298  return _draw_point(points,points.width,points.height,color,opacity);
22299  }
Definition: points.h:30
CImg< T > & _draw_point(const t &points, const unsigned int W, const unsigned int H, const tc *const color, const float opacity)
Definition: CImg.h:22232
CImg<T>& draw_point ( const CImg< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a cloud of colored points.

Definition at line 22303 of file CImg.h.

22304  {
22305  return draw_point(points,color.data,opacity);
22306  }
CImg< T > & draw_point(const int x0, const int y0, const tc *const color, const float opacity=1)
Draw a 2D colored point (pixel).
Definition: CImg.h:22192
Definition: points.h:30
CImg<T>& draw_polygon ( const CImgList< t > &  points,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a filled polygon in the instance image.

Definition at line 25756 of file CImg.h.

Referenced by CImg< uintT >::draw_polygon().

25757  {
25758  if (!points.is_sameY(2))
25759  throw CImgArgumentException("CImg<%s>::draw_polygon() : Given list of points is not valid.",
25760  pixel_type());
25761  return _draw_polygon(points,points.width,color,opacity);
25762  }
CImg< T > & _draw_polygon(const t &points, const unsigned int N, const tc *const color, const float opacity)
Definition: CImg.h:25699
Definition: points.h:30
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041

Here is the caller graph for this function:

CImg<T>& draw_polygon ( const CImgList< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a filled polygon in the instance image.

Definition at line 25766 of file CImg.h.

25767  {
25768  return draw_polygon(points,color.data,opacity);
25769  }
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
Definition: CImg.h:25756
Definition: points.h:30
CImg<T>& draw_polygon ( const CImg< t > &  points,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a filled polygon in the instance image.

Definition at line 25773 of file CImg.h.

25774  {
25775  if (points.height<2)
25776  throw CImgArgumentException("CImg<%s>::draw_polygon() : Given list of points is not valid.",
25777  pixel_type());
25778  return _draw_polygon(points,points.width,color,opacity);
25779  }
CImg< T > & _draw_polygon(const t &points, const unsigned int N, const tc *const color, const float opacity)
Definition: CImg.h:25699
Definition: points.h:30
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg<T>& draw_polygon ( const CImg< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

Draw a filled polygon in the instance image.

Definition at line 25783 of file CImg.h.

25784  {
25785  return draw_polygon(points,color.data,opacity);
25786  }
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
Definition: CImg.h:25756
Definition: points.h:30
CImg<T>& draw_polygon ( const CImgList< t > &  points,
const tc *const  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a polygon outline.

Definition at line 25827 of file CImg.h.

25829  {
25830  unsigned int H = ~0U; cimglist_for(points,p) H = cimg::min(H,(unsigned int)(points[p].size()));
25831  return _draw_polygon(points,points.width,H,color,opacity,pattern);
25832  }
CImg< T > & _draw_polygon(const t &points, const unsigned int N, const tc *const color, const float opacity)
Definition: CImg.h:25699
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Definition: points.h:30
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg<T>& draw_polygon ( const CImgList< t > &  points,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a polygon outline.

Definition at line 25836 of file CImg.h.

25838  {
25839  return draw_polygon(points,color.data,opacity,pattern);
25840  }
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
Definition: CImg.h:25756
Definition: points.h:30
CImg<T>& draw_polygon ( const CImg< t > &  points,
const tc *const  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a polygon outline.

Definition at line 25844 of file CImg.h.

25846  {
25847  return _draw_polygon(points,points.width,points.height,color,opacity,pattern);
25848  }
CImg< T > & _draw_polygon(const t &points, const unsigned int N, const tc *const color, const float opacity)
Definition: CImg.h:25699
Definition: points.h:30
CImg<T>& draw_polygon ( const CImg< t > &  points,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a polygon outline.

Definition at line 25852 of file CImg.h.

25854  {
25855  return draw_polygon(points,color.data,opacity,pattern);
25856  }
CImg< T > & draw_polygon(const CImgList< t > &points, const tc *const color, const float opacity=1)
Draw a filled polygon in the instance image.
Definition: CImg.h:25756
Definition: points.h:30
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 
)
inline

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

Parameters
flowImage of 2d vectors used as input data.
colorImage of dimv()-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.

Definition at line 26498 of file CImg.h.

Referenced by CImg< uintT >::draw_quiver().

26501  {
26502  return draw_quiver(flow,CImg<t2>(color,dim,1,1,1,true),opacity,sampling,factor,arrows,pattern);
26503  }
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 instance image, using a colormap.
Definition: CImg.h:26498
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

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

Parameters
flowImage of 2d vectors used as input data.
colorImage of dimv()-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.

Definition at line 26516 of file CImg.h.

26519  {
26520  if (!is_empty()) {
26521  if (!flow || flow.dim!=2)
26522  throw CImgArgumentException("CImg<%s>::draw_quiver() : Specified flow (%u,%u,%u,%u,%p) has wrong dimensions.",
26523  pixel_type(),flow.width,flow.height,flow.depth,flow.dim,flow.data);
26524  if (sampling<=0)
26525  throw CImgArgumentException("CImg<%s>::draw_quiver() : Incorrect sampling value = %g",
26526  pixel_type(),sampling);
26527  const bool colorfield = (color.width==flow.width && color.height==flow.height && color.depth==1 && color.dim==dim);
26528  if (is_overlapped(flow)) return draw_quiver(+flow,color,opacity,sampling,factor,arrows,pattern);
26529 
26530  float vmax,fact;
26531  if (factor<=0) {
26532  float m, M = (float)flow.get_norm(2).maxmin(m);
26533  vmax = (float)cimg::max(cimg::abs(m),cimg::abs(M));
26534  fact = -factor;
26535  } else { fact = factor; vmax = 1; }
26536 
26537  for (unsigned int y=sampling/2; y<height; y+=sampling)
26538  for (unsigned int x=sampling/2; x<width; x+=sampling) {
26539  const unsigned int X = x*flow.width/width, Y = y*flow.height/height;
26540  float u = (float)flow(X,Y,0,0)*fact/vmax, v = (float)flow(X,Y,0,1)*fact/vmax;
26541  if (arrows) {
26542  const int xx = x+(int)u, yy = y+(int)v;
26543  if (colorfield) draw_arrow(x,y,xx,yy,color.get_vector_at(X,Y).data,opacity,45,sampling/5.0f,pattern);
26544  else draw_arrow(x,y,xx,yy,color,opacity,45,sampling/5.0f,pattern);
26545  } else {
26546  if (colorfield) draw_line((int)(x-0.5*u),(int)(y-0.5*v),(int)(x+0.5*u),(int)(y+0.5*v),color.get_vector_at(X,Y),opacity,pattern);
26547  else draw_line((int)(x-0.5*u),(int)(y-0.5*v),(int)(x+0.5*u),(int)(y+0.5*v),color,opacity,pattern);
26548  }
26549  }
26550  }
26551  return *this;
26552  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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...
Definition: CImg.h:13270
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
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 instance image, using a colormap.
Definition: CImg.h:26498
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 instance image.
Definition: CImg.h:23057
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const int  x1,
const int  y1,
const int  z1,
const int  v1,
const T  val,
const float  opacity = 1 
)
inline

Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).

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.
v0V-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.
v1V-coordinate of the lower-right rectangle corner.
valScalar value used to fill the rectangle area.
opacityDrawing opacity (optional).
Note
  • Clipping is supported.

Definition at line 25546 of file CImg.h.

Referenced by CImg< uintT >::draw_graph(), and CImg< uintT >::draw_rectangle().

25548  {
25549  if (is_empty()) return *this;
25550  const bool bx = (x0<x1), by = (y0<y1), bz = (z0<z1), bv = (v0<v1);
25551  const int
25552  nx0 = bx?x0:x1, nx1 = bx?x1:x0,
25553  ny0 = by?y0:y1, ny1 = by?y1:y0,
25554  nz0 = bz?z0:z1, nz1 = bz?z1:z0,
25555  nv0 = bv?v0:v1, nv1 = bv?v1:v0;
25556  const int
25557  lX = (1 + nx1 - nx0) + (nx1>=dimx()?dimx() - 1 - nx1:0) + (nx0<0?nx0:0),
25558  lY = (1 + ny1 - ny0) + (ny1>=dimy()?dimy() - 1 - ny1:0) + (ny0<0?ny0:0),
25559  lZ = (1 + nz1 - nz0) + (nz1>=dimz()?dimz() - 1 - nz1:0) + (nz0<0?nz0:0),
25560  lV = (1 + nv1 - nv0) + (nv1>=dimv()?dimv() - 1 - nv1:0) + (nv0<0?nv0:0);
25561  const unsigned int offX = width - lX, offY = width*(height - lY), offZ = width*height*(depth - lZ);
25562  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
25563  T *ptrd = ptr(nx0<0?0:nx0,ny0<0?0:ny0,nz0<0?0:nz0,nv0<0?0:nv0);
25564  if (lX>0 && lY>0 && lZ>0 && lV>0)
25565  for (int v = 0; v<lV; ++v) {
25566  for (int z = 0; z<lZ; ++z) {
25567  for (int y = 0; y<lY; ++y) {
25568  if (opacity>=1) {
25569  if (sizeof(T)!=1) { for (int x = 0; x<lX; ++x) *(ptrd++) = val; ptrd+=offX; }
25570  else { std::memset(ptrd,(int)val,lX); ptrd+=width; }
25571  } else { for (int x = 0; x<lX; ++x) { *ptrd = (T)(nopacity*val + *ptrd*copacity); ++ptrd; } ptrd+=offX; }
25572  }
25573  ptrd+=offY;
25574  }
25575  ptrd+=offZ;
25576  }
25577  return *this;
25578  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

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

Draw a 3D filled colored rectangle in the instance image, 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 dimv() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
Note
  • Clipping is supported.

Definition at line 25594 of file CImg.h.

25596  {
25597  if (!color)
25598  throw CImgArgumentException("CImg<%s>::draw_rectangle : specified color is (null)",
25599  pixel_type());
25600  cimg_forV(*this,k) draw_rectangle(x0,y0,z0,k,x1,y1,z1,k,color[k],opacity);
25601  return *this;
25602  }
j indices k indices k
Definition: Indexing.h:6
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  z0,
const int  x1,
const int  y1,
const int  z1,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

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

Definition at line 25606 of file CImg.h.

25608  {
25609  return draw_rectangle(x0,y0,z0,x1,y1,z1,color.data,opacity);
25610  }
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
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 
)
inline

Draw a 3D outlined colored rectangle in the instance image.

Definition at line 25614 of file CImg.h.

25617  {
25618  return draw_line(x0,y0,z0,x1,y0,z0,color,opacity,pattern,true).
25619  draw_line(x1,y0,z0,x1,y1,z0,color,opacity,pattern,false).
25620  draw_line(x1,y1,z0,x0,y1,z0,color,opacity,pattern,false).
25621  draw_line(x0,y1,z0,x0,y0,z0,color,opacity,pattern,false).
25622  draw_line(x0,y0,z1,x1,y0,z1,color,opacity,pattern,true).
25623  draw_line(x1,y0,z1,x1,y1,z1,color,opacity,pattern,false).
25624  draw_line(x1,y1,z1,x0,y1,z1,color,opacity,pattern,false).
25625  draw_line(x0,y1,z1,x0,y0,z1,color,opacity,pattern,false).
25626  draw_line(x0,y0,z0,x0,y0,z1,color,opacity,pattern,true).
25627  draw_line(x1,y0,z0,x1,y0,z1,color,opacity,pattern,true).
25628  draw_line(x1,y1,z0,x1,y1,z1,color,opacity,pattern,true).
25629  draw_line(x0,y1,z0,x0,y1,z1,color,opacity,pattern,true);
25630  }
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.
Definition: CImg.h:22330
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  z0,
const int  x1,
const int  y1,
const int  z1,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a 3D outlined colored rectangle in the instance image.

Definition at line 25634 of file CImg.h.

25637  {
25638  return draw_rectangle(x0,y0,z0,x1,y1,z1,color.data,opacity,pattern);
25639  }
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const tc *const  color,
const float  opacity = 1 
)
inline

Draw a 2D filled colored rectangle in the instance image, 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 dimv() consecutive values of type T, defining the drawing color.
opacityDrawing opacity (optional).
Note
  • Clipping is supported.

Definition at line 25653 of file CImg.h.

25655  {
25656  return draw_rectangle(x0,y0,0,x1,y1,depth-1,color,opacity);
25657  }
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const CImg< tc > &  color,
const float  opacity = 1 
)
inline

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

Definition at line 25661 of file CImg.h.

25663  {
25664  return draw_rectangle(x0,y0,x1,y1,color.data,opacity);
25665  }
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
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 
)
inline

Draw a 2D outlined colored rectangle.

Definition at line 25669 of file CImg.h.

25672  {
25673  if (is_empty()) return *this;
25674  if (y0==y1) return draw_line(x0,y0,x1,y0,color,opacity,pattern,true);
25675  if (x0==x1) return draw_line(x0,y0,x0,y1,color,opacity,pattern,true);
25676  const bool bx = (x0<x1), by = (y0<y1);
25677  const int
25678  nx0 = bx?x0:x1, nx1 = bx?x1:x0,
25679  ny0 = by?y0:y1, ny1 = by?y1:y0;
25680  if (ny1==ny0+1) return draw_line(nx0,ny0,nx1,ny0,color,opacity,pattern,true).
25681  draw_line(nx1,ny1,nx0,ny1,color,opacity,pattern,false);
25682  return draw_line(nx0,ny0,nx1,ny0,color,opacity,pattern,true).
25683  draw_line(nx1,ny0+1,nx1,ny1-1,color,opacity,pattern,false).
25684  draw_line(nx1,ny1,nx0,ny1,color,opacity,pattern,false).
25685  draw_line(nx0,ny1-1,nx0,ny0+1,color,opacity,pattern,false);
25686  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
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.
Definition: CImg.h:22330
CImg<T>& draw_rectangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const CImg< tc > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a 2D outlined colored rectangle.

Definition at line 25690 of file CImg.h.

25693  {
25694  return draw_rectangle(x0,y0,x1,y1,color.data,opacity,pattern);
25695  }
CImg< T > & draw_rectangle(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const T val, const float opacity=1)
Draw a 4D filled rectangle in the instance image, at coordinates (x0,y0,z0,v0)-(x1,y1,z1,v1).
Definition: CImg.h:25546
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 = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

Draw a cubic spline curve in the instance image.

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 dimv() 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);

Definition at line 23122 of file CImg.h.

Referenced by CImg< uintT >::_draw_spline(), and CImg< uintT >::draw_spline().

23126  {
23127  if (is_empty()) return *this;
23128  if (!color)
23129  throw CImgArgumentException("CImg<%s>::draw_spline() : Specified color is (null)",
23130  pixel_type());
23131  bool ninit_hatch = init_hatch;
23132  const float
23133  dx = (float)(x1 - x0),
23134  dy = (float)(y1 - y0),
23135  dmax = cimg::max(cimg::abs(dx),cimg::abs(dy)),
23136  ax = -2*dx + u0 + u1,
23137  bx = 3*dx - 2*u0 - u1,
23138  ay = -2*dy + v0 + v1,
23139  by = 3*dy - 2*v0 - v1,
23140  xprecision = dmax>0?precision/dmax:1.0f,
23141  tmax = 1 + (dmax>0?xprecision:0.0f);
23142  int ox = x0, oy = y0;
23143  for (float t = 0; t<tmax; t+=xprecision) {
23144  const float
23145  t2 = t*t,
23146  t3 = t2*t;
23147  const int
23148  nx = (int)(ax*t3 + bx*t2 + u0*t + x0),
23149  ny = (int)(ay*t3 + by*t2 + v0*t + y0);
23150  draw_line(ox,oy,nx,ny,color,opacity,pattern,ninit_hatch);
23151  ninit_hatch = false;
23152  ox = nx; oy = ny;
23153  }
23154  return *this;
23155  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
NT dx
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
NT dy
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.
Definition: CImg.h:22330

Here is the caller graph for this function:

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< tc > &  color,
const float  opacity = 1,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

Draw a cubic spline curve in the instance image.

Definition at line 23159 of file CImg.h.

23163  {
23164  return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,color.data,opacity,precision,pattern,init_hatch);
23165  }
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
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 
)
inline

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

Note

Definition at line 23173 of file CImg.h.

23177  {
23178  if (is_empty()) return *this;
23179  if (!color)
23180  throw CImgArgumentException("CImg<%s>::draw_spline() : Specified color is (null)",
23181  pixel_type());
23182  bool ninit_hatch = init_hatch;
23183  const float
23184  dx = (float)(x1 - x0),
23185  dy = (float)(y1 - y0),
23186  dz = (float)(z1 - z0),
23187  dmax = cimg::max(cimg::abs(dx),cimg::abs(dy),cimg::abs(dz)),
23188  ax = -2*dx + u0 + u1,
23189  bx = 3*dx - 2*u0 - u1,
23190  ay = -2*dy + v0 + v1,
23191  by = 3*dy - 2*v0 - v1,
23192  az = -2*dz + w0 + w1,
23193  bz = 3*dz - 2*w0 - w1,
23194  xprecision = dmax>0?precision/dmax:1.0f,
23195  tmax = 1 + (dmax>0?xprecision:0.0f);
23196  int ox = x0, oy = y0, oz = z0;
23197  for (float t = 0; t<tmax; t+=xprecision) {
23198  const float
23199  t2 = t*t,
23200  t3 = t2*t;
23201  const int
23202  nx = (int)(ax*t3 + bx*t2 + u0*t + x0),
23203  ny = (int)(ay*t3 + by*t2 + v0*t + y0),
23204  nz = (int)(az*t3 + bz*t2 + w0*t + z0);
23205  draw_line(ox,oy,oz,nx,ny,nz,color,opacity,pattern,ninit_hatch);
23206  ninit_hatch = false;
23207  ox = nx; oy = ny; oz = nz;
23208  }
23209  return *this;
23210  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
NT dx
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
NT dy
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.
Definition: CImg.h:22330
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 CImg< tc > &  color,
const float  opacity = 1,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23214 of file CImg.h.

23218  {
23219  return draw_spline(x0,y0,z0,u0,v0,w0,x1,y1,z1,u1,v1,w1,color.data,opacity,precision,pattern,init_hatch);
23220  }
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
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 
)
inline

Draw a cubic spline curve in the instance image.

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.

Definition at line 23243 of file CImg.h.

23249  {
23250  if (is_empty()) return *this;
23251  if (!texture || texture.dim<dim)
23252  throw CImgArgumentException("CImg<%s>::draw_line() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
23253  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
23254  if (is_overlapped(texture)) return draw_spline(x0,y0,u0,v0,x1,y1,u1,v1,+texture,tx0,ty0,tx1,ty1,precision,opacity,pattern,init_hatch);
23255  bool ninit_hatch = true;
23256  const float
23257  dx = (float)(x1 - x0),
23258  dy = (float)(y1 - y0),
23259  dmax = cimg::max(cimg::abs(dx),cimg::abs(dy)),
23260  ax = -2*dx + u0 + u1,
23261  bx = 3*dx - 2*u0 - u1,
23262  ay = -2*dy + v0 + v1,
23263  by = 3*dy - 2*v0 - v1,
23264  xprecision = dmax>0?precision/dmax:1.0f,
23265  tmax = 1 + (dmax>0?xprecision:0.0f);
23266  int ox = x0, oy = y0, otx = tx0, oty = ty0;
23267  for (float t1 = 0; t1<tmax; t1+=xprecision) {
23268  const float
23269  t2 = t1*t1,
23270  t3 = t2*t1;
23271  const int
23272  nx = (int)(ax*t3 + bx*t2 + u0*t1 + x0),
23273  ny = (int)(ay*t3 + by*t2 + v0*t1 + y0),
23274  ntx = tx0 + (int)((tx1-tx0)*t1/tmax),
23275  nty = ty0 + (int)((ty1-ty0)*t1/tmax);
23276  draw_line(ox,oy,nx,ny,texture,otx,oty,ntx,nty,opacity,pattern,ninit_hatch);
23277  ninit_hatch = false;
23278  ox = nx; oy = ny; otx = ntx; oty = nty;
23279  }
23280  return *this;
23281  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
NT dy
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.
Definition: CImg.h:22330
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_spline ( const CImgList< tp > &  points,
const CImgList< 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 
)
inline

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

Definition at line 23406 of file CImg.h.

23409  {
23410  unsigned int H = ~0U; cimglist_for(points,p) H = cimg::min(H,(unsigned int)(points[p].size()),(unsigned int)(tangents[p].size()));
23411  return _draw_spline(points,tangents,color,opacity,close_set,precision,pattern,init_hatch,points.width,H);
23412  }
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Definition: points.h:30
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:23285
CImg<T>& draw_spline ( const CImgList< tp > &  points,
const CImgList< tt > &  tangents,
const CImg< tc > &  color,
const float  opacity = 1,
const bool  close_set = false,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23416 of file CImg.h.

23419  {
23420  return draw_spline(points,tangents,color.data,opacity,close_set,precision,pattern,init_hatch);
23421  }
Definition: points.h:30
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
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 
)
inline

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

Definition at line 23425 of file CImg.h.

23428  {
23429  return _draw_spline(points,tangents,color,opacity,close_set,precision,pattern,init_hatch,points.width,points.height);
23430  }
Definition: points.h:30
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:23285
CImg<T>& draw_spline ( const CImg< tp > &  points,
const CImg< tt > &  tangents,
const CImg< tc > &  color,
const float  opacity = 1,
const bool  close_set = false,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23434 of file CImg.h.

23437  {
23438  return draw_spline(points,tangents,color.data,opacity,close_set,precision,pattern,init_hatch);
23439  }
Definition: points.h:30
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
CImg<T>& draw_spline ( const CImgList< t > &  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 
)
inline

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

Definition at line 23443 of file CImg.h.

23446  {
23447  unsigned int H = ~0U;
23448  cimglist_for(points,p) { const unsigned int s = points[p].size(); if (s<H) H = s; }
23449  return _draw_spline(points,color,opacity,close_set,precision,pattern,init_hatch,points.width,H);
23450  }
double s
Definition: blastest.C:80
Definition: points.h:30
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:23285
CImg<T>& draw_spline ( const CImgList< t > &  points,
CImg< tc > &  color,
const float  opacity = 1,
const bool  close_set = false,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23454 of file CImg.h.

23457  {
23458  return draw_spline(points,color.data,opacity,close_set,precision,pattern,init_hatch);
23459  }
Definition: points.h:30
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
CImg<T>& draw_spline ( const CImg< t > &  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 
)
inline

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

Definition at line 23463 of file CImg.h.

23466  {
23467  return _draw_spline(points,color,opacity,close_set,precision,pattern,init_hatch,points.width,points.height);
23468  }
Definition: points.h:30
CImg< T > & _draw_spline(const tp &points, const tt &tangents, const unsigned int W, const unsigned int H, const tc *const color, const float opacity, const bool close_set, const float precision, const unsigned int pattern, const bool init_hatch)
Definition: CImg.h:23285
CImg<T>& draw_spline ( const CImg< t > &  points,
const CImg< tc > &  color,
const float  opacity = 1,
const bool  close_set = false,
const float  precision = 4,
const unsigned int  pattern = ~0U,
const bool  init_hatch = true 
)
inline

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

Definition at line 23472 of file CImg.h.

23475  {
23476  return draw_spline(points,color.data,opacity,close_set,precision,pattern,init_hatch);
23477  }
Definition: points.h:30
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=4, const unsigned int pattern=~0U, const bool init_hatch=true)
Draw a cubic spline curve in the instance image.
Definition: CImg.h:23122
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,
  ... 
)
inline

Draw a text.

Parameters
x0X-coordinate of the text in the instance image.
y0Y-coordinate of the text in the instance image.
foreground_colorArray of dimv() values of type T, defining the foreground color (0 means 'transparent').
background_colorArray of dimv() 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.

Definition at line 26338 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d(), CImg< uintT >::draw_axis(), and CImg< uintT >::get_select_graph().

26340  {
26341  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26342  std::vsprintf(tmp,text,ap); va_end(ap);
26343  return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26344  }
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)
Definition: CImg.h:26435

Here is the caller graph for this function:

CImg<T>& draw_text ( const int  x0,
const int  y0,
const char *const  text,
const CImg< tc1 > &  foreground_color,
const CImg< tc2 > &  background_color,
const float  opacity,
const CImgList< t > &  font,
  ... 
)
inline

Draw a text.

Definition at line 26348 of file CImg.h.

26350  {
26351  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26352  std::vsprintf(tmp,text,ap); va_end(ap);
26353  return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26354  }
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)
Definition: CImg.h:26435
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,
  ... 
)
inline

Draw a text.

Definition at line 26358 of file CImg.h.

26360  {
26361  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26362  std::vsprintf(tmp,text,ap); va_end(ap);
26363  return _draw_text(x0,y0,tmp,foreground_color,(tc*)0,opacity,font);
26364  }
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)
Definition: CImg.h:26435
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,
  ... 
)
inline

Draw a text.

Definition at line 26368 of file CImg.h.

26370  {
26371  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font);
26372  std::vsprintf(tmp,text,ap); va_end(ap);
26373  return _draw_text(x0,y0,tmp,(tc*)0,background_color,opacity,font);
26374  }
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)
Definition: CImg.h:26435
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_size = 11,
  ... 
)
inline

Draw a text.

Parameters
x0X-coordinate of the text in the instance image.
y0Y-coordinate of the text in the instance image.
foreground_colorArray of dimv() values of type T, defining the foreground color (0 means 'transparent').
background_colorArray of dimv() values of type T, defining the background color (0 means 'transparent').
font_sizeSize of the font (nearest match).
opacityDrawing opacity.
format'printf'-style format string, followed by arguments.
Note
Clipping is supported.

Definition at line 26388 of file CImg.h.

26390  {
26391  static CImgList<T> font;
26392  static unsigned int fsize = 0;
26393  if (fsize!=font_size) { font = CImgList<T>::font(font_size); fsize = font_size; }
26394  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26395  return _draw_text(x0,y0,tmp,foreground_color,background_color,opacity,font);
26396  }
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)
Definition: CImg.h:26435
static CImgList< T > font(const unsigned int font_width, const bool variable_size=true)
Return a CImg pre-defined font with desired size.
Definition: CImg.h:37048
CImg<T>& draw_text ( const int  x0,
const int  y0,
const char *const  text,
const CImg< tc1 > &  foreground_color,
const CImg< tc2 > &  background_color,
const float  opacity = 1,
const unsigned int  font_size = 11,
  ... 
)
inline

Draw a text.

Definition at line 26400 of file CImg.h.

26402  {
26403  static CImgList<T> font;
26404  static unsigned int fsize = 0;
26405  if (fsize!=font_size) { font = CImgList<T>::font(font_size); fsize = font_size; }
26406  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26407  return _draw_text(x0,y0,tmp,foreground_color.data,background_color.data,opacity,font);
26408  }
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)
Definition: CImg.h:26435
static CImgList< T > font(const unsigned int font_width, const bool variable_size=true)
Return a CImg pre-defined font with desired size.
Definition: CImg.h:37048
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_size = 11,
  ... 
)
inline

Draw a text.

Definition at line 26412 of file CImg.h.

26414  {
26415  static CImgList<T> font;
26416  static unsigned int fsize = 0;
26417  if (fsize!=font_size) { font = CImgList<T>::font(font_size); fsize = font_size; }
26418  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26419  return _draw_text(x0,y0,tmp,foreground_color,(const tc*)background_color,opacity,font);
26420  }
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)
Definition: CImg.h:26435
static CImgList< T > font(const unsigned int font_width, const bool variable_size=true)
Return a CImg pre-defined font with desired size.
Definition: CImg.h:37048
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_size = 11,
  ... 
)
inline

Draw a text.

Definition at line 26424 of file CImg.h.

26426  {
26427  static CImgList<T> font;
26428  static unsigned int fsize = 0;
26429  if (fsize!=font_size) { font = CImgList<T>::font(font_size); fsize = font_size; }
26430  char tmp[2048] = { 0 }; std::va_list ap; va_start(ap,font_size); std::vsprintf(tmp,text,ap); va_end(ap);
26431  return _draw_text(x0,y0,tmp,(tc*)0,background_color,opacity,font);
26432  }
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)
Definition: CImg.h:26435
static CImgList< T > font(const unsigned int font_width, const bool variable_size=true)
Return a CImg pre-defined font with desired size.
Definition: CImg.h:37048
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 
)
inline

Draw a 2D filled colored triangle.

Definition at line 23796 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), and CImg< uintT >::draw_triangle().

23799  {
23800  if (is_empty()) return *this;
23801  if (!color)
23802  throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",
23803  pixel_type());
23804  _draw_triangle(x0,y0,x1,y1,x2,y2,color,opacity,1);
23805  return *this;
23806  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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 float brightness)
Definition: CImg.h:23774

Here is the caller graph for this function:

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 > &  color,
const float  opacity = 1 
)
inline

Draw a 2D filled colored triangle.

Definition at line 23810 of file CImg.h.

23813  {
23814  return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity);
23815  }
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.
Definition: CImg.h:23796
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 
)
inline

Draw a 2D outlined colored triangle.

Definition at line 23819 of file CImg.h.

23823  {
23824  if (is_empty()) return *this;
23825  if (!color)
23826  throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",
23827  pixel_type());
23828  draw_line(x0,y0,x1,y1,color,opacity,pattern,true).
23829  draw_line(x1,y1,x2,y2,color,opacity,pattern,false).
23830  draw_line(x2,y2,x0,y0,color,opacity,pattern,false);
23831  return *this;
23832  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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.
Definition: CImg.h:22330
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 > &  color,
const float  opacity,
const unsigned int  pattern 
)
inline

Draw a 2D outlined colored triangle.

Definition at line 23836 of file CImg.h.

23840  {
23841  return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,opacity,pattern);
23842  }
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.
Definition: CImg.h:23796
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D filled colored triangle, with z-buffering.

Definition at line 23846 of file CImg.h.

23851  {
23852  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
23853  if (!color)
23854  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified color is (null).",
23855  pixel_type());
23856  if (!is_sameXY(zbuffer))
23857  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
23858  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
23859  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
23860  const float
23861  nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0),
23862  nbrightness = brightness<0?0:(brightness>2?2:brightness);
23863  const int whz = width*height*depth, offx = dim*whz;
23864  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
23865  float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
23866  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1);
23867  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nz0,nz2);
23868  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nz1,nz2);
23869  if (ny0>=dimy() || ny2<0) return *this;
23870  float
23871  pzl = (nz1 - nz0)/(ny1 - ny0),
23872  pzr = (nz2 - nz0)/(ny2 - ny0),
23873  pzn = (nz2 - nz1)/(ny2 - ny1),
23874  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
23875  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
23876  _cimg_for_triangle1(*this,xleft0,xright0,y,nx0,ny0,nx1,ny1,nx2,ny2) {
23877  if (y==ny1) { zl = nz1; pzl = pzn; }
23878  int xleft = xleft0, xright = xright0;
23879  float zleft = zl, zright = zr;
23880  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright);
23881  const int dx = xright - xleft;
23882  const float pentez = (zright - zleft)/dx;
23883  if (xleft<0 && dx) zleft-=xleft*(zright - zleft)/dx;
23884  if (xleft<0) xleft = 0;
23885  if (xright>=dimx()-1) xright = dimx()-1;
23886  T* ptrd = ptr(xleft,y,0,0);
23887  float *ptrz = zbuffer.ptr(xleft,y);
23888  if (opacity>=1) {
23889  if (nbrightness==1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23890  if (zleft>*ptrz) {
23891  *ptrz = zleft;
23892  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)*(col++); ptrd+=whz; }
23893  ptrd-=offx;
23894  }
23895  zleft+=pentez;
23896  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23897  if (zleft>*ptrz) {
23898  *ptrz = zleft;
23899  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)(nbrightness*(*col++)); ptrd+=whz; }
23900  ptrd-=offx;
23901  }
23902  zleft+=pentez;
23903  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23904  if (zleft>*ptrz) {
23905  *ptrz = zleft;
23906  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval); ptrd+=whz; }
23907  ptrd-=offx;
23908  }
23909  zleft+=pentez;
23910  }
23911  } else {
23912  if (nbrightness==1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23913  if (zleft>*ptrz) {
23914  *ptrz = zleft;
23915  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)(nopacity**(col++) + *ptrd*copacity); ptrd+=whz; }
23916  ptrd-=offx;
23917  }
23918  zleft+=pentez;
23919  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23920  if (zleft>*ptrz) {
23921  *ptrz = zleft;
23922  const tc *col = color; cimg_forV(*this,k) { *ptrd = (T)(nopacity*nbrightness**(col++) + *ptrd*copacity); ptrd+=whz; }
23923  ptrd-=offx;
23924  }
23925  zleft+=pentez;
23926  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
23927  if (zleft>*ptrz) {
23928  *ptrz = zleft;
23929  const tc *col = color;
23930  cimg_forV(*this,k) {
23931  const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
23932  *ptrd = (T)(nopacity*val + *ptrd*copacity);
23933  ptrd+=whz;
23934  }
23935  ptrd-=offx;
23936  }
23937  zleft+=pentez;
23938  }
23939  }
23940  zr+=pzr; zl+=pzl;
23941  }
23942  return *this;
23943  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define _cimg_for_triangle1(img, xl, xr, y, x0, y0, x1, y1, x2, y2)
Definition: CImg.h:23480
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 > &  color,
const float  opacity = 1,
const float  brightness = 1 
)
inline

Draw a 2D filled colored triangle, with z-buffering.

Definition at line 23947 of file CImg.h.

23952  {
23953  return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,opacity,brightness);
23954  }
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.
Definition: CImg.h:23796
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 
)
inline

Draw a 2D Gouraud-shaded colored triangle.

Parameters
x0= X-coordinate of the first corner in the instance image.
y0= Y-coordinate of the first corner in the instance image.
x1= X-coordinate of the second corner in the instance image.
y1= Y-coordinate of the second corner in the instance image.
x2= X-coordinate of the third corner in the instance image.
y2= Y-coordinate of the third corner in the instance image.
color= array of dimv() 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.

Definition at line 23972 of file CImg.h.

23979  {
23980  if (is_empty()) return *this;
23981  if (!color)
23982  throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",
23983  pixel_type());
23984  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
23985  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
23986  const int whz = width*height*depth, offx = dim*whz-1;
23987  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
23988  nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
23989  nc1 = (int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
23990  nc2 = (int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
23991  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nc0,nc1);
23992  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nc0,nc2);
23993  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nc1,nc2);
23994  if (ny0>=dimy() || ny2<0) return *this;
23995  _cimg_for_triangle2(*this,xleft0,cleft0,xright0,cright0,y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
23996  int xleft = xleft0, xright = xright0, cleft = cleft0, cright = cright0;
23997  if (xright<xleft) cimg::swap(xleft,xright,cleft,cright);
23998  const int
23999  dx = xright - xleft,
24000  dc = cright>cleft?cright - cleft:cleft - cright,
24001  rc = dx?(cright - cleft)/dx:0,
24002  sc = cright>cleft?1:-1,
24003  ndc = dc-(dx?dx*(dc/dx):0);
24004  int errc = dx>>1;
24005  if (xleft<0 && dx) cleft-=xleft*(cright - cleft)/dx;
24006  if (xleft<0) xleft = 0;
24007  if (xright>=dimx()-1) xright = dimx()-1;
24008  T* ptrd = ptr(xleft,y);
24009  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
24010  const tc *col = color;
24011  cimg_forV(*this,k) {
24012  *ptrd = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24013  ptrd+=whz;
24014  }
24015  ptrd-=offx;
24016  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24017  } else for (int x = xleft; x<=xright; ++x) {
24018  const tc *col = color;
24019  cimg_forV(*this,k) {
24020  const T val = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24021  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24022  ptrd+=whz;
24023  }
24024  ptrd-=offx;
24025  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24026  }
24027  }
24028  return *this;
24029  }
#define _cimg_for_triangle2(img, xl, cl, xr, cr, y, x0, y0, c0, x1, y1, c1, x2, y2, c2)
Definition: CImg.h:23509
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 > &  color,
const float  brightness0,
const float  brightness1,
const float  brightness2,
const float  opacity = 1 
)
inline

Draw a 2D Gouraud-shaded colored triangle.

Definition at line 24033 of file CImg.h.

24040  {
24041  return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,brightness0,brightness1,brightness2,opacity);
24042  }
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.
Definition: CImg.h:23796
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D Gouraud-shaded colored triangle, with z-buffering.

Definition at line 24046 of file CImg.h.

24054  {
24055  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
24056  if (!color)
24057  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified color is (null).",
24058  pixel_type());
24059  if (!is_sameXY(zbuffer))
24060  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24061  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
24062  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24063  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
24064  const int whz = width*height*depth, offx = dim*whz;
24065  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24066  nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24067  nc1 = (int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24068  nc2 = (int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24069  float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24070  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nz0,nz1,nc0,nc1);
24071  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nz0,nz2,nc0,nc2);
24072  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nz1,nz2,nc1,nc2);
24073  if (ny0>=dimy() || ny2<0) return *this;
24074  float
24075  pzl = (nz1 - nz0)/(ny1 - ny0),
24076  pzr = (nz2 - nz0)/(ny2 - ny0),
24077  pzn = (nz2 - nz1)/(ny2 - ny1),
24078  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24079  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
24080  _cimg_for_triangle2(*this,xleft0,cleft0,xright0,cright0,y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
24081  if (y==ny1) { zl = nz1; pzl = pzn; }
24082  int xleft = xleft0, xright = xright0, cleft = cleft0, cright = cright0;
24083  float zleft = zl, zright = zr;
24084  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,cleft,cright);
24085  const int
24086  dx = xright - xleft,
24087  dc = cright>cleft?cright - cleft:cleft - cright,
24088  rc = dx?(cright-cleft)/dx:0,
24089  sc = cright>cleft?1:-1,
24090  ndc = dc-(dx?dx*(dc/dx):0);
24091  const float pentez = (zright - zleft)/dx;
24092  int errc = dx>>1;
24093  if (xleft<0 && dx) {
24094  cleft-=xleft*(cright - cleft)/dx;
24095  zleft-=xleft*(zright - zleft)/dx;
24096  }
24097  if (xleft<0) xleft = 0;
24098  if (xright>=dimx()-1) xright = dimx()-1;
24099  T *ptrd = ptr(xleft,y);
24100  float *ptrz = zbuffer.ptr(xleft,y);
24101  if (opacity>=1) for (int x = xleft; x<=xright; ++x, ++ptrd, ++ptrz) {
24102  if (zleft>*ptrz) {
24103  *ptrz = zleft;
24104  const tc *col = color;
24105  cimg_forV(*this,k) {
24106  *ptrd = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24107  ptrd+=whz;
24108  }
24109  ptrd-=offx;
24110  }
24111  zleft+=pentez;
24112  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24113  } else for (int x = xleft; x<=xright; ++x, ++ptrd, ++ptrz) {
24114  if (zleft>*ptrz) {
24115  *ptrz = zleft;
24116  const tc *col = color;
24117  cimg_forV(*this,k) {
24118  const T val = (T)(cleft<256?cleft**(col++)/256:((512-cleft)**(col++)+(cleft-256)*maxval)/256);
24119  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24120  ptrd+=whz;
24121  }
24122  ptrd-=offx;
24123  }
24124  zleft+=pentez;
24125  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24126  }
24127  zr+=pzr; zl+=pzl;
24128  }
24129  return *this;
24130  }
#define _cimg_for_triangle2(img, xl, cl, xr, cr, y, x0, y0, c0, x1, y1, c1, x2, y2, c2)
Definition: CImg.h:23509
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 > &  color,
const float  brightness0,
const float  brightness1,
const float  brightness2,
const float  opacity = 1 
)
inline

Draw a Gouraud triangle with z-buffer consideration.

Definition at line 24134 of file CImg.h.

24142  {
24143  return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,brightness0,brightness1,brightness2,opacity);
24144  }
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.
Definition: CImg.h:23796
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 
)
inline

Draw a colored triangle with interpolated colors.

Definition at line 24148 of file CImg.h.

24154  {
24155  const unsigned char one = 1;
24156  cimg_forV(*this,k) get_shared_channel(k).draw_triangle(x0,y0,x1,y1,x2,y2,&one,color1[k],color2[k],color3[k],opacity);
24157  return *this;
24158  }
j indices k indices k
Definition: Indexing.h:6
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.
Definition: CImg.h:23796
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
CImg<T>& draw_triangle ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const int  x2,
const int  y2,
const CImg< tc1 > &  color1,
const CImg< tc2 > &  color2,
const CImg< tc3 > &  color3,
const float  opacity = 1 
)
inline

Definition at line 24161 of file CImg.h.

24167  {
24168  return draw_triangle(x0,y0,x1,y1,x2,y2,color1.data,color2.data,color3.data,opacity);
24169  }
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.
Definition: CImg.h:23796
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 
)
inline

Draw a 2D textured triangle.

Parameters
x0= X-coordinate of the first corner in the instance image.
y0= Y-coordinate of the first corner in the instance image.
x1= X-coordinate of the second corner in the instance image.
y1= Y-coordinate of the second corner in the instance image.
x2= X-coordinate of the third corner in the instance image.
y2= Y-coordinate of the third corner in the instance image.
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.

Definition at line 24191 of file CImg.h.

24199  {
24200  if (is_empty()) return *this;
24201  if (!texture || texture.dim<dim)
24202  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24203  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24204  if (is_overlapped(texture)) return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24205  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24206  const float
24207  nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0),
24208  nbrightness = brightness<0?0:(brightness>2?2:brightness);
24209  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24210  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24211  ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2;
24212  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1);
24213  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2);
24214  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2);
24215  if (ny0>=dimy() || ny2<0) return *this;
24216  _cimg_for_triangle3(*this,xleft0,txleft0,tyleft0,xright0,txright0,tyright0,y,
24217  nx0,ny0,ntx0,nty0,nx1,ny1,ntx1,nty1,nx2,ny2,ntx2,nty2) {
24218  int
24219  xleft = xleft0, xright = xright0,
24220  txleft = txleft0, txright = txright0,
24221  tyleft = tyleft0, tyright = tyright0;
24222  if (xright<xleft) cimg::swap(xleft,xright,txleft,txright,tyleft,tyright);
24223  const int
24224  dx = xright - xleft,
24225  dtx = txright>txleft?txright - txleft:txleft - txright,
24226  dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
24227  rtx = dx?(txright - txleft)/dx:0,
24228  rty = dx?(tyright - tyleft)/dx:0,
24229  stx = txright>txleft?1:-1,
24230  sty = tyright>tyleft?1:-1,
24231  ndtx = dtx - (dx?dx*(dtx/dx):0),
24232  ndty = dty - (dx?dx*(dty/dx):0);
24233  int errtx = dx>>1, errty = errtx;
24234  if (xleft<0 && dx) {
24235  txleft-=xleft*(txright - txleft)/dx;
24236  tyleft-=xleft*(tyright - tyleft)/dx;
24237  }
24238  if (xleft<0) xleft = 0;
24239  if (xright>=dimx()-1) xright = dimx()-1;
24240  T* ptrd = ptr(xleft,y,0,0);
24241  if (opacity>=1) {
24242  if (nbrightness==1) for (int x = xleft; x<=xright; ++x) {
24243  const tc *col = texture.ptr(txleft,tyleft);
24244  cimg_forV(*this,k) {
24245  *ptrd = (T)*col;
24246  ptrd+=whz; col+=twhz;
24247  }
24248  ptrd-=offx;
24249  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24250  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24251  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x) {
24252  const tc *col = texture.ptr(txleft,tyleft);
24253  cimg_forV(*this,k) {
24254  *ptrd = (T)(nbrightness**col);
24255  ptrd+=whz; col+=twhz;
24256  }
24257  ptrd-=offx;
24258  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24259  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24260  } else for (int x = xleft; x<=xright; ++x) {
24261  const tc *col = texture.ptr(txleft,tyleft);
24262  cimg_forV(*this,k) {
24263  *ptrd = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
24264  ptrd+=whz; col+=twhz;
24265  }
24266  ptrd-=offx;
24267  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24268  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24269  }
24270  } else {
24271  if (nbrightness==1) for (int x = xleft; x<=xright; ++x) {
24272  const tc *col = texture.ptr(txleft,tyleft);
24273  cimg_forV(*this,k) {
24274  *ptrd = (T)(nopacity**col + *ptrd*copacity);
24275  ptrd+=whz; col+=twhz;
24276  }
24277  ptrd-=offx;
24278  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24279  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24280  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x) {
24281  const tc *col = texture.ptr(txleft,tyleft);
24282  cimg_forV(*this,k) {
24283  *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24284  ptrd+=whz; col+=twhz;
24285  }
24286  ptrd-=offx;
24287  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24288  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24289  } else for (int x = xleft; x<=xright; ++x) {
24290  const tc *col = texture.ptr(txleft,tyleft);
24291  cimg_forV(*this,k) {
24292  const T val = (T)((2-nbrightness)**(col++) + (nbrightness-1)*maxval);
24293  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24294  ptrd+=whz; col+=twhz;
24295  }
24296  ptrd-=offx;
24297  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24298  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24299  }
24300  }
24301  }
24302  return *this;
24303  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
Definition: CImg.h:23553
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 
)
inline

Draw a 2D textured triangle, with perspective correction.

Definition at line 24307 of file CImg.h.

24315  {
24316  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
24317  if (!texture || texture.dim<dim)
24318  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24319  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24320  if (is_overlapped(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24321  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24322  const float
24323  nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0),
24324  nbrightness = brightness<0?0:(brightness>2?2:brightness);
24325  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24326  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
24327  float
24328  ntx0 = tx0/z0, nty0 = ty0/z0,
24329  ntx1 = tx1/z1, nty1 = ty1/z1,
24330  ntx2 = tx2/z2, nty2 = ty2/z2,
24331  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24332  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1);
24333  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2);
24334  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2);
24335  if (ny0>=dimy() || ny2<0) return *this;
24336  float
24337  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24338  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24339  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24340  ptyl = (nty1 - nty0)/(ny1 - ny0),
24341  ptyr = (nty2 - nty0)/(ny2 - ny0),
24342  ptyn = (nty2 - nty1)/(ny2 - ny1),
24343  pzl = (nz1 - nz0)/(ny1 - ny0),
24344  pzr = (nz2 - nz0)/(ny2 - ny0),
24345  pzn = (nz2 - nz1)/(ny2 - ny1),
24346  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24347  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24348  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24349  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24350  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24351  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24352  _cimg_for_triangle1(*this,xleft0,xright0,y,nx0,ny0,nx1,ny1,nx2,ny2) {
24353  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24354  int xleft = xleft0, xright = xright0;
24355  float
24356  zleft = zl, zright = zr,
24357  txleft = txl, txright = txr,
24358  tyleft = tyl, tyright = tyr;
24359  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright);
24360  const int dx = xright - xleft;
24361  const float
24362  pentez = (zright - zleft)/dx,
24363  pentetx = (txright - txleft)/dx,
24364  pentety = (tyright - tyleft)/dx;
24365  if (xleft<0 && dx) {
24366  zleft-=xleft*(zright - zleft)/dx;
24367  txleft-=xleft*(txright - txleft)/dx;
24368  tyleft-=xleft*(tyright - tyleft)/dx;
24369  }
24370  if (xleft<0) xleft = 0;
24371  if (xright>=dimx()-1) xright = dimx()-1;
24372  T* ptrd = ptr(xleft,y,0,0);
24373  if (opacity>=1) {
24374  if (nbrightness==1) for (int x = xleft; x<=xright; ++x) {
24375  const float invz = 1/zleft;
24376  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24377  cimg_forV(*this,k) {
24378  *ptrd = (T)*col;
24379  ptrd+=whz; col+=twhz;
24380  }
24381  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24382  } else if (nbrightness<1) for (int x=xleft; x<=xright; ++x) {
24383  const float invz = 1/zleft;
24384  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24385  cimg_forV(*this,k) {
24386  *ptrd = (T)(nbrightness**col);
24387  ptrd+=whz; col+=twhz;
24388  }
24389  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24390  } else for (int x = xleft; x<=xright; ++x) {
24391  const float invz = 1/zleft;
24392  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24393  cimg_forV(*this,k) {
24394  *ptrd = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24395  ptrd+=whz; col+=twhz;
24396  }
24397  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24398  }
24399  } else {
24400  if (nbrightness==1) for (int x = xleft; x<=xright; ++x) {
24401  const float invz = 1/zleft;
24402  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24403  cimg_forV(*this,k) {
24404  *ptrd = (T)(nopacity**col + *ptrd*copacity);
24405  ptrd+=whz; col+=twhz;
24406  }
24407  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24408  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x) {
24409  const float invz = 1/zleft;
24410  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24411  cimg_forV(*this,k) {
24412  *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24413  ptrd+=whz; col+=twhz;
24414  }
24415  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24416  } else for (int x = xleft; x<=xright; ++x) {
24417  const float invz = 1/zleft;
24418  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24419  cimg_forV(*this,k) {
24420  const T val = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24421  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24422  ptrd+=whz; col+=twhz;
24423  }
24424  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24425  }
24426  }
24427  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
24428  }
24429  return *this;
24430  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define _cimg_for_triangle1(img, xl, xr, y, x0, y0, x1, y1, x2, y2)
Definition: CImg.h:23480
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D textured triangle, with z-buffering and perspective correction.

Definition at line 24434 of file CImg.h.

24443  {
24444  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
24445  if (!is_sameXY(zbuffer))
24446  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24447  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
24448  if (!texture || texture.dim<dim)
24449  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24450  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24451  if (is_overlapped(texture)) return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,opacity,brightness);
24452  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24453  const float
24454  nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0),
24455  nbrightness = brightness<0?0:(brightness>2?2:brightness);
24456  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
24457  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2;
24458  float
24459  ntx0 = tx0/z0, nty0 = ty0/z0,
24460  ntx1 = tx1/z1, nty1 = ty1/z1,
24461  ntx2 = tx2/z2, nty2 = ty2/z2,
24462  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24463  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1);
24464  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2);
24465  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2);
24466  if (ny0>=dimy() || ny2<0) return *this;
24467  float
24468  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24469  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24470  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24471  ptyl = (nty1 - nty0)/(ny1 - ny0),
24472  ptyr = (nty2 - nty0)/(ny2 - ny0),
24473  ptyn = (nty2 - nty1)/(ny2 - ny1),
24474  pzl = (nz1 - nz0)/(ny1 - ny0),
24475  pzr = (nz2 - nz0)/(ny2 - ny0),
24476  pzn = (nz2 - nz1)/(ny2 - ny1),
24477  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24478  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24479  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24480  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24481  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24482  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24483  _cimg_for_triangle1(*this,xleft0,xright0,y,nx0,ny0,nx1,ny1,nx2,ny2) {
24484  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24485  int xleft = xleft0, xright = xright0;
24486  float
24487  zleft = zl, zright = zr,
24488  txleft = txl, txright = txr,
24489  tyleft = tyl, tyright = tyr;
24490  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright);
24491  const int dx = xright - xleft;
24492  const float
24493  pentez = (zright - zleft)/dx,
24494  pentetx = (txright - txleft)/dx,
24495  pentety = (tyright - tyleft)/dx;
24496  if (xleft<0 && dx) {
24497  zleft-=xleft*(zright - zleft)/dx;
24498  txleft-=xleft*(txright - txleft)/dx;
24499  tyleft-=xleft*(tyright - tyleft)/dx;
24500  }
24501  if (xleft<0) xleft = 0;
24502  if (xright>=dimx()-1) xright = dimx()-1;
24503  T *ptrd = ptr(xleft,y,0,0);
24504  float *ptrz = zbuffer.ptr(xleft,y);
24505  if (opacity>=1) {
24506  if (nbrightness==1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24507  if (zleft>*ptrz) {
24508  *ptrz = zleft;
24509  const float invz = 1/zleft;
24510  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24511  cimg_forV(*this,k) {
24512  *ptrd = (T)*col;
24513  ptrd+=whz; col+=twhz;
24514  }
24515  ptrd-=offx;
24516  }
24517  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24518  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24519  if (zleft>*ptrz) {
24520  *ptrz = zleft;
24521  const float invz = 1/zleft;
24522  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24523  cimg_forV(*this,k) {
24524  *ptrd = (T)(nbrightness**col);
24525  ptrd+=whz; col+=twhz;
24526  }
24527  ptrd-=offx;
24528  }
24529  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24530  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24531  if (zleft>*ptrz) {
24532  *ptrz = zleft;
24533  const float invz = 1/zleft;
24534  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24535  cimg_forV(*this,k) {
24536  *ptrd = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24537  ptrd+=whz; col+=twhz;
24538  }
24539  ptrd-=offx;
24540  }
24541  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24542  }
24543  } else {
24544  if (nbrightness==1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24545  if (zleft>*ptrz) {
24546  *ptrz = zleft;
24547  const float invz = 1/zleft;
24548  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24549  cimg_forV(*this,k) {
24550  *ptrd = (T)(nopacity**col + *ptrd*copacity);
24551  ptrd+=whz; col+=twhz;
24552  }
24553  ptrd-=offx;
24554  }
24555  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24556  } else if (nbrightness<1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24557  if (zleft>*ptrz) {
24558  *ptrz = zleft;
24559  const float invz = 1/zleft;
24560  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24561  cimg_forV(*this,k) {
24562  *ptrd = (T)(nopacity*nbrightness**col + *ptrd*copacity);
24563  ptrd+=whz; col+=twhz;
24564  }
24565  ptrd-=offx;
24566  }
24567  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24568  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24569  if (zleft>*ptrz) {
24570  *ptrz = zleft;
24571  const float invz = 1/zleft;
24572  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
24573  cimg_forV(*this,k) {
24574  const T val = (T)((2-nbrightness)**col + (nbrightness-1)*maxval);
24575  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24576  ptrd+=whz; col+=twhz;
24577  }
24578  ptrd-=offx;
24579  }
24580  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
24581  }
24582  }
24583  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
24584  }
24585  return *this;
24586  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define _cimg_for_triangle1(img, xl, xr, y, x0, y0, x1, y1, x2, y2)
Definition: CImg.h:23480
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 
)
inline

Draw a 2D Pseudo-Phong-shaded triangle.

Parameters
x0= X-coordinate of the first corner in the instance image.
y0= Y-coordinate of the first corner in the instance image.
x1= X-coordinate of the second corner in the instance image.
y1= Y-coordinate of the second corner in the instance image.
x2= X-coordinate of the third corner in the instance image.
y2= Y-coordinate of the third corner in the instance image.
color= array of dimv() 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.

Definition at line 24608 of file CImg.h.

24616  {
24617  if (is_empty()) return *this;
24618  if (!color)
24619  throw CImgArgumentException("CImg<%s>::draw_triangle : Specified color is (null).",
24620  pixel_type());
24621  if (!light)
24622  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
24623  pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
24624  if (is_overlapped(light)) return draw_triangle(x0,y0,x1,y1,x2,y2,color,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24625  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24626  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
24627  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24628  nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
24629  const int whz = width*height*depth, offx = dim*whz-1;
24630  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nlx0,nlx1,nly0,nly1);
24631  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nlx0,nlx2,nly0,nly2);
24632  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nlx1,nlx2,nly1,nly2);
24633  if (ny0>=dimy() || ny2<0) return *this;
24634  _cimg_for_triangle3(*this,xleft0,lxleft0,lyleft0,xright0,lxright0,lyright0,y,
24635  nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
24636  int
24637  xleft = xleft0, xright = xright0,
24638  lxleft = lxleft0, lxright = lxright0,
24639  lyleft = lyleft0, lyright = lyright0;
24640  if (xright<xleft) cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright);
24641  const int
24642  dx = xright - xleft,
24643  dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
24644  dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
24645  rlx = dx?(lxright - lxleft)/dx:0,
24646  rly = dx?(lyright - lyleft)/dx:0,
24647  slx = lxright>lxleft?1:-1,
24648  sly = lyright>lyleft?1:-1,
24649  ndlx = dlx - (dx?dx*(dlx/dx):0),
24650  ndly = dly - (dx?dx*(dly/dx):0);
24651  int errlx = dx>>1, errly = errlx;
24652  if (xleft<0 && dx) {
24653  lxleft-=xleft*(lxright - lxleft)/dx;
24654  lyleft-=xleft*(lyright - lyleft)/dx;
24655  }
24656  if (xleft<0) xleft = 0;
24657  if (xright>=dimx()-1) xright = dimx()-1;
24658  T* ptrd = ptr(xleft,y,0,0);
24659  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
24660  const tl l = light(lxleft,lyleft);
24661  const tc *col = color;
24662  cimg_forV(*this,k) {
24663  *ptrd = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval));
24664  ptrd+=whz;
24665  }
24666  ptrd-=offx;
24667  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24668  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24669  } else for (int x = xleft; x<=xright; ++x) {
24670  const tl l = light(lxleft,lyleft);
24671  const tc *col = color;
24672  cimg_forV(*this,k) {
24673  const T val = (T)(l<1?l**(col++):((2-l)**(col++)+(l-1)*maxval));
24674  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24675  ptrd+=whz;
24676  }
24677  ptrd-=offx;
24678  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24679  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24680  }
24681  }
24682  return *this;
24683  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
Definition: CImg.h:23553
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 > &  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 
)
inline

Draw a 2D Pseudo-Phong-shaded triangle.

Definition at line 24687 of file CImg.h.

24695  {
24696  return draw_triangle(x0,y0,x1,y1,x2,y2,color.data,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24697  }
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.
Definition: CImg.h:23796
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D Pseudo-Phong-shaded triangle, with z-buffering.

Definition at line 24701 of file CImg.h.

24710  {
24711  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
24712  if (!color)
24713  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified color is (null).",
24714  pixel_type());
24715  if (!light)
24716  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
24717  pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
24718  if (!is_sameXY(zbuffer))
24719  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
24720  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
24721  if (is_overlapped(light)) return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color,
24722  +light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24723  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24724  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
24725  const int whz = width*height*depth, offx = dim*whz;
24726  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24727  nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
24728  float nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24729  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,nlx0,nlx1,nly0,nly1,nz0,nz1);
24730  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,nlx0,nlx2,nly0,nly2,nz0,nz2);
24731  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,nlx1,nlx2,nly1,nly2,nz1,nz2);
24732  if (ny0>=dimy() || ny2<0) return *this;
24733  float
24734  pzl = (nz1 - nz0)/(ny1 - ny0),
24735  pzr = (nz2 - nz0)/(ny2 - ny0),
24736  pzn = (nz2 - nz1)/(ny2 - ny1),
24737  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24738  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1)));
24739  _cimg_for_triangle3(*this,xleft0,lxleft0,lyleft0,xright0,lxright0,lyright0,y,
24740  nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
24741  if (y==ny1) { zl = nz1; pzl = pzn; }
24742  int
24743  xleft = xleft0, xright = xright0,
24744  lxleft = lxleft0, lxright = lxright0,
24745  lyleft = lyleft0, lyright = lyright0;
24746  float zleft = zl, zright = zr;
24747  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,lxleft,lxright,lyleft,lyright);
24748  const int
24749  dx = xright - xleft,
24750  dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
24751  dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
24752  rlx = dx?(lxright - lxleft)/dx:0,
24753  rly = dx?(lyright - lyleft)/dx:0,
24754  slx = lxright>lxleft?1:-1,
24755  sly = lyright>lyleft?1:-1,
24756  ndlx = dlx - (dx?dx*(dlx/dx):0),
24757  ndly = dly - (dx?dx*(dly/dx):0);
24758  const float pentez = (zright - zleft)/dx;
24759  int errlx = dx>>1, errly = errlx;
24760  if (xleft<0 && dx) {
24761  zleft-=xleft*(zright - zleft)/dx;
24762  lxleft-=xleft*(lxright - lxleft)/dx;
24763  lyleft-=xleft*(lyright - lyleft)/dx;
24764  }
24765  if (xleft<0) xleft = 0;
24766  if (xright>=dimx()-1) xright = dimx()-1;
24767  T *ptrd = ptr(xleft,y,0,0);
24768  float *ptrz = zbuffer.ptr(xleft,y);
24769  if (opacity>=1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24770  if (zleft>*ptrz) {
24771  *ptrz = zleft;
24772  const tl l = light(lxleft,lyleft);
24773  const tc *col = color;
24774  cimg_forV(*this,k) {
24775  const tc cval = *(col++);
24776  *ptrd = (T)(l<1?l*cval:(2-l)*cval+(l-1)*maxval);
24777  ptrd+=whz;
24778  }
24779  ptrd-=offx;
24780  }
24781  zleft+=pentez;
24782  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24783  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24784  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
24785  if (zleft>*ptrz) {
24786  *ptrz = zleft;
24787  const tl l = light(lxleft,lyleft);
24788  const tc *col = color;
24789  cimg_forV(*this,k) {
24790  const tc cval = *(col++);
24791  const T val = (T)(l<1?l*cval:(2-l)*cval+(l-1)*maxval);
24792  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24793  ptrd+=whz;
24794  }
24795  ptrd-=offx;
24796  }
24797  zleft+=pentez;
24798  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
24799  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
24800  }
24801  zr+=pzr; zl+=pzl;
24802  }
24803  return *this;
24804  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
Definition: CImg.h:23553
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 > &  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 
)
inline

Draw a 2D Pseudo-Phong-shaded triangle, with z-buffering.

Definition at line 24808 of file CImg.h.

24817  {
24818  return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,color.data,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
24819  }
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.
Definition: CImg.h:23796
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 
)
inline

Draw a 2D Gouraud-shaded textured triangle.

Parameters
x0= X-coordinate of the first corner in the instance image.
y0= Y-coordinate of the first corner in the instance image.
x1= X-coordinate of the second corner in the instance image.
y1= Y-coordinate of the second corner in the instance image.
x2= X-coordinate of the third corner in the instance image.
y2= Y-coordinate of the third corner in the instance image.
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.

Definition at line 24843 of file CImg.h.

24853  {
24854  if (is_empty()) return *this;
24855  if (!texture || texture.dim<dim)
24856  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24857  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24858  if (is_overlapped(texture))
24859  return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,brightness0,brightness1,brightness2,opacity);
24860  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24861  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
24862  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24863  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24864  ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2,
24865  nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24866  nc1 = (int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24867  nc2 = (int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24868  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nc0,nc1);
24869  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nc0,nc2);
24870  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nc1,nc2);
24871  if (ny0>=dimy() || ny2<0) return *this;
24872  _cimg_for_triangle4(*this,xleft0,cleft0,txleft0,tyleft0,xright0,cright0,txright0,tyright0,y,
24873  nx0,ny0,nc0,ntx0,nty0,nx1,ny1,nc1,ntx1,nty1,nx2,ny2,nc2,ntx2,nty2) {
24874  int
24875  xleft = xleft0, xright = xright0,
24876  cleft = cleft0, cright = cright0,
24877  txleft = txleft0, txright = txright0,
24878  tyleft = tyleft0, tyright = tyright0;
24879  if (xright<xleft) cimg::swap(xleft,xright,cleft,cright,txleft,txright,tyleft,tyright);
24880  const int
24881  dx = xright - xleft,
24882  dc = cright>cleft?cright - cleft:cleft - cright,
24883  dtx = txright>txleft?txright - txleft:txleft - txright,
24884  dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
24885  rc = dx?(cright - cleft)/dx:0,
24886  rtx = dx?(txright - txleft)/dx:0,
24887  rty = dx?(tyright - tyleft)/dx:0,
24888  sc = cright>cleft?1:-1,
24889  stx = txright>txleft?1:-1,
24890  sty = tyright>tyleft?1:-1,
24891  ndc = dc - (dx?dx*(dc/dx):0),
24892  ndtx = dtx - (dx?dx*(dtx/dx):0),
24893  ndty = dty - (dx?dx*(dty/dx):0);
24894  int errc = dx>>1, errtx = errc, errty = errc;
24895  if (xleft<0 && dx) {
24896  cleft-=xleft*(cright - cleft)/dx;
24897  txleft-=xleft*(txright - txleft)/dx;
24898  tyleft-=xleft*(tyright - tyleft)/dx;
24899  }
24900  if (xleft<0) xleft = 0;
24901  if (xright>=dimx()-1) xright = dimx()-1;
24902  T* ptrd = ptr(xleft,y,0,0);
24903  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
24904  const tc *col = texture.ptr(txleft,tyleft);
24905  cimg_forV(*this,k) {
24906  *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
24907  ptrd+=whz; col+=twhz;
24908  }
24909  ptrd-=offx;
24910  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24911  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24912  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24913  } else for (int x = xleft; x<=xright; ++x) {
24914  const tc *col = texture.ptr(txleft,tyleft);
24915  cimg_forV(*this,k) {
24916  const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
24917  *ptrd = (T)(nopacity*val + *ptrd*copacity);
24918  ptrd+=whz; col+=twhz;
24919  }
24920  ptrd-=offx;
24921  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
24922  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
24923  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
24924  }
24925  }
24926  return *this;
24927  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define _cimg_for_triangle4(img, xl, cl, txl, tyl, xr, cr, txr, tyr, y, x0, y0, c0, tx0, ty0, x1, y1, c1, tx1, ty1, x2, y2, c2, tx2, ty2)
Definition: CImg.h:23612
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 
)
inline

Draw a 2D Gouraud-shaded textured triangle, with perspective correction.

Definition at line 24931 of file CImg.h.

24941  {
24942  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
24943  if (!texture || texture.dim<dim)
24944  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
24945  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
24946  if (is_overlapped(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,
24947  brightness0,brightness1,brightness2,opacity);
24948  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
24949  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
24950  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
24951  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
24952  nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
24953  nc1 = (int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
24954  nc2 = (int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
24955  float
24956  ntx0 = tx0/z0, nty0 = ty0/z0,
24957  ntx1 = tx1/z1, nty1 = ty1/z1,
24958  ntx2 = tx2/z2, nty2 = ty2/z2,
24959  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
24960  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1,nc0,nc1);
24961  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2,nc0,nc2);
24962  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2,nc1,nc2);
24963  if (ny0>=dimy() || ny2<0) return *this;
24964  float
24965  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
24966  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
24967  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
24968  ptyl = (nty1 - nty0)/(ny1 - ny0),
24969  ptyr = (nty2 - nty0)/(ny2 - ny0),
24970  ptyn = (nty2 - nty1)/(ny2 - ny1),
24971  pzl = (nz1 - nz0)/(ny1 - ny0),
24972  pzr = (nz2 - nz0)/(ny2 - ny0),
24973  pzn = (nz2 - nz1)/(ny2 - ny1),
24974  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
24975  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
24976  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
24977  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
24978  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
24979  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
24980  _cimg_for_triangle2(*this,xleft0,cleft0,xright0,cright0,y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
24981  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
24982  int
24983  xleft = xleft0, xright = xright0,
24984  cleft = cleft0, cright = cright0;
24985  float
24986  zleft = zl, zright = zr,
24987  txleft = txl, txright = txr,
24988  tyleft = tyl, tyright = tyr;
24989  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,cleft,cright);
24990  const int
24991  dx = xright - xleft,
24992  dc = cright>cleft?cright - cleft:cleft - cright,
24993  rc = dx?(cright - cleft)/dx:0,
24994  sc = cright>cleft?1:-1,
24995  ndc = dc - (dx?dx*(dc/dx):0);
24996  const float
24997  pentez = (zright - zleft)/dx,
24998  pentetx = (txright - txleft)/dx,
24999  pentety = (tyright - tyleft)/dx;
25000  int errc = dx>>1;
25001  if (xleft<0 && dx) {
25002  cleft-=xleft*(cright - cleft)/dx;
25003  zleft-=xleft*(zright - zleft)/dx;
25004  txleft-=xleft*(txright - txleft)/dx;
25005  tyleft-=xleft*(tyright - tyleft)/dx;
25006  }
25007  if (xleft<0) xleft = 0;
25008  if (xright>=dimx()-1) xright = dimx()-1;
25009  T* ptrd = ptr(xleft,y,0,0);
25010  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
25011  const float invz = 1/zleft;
25012  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25013  cimg_forV(*this,k) {
25014  *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25015  ptrd+=whz; col+=twhz;
25016  }
25017  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25018  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25019  } else for (int x = xleft; x<=xright; ++x) {
25020  const float invz = 1/zleft;
25021  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25022  cimg_forV(*this,k) {
25023  const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25024  *ptrd = (T)(nopacity*val + *ptrd*copacity);
25025  ptrd+=whz; col+=twhz;
25026  }
25027  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25028  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25029  }
25030  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25031  }
25032  return *this;
25033  }
#define _cimg_for_triangle2(img, xl, cl, xr, cr, y, x0, y0, c0, x1, y1, c1, x2, y2, c2)
Definition: CImg.h:23509
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D Gouraud-shaded textured triangle, with z-buffering and perspective correction.

Definition at line 25037 of file CImg.h.

25048  {
25049  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
25050  if (!is_sameXY(zbuffer))
25051  throw CImgArgumentException("CImg<%s>::draw_line() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
25052  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
25053  if (!texture || texture.dim<dim)
25054  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25055  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25056  if (is_overlapped(texture)) return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,
25057  brightness0,brightness1,brightness2,opacity);
25058  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
25059  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
25060  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
25061  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25062  nc0 = (int)((brightness0<0.0f?0.0f:(brightness0>2.0f?2.0f:brightness0))*256.0f),
25063  nc1 = (int)((brightness1<0.0f?0.0f:(brightness1>2.0f?2.0f:brightness1))*256.0f),
25064  nc2 = (int)((brightness2<0.0f?0.0f:(brightness2>2.0f?2.0f:brightness2))*256.0f);
25065  float
25066  ntx0 = tx0/z0, nty0 = ty0/z0,
25067  ntx1 = tx1/z1, nty1 = ty1/z1,
25068  ntx2 = tx2/z2, nty2 = ty2/z2,
25069  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25070  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nz0,nz1,nc0,nc1);
25071  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nz0,nz2,nc0,nc2);
25072  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nz1,nz2,nc1,nc2);
25073  if (ny0>=dimy() || ny2<0) return *this;
25074  float
25075  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25076  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25077  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25078  ptyl = (nty1 - nty0)/(ny1 - ny0),
25079  ptyr = (nty2 - nty0)/(ny2 - ny0),
25080  ptyn = (nty2 - nty1)/(ny2 - ny1),
25081  pzl = (nz1 - nz0)/(ny1 - ny0),
25082  pzr = (nz2 - nz0)/(ny2 - ny0),
25083  pzn = (nz2 - nz1)/(ny2 - ny1),
25084  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25085  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25086  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25087  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25088  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25089  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25090  _cimg_for_triangle2(*this,xleft0,cleft0,xright0,cright0,y,nx0,ny0,nc0,nx1,ny1,nc1,nx2,ny2,nc2) {
25091  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25092  int
25093  xleft = xleft0, xright = xright0,
25094  cleft = cleft0, cright = cright0;
25095  float
25096  zleft = zl, zright = zr,
25097  txleft = txl, txright = txr,
25098  tyleft = tyl, tyright = tyr;
25099  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,cleft,cright);
25100  const int
25101  dx = xright - xleft,
25102  dc = cright>cleft?cright - cleft:cleft - cright,
25103  rc = dx?(cright - cleft)/dx:0,
25104  sc = cright>cleft?1:-1,
25105  ndc = dc - (dx?dx*(dc/dx):0);
25106  const float
25107  pentez = (zright - zleft)/dx,
25108  pentetx = (txright - txleft)/dx,
25109  pentety = (tyright - tyleft)/dx;
25110  int errc = dx>>1;
25111  if (xleft<0 && dx) {
25112  cleft-=xleft*(cright - cleft)/dx;
25113  zleft-=xleft*(zright - zleft)/dx;
25114  txleft-=xleft*(txright - txleft)/dx;
25115  tyleft-=xleft*(tyright - tyleft)/dx;
25116  }
25117  if (xleft<0) xleft = 0;
25118  if (xright>=dimx()-1) xright = dimx()-1;
25119  T* ptrd = ptr(xleft,y);
25120  float *ptrz = zbuffer.ptr(xleft,y);
25121  if (opacity>=1) for (int x = xleft; x<=xright; ++x, ++ptrd, ++ptrz) {
25122  if (zleft>*ptrz) {
25123  *ptrz = zleft;
25124  const float invz = 1/zleft;
25125  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25126  cimg_forV(*this,k) {
25127  *ptrd = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25128  ptrd+=whz; col+=twhz;
25129  }
25130  ptrd-=offx;
25131  }
25132  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25133  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25134  } else for (int x = xleft; x<=xright; ++x, ++ptrd, ++ptrz) {
25135  if (zleft>*ptrz) {
25136  *ptrz = zleft;
25137  const float invz = 1/zleft;
25138  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25139  cimg_forV(*this,k) {
25140  const T val = (T)(cleft<256?cleft**col/256:((512-cleft)**col+(cleft-256)*maxval)/256);
25141  *ptrd = (T)(nopacity*val + *ptrd*copacity);
25142  ptrd+=whz; col+=twhz;
25143  }
25144  ptrd-=offx;
25145  }
25146  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25147  cleft+=rc+((errc-=ndc)<0?errc+=dx,sc:0);
25148  }
25149  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25150  }
25151  return *this;
25152  }
#define _cimg_for_triangle2(img, xl, cl, xr, cr, y, x0, y0, c0, x1, y1, c1, x2, y2, c2)
Definition: CImg.h:23509
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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 
)
inline

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

Parameters
x0= X-coordinate of the first corner in the instance image.
y0= Y-coordinate of the first corner in the instance image.
x1= X-coordinate of the second corner in the instance image.
y1= Y-coordinate of the second corner in the instance image.
x2= X-coordinate of the third corner in the instance image.
y2= Y-coordinate of the third corner in the instance image.
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.

Definition at line 25180 of file CImg.h.

25191  {
25192  if (is_empty()) return *this;
25193  if (!texture || texture.dim<dim)
25194  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25195  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25196  if (!light)
25197  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25198  pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25199  if (is_overlapped(texture)) return draw_triangle(x0,y0,x1,y1,x2,y2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25200  if (is_overlapped(light)) return draw_triangle(x0,y0,x1,y1,x2,y2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25201  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
25202  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
25203  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
25204  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25205  ntx0 = tx0, nty0 = ty0, ntx1 = tx1, nty1 = ty1, ntx2 = tx2, nty2 = ty2,
25206  nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25207  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1);
25208  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2);
25209  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2);
25210  if (ny0>=dimy() || ny2<0) return *this;
25211  _cimg_for_triangle5(*this,xleft0,lxleft0,lyleft0,txleft0,tyleft0,xright0,lxright0,lyright0,txright0,tyright0,y,
25212  nx0,ny0,nlx0,nly0,ntx0,nty0,nx1,ny1,nlx1,nly1,ntx1,nty1,nx2,ny2,nlx2,nly2,ntx2,nty2) {
25213  int
25214  xleft = xleft0, xright = xright0,
25215  lxleft = lxleft0, lxright = lxright0,
25216  lyleft = lyleft0, lyright = lyright0,
25217  txleft = txleft0, txright = txright0,
25218  tyleft = tyleft0, tyright = tyright0;
25219  if (xright<xleft) cimg::swap(xleft,xright,lxleft,lxright,lyleft,lyright,txleft,txright,tyleft,tyright);
25220  const int
25221  dx = xright - xleft,
25222  dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25223  dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25224  dtx = txright>txleft?txright - txleft:txleft - txright,
25225  dty = tyright>tyleft?tyright - tyleft:tyleft - tyright,
25226  rlx = dx?(lxright - lxleft)/dx:0,
25227  rly = dx?(lyright - lyleft)/dx:0,
25228  rtx = dx?(txright - txleft)/dx:0,
25229  rty = dx?(tyright - tyleft)/dx:0,
25230  slx = lxright>lxleft?1:-1,
25231  sly = lyright>lyleft?1:-1,
25232  stx = txright>txleft?1:-1,
25233  sty = tyright>tyleft?1:-1,
25234  ndlx = dlx - (dx?dx*(dlx/dx):0),
25235  ndly = dly - (dx?dx*(dly/dx):0),
25236  ndtx = dtx - (dx?dx*(dtx/dx):0),
25237  ndty = dty - (dx?dx*(dty/dx):0);
25238  int errlx = dx>>1, errly = errlx, errtx = errlx, errty = errlx;
25239  if (xleft<0 && dx) {
25240  lxleft-=xleft*(lxright - lxleft)/dx;
25241  lyleft-=xleft*(lyright - lyleft)/dx;
25242  txleft-=xleft*(txright - txleft)/dx;
25243  tyleft-=xleft*(tyright - tyleft)/dx;
25244  }
25245  if (xleft<0) xleft = 0;
25246  if (xright>=dimx()-1) xright = dimx()-1;
25247  T* ptrd = ptr(xleft,y,0,0);
25248  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
25249  const tl l = light(lxleft,lyleft);
25250  const tc *col = texture.ptr(txleft,tyleft);
25251  cimg_forV(*this,k) {
25252  *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25253  ptrd+=whz; col+=twhz;
25254  }
25255  ptrd-=offx;
25256  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25257  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25258  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
25259  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
25260  } else for (int x = xleft; x<=xright; ++x) {
25261  const tl l = light(lxleft,lyleft);
25262  const tc *col = texture.ptr(txleft,tyleft);
25263  cimg_forV(*this,k) {
25264  const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25265  *ptrd = (T)(nopacity*val + *ptrd*copacity);
25266  ptrd+=whz; col+=twhz;
25267  }
25268  ptrd-=offx;
25269  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25270  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25271  txleft+=rtx+((errtx-=ndtx)<0?errtx+=dx,stx:0);
25272  tyleft+=rty+((errty-=ndty)<0?errty+=dx,sty:0);
25273  }
25274  }
25275  return *this;
25276  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define _cimg_for_triangle5(img, xl, txl, tyl, lxl, lyl, xr, txr, tyr, lxr, lyr, y, x0, y0, tx0, ty0, lx0, ly0, x1, y1, tx1, ty1, lx1, ly1, x2, y2, tx2, ty2, lx2, ly2)
Definition: CImg.h:23686
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 
)
inline

Draw a 2D Pseudo-Phong-shaded textured triangle, with perspective correction.

Definition at line 25280 of file CImg.h.

25291  {
25292  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
25293  if (!texture || texture.dim<dim)
25294  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25295  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25296  if (!light)
25297  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25298  pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25299  if (is_overlapped(texture)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,+texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25300  if (is_overlapped(light)) return draw_triangle(x0,y0,z0,x1,y1,z1,x2,y2,z2,texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25301  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
25302  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
25303  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz-1;
25304  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25305  nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25306  float
25307  ntx0 = tx0/z0, nty0 = ty0/z0,
25308  ntx1 = tx1/z1, nty1 = ty1/z1,
25309  ntx2 = tx2/z2, nty2 = ty2/z2,
25310  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25311  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1,nz0,nz1);
25312  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2,nz0,nz2);
25313  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2,nz1,nz2);
25314  if (ny0>=dimy() || ny2<0) return *this;
25315  float
25316  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25317  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25318  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25319  ptyl = (nty1 - nty0)/(ny1 - ny0),
25320  ptyr = (nty2 - nty0)/(ny2 - ny0),
25321  ptyn = (nty2 - nty1)/(ny2 - ny1),
25322  pzl = (nz1 - nz0)/(ny1 - ny0),
25323  pzr = (nz2 - nz0)/(ny2 - ny0),
25324  pzn = (nz2 - nz1)/(ny2 - ny1),
25325  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25326  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25327  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25328  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25329  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25330  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25331  _cimg_for_triangle3(*this,xleft0,lxleft0,lyleft0,xright0,lxright0,lyright0,y,
25332  nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
25333  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25334  int
25335  xleft = xleft0, xright = xright0,
25336  lxleft = lxleft0, lxright = lxright0,
25337  lyleft = lyleft0, lyright = lyright0;
25338  float
25339  zleft = zl, zright = zr,
25340  txleft = txl, txright = txr,
25341  tyleft = tyl, tyright = tyr;
25342  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,lxleft,lxright,lyleft,lyright);
25343  const int
25344  dx = xright - xleft,
25345  dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25346  dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25347  rlx = dx?(lxright - lxleft)/dx:0,
25348  rly = dx?(lyright - lyleft)/dx:0,
25349  slx = lxright>lxleft?1:-1,
25350  sly = lyright>lyleft?1:-1,
25351  ndlx = dlx - (dx?dx*(dlx/dx):0),
25352  ndly = dly - (dx?dx*(dly/dx):0);
25353  const float
25354  pentez = (zright - zleft)/dx,
25355  pentetx = (txright - txleft)/dx,
25356  pentety = (tyright - tyleft)/dx;
25357  int errlx = dx>>1, errly = errlx;
25358  if (xleft<0 && dx) {
25359  zleft-=xleft*(zright - zleft)/dx;
25360  lxleft-=xleft*(lxright - lxleft)/dx;
25361  lyleft-=xleft*(lyright - lyleft)/dx;
25362  txleft-=xleft*(txright - txleft)/dx;
25363  tyleft-=xleft*(tyright - tyleft)/dx;
25364  }
25365  if (xleft<0) xleft = 0;
25366  if (xright>=dimx()-1) xright = dimx()-1;
25367  T* ptrd = ptr(xleft,y,0,0);
25368  if (opacity>=1) for (int x = xleft; x<=xright; ++x) {
25369  const float invz = 1/zleft;
25370  const tl l = light(lxleft,lyleft);
25371  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25372  cimg_forV(*this,k) {
25373  *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25374  ptrd+=whz; col+=twhz;
25375  }
25376  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25377  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25378  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25379  } else for (int x = xleft; x<=xright; ++x) {
25380  const float invz = 1/zleft;
25381  const tl l = light(lxleft,lyleft);
25382  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25383  cimg_forV(*this,k) {
25384  const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25385  *ptrd = (T)(nopacity*val + *ptrd*copacity);
25386  ptrd+=whz; col+=twhz;
25387  }
25388  ptrd-=offx; zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25389  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25390  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25391  }
25392  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25393  }
25394  return *this;
25395  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
Definition: CImg.h:23553
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& draw_triangle ( CImg< floatT > &  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 
)
inline

Draw a 2D Pseudo-Phong-shaded textured triangle, with z-buffering and perspective correction.

Definition at line 25399 of file CImg.h.

25411  {
25412  if (is_empty() || z0<=0 || z1<=0 || z2<=0) return *this;
25413  if (!is_sameXY(zbuffer))
25414  throw CImgArgumentException("CImg<%s>::draw_triangle() : Z-buffer (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) have different dimensions.",
25415  pixel_type(),zbuffer.width,zbuffer.height,zbuffer.depth,zbuffer.dim,zbuffer.data,width,height,depth,dim,data);
25416  if (!texture || texture.dim<dim)
25417  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified texture (%u,%u,%u,%u,%p) is not a valid argument.",
25418  pixel_type(),texture.width,texture.height,texture.depth,texture.dim,texture.data);
25419  if (!light)
25420  throw CImgArgumentException("CImg<%s>::draw_triangle() : Specified light texture (%u,%u,%u,%u,%p) is empty.",
25421  pixel_type(),light.width,light.height,light.depth,light.dim,light.data);
25422  if (is_overlapped(texture)) return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,
25423  +texture,tx0,ty0,tx1,ty1,tx2,ty2,light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25424  if (is_overlapped(light)) return draw_triangle(zbuffer,x0,y0,z0,x1,y1,z1,x2,y2,z2,
25425  texture,tx0,ty0,tx1,ty1,tx2,ty2,+light,lx0,ly0,lx1,ly1,lx2,ly2,opacity);
25426  static const T maxval = (T)cimg::min(cimg::type<T>::max(),cimg::type<tc>::max());
25427  const float nopacity = cimg::abs(opacity), copacity = 1 - cimg::max(opacity,0);
25428  const int whz = width*height*depth, twhz = texture.width*texture.height*texture.depth, offx = dim*whz;
25429  int nx0 = x0, ny0 = y0, nx1 = x1, ny1 = y1, nx2 = x2, ny2 = y2,
25430  nlx0 = lx0, nly0 = ly0, nlx1 = lx1, nly1 = ly1, nlx2 = lx2, nly2 = ly2;
25431  float
25432  ntx0 = tx0/z0, nty0 = ty0/z0,
25433  ntx1 = tx1/z1, nty1 = ty1/z1,
25434  ntx2 = tx2/z2, nty2 = ty2/z2,
25435  nz0 = 1/z0, nz1 = 1/z1, nz2 = 1/z2;
25436  if (ny0>ny1) cimg::swap(nx0,nx1,ny0,ny1,ntx0,ntx1,nty0,nty1,nlx0,nlx1,nly0,nly1,nz0,nz1);
25437  if (ny0>ny2) cimg::swap(nx0,nx2,ny0,ny2,ntx0,ntx2,nty0,nty2,nlx0,nlx2,nly0,nly2,nz0,nz2);
25438  if (ny1>ny2) cimg::swap(nx1,nx2,ny1,ny2,ntx1,ntx2,nty1,nty2,nlx1,nlx2,nly1,nly2,nz1,nz2);
25439  if (ny0>=dimy() || ny2<0) return *this;
25440  float
25441  ptxl = (ntx1 - ntx0)/(ny1 - ny0),
25442  ptxr = (ntx2 - ntx0)/(ny2 - ny0),
25443  ptxn = (ntx2 - ntx1)/(ny2 - ny1),
25444  ptyl = (nty1 - nty0)/(ny1 - ny0),
25445  ptyr = (nty2 - nty0)/(ny2 - ny0),
25446  ptyn = (nty2 - nty1)/(ny2 - ny1),
25447  pzl = (nz1 - nz0)/(ny1 - ny0),
25448  pzr = (nz2 - nz0)/(ny2 - ny0),
25449  pzn = (nz2 - nz1)/(ny2 - ny1),
25450  zr = ny0>=0?nz0:(nz0 - ny0*(nz2 - nz0)/(ny2 - ny0)),
25451  txr = ny0>=0?ntx0:(ntx0 - ny0*(ntx2 - ntx0)/(ny2 - ny0)),
25452  tyr = ny0>=0?nty0:(nty0 - ny0*(nty2 - nty0)/(ny2 - ny0)),
25453  zl = ny1>=0?(ny0>=0?nz0:(nz0 - ny0*(nz1 - nz0)/(ny1 - ny0))):(pzl=pzn,(nz1 - ny1*(nz2 - nz1)/(ny2 - ny1))),
25454  txl = ny1>=0?(ny0>=0?ntx0:(ntx0 - ny0*(ntx1 - ntx0)/(ny1 - ny0))):(ptxl=ptxn,(ntx1 - ny1*(ntx2 - ntx1)/(ny2 - ny1))),
25455  tyl = ny1>=0?(ny0>=0?nty0:(nty0 - ny0*(nty1 - nty0)/(ny1 - ny0))):(ptyl=ptyn,(nty1 - ny1*(nty2 - nty1)/(ny2 - ny1)));
25456  _cimg_for_triangle3(*this,xleft0,lxleft0,lyleft0,xright0,lxright0,lyright0,y,
25457  nx0,ny0,nlx0,nly0,nx1,ny1,nlx1,nly1,nx2,ny2,nlx2,nly2) {
25458  if (y==ny1) { zl = nz1; txl = ntx1; tyl = nty1; pzl = pzn; ptxl = ptxn; ptyl = ptyn; }
25459  int
25460  xleft = xleft0, xright = xright0,
25461  lxleft = lxleft0, lxright = lxright0,
25462  lyleft = lyleft0, lyright = lyright0;
25463  float
25464  zleft = zl, zright = zr,
25465  txleft = txl, txright = txr,
25466  tyleft = tyl, tyright = tyr;
25467  if (xright<xleft) cimg::swap(xleft,xright,zleft,zright,txleft,txright,tyleft,tyright,lxleft,lxright,lyleft,lyright);
25468  const int
25469  dx = xright - xleft,
25470  dlx = lxright>lxleft?lxright - lxleft:lxleft - lxright,
25471  dly = lyright>lyleft?lyright - lyleft:lyleft - lyright,
25472  rlx = dx?(lxright - lxleft)/dx:0,
25473  rly = dx?(lyright - lyleft)/dx:0,
25474  slx = lxright>lxleft?1:-1,
25475  sly = lyright>lyleft?1:-1,
25476  ndlx = dlx - (dx?dx*(dlx/dx):0),
25477  ndly = dly - (dx?dx*(dly/dx):0);
25478  const float
25479  pentez = (zright - zleft)/dx,
25480  pentetx = (txright - txleft)/dx,
25481  pentety = (tyright - tyleft)/dx;
25482  int errlx = dx>>1, errly = errlx;
25483  if (xleft<0 && dx) {
25484  zleft-=xleft*(zright - zleft)/dx;
25485  lxleft-=xleft*(lxright - lxleft)/dx;
25486  lyleft-=xleft*(lyright - lyleft)/dx;
25487  txleft-=xleft*(txright - txleft)/dx;
25488  tyleft-=xleft*(tyright - tyleft)/dx;
25489  }
25490  if (xleft<0) xleft = 0;
25491  if (xright>=dimx()-1) xright = dimx()-1;
25492  T* ptrd = ptr(xleft,y);
25493  float *ptrz = zbuffer.ptr(xleft,y);
25494  if (opacity>=1) for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
25495  if (zleft>*ptrz) {
25496  *ptrz = zleft;
25497  const float invz = 1/zleft;
25498  const tl l = light(lxleft,lyleft);
25499  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25500  cimg_forV(*this,k) {
25501  *ptrd = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25502  ptrd+=whz; col+=twhz;
25503  }
25504  ptrd-=offx;
25505  }
25506  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25507  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25508  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25509  } else for (int x = xleft; x<=xright; ++x, ++ptrz, ++ptrd) {
25510  if (zleft>*ptrz) {
25511  *ptrz = zleft;
25512  const float invz = 1/zleft;
25513  const tl l = light(lxleft,lyleft);
25514  const tc *col = texture.ptr((int)(txleft*invz),(int)(tyleft*invz));
25515  cimg_forV(*this,k) {
25516  const T val = (T)(l<1?l**col:(2-l)**col+(l-1)*maxval);
25517  *ptrd = (T)(nopacity*val + *ptrd*copacity);
25518  ptrd+=whz; col+=twhz;
25519  }
25520  ptrd-=offx;
25521  }
25522  zleft+=pentez; txleft+=pentetx; tyleft+=pentety;
25523  lxleft+=rlx+((errlx-=ndlx)<0?errlx+=dx,slx:0);
25524  lyleft+=rly+((errly-=ndly)<0?errly+=dx,sly:0);
25525  }
25526  zr+=pzr; txr+=ptxr; tyr+=ptyr; zl+=pzl; txl+=ptxl; tyl+=ptyl;
25527  }
25528  return *this;
25529  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
#define _cimg_for_triangle3(img, xl, txl, tyl, xr, txr, tyr, y, x0, y0, tx0, ty0, x1, y1, tx1, ty1, x2, y2, tx2, ty2)
Definition: CImg.h:23553
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
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.
Definition: CImg.h:23796
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& edge_tensors ( const float  sharpness = 0.7f,
const float  anisotropy = 0.3f,
const float  alpha = 0.6f,
const float  sigma = 1.1f,
const bool  is_sqrt = false 
)
inline

Get a diffusion tensor for edge-preserving anisotropic smoothing of an image.

Definition at line 20276 of file CImg.h.

Referenced by CImg< uintT >::get_edge_tensors().

20277  {
20278  CImg<Tfloat> dest;
20279  const float nsharpness = cimg::max(sharpness,1e-5f), power1 = (is_sqrt?0.5f:1)*nsharpness, power2 = power1/(1e-7f+1-anisotropy);
20280  blur(alpha).normalize(0,(T)255);
20281 
20282  if (depth>1) { // for 3D volumes
20283  CImg<floatT> val(3), vec(3,3);
20284  get_structure_tensor().transfer_to(dest).blur(sigma);
20285  cimg_forXYZ(*this,x,y,z) {
20286  dest.get_tensor_at(x,y,z).symmetric_eigen(val,vec);
20287  const float
20288  _l1 = val[2], _l2 = val[1], _l3 = val[0],
20289  l1 = _l1>0?_l1:0, l2 = _l2>0?_l2:0, l3 = _l3>0?_l3:0,
20290  ux = vec(0,0), uy = vec(0,1), uz = vec(0,2),
20291  vx = vec(1,0), vy = vec(1,1), vz = vec(1,2),
20292  wx = vec(2,0), wy = vec(2,1), wz = vec(2,2),
20293  n1 = (float)std::pow(1+l1+l2+l3,-power1),
20294  n2 = (float)std::pow(1+l1+l2+l3,-power2);
20295  dest(x,y,z,0) = n1*(ux*ux + vx*vx) + n2*wx*wx;
20296  dest(x,y,z,1) = n1*(ux*uy + vx*vy) + n2*wx*wy;
20297  dest(x,y,z,2) = n1*(ux*uz + vx*vz) + n2*wx*wz;
20298  dest(x,y,z,3) = n1*(uy*uy + vy*vy) + n2*wy*wy;
20299  dest(x,y,z,4) = n1*(uy*uz + vy*vz) + n2*wy*wz;
20300  dest(x,y,z,5) = n1*(uz*uz + vz*vz) + n2*wz*wz;
20301  }
20302  } else { // for 2D images
20303  CImg<floatT> val(2), vec(2,2);
20304  get_structure_tensor().transfer_to(dest).blur(sigma);
20305  cimg_forXY(*this,x,y) {
20306  dest.get_tensor_at(x,y).symmetric_eigen(val,vec);
20307  const float
20308  _l1 = val[1], _l2 = val[0],
20309  l1 = _l1>0?_l1:0, l2 = _l2>0?_l2:0,
20310  ux = vec(1,0), uy = vec(1,1),
20311  vx = vec(0,0), vy = vec(0,1),
20312  n1 = (float)std::pow(1+l1+l2,-power1),
20313  n2 = (float)std::pow(1+l1+l2,-power2);
20314  dest(x,y,0,0) = n1*ux*ux + n2*vx*vx;
20315  dest(x,y,0,1) = n1*ux*uy + n2*vx*vy;
20316  dest(x,y,0,2) = n1*uy*uy + n2*vy*vy;
20317  }
20318  }
20319  return dest.transfer_to(*this);
20320  }
void int int REAL REAL * y
Definition: read.cpp:74
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
void int int int REAL REAL REAL * z
Definition: write.cpp:76
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
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.
Definition: CImg.h:19211
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
CImg< Tfloat > get_structure_tensor(const unsigned int scheme=1) const
Definition: CImg.h:20186

Here is the caller graph for this function:

const CImg<T>& eigen ( CImg< t > &  val,
CImg< t > &  vec 
) const
inline

Compute the eigenvalues and eigenvectors of a matrix.

Definition at line 13660 of file CImg.h.

Referenced by CImg< uintT >::get_eigen(), and CImg< uintT >::symmetric_eigen().

13660  {
13661  if (is_empty()) { val.assign(); vec.assign(); }
13662  else {
13663  if (width!=height || depth>1 || dim>1)
13664  throw CImgInstanceException("CImg<%s>::eigen() : Instance object (%u,%u,%u,%u,%p) is empty.",
13666  if (val.size()<width) val.assign(1,width);
13667  if (vec.size()<width*width) vec.assign(width,width);
13668  switch (width) {
13669  case 1 : { val[0]=(t)(*this)[0]; vec[0]=(t)1; } break;
13670  case 2 : {
13671  const double a = (*this)[0], b = (*this)[1], c = (*this)[2], d = (*this)[3], e = a+d;
13672  double f = e*e-4*(a*d-b*c);
13673  if (f<0)
13674  cimg::warn("CImg<%s>::eigen() : Complex eigenvalues",
13675  pixel_type());
13676  f = std::sqrt(f);
13677  const double l1 = 0.5*(e-f), l2 = 0.5*(e+f);
13678  const double theta1 = std::atan2(l2-a,b), theta2 = std::atan2(l1-a,b);
13679  val[0]=(t)l2;
13680  val[1]=(t)l1;
13681  vec(0,0) = (t)std::cos(theta1);
13682  vec(0,1) = (t)std::sin(theta1);
13683  vec(1,0) = (t)std::cos(theta2);
13684  vec(1,1) = (t)std::sin(theta2);
13685  } break;
13686  default :
13687  throw CImgInstanceException("CImg<%s>::eigen() : Eigenvalues computation of general matrices is limited"
13688  "to 2x2 matrices (given is %ux%u)",
13689  pixel_type(),width,height);
13690  }
13691  }
13692  return *this;
13693  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
const NT & d
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
NT & sin
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
NT & cos
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

Get elevation3d of a function.

Definition at line 21284 of file CImg.h.

Referenced by CImg< uintT >::elevation3d(), and CImg< uintT >::get_elevation3d().

21286  {
21287  const float
21288  nx0 = x0<x1?x0:x1, ny0 = y0<y1?y0:y1,
21289  nx1 = x0<x1?x1:x0, ny1 = y0<y1?y1:y0;
21290  const unsigned int
21291  _nsize_x = (unsigned int)(size_x>=0?size_x:(nx1-nx0)*-size_x/100), nsize_x = _nsize_x?_nsize_x:1, nsize_x1 = nsize_x - 1,
21292  _nsize_y = (unsigned int)(size_y>=0?size_y:(ny1-ny0)*-size_y/100), nsize_y = _nsize_y?_nsize_y:1, nsize_y1 = nsize_y - 1;
21293  if (nsize_x<2 || nsize_y<2)
21294  throw CImgArgumentException("CImg<%s>::elevation3d() : Invalid requested size (%d,%d).",
21295  pixel_type(),nsize_x,nsize_y);
21296  CImg<floatT> vertices(nsize_x*nsize_y,3);
21297  floatT *ptr_x = vertices.ptr(0,0), *ptr_y = vertices.ptr(0,1), *ptr_z = vertices.ptr(0,2);
21298  for (unsigned int y = 0; y<nsize_y; ++y) {
21299  const float Y = ny0 + y*(ny1-ny0)/nsize_y1;
21300  for (unsigned int x = 0; x<nsize_x; ++x) {
21301  const float X = nx0 + x*(nx1-nx0)/nsize_x1;
21302  *(ptr_x++) = (float)x;
21303  *(ptr_y++) = (float)y;
21304  *(ptr_z++) = (float)func(X,Y);
21305  }
21306  }
21307  primitives.assign(nsize_x1*nsize_y1,1,4);
21308  for (unsigned int p = 0, y = 0; y<nsize_y1; ++y) {
21309  const unsigned int yw = y*nsize_x;
21310  for (unsigned int x = 0; x<nsize_x1; ++x) {
21311  const unsigned int xpyw = x + yw, xpyww = xpyw + nsize_x;
21312  primitives[p++].fill(xpyw,xpyww,xpyww+1,xpyw+1);
21313  }
21314  }
21315  return vertices;
21316  }
void int int REAL REAL * y
Definition: read.cpp:74
cimg::last< T, float >::type floatT
Definition: CImg.h:9792
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
void int int REAL * x
Definition: read.cpp:74
for(;;)

Here is the caller graph for this function:

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

Definition at line 21319 of file CImg.h.

21321  {
21322  const _marching2d_func_expr func(expression);
21323  return elevation3d(primitives,func,x0,y0,x1,y1,sizex,sizey);
21324  }
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.
Definition: CImg.h:21284
static CImg<floatT> ellipsoid3d ( CImgList< tf > &  primitives,
const CImg< t > &  tensor,
const unsigned int  subdivisions = 3 
)
inlinestatic

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(points3d,faces3d);
ref_ellipsoid3d.jpg

Definition at line 22071 of file CImg.h.

22072  {
22073  primitives.assign();
22074  if (!subdivisions) return CImg<floatT>();
22075  CImg<floatT> S,V;
22076  tensor.symmetric_eigen(S,V);
22077  const float l0 = S[0], l1 = S[1], l2 = S[2];
22078  CImg<floatT> vertices = sphere(primitives,subdivisions);
22079  vertices.get_shared_line(0)*=l0;
22080  vertices.get_shared_line(1)*=l1;
22081  vertices.get_shared_line(2)*=l2;
22082  return V.transpose()*vertices;
22083  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
static CImg<T>& empty ( void  )
inlinestatic

Return a reference to an empty image.

Definition at line 10351 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d(), and CImg< T >::_cimg_math_parser::eval().

10351  {
10352  static CImg<T> _empty;
10353  return _empty.assign();
10354  }

Here is the caller graph for this function:

iterator end ( )
inline

Return an iterator pointing after the last image pixel (STL-compliant name).

Definition at line 11161 of file CImg.h.

Referenced by CImg< T >::_cimg_math_parser::compile(), CImg< uintT >::fill(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::operator~(), and CImg< uintT >::print().

11161  {
11162  return data + size();
11163  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075

Here is the caller graph for this function:

const_iterator end ( ) const
inline

Definition at line 11165 of file CImg.h.

11165  {
11166  return data + size();
11167  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T>& equalize ( const unsigned int  nb_levels,
const T  value_min = (T)0,
const T  value_max = (T)0 
)
inline

Compute the histogram-equalized version of the instance image.

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 instance image.
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 instance image.
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_equalize(256);
(img,res).display();
ref_equalize.jpg

Definition at line 15305 of file CImg.h.

Referenced by CImg< uintT >::get_equalize().

15305  {
15306  if (is_empty()) return *this;
15307  T vmin = value_min, vmax = value_max;
15308  if (vmin==vmax && vmin==0) vmin = minmax(vmax);
15309  if (vmin<vmax) {
15310  CImg<floatT> hist = get_histogram(nb_levels,vmin,vmax);
15311  float cumul = 0;
15312  cimg_forX(hist,pos) { cumul+=hist[pos]; hist[pos] = cumul; }
15313  cimg_for(*this,ptr,T) {
15314  const int pos = (unsigned int)((*ptr-vmin)*(nb_levels-1)/(vmax-vmin));
15315  if (pos>=0 && pos<(int)nb_levels) *ptr = (T)(vmin + (vmax-vmin)*hist[pos]/size());
15316  }
15317  }
15318  return *this;
15319  }
CImg< floatT > get_histogram(const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0) const
Definition: CImg.h:15273
#define cimg_forX(img, x)
Definition: CImg.h:593
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
Definition: CImg.h:12920
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& erode ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_erosion = false 
)
inline

Return the erosion of the image by a structuring element.

Definition at line 18915 of file CImg.h.

18915  {
18916  return get_erode(mask,cond,weighted_erosion).transfer_to(*this);
18917  }
CImg< _cimg_Tt > get_erode(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false) const
Definition: CImg.h:18920
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg<T>& erode ( const unsigned int  n,
const unsigned int  cond = 1 
)
inline

Erode the image by a square structuring element of size n.

Definition at line 18999 of file CImg.h.

18999  {
19000  if (n<2) return *this;
19001  return get_erode(n,cond).transfer_to(*this);
19002  }
CImg< _cimg_Tt > get_erode(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false) const
Definition: CImg.h:18920
const NT & n
double eval ( const char *const  expression,
const double  x = 0,
const double  y = 0,
const double  z = 0,
const double  v = 0 
) const
inline

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.

Definition at line 13140 of file CImg.h.

13140  {
13141  static _cimg_math_parser *mp = 0;
13142  if (expression) { if (mp) delete mp; mp = new _cimg_math_parser(expression,"eval"); }
13143  if (!mp) throw CImgArgumentException("CImg<%s>::eval() : No expression has been previously defined.",pixel_type());
13144  return mp->eval(*this,x,y,z,v);
13145  }
void int int REAL REAL * y
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg<T>& exp ( )
inline

Compute the exponential of each pixel value.

Definition at line 12540 of file CImg.h.

Referenced by CImg< uintT >::get_exp().

12540  {
12541  cimg_for(*this,ptr,T) (*ptr) = (T)std::exp((double)(*ptr));
12542  return *this;
12543  }
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

static void FFT ( CImg< T > &  real,
CImg< T > &  imag,
const char  axis,
const bool  invert = false 
)
inlinestatic

Compute a 1D Fast Fourier Transform, along a specified axis.

Definition at line 20832 of file CImg.h.

Referenced by CImg< uintT >::FFT(), CImgList< uintT >::FFT(), and CImg< uintT >::get_FFT().

20832  {
20833  if (!real) throw CImgInstanceException("CImg<%s>::FFT() : Input real image is empty.",pixel_type());
20834  if (!imag) imag.assign(real.width,real.height,real.depth,real.dim,0);
20835  if (!real.is_sameXYZV(imag))
20836  throw CImgInstanceException("CImg<%s>::FFT() : Real image (%u,%u,%u,%u,%p) and imaginary image (%u,%u,%u,%u,%p) "
20837  "have different dimensions",
20838  pixel_type(),real.width,real.height,real.depth,real.dim,real.data,
20839  imag.width,imag.height,imag.depth,imag.dim,imag.data);
20840 #ifdef cimg_use_fftw3
20841  fftw_complex *data_in;
20842  fftw_plan data_plan;
20843 
20844  switch (cimg::uncase(axis)) {
20845  case 'x' : { // Fourier along X, using FFTW library.
20846  data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*real.width);
20847  data_plan = fftw_plan_dft_1d(real.width,data_in,data_in,invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20848  cimg_forYZV(real,y,z,k) {
20849  T *ptrr = real.ptr(0,y,z,k), *ptri = imag.ptr(0,y,z,k);
20850  double *ptrd = (double*)data_in;
20851  cimg_forX(real,x) { *(ptrd++) = (double)*(ptrr++); *(ptrd++) = (double)*(ptri++); }
20852  fftw_execute(data_plan);
20853  const unsigned int fact = real.width;
20854  if (invert) cimg_forX(real,x) { *(--ptri) = (T)(*(--ptrd)/fact); *(--ptrr) = (T)(*(--ptrd)/fact); }
20855  else cimg_forX(real,x) { *(--ptri) = (T)*(--ptrd); *(--ptrr) = (T)*(--ptrd); }
20856  }
20857  } break;
20858  case 'y' : { // Fourier along Y, using FFTW library.
20859  data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * real.height);
20860  data_plan = fftw_plan_dft_1d(real.height,data_in,data_in,invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20861  const unsigned int off = real.width;
20862  cimg_forXZV(real,x,z,k) {
20863  T *ptrr = real.ptr(x,0,z,k), *ptri = imag.ptr(x,0,z,k);
20864  double *ptrd = (double*)data_in;
20865  cimg_forY(real,y) { *(ptrd++) = (double)*ptrr; *(ptrd++) = (double)*ptri; ptrr+=off; ptri+=off; }
20866  fftw_execute(data_plan);
20867  const unsigned int fact = real.height;
20868  if (invert) cimg_forY(real,y) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20869  else cimg_forY(real,y) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20870  }
20871  } break;
20872  case 'z' : { // Fourier along Z, using FFTW library.
20873  data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * real.depth);
20874  data_plan = fftw_plan_dft_1d(real.depth,data_in,data_in,invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20875  const unsigned int off = real.width*real.height;
20876  cimg_forXYV(real,x,y,k) {
20877  T *ptrr = real.ptr(x,y,0,k), *ptri = imag.ptr(x,y,0,k);
20878  double *ptrd = (double*)data_in;
20879  cimg_forZ(real,z) { *(ptrd++) = (double)*ptrr; *(ptrd++) = (double)*ptri; ptrr+=off; ptri+=off; }
20880  fftw_execute(data_plan);
20881  const unsigned int fact = real.depth;
20882  if (invert) cimg_forZ(real,z) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20883  else cimg_forZ(real,z) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20884  }
20885  } break;
20886  case 'v' : { // Fourier along V, using FFTW library.
20887  data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * real.dim);
20888  data_plan = fftw_plan_dft_1d(real.dim,data_in,data_in,invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
20889  const unsigned int off = real.width*real.height*real.depth;
20890  cimg_forXYZ(real,x,y,z) {
20891  T *ptrr = real.ptr(x,y,z,0), *ptri = imag.ptr(x,y,z,0);
20892  double *ptrd = (double*)data_in;
20893  cimg_forV(real,k) { *(ptrd++) = (double)*ptrr; *(ptrd++) = (double)*ptri; ptrr+=off; ptri+=off; }
20894  fftw_execute(data_plan);
20895  const unsigned int fact = real.dim;
20896  if (invert) cimg_forV(real,k) { ptrr-=off; ptri-=off; *ptri = (T)(*(--ptrd)/fact); *ptrr = (T)(*(--ptrd)/fact); }
20897  else cimg_forV(real,k) { ptrr-=off; ptri-=off; *ptri = (T)*(--ptrd); *ptrr = (T)*(--ptrd); }
20898  }
20899  } break;
20900  }
20901  fftw_destroy_plan(data_plan);
20902  fftw_free(data_in);
20903 #else
20904  switch (cimg::uncase(axis)) {
20905  case 'x' : { // Fourier along X, using built-in functions.
20906  const unsigned int N = real.width, N2 = (N>>1);
20907  if (((N-1)&N) && N!=1)
20908  throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image along 'x' is %d != 2^N",
20909  pixel_type(),N);
20910  for (unsigned int i = 0, j = 0; i<N2; ++i) {
20911  if (j>i) cimg_forYZV(real,y,z,v) { cimg::swap(real(i,y,z,v),real(j,y,z,v)); cimg::swap(imag(i,y,z,v),imag(j,y,z,v));
20912  if (j<N2) {
20913  const unsigned int ri = N-1-i, rj = N-1-j;
20914  cimg::swap(real(ri,y,z,v),real(rj,y,z,v)); cimg::swap(imag(ri,y,z,v),imag(rj,y,z,v));
20915  }}
20916  for (unsigned int m = N, n = N2; (j+=n)>=m; j-=m, m = n, n>>=1) {}
20917  }
20918  for (unsigned int delta = 2; delta<=N; delta<<=1) {
20919  const unsigned int delta2 = (delta>>1);
20920  for (unsigned int i = 0; i<N; i+=delta) {
20921  float wr = 1, wi = 0;
20922  const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta),
20923  ca = (float)std::cos(angle),
20924  sa = (float)std::sin(angle);
20925  for (unsigned int k = 0; k<delta2; ++k) {
20926  const unsigned int j = i + k, nj = j + delta2;
20927  cimg_forYZV(real,y,z,k) {
20928  T &ir = real(j,y,z,k), &ii = imag(j,y,z,k), &nir = real(nj,y,z,k), &nii = imag(nj,y,z,k);
20929  const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
20930  nir = (T)(ir - tmpr);
20931  nii = (T)(ii - tmpi);
20932  ir += (T)tmpr;
20933  ii += (T)tmpi;
20934  }
20935  const float nwr = wr*ca-wi*sa;
20936  wi = wi*ca + wr*sa;
20937  wr = nwr;
20938  }
20939  }
20940  }
20941  if (invert) { real/=N; imag/=N; }
20942  } break;
20943  case 'y' : { // Fourier along Y, using built-in functions.
20944  const unsigned int N = real.height, N2 = (N>>1);
20945  if (((N-1)&N) && N!=1)
20946  throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image(s) along 'y' is %d != 2^N",
20947  pixel_type(),N);
20948  for (unsigned int i = 0, j = 0; i<N2; ++i) {
20949  if (j>i) cimg_forXZV(real,x,z,v) { cimg::swap(real(x,i,z,v),real(x,j,z,v)); cimg::swap(imag(x,i,z,v),imag(x,j,z,v));
20950  if (j<N2) {
20951  const unsigned int ri = N-1-i, rj = N-1-j;
20952  cimg::swap(real(x,ri,z,v),real(x,rj,z,v)); cimg::swap(imag(x,ri,z,v),imag(x,rj,z,v));
20953  }}
20954  for (unsigned int m = N, n = N2; (j+=n)>=m; j-=m, m = n, n>>=1) {}
20955  }
20956  for (unsigned int delta = 2; delta<=N; delta<<=1) {
20957  const unsigned int delta2 = (delta>>1);
20958  for (unsigned int i = 0; i<N; i+=delta) {
20959  float wr = 1, wi = 0;
20960  const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta),
20961  ca = (float)std::cos(angle), sa = (float)std::sin(angle);
20962  for (unsigned int k = 0; k<delta2; ++k) {
20963  const unsigned int j = i + k, nj = j + delta2;
20964  cimg_forXZV(real,x,z,k) {
20965  T &ir = real(x,j,z,k), &ii = imag(x,j,z,k), &nir = real(x,nj,z,k), &nii = imag(x,nj,z,k);
20966  const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
20967  nir = (T)(ir - tmpr);
20968  nii = (T)(ii - tmpi);
20969  ir += (T)tmpr;
20970  ii += (T)tmpi;
20971  }
20972  const float nwr = wr*ca-wi*sa;
20973  wi = wi*ca + wr*sa;
20974  wr = nwr;
20975  }
20976  }
20977  }
20978  if (invert) { real/=N; imag/=N; }
20979  } break;
20980  case 'z' : { // Fourier along Z, using built-in functions.
20981  const unsigned int N = real.depth, N2 = (N>>1);
20982  if (((N-1)&N) && N!=1)
20983  throw CImgInstanceException("CImgList<%s>::FFT() : Dimension of instance image(s) along 'z' is %d != 2^N",
20984  pixel_type(),N);
20985  for (unsigned int i = 0, j = 0; i<N2; ++i) {
20986  if (j>i) cimg_forXYV(real,x,y,v) { cimg::swap(real(x,y,i,v),real(x,y,j,v)); cimg::swap(imag(x,y,i,v),imag(x,y,j,v));
20987  if (j<N2) {
20988  const unsigned int ri = N-1-i, rj = N-1-j;
20989  cimg::swap(real(x,y,ri,v),real(x,y,rj,v)); cimg::swap(imag(x,y,ri,v),imag(x,y,rj,v));
20990  }}
20991  for (unsigned int m = N, n = N2; (j+=n)>=m; j-=m, m = n, n>>=1) {}
20992  }
20993  for (unsigned int delta = 2; delta<=N; delta<<=1) {
20994  const unsigned int delta2 = (delta>>1);
20995  for (unsigned int i = 0; i<N; i+=delta) {
20996  float wr = 1, wi = 0;
20997  const float angle = (float)((invert?+1:-1)*2*cimg::valuePI/delta),
20998  ca = (float)std::cos(angle), sa = (float)std::sin(angle);
20999  for (unsigned int k = 0; k<delta2; ++k) {
21000  const unsigned int j = i + k, nj = j + delta2;
21001  cimg_forXYV(real,x,y,k) {
21002  T &ir = real(x,y,j,k), &ii = imag(x,y,j,k), &nir = real(x,y,nj,k), &nii = imag(x,y,nj,k);
21003  const float tmpr = (float)(wr*nir - wi*nii), tmpi = (float)(wr*nii + wi*nir);
21004  nir = (T)(ir - tmpr);
21005  nii = (T)(ii - tmpi);
21006  ir += (T)tmpr;
21007  ii += (T)tmpi;
21008  }
21009  const float nwr = wr*ca-wi*sa;
21010  wi = wi*ca + wr*sa;
21011  wr = nwr;
21012  }
21013  }
21014  }
21015  if (invert) { real/=N; imag/=N; }
21016  } break;
21017  default :
21018  throw CImgArgumentException("CImgList<%s>::FFT() : Invalid axis '%c', must be 'x','y' or 'z'.");
21019  }
21020 #endif
21021  }
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
#define cimg_forX(img, x)
Definition: CImg.h:593
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
float real
Definition: gridutil.h:70
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
NT & sin
blockLoc i
Definition: read.cpp:79
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimg_forV(img, v)
Definition: CImg.h:596
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
j indices j
Definition: Indexing.h:6
#define cimg_forZ(img, z)
Definition: CImg.h:595
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
#define cimg_forY(img, y)
Definition: CImg.h:594
void int * nj
Definition: read.cpp:74
NT & cos
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

static void FFT ( CImg< T > &  real,
CImg< T > &  imag,
const bool  invert = false 
)
inlinestatic

Compute a N-D Fast Fourier Transform.

Definition at line 21024 of file CImg.h.

21024  {
21025  if (!real) throw CImgInstanceException("CImgList<%s>::FFT() : Input real image is empty.",pixel_type());
21026  if (!imag) imag.assign(real.width,real.height,real.depth,real.dim,0);
21027  if (!real.is_sameXYZV(imag))
21028  throw CImgInstanceException("CImgList<%s>::FFT() : Real image (%u,%u,%u,%u,%p) and imaginary image (%u,%u,%u,%u,%p) "
21029  "have different dimensions",
21030  pixel_type(),real.width,real.height,real.depth,real.dim,real.data,
21031  imag.width,imag.height,imag.depth,imag.dim,imag.data);
21032 #ifdef cimg_use_fftw3
21033  fftw_complex *data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*real.width*real.height*real.depth);
21034  fftw_plan data_plan;
21035  const unsigned int w = real.width, wh = w*real.height, whd = wh*real.depth;
21036  data_plan = fftw_plan_dft_3d(real.width,real.height,real.depth,data_in,data_in,invert?FFTW_BACKWARD:FFTW_FORWARD,FFTW_ESTIMATE);
21037  cimg_forV(real,k) {
21038  T *ptrr = real.ptr(0,0,0,k), *ptri = imag.ptr(0,0,0,k);
21039  double *ptrd = (double*)data_in;
21040  for (unsigned int x = 0; x<real.width; ++x, ptrr-=wh-1, ptri-=wh-1)
21041  for (unsigned int y = 0; y<real.height; ++y, ptrr-=whd-w, ptri-=whd-w)
21042  for (unsigned int z = 0; z<real.depth; ++z, ptrr+=wh, ptri+=wh) {
21043  *(ptrd++) = (double)*ptrr; *(ptrd++) = (double)*ptri;
21044  }
21045  fftw_execute(data_plan);
21046  ptrd = (double*)data_in;
21047  ptrr = real.ptr(0,0,0,k);
21048  ptri = imag.ptr(0,0,0,k);
21049  if (!invert) for (unsigned int x = 0; x<real.width; ++x, ptrr-=wh-1, ptri-=wh-1)
21050  for (unsigned int y = 0; y<real.height; ++y, ptrr-=whd-w, ptri-=whd-w)
21051  for (unsigned int z = 0; z<real.depth; ++z, ptrr+=wh, ptri+=wh) {
21052  *ptrr = (T)*(ptrd++); *ptri = (T)*(ptrd++);
21053  }
21054  else for (unsigned int x = 0; x<real.width; ++x, ptrr-=wh-1, ptri-=wh-1)
21055  for (unsigned int y = 0; y<real.height; ++y, ptrr-=whd-w, ptri-=whd-w)
21056  for (unsigned int z = 0; z<real.depth; ++z, ptrr+=wh, ptri+=wh) {
21057  *ptrr = (T)(*(ptrd++)/whd); *ptri = (T)(*(ptrd++)/whd);
21058  }
21059  }
21060  fftw_destroy_plan(data_plan);
21061  fftw_free(data_in);
21062 #else
21063  if (real.depth>1) FFT(real,imag,'z',invert);
21064  if (real.height>1) FFT(real,imag,'y',invert);
21065  if (real.width>1) FFT(real,imag,'x',invert);
21066 #endif
21067  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
float real
Definition: gridutil.h:70
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
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.
Definition: CImg.h:20832
CImg<T>& fill ( const T  val)
inline

Fill an image by a value val.

Parameters
val= fill value
Note
All pixel values of the instance image will be initialized by val.

Definition at line 14432 of file CImg.h.

Referenced by CImg< uintT >::_LU(), CImg< uintT >::CImg(), CImg< uintT >::get_fill(), CImg< uintT >::get_stats(), CImg< uintT >::invert(), CImg< uintT >::normalize(), CImg< uintT >::operator=(), CImg< uintT >::pow(), CImg< uintT >::solve(), and CImg< uintT >::translate().

14432  {
14433  if (is_empty()) return *this;
14434  if (val && sizeof(T)!=1) cimg_for(*this,ptr,T) *ptr = val;
14435  else std::memset(data,(int)val,size()*sizeof(T));
14436  return *this;
14437  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& fill ( const T  val0,
const T  val1 
)
inline

Fill sequentially all pixel values with values val0 and val1 respectively.

Definition at line 14444 of file CImg.h.

14444  {
14445  if (is_empty()) return *this;
14446  T *ptr, *ptr_end = end()-1;
14447  for (ptr = data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; }
14448  if (ptr!=ptr_end+1) *(ptr++) = val0;
14449  return *this;
14450  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const T  val0,
const T  val1,
const T  val2 
)
inline

Fill sequentially all pixel values with values val0 and val1 and val2.

Definition at line 14457 of file CImg.h.

14457  {
14458  if (is_empty()) return *this;
14459  T *ptr, *ptr_end = end()-2;
14460  for (ptr = data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; }
14461  ptr_end+=2;
14462  switch (ptr_end-ptr) {
14463  case 2 : *(--ptr_end) = val1;
14464  case 1 : *(--ptr_end) = val0;
14465  }
14466  return *this;
14467  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3 
)
inline

Fill sequentially all pixel values with values val0 and val1 and val2 and val3.

Definition at line 14474 of file CImg.h.

14474  {
14475  if (is_empty()) return *this;
14476  T *ptr, *ptr_end = end()-3;
14477  for (ptr = data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; }
14478  ptr_end+=3;
14479  switch (ptr_end-ptr) {
14480  case 3 : *(--ptr_end) = val2;
14481  case 2 : *(--ptr_end) = val1;
14482  case 1 : *(--ptr_end) = val0;
14483  }
14484  return *this;
14485  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3,
const T  val4 
)
inline

Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4.

Definition at line 14492 of file CImg.h.

14492  {
14493  if (is_empty()) return *this;
14494  T *ptr, *ptr_end = end()-4;
14495  for (ptr = data; ptr<ptr_end; ) { *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; }
14496  ptr_end+=4;
14497  switch (ptr_end-ptr) {
14498  case 4 : *(--ptr_end) = val3;
14499  case 3 : *(--ptr_end) = val2;
14500  case 2 : *(--ptr_end) = val1;
14501  case 1 : *(--ptr_end) = val0;
14502  }
14503  return *this;
14504  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3,
const T  val4,
const T  val5 
)
inline

Fill sequentially all pixel values with values val0 and val1 and val2 and val3 and val4 and val5.

Definition at line 14511 of file CImg.h.

14511  {
14512  if (is_empty()) return *this;
14513  T *ptr, *ptr_end = end()-5;
14514  for (ptr = data; ptr<ptr_end; ) {
14515  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14516  }
14517  ptr_end+=5;
14518  switch (ptr_end-ptr) {
14519  case 5 : *(--ptr_end) = val4;
14520  case 4 : *(--ptr_end) = val3;
14521  case 3 : *(--ptr_end) = val2;
14522  case 2 : *(--ptr_end) = val1;
14523  case 1 : *(--ptr_end) = val0;
14524  }
14525  return *this;
14526  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3,
const T  val4,
const T  val5,
const T  val6 
)
inline

Fill sequentially pixel values.

Definition at line 14533 of file CImg.h.

14533  {
14534  if (is_empty()) return *this;
14535  T *ptr, *ptr_end = end()-6;
14536  for (ptr = data; ptr<ptr_end; ) {
14537  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6;
14538  }
14539  ptr_end+=6;
14540  switch (ptr_end-ptr) {
14541  case 6 : *(--ptr_end) = val5;
14542  case 5 : *(--ptr_end) = val4;
14543  case 4 : *(--ptr_end) = val3;
14544  case 3 : *(--ptr_end) = val2;
14545  case 2 : *(--ptr_end) = val1;
14546  case 1 : *(--ptr_end) = val0;
14547  }
14548  return *this;
14549  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14556 of file CImg.h.

14557  {
14558  if (is_empty()) return *this;
14559  T *ptr, *ptr_end = end()-7;
14560  for (ptr = data; ptr<ptr_end; ) {
14561  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3;
14562  *(ptr++) = val4; *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7;
14563  }
14564  ptr_end+=7;
14565  switch (ptr_end-ptr) {
14566  case 7 : *(--ptr_end) = val6;
14567  case 6 : *(--ptr_end) = val5;
14568  case 5 : *(--ptr_end) = val4;
14569  case 4 : *(--ptr_end) = val3;
14570  case 3 : *(--ptr_end) = val2;
14571  case 2 : *(--ptr_end) = val1;
14572  case 1 : *(--ptr_end) = val0;
14573  }
14574  return *this;
14575  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14583 of file CImg.h.

14584  {
14585  if (is_empty()) return *this;
14586  T *ptr, *ptr_end = end()-8;
14587  for (ptr = data; ptr<ptr_end; ) {
14588  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2;
14589  *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14590  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8;
14591  }
14592  ptr_end+=8;
14593  switch (ptr_end-ptr) {
14594  case 8 : *(--ptr_end) = val7;
14595  case 7 : *(--ptr_end) = val6;
14596  case 6 : *(--ptr_end) = val5;
14597  case 5 : *(--ptr_end) = val4;
14598  case 4 : *(--ptr_end) = val3;
14599  case 3 : *(--ptr_end) = val2;
14600  case 2 : *(--ptr_end) = val1;
14601  case 1 : *(--ptr_end) = val0;
14602  }
14603  return *this;
14604  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14612 of file CImg.h.

14613  {
14614  if (is_empty()) return *this;
14615  T *ptr, *ptr_end = end()-9;
14616  for (ptr = data; ptr<ptr_end; ) {
14617  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4;
14618  *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9;
14619  }
14620  ptr_end+=9;
14621  switch (ptr_end-ptr) {
14622  case 9 : *(--ptr_end) = val8;
14623  case 8 : *(--ptr_end) = val7;
14624  case 7 : *(--ptr_end) = val6;
14625  case 6 : *(--ptr_end) = val5;
14626  case 5 : *(--ptr_end) = val4;
14627  case 4 : *(--ptr_end) = val3;
14628  case 3 : *(--ptr_end) = val2;
14629  case 2 : *(--ptr_end) = val1;
14630  case 1 : *(--ptr_end) = val0;
14631  }
14632  return *this;
14633  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14641 of file CImg.h.

14642  {
14643  if (is_empty()) return *this;
14644  T *ptr, *ptr_end = end()-10;
14645  for (ptr = data; ptr<ptr_end; ) {
14646  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4;
14647  *(ptr++) = val5; *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9;
14648  *(ptr++) = val10;
14649  }
14650  ptr_end+=10;
14651  switch (ptr_end-ptr) {
14652  case 10 : *(--ptr_end) = val9;
14653  case 9 : *(--ptr_end) = val8;
14654  case 8 : *(--ptr_end) = val7;
14655  case 7 : *(--ptr_end) = val6;
14656  case 6 : *(--ptr_end) = val5;
14657  case 5 : *(--ptr_end) = val4;
14658  case 4 : *(--ptr_end) = val3;
14659  case 3 : *(--ptr_end) = val2;
14660  case 2 : *(--ptr_end) = val1;
14661  case 1 : *(--ptr_end) = val0;
14662  }
14663  return *this;
14664  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14672 of file CImg.h.

14673  {
14674  if (is_empty()) return *this;
14675  T *ptr, *ptr_end = end()-11;
14676  for (ptr = data; ptr<ptr_end; ) {
14677  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14678  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14679  }
14680  ptr_end+=11;
14681  switch (ptr_end-ptr) {
14682  case 11 : *(--ptr_end) = val10;
14683  case 10 : *(--ptr_end) = val9;
14684  case 9 : *(--ptr_end) = val8;
14685  case 8 : *(--ptr_end) = val7;
14686  case 7 : *(--ptr_end) = val6;
14687  case 6 : *(--ptr_end) = val5;
14688  case 5 : *(--ptr_end) = val4;
14689  case 4 : *(--ptr_end) = val3;
14690  case 3 : *(--ptr_end) = val2;
14691  case 2 : *(--ptr_end) = val1;
14692  case 1 : *(--ptr_end) = val0;
14693  }
14694  return *this;
14695  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14703 of file CImg.h.

14704  {
14705  if (is_empty()) return *this;
14706  T *ptr, *ptr_end = end()-12;
14707  for (ptr = data; ptr<ptr_end; ) {
14708  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14709  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14710  *(ptr++) = val12;
14711  }
14712  ptr_end+=12;
14713  switch (ptr_end-ptr) {
14714  case 12 : *(--ptr_end) = val11;
14715  case 11 : *(--ptr_end) = val10;
14716  case 10 : *(--ptr_end) = val9;
14717  case 9 : *(--ptr_end) = val8;
14718  case 8 : *(--ptr_end) = val7;
14719  case 7 : *(--ptr_end) = val6;
14720  case 6 : *(--ptr_end) = val5;
14721  case 5 : *(--ptr_end) = val4;
14722  case 4 : *(--ptr_end) = val3;
14723  case 3 : *(--ptr_end) = val2;
14724  case 2 : *(--ptr_end) = val1;
14725  case 1 : *(--ptr_end) = val0;
14726  }
14727  return *this;
14728  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14736 of file CImg.h.

14738  {
14739  if (is_empty()) return *this;
14740  T *ptr, *ptr_end = end()-13;
14741  for (ptr = data; ptr<ptr_end; ) {
14742  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14743  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14744  *(ptr++) = val12; *(ptr++) = val13;
14745  }
14746  ptr_end+=13;
14747  switch (ptr_end-ptr) {
14748  case 13 : *(--ptr_end) = val12;
14749  case 12 : *(--ptr_end) = val11;
14750  case 11 : *(--ptr_end) = val10;
14751  case 10 : *(--ptr_end) = val9;
14752  case 9 : *(--ptr_end) = val8;
14753  case 8 : *(--ptr_end) = val7;
14754  case 7 : *(--ptr_end) = val6;
14755  case 6 : *(--ptr_end) = val5;
14756  case 5 : *(--ptr_end) = val4;
14757  case 4 : *(--ptr_end) = val3;
14758  case 3 : *(--ptr_end) = val2;
14759  case 2 : *(--ptr_end) = val1;
14760  case 1 : *(--ptr_end) = val0;
14761  }
14762  return *this;
14763  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14773 of file CImg.h.

14775  {
14776  if (is_empty()) return *this;
14777  T *ptr, *ptr_end = end()-14;
14778  for (ptr = data; ptr<ptr_end; ) {
14779  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14780  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14781  *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14;
14782  }
14783  ptr_end+=14;
14784  switch (ptr_end-ptr) {
14785  case 14 : *(--ptr_end) = val13;
14786  case 13 : *(--ptr_end) = val12;
14787  case 12 : *(--ptr_end) = val11;
14788  case 11 : *(--ptr_end) = val10;
14789  case 10 : *(--ptr_end) = val9;
14790  case 9 : *(--ptr_end) = val8;
14791  case 8 : *(--ptr_end) = val7;
14792  case 7 : *(--ptr_end) = val6;
14793  case 6 : *(--ptr_end) = val5;
14794  case 5 : *(--ptr_end) = val4;
14795  case 4 : *(--ptr_end) = val3;
14796  case 3 : *(--ptr_end) = val2;
14797  case 2 : *(--ptr_end) = val1;
14798  case 1 : *(--ptr_end) = val0;
14799  }
14800  return *this;
14801  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inline

Fill sequentially pixel values.

Definition at line 14811 of file CImg.h.

14813  {
14814  if (is_empty()) return *this;
14815  T *ptr, *ptr_end = end()-15;
14816  for (ptr = data; ptr<ptr_end; ) {
14817  *(ptr++) = val0; *(ptr++) = val1; *(ptr++) = val2; *(ptr++) = val3; *(ptr++) = val4; *(ptr++) = val5;
14818  *(ptr++) = val6; *(ptr++) = val7; *(ptr++) = val8; *(ptr++) = val9; *(ptr++) = val10; *(ptr++) = val11;
14819  *(ptr++) = val12; *(ptr++) = val13; *(ptr++) = val14; *(ptr++) = val15;
14820  }
14821  ptr_end+=15;
14822  switch (ptr_end-ptr) {
14823  case 15 : *(--ptr_end) = val14;
14824  case 14 : *(--ptr_end) = val13;
14825  case 13 : *(--ptr_end) = val12;
14826  case 12 : *(--ptr_end) = val11;
14827  case 11 : *(--ptr_end) = val10;
14828  case 10 : *(--ptr_end) = val9;
14829  case 9 : *(--ptr_end) = val8;
14830  case 8 : *(--ptr_end) = val7;
14831  case 7 : *(--ptr_end) = val6;
14832  case 6 : *(--ptr_end) = val5;
14833  case 5 : *(--ptr_end) = val4;
14834  case 4 : *(--ptr_end) = val3;
14835  case 3 : *(--ptr_end) = val2;
14836  case 2 : *(--ptr_end) = val1;
14837  case 1 : *(--ptr_end) = val0;
14838  }
14839  return *this;
14840  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& fill ( const char *const  expression,
const bool  repeat_flag 
)
inline

Fill image values according to the given expression, which can be a formula or a list of values.

Definition at line 14850 of file CImg.h.

14850  {
14851  if (is_empty() || !expression || !*expression) return *this;
14852  const unsigned int omode = cimg::exception_mode();
14853  cimg::exception_mode() = 0;
14854  try { // Try to fill values according to a formula.
14855  _cimg_math_parser mp(expression,"fill");
14856  const CImg<T> _base = std::strstr(expression,"i(")?+*this:CImg<T>(), &base = _base?_base:*this;
14857  T *ptrd = data;
14858  cimg_forXYZV(*this,x,y,z,v) *(ptrd++) = (T)mp.eval(base,(double)x,(double)y,(double)z,(double)v);
14859  } catch (CImgException&) { // If failed, try to recognize a list of values.
14860  char item[16384] = { 0 }, sep = 0; const char *nexpression = expression;
14861  unsigned int nb = 0; const unsigned int siz = size();
14862  T *ptrd = data;
14863  for (double val = 0; *nexpression && nb<siz; ++nb) {
14864  const int err = std::sscanf(nexpression,"%4095[ \n\t0-9.e+-]%c",item,&sep);
14865  if (err>0 && std::sscanf(item,"%lf",&val)==1) {
14866  nexpression += std::strlen(item) + (err>1?1:0);
14867  *(ptrd++) = (T)val;
14868  } else break;
14869  }
14870  cimg::exception_mode() = omode;
14871  if (*nexpression)
14872  throw CImgArgumentException("CImg<%s>::fill() : Invalid expression '%s'.",pixel_type(),expression);
14873  if (repeat_flag && nb) for (T *ptrs = data, *const ptr_end = data + siz; ptrd<ptr_end; ++ptrs) *(ptrd++) = *ptrs;
14874  }
14875  cimg::exception_mode() = omode;
14876  return *this;
14877  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
CImg<T>& fill ( const CImg< t > &  values,
const bool  repeat_values = true 
)
inline

Fill image values according to the values found in the specified image.

Definition at line 14885 of file CImg.h.

14885  {
14886  if (is_empty() || !values) return *this;
14887  T *ptrd = data, *ptrd_end = ptrd + size();
14888  for (t *ptrs = values.data, *ptrs_end = ptrs + values.size(); ptrs<ptrs_end && ptrd<ptrd_end; ++ptrs) *(ptrd++) = (T)*ptrs;
14889  if (repeat_values && ptrd<ptrd_end) for (T *ptrs = data; ptrd<ptrd_end; ++ptrs) *(ptrd++) = *ptrs;
14890  return *this;
14891  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T>& fillV ( const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const int  a0,
  ... 
)
inline

Fill image values along the V-axis at the specified pixel position (x,y,z).

Definition at line 14938 of file CImg.h.

14938  {
14939  const unsigned int whz = width*height*depth;
14940  if (x<width && y<height && z<depth) _cimg_fill1(x,y,z,0,whz,dim,int);
14941  return *this;
14942  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillV ( const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const double  a0,
  ... 
)
inline

Definition at line 14944 of file CImg.h.

14944  {
14945  const unsigned int whz = width*height*depth;
14946  if (x<width && y<height && z<depth) _cimg_fill1(x,y,z,0,whz,dim,double);
14947  return *this;
14948  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillX ( const unsigned int  y,
const unsigned int  z,
const unsigned int  v,
const int  a0,
  ... 
)
inline

Fill image values along the X-axis at the specified pixel position (y,z,v).

Definition at line 14899 of file CImg.h.

14899  {
14900 #define _cimg_fill1(x,y,z,v,off,siz,t) { \
14901  va_list ap; va_start(ap,a0); T *ptrd = ptr(x,y,z,v); *ptrd = (T)a0; \
14902  for (unsigned int k = 1; k<siz; ++k) { ptrd+=off; *ptrd = (T)va_arg(ap,t); } \
14903  va_end(ap); }
14904  if (y<height && z<depth && v<dim) _cimg_fill1(0,y,z,v,1,width,int);
14905  return *this;
14906  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillX ( const unsigned int  y,
const unsigned int  z,
const unsigned int  v,
const double  a0,
  ... 
)
inline

Definition at line 14908 of file CImg.h.

14908  {
14909  if (y<height && z<depth && v<dim) _cimg_fill1(0,y,z,v,1,width,double);
14910  return *this;
14911  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillY ( const unsigned int  x,
const unsigned int  z,
const unsigned int  v,
const int  a0,
  ... 
)
inline

Fill image values along the Y-axis at the specified pixel position (x,z,v).

Definition at line 14914 of file CImg.h.

14914  {
14915  if (x<width && z<depth && v<dim) _cimg_fill1(x,0,z,v,width,height,int);
14916  return *this;
14917  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillY ( const unsigned int  x,
const unsigned int  z,
const unsigned int  v,
const double  a0,
  ... 
)
inline

Definition at line 14919 of file CImg.h.

14919  {
14920  if (x<width && z<depth && v<dim) _cimg_fill1(x,0,z,v,width,height,double);
14921  return *this;
14922  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillZ ( const unsigned int  x,
const unsigned int  y,
const unsigned int  v,
const int  a0,
  ... 
)
inline

Fill image values along the Z-axis at the specified pixel position (x,y,v).

Definition at line 14925 of file CImg.h.

14925  {
14926  const unsigned int wh = width*height;
14927  if (x<width && y<height && v<dim) _cimg_fill1(x,y,0,v,wh,depth,int);
14928  return *this;
14929  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& fillZ ( const unsigned int  x,
const unsigned int  y,
const unsigned int  v,
const double  a0,
  ... 
)
inline

Definition at line 14931 of file CImg.h.

14931  {
14932  const unsigned int wh = width*height;
14933  if (x<width && y<height && v<dim) _cimg_fill1(x,y,0,v,wh,depth,double);
14934  return *this;
14935  }
#define _cimg_fill1(x, y, z, v, off, siz, t)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
const T& front ( ) const
inline

Return reference to the first image pixel (STL-compliant name).

Definition at line 11170 of file CImg.h.

11170  {
11171  return *data;
11172  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
T& front ( )
inline

Definition at line 11174 of file CImg.h.

11174  {
11175  return *data;
11176  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
CImg<Tfloat> get_abs ( ) const
inline

Definition at line 12575 of file CImg.h.

Referenced by cimg_library::abs(), and CImg< uintT >::get_norm().

12575  {
12576  return CImg<Tfloat>(*this,false).abs();
12577  }
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570

Here is the caller graph for this function:

CImg<Tfloat> get_acos ( ) const
inline

Definition at line 12645 of file CImg.h.

Referenced by cimg_library::acos().

12645  {
12646  return CImg<Tfloat>(*this,false).acos();
12647  }
CImg< T > & acos()
Compute the arc-cosine of each pixel value.
Definition: CImg.h:12640

Here is the caller graph for this function:

CImg<_cimg_Tt> get_append ( const CImg< T > &  img,
const char  axis = 'x',
const char  align = 'p' 
) const
inline

Definition at line 18655 of file CImg.h.

Referenced by CImg< uintT >::append(), and CImg< uintT >::get_append().

18655  {
18656  if (is_empty()) return +img;
18657  if (!img) return +*this;
18658  return CImgList<_cimg_Tt>(*this,img).get_append(axis,align);
18659  }
CImg< _cimg_Tt > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
Definition: CImg.h:18655
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864

Here is the caller graph for this function:

CImg<T> get_append ( const CImg< T > &  img,
const char  axis = 'x',
const char  align = 'p' 
) const
inline

Definition at line 18661 of file CImg.h.

18661  {
18662  if (is_empty()) return +img;
18663  if (!img) return +*this;
18664  return CImgList<T>(*this,img,true).get_append(axis,align);
18665  }
CImg< _cimg_Tt > get_append(const CImg< T > &img, const char axis='x', const char align='p') const
Definition: CImg.h:18655
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg<Tfloat> get_asin ( ) const
inline

Definition at line 12655 of file CImg.h.

Referenced by cimg_library::asin().

12655  {
12656  return CImg<Tfloat>(*this,false).asin();
12657  }
CImg< T > & asin()
Compute the arc-sinus of each pixel value.
Definition: CImg.h:12650

Here is the caller graph for this function:

CImg<Tfloat> get_atan ( ) const
inline

Definition at line 12665 of file CImg.h.

Referenced by cimg_library::atan().

12665  {
12666  return CImg<Tfloat>(*this,false).atan();
12667  }
CImg< T > & atan()
Compute the arc-tangent of each pixel.
Definition: CImg.h:12660

Here is the caller graph for this function:

CImg<Tfloat> get_atan2 ( const CImg< t > &  img) const
inline

Definition at line 12679 of file CImg.h.

12679  {
12680  return CImg<Tfloat>(*this,false).atan2(img);
12681  }
CImg< T > & atan2(const CImg< t > &img)
Compute the arc-tangent of each pixel.
Definition: CImg.h:12671
CImg<T> get_autocrop ( const T  value,
const char *const  axes = "vzyx" 
) const
inline

Definition at line 18297 of file CImg.h.

Referenced by CImg< uintT >::autocrop(), and CImg< uintT >::get_autocrop().

18297  {
18298  return (+*this).autocrop(value,axes);
18299  }

Here is the caller graph for this function:

CImg<T> get_autocrop ( const T *const  color,
const char *const  axes = "zyx" 
) const
inline

Definition at line 18342 of file CImg.h.

18342  {
18343  return (+*this).autocrop(color,axes);
18344  }
CImg<T> get_autocrop ( const CImg< t > &  color,
const char *const  axes = "zyx" 
) const
inline

Definition at line 18351 of file CImg.h.

18351  {
18352  return get_autocrop(color.data,axes);
18353  }
CImg< T > get_autocrop(const T value, const char *const axes="vzyx") const
Definition: CImg.h:18297
CImg<Tuchar> get_BayertoRGB ( const unsigned int  interpolation_type = 3) const
inline

Definition at line 16498 of file CImg.h.

Referenced by CImg< uintT >::BayertoRGB().

16498  {
16499  if (is_empty()) return *this;
16500  if (dim!=1)
16501  throw CImgInstanceException("CImg<%s>::BayertoRGB() : Input image dimension is dim=%u, "
16502  "should be a Bayer image (dim=1)",
16503  pixel_type(),dim);
16504  CImg<Tuchar> res(width,height,depth,3);
16505  CImg_3x3(I,T);
16506  Tuchar *pR = res.ptr(0,0,0,0), *pG = res.ptr(0,0,0,1), *pB = res.ptr(0,0,0,2);
16507  switch (interpolation_type) {
16508  case 3 : { // Edge-directed
16509  CImg_3x3(R,T);
16510  CImg_3x3(G,T);
16511  CImg_3x3(B,T);
16512  cimg_forXYZ(*this,x,y,z) {
16513  const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1;
16514  cimg_get3x3(*this,x,y,z,0,I);
16515  if (y%2) {
16516  if (x%2) {
16517  const Tfloat alpha = cimg::sqr((Tfloat)Inc - Ipc), beta = cimg::sqr((Tfloat)Icn - Icp), cx = 1/(1+alpha), cy = 1/(1+beta);
16518  *pG = (Tuchar)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy)));
16519  } else *pG = (Tuchar)Icc;
16520  } else {
16521  if (x%2) *pG = (Tuchar)Icc;
16522  else {
16523  const Tfloat alpha = cimg::sqr((Tfloat)Inc - Ipc), beta = cimg::sqr((Tfloat)Icn - Icp), cx = 1/(1+alpha), cy = 1/(1+beta);
16524  *pG = (Tuchar)((cx*(Inc+Ipc) + cy*(Icn+Icp))/(2*(cx+cy)));
16525  }
16526  }
16527  ++pG;
16528  }
16529  cimg_forXYZ(*this,x,y,z) {
16530  const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1;
16531  cimg_get3x3(*this,x,y,z,0,I);
16532  cimg_get3x3(res,x,y,z,1,G);
16533  if (y%2) {
16534  if (x%2) *pB = (Tuchar)Icc;
16535  else { *pR = (Tuchar)((Icn+Icp)/2); *pB = (Tuchar)((Inc+Ipc)/2); }
16536  } else {
16537  if (x%2) { *pR = (Tuchar)((Inc+Ipc)/2); *pB = (Tuchar)((Icn+Icp)/2); }
16538  else *pR = (Tuchar)Icc;
16539  }
16540  ++pR; ++pB;
16541  }
16542  pR = res.ptr(0,0,0,0);
16543  pG = res.ptr(0,0,0,1);
16544  pB = res.ptr(0,0,0,2);
16545  cimg_forXYZ(*this,x,y,z) {
16546  const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1;
16547  cimg_get3x3(res,x,y,z,0,R);
16548  cimg_get3x3(res,x,y,z,1,G);
16549  cimg_get3x3(res,x,y,z,2,B);
16550  if (y%2) {
16551  if (x%2) {
16552  const float alpha = (float)cimg::sqr(Rnc-Rpc), beta = (float)cimg::sqr(Rcn-Rcp), cx = 1/(1+alpha), cy = 1/(1+beta);
16553  *pR = (Tuchar)((cx*(Rnc+Rpc) + cy*(Rcn+Rcp))/(2*(cx+cy)));
16554  }
16555  } else {
16556  if (!(x%2)) {
16557  const float alpha = (float)cimg::sqr(Bnc-Bpc), beta = (float)cimg::sqr(Bcn-Bcp), cx = 1/(1+alpha), cy = 1/(1+beta);
16558  *pB = (Tuchar)((cx*(Bnc+Bpc) + cy*(Bcn+Bcp))/(2*(cx+cy)));
16559  }
16560  }
16561  ++pR; ++pG; ++pB;
16562  }
16563  } break;
16564  case 2 : { // Linear interpolation
16565  cimg_forXYZ(*this,x,y,z) {
16566  const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1;
16567  cimg_get3x3(*this,x,y,z,0,I);
16568  if (y%2) {
16569  if (x%2) { *pR = (Tuchar)((Ipp+Inn+Ipn+Inp)/4); *pG = (Tuchar)((Inc+Ipc+Icn+Icp)/4); *pB = (Tuchar)Icc; }
16570  else { *pR = (Tuchar)((Icp+Icn)/2); *pG = (Tuchar)Icc; *pB = (Tuchar)((Inc+Ipc)/2); }
16571  } else {
16572  if (x%2) { *pR = (Tuchar)((Ipc+Inc)/2); *pG = (Tuchar)Icc; *pB = (Tuchar)((Icn+Icp)/2); }
16573  else { *pR = (Tuchar)Icc; *pG = (Tuchar)((Inc+Ipc+Icn+Icp)/4); *pB = (Tuchar)((Ipp+Inn+Ipn+Inp)/4); }
16574  }
16575  ++pR; ++pG; ++pB;
16576  }
16577  } break;
16578  case 1 : { // Nearest neighbor interpolation
16579  cimg_forXYZ(*this,x,y,z) {
16580  const int _p1x = x?x-1:1, _p1y = y?y-1:1, _n1x = x<dimx()-1?x+1:x-1, _n1y = y<dimy()-1?y+1:y-1;
16581  cimg_get3x3(*this,x,y,z,0,I);
16582  if (y%2) {
16583  if (x%2) { *pR = (Tuchar)cimg::min(Ipp,Inn,Ipn,Inp); *pG = (Tuchar)cimg::min(Inc,Ipc,Icn,Icp); *pB = (Tuchar)Icc; }
16584  else { *pR = (Tuchar)cimg::min(Icn,Icp); *pG = (Tuchar)Icc; *pB = (Tuchar)cimg::min(Inc,Ipc); }
16585  } else {
16586  if (x%2) { *pR = (Tuchar)cimg::min(Inc,Ipc); *pG = (Tuchar)Icc; *pB = (Tuchar)cimg::min(Icn,Icp); }
16587  else { *pR = (Tuchar)Icc; *pG = (Tuchar)cimg::min(Inc,Ipc,Icn,Icp); *pB = (Tuchar)cimg::min(Ipp,Inn,Ipn,Inp); }
16588  }
16589  ++pR; ++pG; ++pB;
16590  }
16591  } break;
16592  default : { // 0-filling interpolation
16593  const T *ptrs = data;
16594  res.fill(0);
16595  cimg_forXYZ(*this,x,y,z) {
16596  const T val = *(ptrs++);
16597  if (y%2) { if (x%2) *pB = val; else *pG = val; } else { if (x%2) *pG = val; else *pR = val; }
16598  ++pR; ++pG; ++pB;
16599  }
16600  }
16601  }
16602  return res;
16603  }
cimg::superset< T, unsigned char >::type Tuchar
Definition: CImg.h:9773
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_get3x3(img, x, y, z, v, I)
Definition: CImg.h:484
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T sqr(const T val)
Return the square of a number.
Definition: CImg.h:4717
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_blur ( const float  sigmax,
const float  sigmay,
const float  sigmaz,
const bool  cond = true 
) const
inline

Definition at line 19220 of file CImg.h.

Referenced by CImg< uintT >::get_blur_patch(), and CImg< uintT >::sharpen().

19220  {
19221  return CImg<Tfloat>(*this,false).blur(sigmax,sigmay,sigmaz,cond);
19222  }
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.
Definition: CImg.h:19211

Here is the caller graph for this function:

CImg<Tfloat> get_blur ( const float  sigma,
const bool  cond = true 
) const
inline

Definition at line 19230 of file CImg.h.

19230  {
19231  return CImg<Tfloat>(*this,false).blur(sigma,cond);
19232  }
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.
Definition: CImg.h:19211
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 unsigned int  fast_approx = 1 
) const
inline

Definition at line 19500 of file CImg.h.

19503  {
19504  return (+*this).blur_anisotropic(G,amplitude,dl,da,gauss_prec,interpolation_type,fast_approx);
19505  }
CImg<T> get_blur_anisotropic ( const float  amplitude,
const float  sharpness = 0.7f,
const float  anisotropy = 0.3f,
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 unsigned int  fast_approx = 1 
) const
inline

Definition at line 19516 of file CImg.h.

19519  {
19520  return (+*this).blur_anisotropic(amplitude,sharpness,anisotropy,alpha,sigma,dl,da,gauss_prec,interpolation_type,fast_approx);
19521  }
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
inline

Definition at line 19614 of file CImg.h.

19616  {
19617  return (+*this).blur_bilateral(sigma_x,sigma_y,sigma_z,sigma_r,bgrid_x,bgrid_y,bgrid_z,bgrid_r,interpolation_type);
19618  }
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
inline

Definition at line 19627 of file CImg.h.

19628  {
19629  return (+*this).blur_bilateral(sigma_s,sigma_s,sigma_s,sigma_r,bgrid_s,bgrid_s,bgrid_s,bgrid_r,interpolation_type);
19630  }
CImg<T> get_blur_median ( const unsigned int  n) const
inline

Definition at line 19815 of file CImg.h.

Referenced by CImg< uintT >::blur_median().

19815  {
19816  CImg<T> res(width,height,depth,dim);
19817  if (!n || n==1) return *this;
19818  const int hl=n/2, hr=hl-1+n%2;
19819  if (res.depth!=1) { // 3D median filter
19820  CImg<T> vois;
19821  cimg_forXYZV(*this,x,y,z,k) {
19822  const int
19823  x0 = x - hl, y0 = y - hl, z0 = z-hl, x1 = x + hr, y1 = y + hr, z1 = z+hr,
19824  nx0 = x0<0?0:x0, ny0 = y0<0?0:y0, nz0 = z0<0?0:z0,
19825  nx1 = x1>=dimx()?dimx()-1:x1, ny1 = y1>=dimy()?dimy()-1:y1, nz1 = z1>=dimz()?dimz()-1:z1;
19826  vois = get_crop(nx0,ny0,nz0,k,nx1,ny1,nz1,k);
19827  res(x,y,z,k) = vois.median();
19828  }
19829  } else {
19830 #define _cimg_median_sort(a,b) if ((a)>(b)) cimg::swap(a,b)
19831  if (res.height!=1) switch (n) { // 2D median filter
19832  case 3 : {
19833  T I[9] = { 0 };
19834  CImg_3x3(J,T);
19835  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
19836  std::memcpy(J,I,9*sizeof(T));
19837  _cimg_median_sort(Jcp, Jnp); _cimg_median_sort(Jcc, Jnc); _cimg_median_sort(Jcn, Jnn);
19838  _cimg_median_sort(Jpp, Jcp); _cimg_median_sort(Jpc, Jcc); _cimg_median_sort(Jpn, Jcn);
19839  _cimg_median_sort(Jcp, Jnp); _cimg_median_sort(Jcc, Jnc); _cimg_median_sort(Jcn, Jnn);
19840  _cimg_median_sort(Jpp, Jpc); _cimg_median_sort(Jnc, Jnn); _cimg_median_sort(Jcc, Jcn);
19841  _cimg_median_sort(Jpc, Jpn); _cimg_median_sort(Jcp, Jcc); _cimg_median_sort(Jnp, Jnc);
19842  _cimg_median_sort(Jcc, Jcn); _cimg_median_sort(Jcc, Jnp); _cimg_median_sort(Jpn, Jcc);
19843  _cimg_median_sort(Jcc, Jnp);
19844  res(x,y,0,k) = Jcc;
19845  }
19846  } break;
19847  case 5 : {
19848  T I[25] = { 0 };
19849  CImg_5x5(J,T);
19850  cimg_forV(*this,k) cimg_for5x5(*this,x,y,0,k,I) {
19851  std::memcpy(J,I,25*sizeof(T));
19852  _cimg_median_sort(Jbb, Jpb); _cimg_median_sort(Jnb, Jab); _cimg_median_sort(Jcb, Jab); _cimg_median_sort(Jcb, Jnb);
19853  _cimg_median_sort(Jpp, Jcp); _cimg_median_sort(Jbp, Jcp); _cimg_median_sort(Jbp, Jpp); _cimg_median_sort(Jap, Jbc);
19854  _cimg_median_sort(Jnp, Jbc); _cimg_median_sort(Jnp, Jap); _cimg_median_sort(Jcc, Jnc); _cimg_median_sort(Jpc, Jnc);
19855  _cimg_median_sort(Jpc, Jcc); _cimg_median_sort(Jbn, Jpn); _cimg_median_sort(Jac, Jpn); _cimg_median_sort(Jac, Jbn);
19856  _cimg_median_sort(Jnn, Jan); _cimg_median_sort(Jcn, Jan); _cimg_median_sort(Jcn, Jnn); _cimg_median_sort(Jpa, Jca);
19857  _cimg_median_sort(Jba, Jca); _cimg_median_sort(Jba, Jpa); _cimg_median_sort(Jna, Jaa); _cimg_median_sort(Jcb, Jbp);
19858  _cimg_median_sort(Jnb, Jpp); _cimg_median_sort(Jbb, Jpp); _cimg_median_sort(Jbb, Jnb); _cimg_median_sort(Jab, Jcp);
19859  _cimg_median_sort(Jpb, Jcp); _cimg_median_sort(Jpb, Jab); _cimg_median_sort(Jpc, Jac); _cimg_median_sort(Jnp, Jac);
19860  _cimg_median_sort(Jnp, Jpc); _cimg_median_sort(Jcc, Jbn); _cimg_median_sort(Jap, Jbn); _cimg_median_sort(Jap, Jcc);
19861  _cimg_median_sort(Jnc, Jpn); _cimg_median_sort(Jbc, Jpn); _cimg_median_sort(Jbc, Jnc); _cimg_median_sort(Jba, Jna);
19862  _cimg_median_sort(Jcn, Jna); _cimg_median_sort(Jcn, Jba); _cimg_median_sort(Jpa, Jaa); _cimg_median_sort(Jnn, Jaa);
19863  _cimg_median_sort(Jnn, Jpa); _cimg_median_sort(Jan, Jca); _cimg_median_sort(Jnp, Jcn); _cimg_median_sort(Jap, Jnn);
19864  _cimg_median_sort(Jbb, Jnn); _cimg_median_sort(Jbb, Jap); _cimg_median_sort(Jbc, Jan); _cimg_median_sort(Jpb, Jan);
19865  _cimg_median_sort(Jpb, Jbc); _cimg_median_sort(Jpc, Jba); _cimg_median_sort(Jcb, Jba); _cimg_median_sort(Jcb, Jpc);
19866  _cimg_median_sort(Jcc, Jpa); _cimg_median_sort(Jnb, Jpa); _cimg_median_sort(Jnb, Jcc); _cimg_median_sort(Jnc, Jca);
19867  _cimg_median_sort(Jab, Jca); _cimg_median_sort(Jab, Jnc); _cimg_median_sort(Jac, Jna); _cimg_median_sort(Jbp, Jna);
19868  _cimg_median_sort(Jbp, Jac); _cimg_median_sort(Jbn, Jaa); _cimg_median_sort(Jpp, Jaa); _cimg_median_sort(Jpp, Jbn);
19869  _cimg_median_sort(Jcp, Jpn); _cimg_median_sort(Jcp, Jan); _cimg_median_sort(Jnc, Jpa); _cimg_median_sort(Jbn, Jna);
19870  _cimg_median_sort(Jcp, Jnc); _cimg_median_sort(Jcp, Jbn); _cimg_median_sort(Jpb, Jap); _cimg_median_sort(Jnb, Jpc);
19871  _cimg_median_sort(Jbp, Jcn); _cimg_median_sort(Jpc, Jcn); _cimg_median_sort(Jap, Jcn); _cimg_median_sort(Jab, Jbc);
19872  _cimg_median_sort(Jpp, Jcc); _cimg_median_sort(Jcp, Jac); _cimg_median_sort(Jab, Jpp); _cimg_median_sort(Jab, Jcp);
19873  _cimg_median_sort(Jcc, Jac); _cimg_median_sort(Jbc, Jac); _cimg_median_sort(Jpp, Jcp); _cimg_median_sort(Jbc, Jcc);
19874  _cimg_median_sort(Jpp, Jbc); _cimg_median_sort(Jpp, Jcn); _cimg_median_sort(Jcc, Jcn); _cimg_median_sort(Jcp, Jcn);
19875  _cimg_median_sort(Jcp, Jbc); _cimg_median_sort(Jcc, Jnn); _cimg_median_sort(Jcp, Jcc); _cimg_median_sort(Jbc, Jnn);
19876  _cimg_median_sort(Jcc, Jba); _cimg_median_sort(Jbc, Jba); _cimg_median_sort(Jbc, Jcc);
19877  res(x,y,0,k) = Jcc;
19878  }
19879  } break;
19880  default : {
19881  CImg<T> vois;
19882  cimg_forXYV(*this,x,y,k) {
19883  const int
19884  x0 = x - hl, y0 = y - hl, x1 = x + hr, y1 = y + hr,
19885  nx0 = x0<0?0:x0, ny0 = y0<0?0:y0,
19886  nx1 = x1>=dimx()?dimx()-1:x1, ny1 = y1>=dimy()?dimy()-1:y1;
19887  vois = get_crop(nx0,ny0,0,k,nx1,ny1,0,k);
19888  res(x,y,0,k) = vois.median();
19889  }
19890  }
19891  } else switch (n) { // 1D median filter
19892  case 2 : {
19893  T I[4] = { 0 };
19894  cimg_forV(*this,k) cimg_for2x2(*this,x,y,0,k,I) res(x,0,0,k) = (T)(0.5f*(I[0]+I[1]));
19895  } break;
19896  case 3 : {
19897  T I[9] = { 0 };
19898  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
19899  res(x,0,0,k) = I[3]<I[4]?
19900  (I[4]<I[5]?I[4]:
19901  (I[3]<I[5]?I[5]:I[3])):
19902  (I[3]<I[5]?I[3]:
19903  (I[4]<I[5]?I[5]:I[4]));
19904  }
19905  } break;
19906  default : {
19907  CImg<T> vois;
19908  cimg_forXV(*this,x,k) {
19909  const int
19910  x0 = x - hl, x1 = x + hr,
19911  nx0 = x0<0?0:x0, nx1 = x1>=dimx()?dimx()-1:x1;
19912  vois = get_crop(nx0,0,0,k,nx1,0,0,k);
19913  res(x,0,0,k) = vois.median();
19914  }
19915  }
19916  }
19917  }
19918  return res;
19919  }
#define cimg_for5x5(img, x, y, z, v, I)
Definition: CImg.h:1176
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define CImg_5x5(I, T)
Definition: CImg.h:439
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define _cimg_median_sort(a, b)
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
#define cimg_for2x2(img, x, y, z, v, I)
Definition: CImg.h:1053
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
#define cimg_forXV(img, x, v)
Definition: CImg.h:600
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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
inline

Definition at line 19638 of file CImg.h.

Referenced by CImg< uintT >::blur_patch().

19639  {
19640 
19641 #define _cimg_blur_patch3d_fast(N) \
19642  cimg_for##N##XYZ(res,x,y,z) { \
19643  cimg_forV(res,k) cimg_get##N##x##N##x##N(img,x,y,z,k,P.ptr(N3*k)); \
19644  const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2; \
19645  float sum_weights = 0; \
19646  cimg_for_in##N##XYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) if (cimg::abs(img(x,y,z,0)-img(p,q,r,0))<sigma_p3) { \
19647  cimg_forV(res,k) cimg_get##N##x##N##x##N(img,p,q,r,k,Q.ptr(N3*k)); \
19648  float distance2 = 0; \
19649  const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP - (float)*(--pQ); distance2+=dI*dI; } \
19650  distance2/=Pnorm; \
19651  const float dx = (float)p - x, dy = (float)q - y, dz = (float)r - z, \
19652  alldist = distance2 + (dx*dx + dy*dy + dz*dz)/sigma_s2, weight = alldist>3?0.0f:1.0f; \
19653  sum_weights+=weight; \
19654  cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); \
19655  } \
19656  if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights; \
19657  else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k)); \
19658  }
19659 
19660 #define _cimg_blur_patch3d(N) \
19661  cimg_for##N##XYZ(res,x,y,z) { \
19662  cimg_forV(res,k) cimg_get##N##x##N##x##N(img,x,y,z,k,P.ptr(N3*k)); \
19663  const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2; \
19664  float sum_weights = 0; \
19665  cimg_for_in##N##XYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) { \
19666  cimg_forV(res,k) cimg_get##N##x##N##x##N(img,p,q,r,k,Q.ptr(N3*k)); \
19667  float distance2 = 0; \
19668  const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP - (float)*(--pQ); distance2+=dI*dI; } \
19669  distance2/=Pnorm; \
19670  const float dx = (float)p - x, dy = (float)q - y, dz = (float)r - z, \
19671  alldist = distance2 + (dx*dx + dy*dy + dz*dz)/sigma_s2, weight = (float)std::exp(-alldist); \
19672  sum_weights+=weight; \
19673  cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k); \
19674  } \
19675  if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights; \
19676  else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k)); \
19677  }
19678 
19679 #define _cimg_blur_patch2d_fast(N) \
19680  cimg_for##N##XY(res,x,y) { \
19681  cimg_forV(res,k) cimg_get##N##x##N(img,x,y,0,k,P.ptr(N2*k)); \
19682  const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; \
19683  float sum_weights = 0; \
19684  cimg_for_in##N##XY(res,x0,y0,x1,y1,p,q) if (cimg::abs(img(x,y,0,0)-img(p,q,0,0))<sigma_p3) { \
19685  cimg_forV(res,k) cimg_get##N##x##N(img,p,q,0,k,Q.ptr(N2*k)); \
19686  float distance2 = 0; \
19687  const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } \
19688  distance2/=Pnorm; \
19689  const float dx = (float)p-x, dy = (float)q-y, \
19690  alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = alldist>3?0.0f:1.0f; \
19691  sum_weights+=weight; \
19692  cimg_forV(res,k) res(x,y,k)+=weight*(*this)(p,q,k); \
19693  } \
19694  if (sum_weights>0) cimg_forV(res,k) res(x,y,k)/=sum_weights; \
19695  else cimg_forV(res,k) res(x,y,k) = (Tfloat)((*this)(x,y,k)); \
19696  }
19697 
19698 #define _cimg_blur_patch2d(N) \
19699  cimg_for##N##XY(res,x,y) { \
19700  cimg_forV(res,k) cimg_get##N##x##N(img,x,y,0,k,P.ptr(N2*k)); \
19701  const int x0 = x-rsize1, y0 = y-rsize1, x1 = x+rsize2, y1 = y+rsize2; \
19702  float sum_weights = 0; \
19703  cimg_for_in##N##XY(res,x0,y0,x1,y1,p,q) { \
19704  cimg_forV(res,k) cimg_get##N##x##N(img,p,q,0,k,Q.ptr(N2*k)); \
19705  float distance2 = 0; \
19706  const T *pQ = Q.end(); cimg_for(P,pP,T) { const float dI = (float)*pP-(float)*(--pQ); distance2+=dI*dI; } \
19707  distance2/=Pnorm; \
19708  const float dx = (float)p-x, dy = (float)q-y, \
19709  alldist = distance2 + (dx*dx+dy*dy)/sigma_s2, weight = (float)std::exp(-alldist); \
19710  sum_weights+=weight; \
19711  cimg_forV(res,k) res(x,y,k)+=weight*(*this)(p,q,k); \
19712  } \
19713  if (sum_weights>0) cimg_forV(res,k) res(x,y,k)/=sum_weights; \
19714  else cimg_forV(res,k) res(x,y,k) = (Tfloat)((*this)(x,y,k)); \
19715  }
19716 
19717  CImg<Tfloat> res(width,height,depth,dim,0);
19718  const CImg<T> _img = smoothness>0?get_blur(smoothness):CImg<Tfloat>(),&img = smoothness>0?_img:*this;
19719  CImg<T> P(patch_size*patch_size*dim), Q(P);
19720  const float
19721  nsigma_s = sigma_s>=0?sigma_s:-sigma_s*cimg::max(width,height,depth)/100,
19722  sigma_s2 = nsigma_s*nsigma_s, sigma_p2 = sigma_p*sigma_p, sigma_p3 = 3*sigma_p,
19723  Pnorm = P.size()*sigma_p2;
19724  const int rsize2 = (int)lookup_size/2, rsize1 = rsize2-1+(lookup_size%2);
19725  const unsigned int N2 = patch_size*patch_size, N3 = N2*patch_size;
19726  if (depth>1) switch (patch_size) { // 3D version
19727  case 2 : if (fast_approx) _cimg_blur_patch3d_fast(2) else _cimg_blur_patch3d(2) break;
19728  case 3 : if (fast_approx) _cimg_blur_patch3d_fast(3) else _cimg_blur_patch3d(3) break;
19729  default : {
19730  const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2);
19731  if (fast_approx) cimg_forXYZ(res,x,y,z) { // 3D fast approximation.
19732  P = img.get_crop(x - psize0,y - psize0,z - psize0,x + psize1,y + psize1,z + psize1,true);
19733  const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2;
19734  float sum_weights = 0;
19735  cimg_for_inXYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) if (cimg::abs(img(x,y,z,0)-img(p,q,r,0))<sigma_p3) {
19736  (Q = img.get_crop(p - psize0,q - psize0,r - psize0,p + psize1,q + psize1,r + psize1,true))-=P;
19737  const float
19738  dx = (float)x - p, dy = (float)y - q, dz = (float)z - r,
19739  distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy + dz*dz)/sigma_s2),
19740  weight = distance2>3?0.0f:1.0f;
19741  sum_weights+=weight;
19742  cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k);
19743  }
19744  if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights;
19745  else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k));
19746  } else cimg_forXYZ(res,x,y,z) { // 3D exact algorithm.
19747  P = img.get_crop(x - psize0,y - psize0,z - psize0,x + psize1,y + psize1,z + psize1,true);
19748  const int x0 = x - rsize1, y0 = y - rsize1, z0 = z - rsize1, x1 = x + rsize2, y1 = y + rsize2, z1 = z + rsize2;
19749  float sum_weights = 0;
19750  cimg_for_inXYZ(res,x0,y0,z0,x1,y1,z1,p,q,r) {
19751  (Q = img.get_crop(p - psize0,q - psize0,r - psize0,p + psize1,q + psize1,r + psize1,true))-=P;
19752  const float
19753  dx = (float)x - p, dy = (float)y - q, dz = (float)z - r,
19754  distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy + dz*dz)/sigma_s2),
19755  weight = (float)std::exp(-distance2);
19756  sum_weights+=weight;
19757  cimg_forV(res,k) res(x,y,z,k)+=weight*(*this)(p,q,r,k);
19758  }
19759  if (sum_weights>0) cimg_forV(res,k) res(x,y,z,k)/=sum_weights;
19760  else cimg_forV(res,k) res(x,y,z,k) = (Tfloat)((*this)(x,y,z,k));
19761  }
19762  }
19763  } else switch (patch_size) { // 2D version
19764  case 2 : if (fast_approx) _cimg_blur_patch2d_fast(2) else _cimg_blur_patch2d(2) break;
19765  case 3 : if (fast_approx) _cimg_blur_patch2d_fast(3) else _cimg_blur_patch2d(3) break;
19766  case 4 : if (fast_approx) _cimg_blur_patch2d_fast(4) else _cimg_blur_patch2d(4) break;
19767  case 5 : if (fast_approx) _cimg_blur_patch2d_fast(5) else _cimg_blur_patch2d(5) break;
19768  case 6 : if (fast_approx) _cimg_blur_patch2d_fast(6) else _cimg_blur_patch2d(6) break;
19769  case 7 : if (fast_approx) _cimg_blur_patch2d_fast(7) else _cimg_blur_patch2d(7) break;
19770  case 8 : if (fast_approx) _cimg_blur_patch2d_fast(8) else _cimg_blur_patch2d(8) break;
19771  case 9 : if (fast_approx) _cimg_blur_patch2d_fast(9) else _cimg_blur_patch2d(9) break;
19772  default : {
19773  const int psize1 = (int)patch_size/2, psize0 = psize1-1+(patch_size%2);
19774  if (fast_approx) cimg_forXY(res,x,y) { // 2D fast approximation.
19775  P = img.get_crop(x - psize0,y - psize0,x + psize1,y + psize1,true);
19776  const int x0 = x - rsize1, y0 = y - rsize1, x1 = x + rsize2, y1 = y + rsize2;
19777  float sum_weights = 0;
19778  cimg_for_inXY(res,x0,y0,x1,y1,p,q) if (cimg::abs(img(x,y,0,0)-img(p,q,0,0))<sigma_p3) {
19779  (Q = img.get_crop(p - psize0,q - psize0,p + psize1,q + psize1,true))-=P;
19780  const float
19781  dx = (float)x - p, dy = (float)y - q,
19782  distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy)/sigma_s2),
19783  weight = distance2>3?0.0f:1.0f;
19784  sum_weights+=weight;
19785  cimg_forV(res,k) res(x,y,0,k)+=weight*(*this)(p,q,0,k);
19786  }
19787  if (sum_weights>0) cimg_forV(res,k) res(x,y,0,k)/=sum_weights;
19788  else cimg_forV(res,k) res(x,y,0,k) = (Tfloat)((*this)(x,y,0,k));
19789  } else cimg_forXY(res,x,y) { // 2D exact algorithm.
19790  P = img.get_crop(x - psize0,y - psize0,x + psize1,y + psize1,true);
19791  const int x0 = x - rsize1, y0 = y - rsize1, x1 = x + rsize2, y1 = y + rsize2;
19792  float sum_weights = 0;
19793  cimg_for_inXY(res,x0,y0,x1,y1,p,q) {
19794  (Q = img.get_crop(p - psize0,q - psize0,p + psize1,q + psize1,true))-=P;
19795  const float
19796  dx = (float)x - p, dy = (float)y - q,
19797  distance2 = (float)(Q.pow(2).sum()/Pnorm + (dx*dx + dy*dy)/sigma_s2),
19798  weight = (float)std::exp(-distance2);
19799  sum_weights+=weight;
19800  cimg_forV(res,k) res(x,y,0,k)+=weight*(*this)(p,q,0,k);
19801  }
19802  if (sum_weights>0) cimg_forV(res,k) res(x,y,0,k)/=sum_weights;
19803  else cimg_forV(res,k) res(x,y,0,k) = (Tfloat)((*this)(x,y,0,k));
19804  }
19805  }
19806  }
19807  return res;
19808  }
if(dy > dx)
#define _cimg_blur_patch3d_fast(N)
CImg< _cimg_Tfloat > exp(const CImg< T > &instance)
Definition: CImg.h:6016
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
#define _cimg_blur_patch2d(N)
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
void int int int REAL REAL REAL * z
Definition: write.cpp:76
#define cimg_for_inXYZ(img, x0, y0, z0, x1, y1, z1, x, y, z)
Definition: CImg.h:621
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
#define _cimg_blur_patch3d(N)
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
CImg< Tfloat > get_blur(const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) const
Definition: CImg.h:19220
#define cimg_forV(img, v)
Definition: CImg.h:596
#define _cimg_blur_patch2d_fast(N)
NT dy
NT q
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_for_inXY(img, x0, y0, x1, y1, x, y)
Definition: CImg.h:615

Here is the caller graph for this function:

CImg<T> get_channel ( const unsigned int  v0) const
inline

Definition at line 18461 of file CImg.h.

18461  {
18462  return get_channels(v0,v0);
18463  }
CImg< T > get_channels(const unsigned int v0, const unsigned int v1) const
Definition: CImg.h:18470
CImg<T> get_channels ( const unsigned int  v0,
const unsigned int  v1 
) const
inline

Definition at line 18470 of file CImg.h.

Referenced by CImg< uintT >::_get_select(), CImg< uintT >::channels(), and CImg< uintT >::get_channel().

18470  {
18471  return get_crop(0,0,0,(int)v0,dimx()-1,dimy()-1,dimz()-1,(int)v1);
18472  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046

Here is the caller graph for this function:

CImg<Tfloat> get_CMYKtoCMY ( ) const
inline

Definition at line 16215 of file CImg.h.

Referenced by CImg< uintT >::CMYKtoCMY().

16215  {
16216  if (is_empty()) return *this;
16217  if (dim!=4)
16218  throw CImgInstanceException("CImg<%s>::CMYKtoCMY() : Input image dimension is dim=%u, "
16219  "should be a (C,M,Y,K) image (dim=4)",
16220  pixel_type(),dim);
16221  CImg<Tfloat> res(width,height,depth,3);
16222  const T *ps1 = ptr(0,0,0,0), *ps2 = ptr(0,0,0,1), *ps3 = ptr(0,0,0,2), *ps4 = ptr(0,0,0,3);
16223  Tfloat *pd1 = res.ptr(0,0,0,0), *pd2 = res.ptr(0,0,0,1), *pd3 = res.ptr(0,0,0,2);
16224  for (unsigned int N = width*height*depth; N; --N) {
16225  const Tfloat
16226  C = (Tfloat)*ps1,
16227  M = (Tfloat)*ps2,
16228  Y = (Tfloat)*ps3,
16229  K = (Tfloat)*ps4,
16230  K1 = 1 - K;
16231  *(pd1++) = C*K1 + K;
16232  *(pd2++) = M*K1 + K;
16233  *(pd3++) = Y*K1 + K;
16234  }
16235  return res;
16236  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tuchar> get_CMYKtoRGB ( ) const
inline

Definition at line 16459 of file CImg.h.

16459  {
16460  return CImg<Tuchar>(*this,false).CMYKtoRGB();
16461  }
CImg< T > & CMYKtoRGB()
Convert a (C,M,Y,K) image to a (R,G,B) one.
Definition: CImg.h:16455
CImg<Tfloat> get_CMYtoCMYK ( ) const
inline

Definition at line 16185 of file CImg.h.

Referenced by CImg< uintT >::CMYtoCMYK().

16185  {
16186  if (is_empty()) return *this;
16187  if (dim!=3)
16188  throw CImgInstanceException("CImg<%s>::CMYtoCMYK() : Input image dimension is dim=%u, "
16189  "should be a (C,M,Y) image (dim=3)",
16190  pixel_type(),dim);
16191  CImg<Tfloat> res(width,height,depth,4);
16192  const T *ps1 = ptr(0,0,0,0), *ps2 = ptr(0,0,0,1), *ps3 = ptr(0,0,0,2);
16193  Tfloat *pd1 = res.ptr(0,0,0,0), *pd2 = res.ptr(0,0,0,1), *pd3 = res.ptr(0,0,0,2), *pd4 = res.ptr(0,0,0,3);
16194  for (unsigned int N = width*height*depth; N; --N) {
16195  Tfloat
16196  C = (Tfloat)*(ps1++),
16197  M = (Tfloat)*(ps2++),
16198  Y = (Tfloat)*(ps3++),
16199  K = cimg::min(C,M,Y);
16200  if (K==1) C = M = Y = 0;
16201  else { const Tfloat K1 = 1 - K; C = (C - K)/K1; M = (M - K)/K1; Y = (Y - K)/K1; }
16202  *(pd1++) = C;
16203  *(pd2++) = M;
16204  *(pd3++) = Y;
16205  *(pd4++) = K;
16206  }
16207  return res;
16208  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tuchar> get_CMYtoRGB ( ) const
inline

Definition at line 16176 of file CImg.h.

16176  {
16177  return CImg<Tuchar>(*this,false).CMYtoRGB();
16178  }
CImg< T > & CMYtoRGB()
Convert (C,M,Y) pixels of a color image into the (R,G,B) color space.
Definition: CImg.h:16154
CImg<T> get_column ( const unsigned int  x0) const
inline

Definition at line 18407 of file CImg.h.

18407  {
18408  return get_columns(x0,x0);
18409  }
CImg< T > get_columns(const unsigned int x0, const unsigned int x1) const
Definition: CImg.h:18416
CImg<T> get_columns ( const unsigned int  x0,
const unsigned int  x1 
) const
inline

Definition at line 18416 of file CImg.h.

Referenced by CImg< uintT >::columns(), and CImg< uintT >::get_column().

18416  {
18417  return get_crop((int)x0,0,0,0,(int)x1,dimy()-1,dimz()-1,dimv()-1);
18418  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<_cimg_Ttfloat> get_convolve ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_convol = false 
) const
inline

Definition at line 18904 of file CImg.h.

Referenced by CImg< uintT >::convolve().

18905  {
18906  if (is_empty()) return *this;
18907  if (!mask || mask.dim!=1)
18908  throw CImgArgumentException("CImg<%s>::convolve() : Specified mask (%u,%u,%u,%u,%p) is not scalar.",
18909  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18910  return get_correlate(CImg<t>(mask.ptr(),mask.size(),1,1,1,true).get_mirror('x').resize(mask,-1),cond,weighted_convol);
18911  }
CImg< T > get_mirror(const char axis) const
Definition: CImg.h:17212
CImg< _cimg_Ttfloat > get_correlate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_correl=false) const
Definition: CImg.h:18690
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62

Here is the caller graph for this function:

CImg<_cimg_Ttfloat> get_correlate ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_correl = false 
) const
inline

Definition at line 18690 of file CImg.h.

Referenced by CImg< uintT >::correlate(), and CImg< uintT >::get_convolve().

18691  {
18692  if (is_empty()) return *this;
18693  if (!mask || mask.dim!=1)
18694  throw CImgArgumentException("CImg<%s>::correlate() : Specified mask (%u,%u,%u,%u,%p) is not scalar.",
18695  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18696  typedef _cimg_Ttfloat Ttfloat;
18697  CImg<Ttfloat> dest(width,height,depth,dim);
18698  if (cond && mask.width==mask.height && ((mask.depth==1 && mask.width<=5) || (mask.depth==mask.width && mask.width<=3))) {
18699  // A special optimization is done for 2x2, 3x3, 4x4, 5x5, 2x2x2 and 3x3x3 mask (with cond=1)
18700  switch (mask.depth) {
18701  case 3 : {
18702  T I[27] = { 0 };
18703  cimg_forZV(*this,z,v) cimg_for3x3x3(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18704  (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] +
18705  I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] +
18706  I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] +
18707  I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18708  I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] +
18709  I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] +
18710  I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] +
18711  I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] +
18712  I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26]);
18713  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for3x3x3(*this,x,y,z,v,I) {
18714  const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] +
18715  I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] +
18716  I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] +
18717  I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18718  I[12]*I[12] + I[13]*I[13] + I[14]*I[14] +
18719  I[15]*I[15] + I[16]*I[16] + I[17]*I[17] +
18720  I[18]*I[18] + I[19]*I[19] + I[20]*I[20] +
18721  I[21]*I[21] + I[22]*I[22] + I[23]*I[23] +
18722  I[24]*I[24] + I[25]*I[25] + I[26]*I[26]);
18723  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18724  }
18725  } break;
18726  case 2 : {
18727  T I[8] = { 0 };
18728  cimg_forZV(*this,z,v) cimg_for2x2x2(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18729  (I[0]*mask[0] + I[1]*mask[1] +
18730  I[2]*mask[2] + I[3]*mask[3] +
18731  I[4]*mask[4] + I[5]*mask[5] +
18732  I[6]*mask[6] + I[7]*mask[7]);
18733  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for2x2x2(*this,x,y,z,v,I) {
18734  const double weight = (double)(I[0]*I[0] + I[1]*I[1] +
18735  I[2]*I[2] + I[3]*I[3] +
18736  I[4]*I[4] + I[5]*I[5] +
18737  I[6]*I[6] + I[7]*I[7]);
18738  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18739  }
18740  } break;
18741  default :
18742  case 1 :
18743  switch (mask.width) {
18744  case 6 : {
18745  T I[36] = { 0 };
18746  cimg_forZV(*this,z,v) cimg_for6x6(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18747  (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] + I[ 5]*mask[ 5] +
18748  I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18749  I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] +
18750  I[18]*mask[18] + I[19]*mask[19] + I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] +
18751  I[24]*mask[24] + I[25]*mask[25] + I[26]*mask[26] + I[27]*mask[27] + I[28]*mask[28] + I[29]*mask[29] +
18752  I[30]*mask[30] + I[31]*mask[31] + I[32]*mask[32] + I[33]*mask[33] + I[34]*mask[34] + I[35]*mask[35]);
18753  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for5x5(*this,x,y,z,v,I) {
18754  const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] + I[ 5]*I[ 5] +
18755  I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18756  I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15] + I[16]*I[16] + I[17]*I[17] +
18757  I[18]*I[18] + I[19]*I[19] + I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] +
18758  I[24]*I[24] + I[25]*I[25] + I[26]*I[26] + I[27]*I[27] + I[28]*I[28] + I[29]*I[29] +
18759  I[30]*I[30] + I[31]*I[31] + I[32]*I[32] + I[33]*I[33] + I[34]*I[34] + I[35]*I[35]);
18760  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18761  }
18762  } break;
18763  case 5 : {
18764  T I[25] = { 0 };
18765  cimg_forZV(*this,z,v) cimg_for5x5(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18766  (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] + I[ 4]*mask[ 4] +
18767  I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] + I[ 8]*mask[ 8] + I[ 9]*mask[ 9] +
18768  I[10]*mask[10] + I[11]*mask[11] + I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] +
18769  I[15]*mask[15] + I[16]*mask[16] + I[17]*mask[17] + I[18]*mask[18] + I[19]*mask[19] +
18770  I[20]*mask[20] + I[21]*mask[21] + I[22]*mask[22] + I[23]*mask[23] + I[24]*mask[24]);
18771  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for5x5(*this,x,y,z,v,I) {
18772  const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] + I[ 4]*I[ 4] +
18773  I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] + I[ 8]*I[ 8] + I[ 9]*I[ 9] +
18774  I[10]*I[10] + I[11]*I[11] + I[12]*I[12] + I[13]*I[13] + I[14]*I[14] +
18775  I[15]*I[15] + I[16]*I[16] + I[17]*I[17] + I[18]*I[18] + I[19]*I[19] +
18776  I[20]*I[20] + I[21]*I[21] + I[22]*I[22] + I[23]*I[23] + I[24]*I[24]);
18777  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18778  }
18779  } break;
18780  case 4 : {
18781  T I[16] = { 0 };
18782  cimg_forZV(*this,z,v) cimg_for4x4(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18783  (I[ 0]*mask[ 0] + I[ 1]*mask[ 1] + I[ 2]*mask[ 2] + I[ 3]*mask[ 3] +
18784  I[ 4]*mask[ 4] + I[ 5]*mask[ 5] + I[ 6]*mask[ 6] + I[ 7]*mask[ 7] +
18785  I[ 8]*mask[ 8] + I[ 9]*mask[ 9] + I[10]*mask[10] + I[11]*mask[11] +
18786  I[12]*mask[12] + I[13]*mask[13] + I[14]*mask[14] + I[15]*mask[15]);
18787  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for4x4(*this,x,y,z,v,I) {
18788  const double weight = (double)(I[ 0]*I[ 0] + I[ 1]*I[ 1] + I[ 2]*I[ 2] + I[ 3]*I[ 3] +
18789  I[ 4]*I[ 4] + I[ 5]*I[ 5] + I[ 6]*I[ 6] + I[ 7]*I[ 7] +
18790  I[ 8]*I[ 8] + I[ 9]*I[ 9] + I[10]*I[10] + I[11]*I[11] +
18791  I[12]*I[12] + I[13]*I[13] + I[14]*I[14] + I[15]*I[15]);
18792  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18793  }
18794  } break;
18795  case 3 : {
18796  T I[9] = { 0 };
18797  cimg_forZV(*this,z,v) cimg_for3x3(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18798  (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] +
18799  I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] +
18800  I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]);
18801  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for3x3(*this,x,y,z,v,I) {
18802  const double weight = (double)(I[0]*I[0] + I[1]*I[1] + I[2]*I[2] +
18803  I[3]*I[3] + I[4]*I[4] + I[5]*I[5] +
18804  I[6]*I[6] + I[7]*I[7] + I[8]*I[8]);
18805  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18806  }
18807  } break;
18808  case 2 : {
18809  T I[4] = { 0 };
18810  cimg_forZV(*this,z,v) cimg_for2x2(*this,x,y,z,v,I) dest(x,y,z,v) = (Ttfloat)
18811  (I[0]*mask[0] + I[1]*mask[1] +
18812  I[2]*mask[2] + I[3]*mask[3]);
18813  if (weighted_correl) cimg_forZV(*this,z,v) cimg_for2x2(*this,x,y,z,v,I) {
18814  const double weight = (double)(I[0]*I[0] + I[1]*I[1] +
18815  I[2]*I[2] + I[3]*I[3]);
18816  if (weight>0) dest(x,y,z,v)/=(Ttfloat)std::sqrt(weight);
18817  }
18818  } break;
18819  case 1 : (dest.assign(*this))*=mask(0); break;
18820  }
18821  }
18822  } else { // Generic version for other masks
18823  const int
18824  mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
18825  mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
18826  mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2;
18827  cimg_forV(*this,v)
18828  if (!weighted_correl) { // Classical correlation
18829  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
18830  Ttfloat val = 0;
18831  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm)
18832  val+=(*this)(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm);
18833  dest(x,y,z,v) = (Ttfloat)val;
18834  }
18835  if (cond)
18836  cimg_forYZV(*this,y,z,v)
18837  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18838  Ttfloat val = 0;
18839  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm)
18840  val+=_atXYZ(x+xm,y+ym,z+zm,v)*mask(mx1+xm,my1+ym,mz1+zm);
18841  dest(x,y,z,v) = (Ttfloat)val;
18842  }
18843  else
18844  cimg_forYZV(*this,y,z,v)
18845  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18846  Ttfloat val = 0;
18847  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm)
18848  val+=atXYZ(x+xm,y+ym,z+zm,v,0)*mask(mx1+xm,my1+ym,mz1+zm);
18849  dest(x,y,z,v) = (Ttfloat)val;
18850  }
18851  } else { // Weighted correlation
18852  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
18853  Ttfloat val = 0, weight = 0;
18854  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18855  const Ttfloat cval = (Ttfloat)(*this)(x+xm,y+ym,z+zm,v);
18856  val+=cval*mask(mx1+xm,my1+ym,mz1+zm);
18857  weight+=cval*cval;
18858  }
18859  dest(x,y,z,v) = (weight>(Ttfloat)0)?(Ttfloat)(val/std::sqrt((double)weight)):(Ttfloat)0;
18860  }
18861  if (cond)
18862  cimg_forYZV(*this,y,z,v)
18863  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18864  Ttfloat val = 0, weight = 0;
18865  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18866  const Ttfloat cval = (Ttfloat)_atXYZ(x+xm,y+ym,z+zm,v);
18867  val+=cval*mask(mx1+xm,my1+ym,mz1+zm);
18868  weight+=cval*cval;
18869  }
18870  dest(x,y,z,v) = (weight>(Ttfloat)0)?(Ttfloat)(val/std::sqrt((double)weight)):(Ttfloat)0;
18871  }
18872  else
18873  cimg_forYZV(*this,y,z,v)
18874  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18875  Ttfloat val = 0, weight = 0;
18876  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18877  const Ttfloat cval = (Ttfloat)atXYZ(x+xm,y+ym,z+zm,v,0);
18878  val+=cval*mask(mx1+xm,my1+ym,mz1+zm);
18879  weight+=cval*cval;
18880  }
18881  dest(x,y,z,v) = (weight>(Ttfloat)0)?(Ttfloat)(val/std::sqrt((double)weight)):(Ttfloat)0;
18882  }
18883  }
18884  }
18885  return dest;
18886  }
#define cimg_for5x5(img, x, y, z, v, I)
Definition: CImg.h:1176
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define _cimg_Ttfloat
Definition: CImg.h:2302
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
#define cimg_for2x2(img, x, y, z, v, I)
Definition: CImg.h:1053
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
void int int REAL * x
Definition: read.cpp:74
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_for4x4(img, x, y, z, v, I)
Definition: CImg.h:1120
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
Definition: CImg.h:11257
#define cimg_for6x6(img, x, y, z, v, I)
Definition: CImg.h:1247
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define cimg_for2x2x2(img, x, y, z, v, I)
Definition: CImg.h:1774
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

CImg<Tfloat> get_cos ( ) const
inline

Definition at line 12585 of file CImg.h.

Referenced by cimg_library::cos().

12585  {
12586  return CImg<Tfloat>(*this,false).cos();
12587  }
CImg< T > & cos()
Compute the cosinus of each pixel value.
Definition: CImg.h:12580

Here is the caller graph for this function:

CImg<Tfloat> get_cosh ( ) const
inline

Definition at line 12615 of file CImg.h.

Referenced by cimg_library::cosh().

12615  {
12616  return CImg<Tfloat>(*this,false).cosh();
12617  }
CImg< T > & cosh()
Compute the hyperbolic cosine of each pixel value.
Definition: CImg.h:12610

Here is the caller graph for this function:

CImg<T> get_crop ( const int  x0,
const int  y0,
const int  z0,
const int  v0,
const int  x1,
const int  y1,
const int  z1,
const int  v1,
const bool  border_condition = false 
) const
inline

Definition at line 18190 of file CImg.h.

Referenced by CImg< uintT >::_display(), CImg< uintT >::crop(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_channels(), CImg< uintT >::get_columns(), CImg< uintT >::get_crop(), CImg< uintT >::get_index(), CImg< uintT >::get_lines(), CImg< uintT >::get_slices(), and CImg< uintT >::get_split().

18192  {
18193  if (is_empty()) return *this;
18194  const int
18195  nx0 = x0<x1?x0:x1, nx1 = x0^x1^nx0,
18196  ny0 = y0<y1?y0:y1, ny1 = y0^y1^ny0,
18197  nz0 = z0<z1?z0:z1, nz1 = z0^z1^nz0,
18198  nv0 = v0<v1?v0:v1, nv1 = v0^v1^nv0;
18199  CImg<T> dest(1U+nx1-nx0,1U+ny1-ny0,1U+nz1-nz0,1U+nv1-nv0);
18200  if (nx0<0 || nx1>=dimx() || ny0<0 || ny1>=dimy() || nz0<0 || nz1>=dimz() || nv0<0 || nv1>=dimv()) {
18201  if (border_condition) cimg_forXYZV(dest,x,y,z,v) dest(x,y,z,v) = _atXYZV(nx0+x,ny0+y,nz0+z,nv0+v);
18202  else dest.fill(0).draw_image(-nx0,-ny0,-nz0,-nv0,*this);
18203  } else dest.draw_image(-nx0,-ny0,-nz0,-nv0,*this);
18204  return dest;
18205  }
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
void int int REAL REAL * y
Definition: read.cpp:74
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
T & _atXYZV(const int x, const int y, const int z, const int v)
Definition: CImg.h:11246
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

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
inline

Definition at line 18224 of file CImg.h.

18226  {
18227  return get_crop(x0,y0,z0,0,x1,y1,z1,dim-1,border_condition);
18228  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_crop ( const int  x0,
const int  y0,
const int  x1,
const int  y1,
const bool  border_condition = false 
) const
inline

Definition at line 18245 of file CImg.h.

18247  {
18248  return get_crop(x0,y0,0,0,x1,y1,depth-1,dim-1,border_condition);
18249  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_crop ( const int  x0,
const int  x1,
const bool  border_condition = false 
) const
inline

Definition at line 18262 of file CImg.h.

18262  {
18263  return get_crop(x0,0,0,0,x1,height-1,depth-1,dim-1,border_condition);
18264  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<_cimg_Tt> get_cross ( const CImg< t > &  img) const
inline

Definition at line 13469 of file CImg.h.

13469  {
13470  return CImg<_cimg_Tt>(*this).cross(img);
13471  }
CImg<T> get_cut ( const T  value_min,
const T  value_max 
) const
inline

Definition at line 15179 of file CImg.h.

15179  {
15180  return (+*this).cut(value_min,value_max);
15181  }
CImg<Tfloat> get_deriche ( const float  sigma,
const int  order = 0,
const char  axis = 'x',
const bool  cond = true 
) const
inline

Definition at line 19203 of file CImg.h.

Referenced by CImg< uintT >::get_gradient().

19203  {
19204  return CImg<Tfloat>(*this,false).deriche(sigma,order,axis,cond);
19205  }
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.
Definition: CImg.h:19118

Here is the caller graph for this function:

CImg<T> get_diagonal ( ) const
inline

Definition at line 13408 of file CImg.h.

Referenced by CImg< uintT >::diagonal().

13408  {
13409  if (is_empty()) return *this;
13410  CImg<T> res(size(),size(),1,1,0);
13411  cimg_foroff(*this,off) res(off,off) = (*this)(off);
13412  return res;
13413  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_foroff(img, off)
Definition: CImg.h:590

Here is the caller graph for this function:

CImg<T> get_dijkstra ( const unsigned int  starting_node,
const unsigned int  ending_node,
CImg< t > &  previous 
) const
inline

Definition at line 14116 of file CImg.h.

Referenced by CImg< uintT >::dijkstra(), and CImg< uintT >::get_dijkstra().

14116  {
14117  if (width!=height || depth!=1 || dim!=1)
14118  throw CImgInstanceException("CImg<%s>::dijkstra() : Instance image (%u,%u,%u,%u,%p) is not a graph adjacency matrix",
14120  return dijkstra(*this,width,starting_node,ending_node,previous);
14121  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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.
Definition: CImg.h:14048
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_dijkstra ( const unsigned int  starting_node,
const unsigned int  ending_node = ~0U 
) const
inline

Definition at line 14128 of file CImg.h.

14128  {
14129  CImg<uintT> foo;
14130  return get_dijkstra(starting_node,ending_node,foo);
14131  }
CImg< T > get_dijkstra(const unsigned int starting_node, const unsigned int ending_node, CImg< t > &previous) const
Definition: CImg.h:14116
CImg<_cimg_Tt> get_dilate ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_dilatation = false 
) const
inline

Definition at line 19020 of file CImg.h.

Referenced by CImg< uintT >::dilate(), and CImg< uintT >::get_dilate().

19021  {
19022  if (is_empty()) return *this;
19023  if (!mask || mask.dim!=1)
19024  throw CImgArgumentException("CImg<%s>::dilate() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.",
19025  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
19026  typedef _cimg_Tt Tt;
19027  CImg<Tt> dest(width,height,depth,dim);
19028  const int
19029  mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
19030  mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
19031  mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2;
19032  cimg_forV(*this,v)
19033  if (!weighted_dilatation) { // Classical dilatation
19034  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
19035  Tt max_val = cimg::type<Tt>::min();
19036  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19037  const Tt cval = (Tt)(*this)(x+xm,y+ym,z+zm,v);
19038  if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19039  }
19040  dest(x,y,z,v) = max_val;
19041  }
19042  if (cond)
19043  cimg_forYZV(*this,y,z,v)
19044  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19045  Tt max_val = cimg::type<Tt>::min();
19046  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19047  const T cval = (Tt)_atXYZ(x+xm,y+ym,z+zm,v);
19048  if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19049  }
19050  dest(x,y,z,v) = max_val;
19051  }
19052  else
19053  cimg_forYZV(*this,y,z,v)
19054  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19055  Tt max_val = cimg::type<Tt>::min();
19056  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19057  const T cval = (Tt)atXYZ(x+xm,y+ym,z+zm,v,0);
19058  if (mask(mx1+xm,my1+ym,mz1+zm) && cval>max_val) max_val = cval;
19059  }
19060  dest(x,y,z,v) = max_val;
19061  }
19062  } else { // Weighted dilatation
19063  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
19064  Tt max_val = cimg::type<Tt>::min();
19065  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19066  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
19067  const Tt cval = (Tt)((*this)(x+xm,y+ym,z+zm,v) - mval);
19068  if (mval && cval>max_val) max_val = cval;
19069  }
19070  dest(x,y,z,v) = max_val;
19071  }
19072  if (cond)
19073  cimg_forYZV(*this,y,z,v)
19074  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19075  Tt max_val = cimg::type<Tt>::min();
19076  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19077  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
19078  const Tt cval = (Tt)(_atXYZ(x+xm,y+ym,z+zm,v) - mval);
19079  if (mval && cval>max_val) max_val = cval;
19080  }
19081  dest(x,y,z,v) = max_val;
19082  }
19083  else
19084  cimg_forYZV(*this,y,z,v)
19085  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
19086  Tt max_val = cimg::type<Tt>::min();
19087  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
19088  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
19089  const Tt cval = (Tt)(atXYZ(x+xm,y+ym,z+zm,v,0) - mval);
19090  if (mval && cval>max_val) max_val = cval;
19091  }
19092  dest(x,y,z,v) = max_val;
19093  }
19094  }
19095  return dest;
19096  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
void int int REAL * x
Definition: read.cpp:74
#define _cimg_Tt
Definition: CImg.h:2300
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
#define cimg_forV(img, v)
Definition: CImg.h:596
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
Definition: CImg.h:11257
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

CImg<T> get_dilate ( const unsigned int  n,
const unsigned int  cond = 1 
) const
inline

Definition at line 19104 of file CImg.h.

19104  {
19105  static CImg<T> mask;
19106  if (n<2) return *this;
19107  if (mask.width!=n) mask.assign(n,n,1,1,1);
19108  const CImg<T> res = get_dilate(mask,cond,false);
19109  if (n>20) mask.assign();
19110  return res;
19111  }
const NT & n
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg< _cimg_Tt > get_dilate(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_dilatation=false) const
Definition: CImg.h:19020
CImg<Tfloat> get_displacement_field ( const CImg< T > &  target,
const float  smoothness = 0.1f,
const float  precision = 0.1f,
const unsigned int  nb_scales = 0,
const unsigned int  itermax = 1000,
const bool  backward = true 
) const
inline

Definition at line 20337 of file CImg.h.

Referenced by CImg< uintT >::displacement_field().

20340  {
20341  if (is_empty() || !target) return *this;
20342  if (!is_sameXYZV(target))
20343  throw CImgArgumentException("CImg<%s>::displacement_field() : Instance image (%u,%u,%u,%u,%p) and target image (%u,%u,%u,%u,%p) "
20344  "have different size.",
20346  target.width,target.height,target.depth,target.dim,target.data);
20347  if (smoothness<0)
20348  throw CImgArgumentException("CImg<%s>::displacement_field() : Smoothness parameter %g is negative.",
20349  pixel_type(),smoothness);
20350  if (precision<0)
20351  throw CImgArgumentException("CImg<%s>::displacement_field() : Precision parameter %g is negative.",
20352  pixel_type(),precision);
20353 
20354  const unsigned int nscales = nb_scales>0?nb_scales:(unsigned int)(2*std::log((double)(cimg::max(width,height,depth))));
20355  Tfloat m1, M1 = (Tfloat)maxmin(m1), m2, M2 = (Tfloat)target.maxmin(m2);
20356  const Tfloat factor = cimg::max(cimg::abs(m1),cimg::abs(M1),cimg::abs(m2),cimg::abs(M2));
20357  CImg<Tfloat> U0;
20358  const bool threed = (depth>1);
20359 
20360  // Begin multi-scale motion estimation
20361  for (int scale = (int)nscales-1; scale>=0; --scale) {
20362  const float sfactor = (float)std::pow(1.5f,(float)scale), sprecision = (float)(precision/std::pow(2.25,1+scale));
20363  const int
20364  sw = (int)(width/sfactor), sh = (int)(height/sfactor), sd = (int)(depth/sfactor),
20365  swidth = sw?sw:1, sheight = sh?sh:1, sdepth = sd?sd:1;
20366  CImg<Tfloat>
20367  I1 = get_resize(swidth,sheight,sdepth,-100,2),
20368  I2 = target.get_resize(swidth,sheight,sdepth,-100,2);
20369  I1/=factor; I2/=factor;
20370  CImg<Tfloat> U;
20371  if (U0) U = (U0*=1.5f).get_resize(I1.dimx(),I1.dimy(),I1.dimz(),-100,3);
20372  else U.assign(I1.dimx(),I1.dimy(),I1.dimz(),threed?3:2,0);
20373 
20374  // Begin single-scale motion estimation
20375  CImg<Tfloat> veloc(U);
20376  float dt = 2, energy = cimg::type<float>::max();
20377  const CImgList<Tfloat> dI = backward?I1.get_gradient():I2.get_gradient();
20378  for (unsigned int iter = 0; iter<itermax; iter++) {
20379  veloc.fill(0);
20380  float nenergy = 0;
20381  if (threed) {
20382  cimg_for3XYZ(U,x,y,z) {
20383  const float
20384  sgnU = backward?-1.0f:1.0f,
20385  X = (float)(x + sgnU * U(x,y,z,0)),
20386  Y = (float)(y + sgnU * U(x,y,z,1)),
20387  Z = (float)(z + sgnU * U(x,y,z,2));
20388  cimg_forV(U,k) {
20389  const Tfloat
20390  Ux = 0.5f*(U(_n1x,y,z,k) - U(_p1x,y,z,k)),
20391  Uy = 0.5f*(U(x,_n1y,z,k) - U(x,_p1y,z,k)),
20392  Uz = 0.5f*(U(x,y,_n1z,k) - U(x,y,_p1z,k)),
20393  Uxx = U(_n1x,y,z,k) + U(_p1x,y,z,k) - 2*U(x,y,z,k),
20394  Uyy = U(x,_n1y,z,k) + U(x,_p1y,z,k) - 2*U(x,y,z,k),
20395  Uzz = U(x,y,_n1z,k) + U(x,y,_n1z,k) - 2*U(x,y,z,k);
20396  nenergy += (float)(smoothness*(Ux*Ux + Uy*Uy + Uz*Uz));
20397  Tfloat deltaIgrad = 0;
20398  cimg_forV(I1,i) {
20399  const Tfloat deltaIi = (float)(backward?I2(x,y,z,i)-I1._linear_atXYZ(X,Y,Z,i):I2._linear_atXYZ(X,Y,Z,i)-I1(x,y,z,i));
20400  nenergy += (float)(deltaIi*deltaIi/2);
20401  deltaIgrad+=-deltaIi*dI[k]._linear_atXYZ(X,Y,Z,i);
20402  }
20403  veloc(x,y,z,k) = deltaIgrad + smoothness*(Uxx + Uyy + Uzz);
20404  }
20405  }
20406  } else {
20407  cimg_for3XY(U,x,y) {
20408  const float
20409  sgnU = backward?-1.0f:1.0f,
20410  X = (float)(x + sgnU * U(x,y,0)),
20411  Y = (float)(y + sgnU * U(x,y,1));
20412  cimg_forV(U,k) {
20413  const Tfloat
20414  Ux = 0.5f*(U(_n1x,y,k) - U(_p1x,y,k)),
20415  Uy = 0.5f*(U(x,_n1y,k) - U(x,_p1y,k)),
20416  Uxx = U(_n1x,y,k) + U(_p1x,y,k) - 2*U(x,y,k),
20417  Uyy = U(x,_n1y,k) + U(x,_p1y,k) - 2*U(x,y,k);
20418  nenergy += (float)(smoothness*(Ux*Ux + Uy*Uy));
20419  Tfloat deltaIgrad = 0;
20420  cimg_forV(I1,i) {
20421  const Tfloat deltaIi = (float)(backward?I2(x,y,i)-I1.linear_atXY(X,Y,i):I2._linear_atXY(X,Y,i)-I1(x,y,i));
20422  nenergy += (float)(deltaIi*deltaIi/2);
20423  deltaIgrad+=-deltaIi*dI[k]._linear_atXY(X,Y,i);
20424  }
20425  veloc(x,y,k) = deltaIgrad + smoothness*(Uxx + Uyy);
20426  }
20427  }
20428  }
20429  const Tfloat vmax = cimg::max(cimg::abs(veloc.min()), cimg::abs(veloc.max()));
20430  U+=(veloc*=dt/(1e-6+vmax));
20431  if (cimg::abs(nenergy-energy)<sprecision) break;
20432  if (nenergy<energy) dt*=0.5f;
20433  energy = nenergy;
20434  }
20435  U.transfer_to(U0);
20436  }
20437  return U0;
20438  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< _cimg_Tfloat > log(const CImg< T > &instance)
Definition: CImg.h:6021
void int int int REAL REAL REAL * z
Definition: write.cpp:76
#define cimg_for3XYZ(img, x, y, z)
Definition: CImg.h:745
blockLoc i
Definition: read.cpp:79
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
#define cimg_for3XY(img, x, y)
Definition: CImg.h:739
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
bool is_sameXYZV(const unsigned int dx, const unsigned int dy, const unsigned int dz, const unsigned int dv) const
Return true if image (*this) has the specified width, height, depth and number of channels...
Definition: CImg.h:12038
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<floatT> get_distance ( const T  isovalue,
const float  sizex = 1,
const float  sizey = 1,
const float  sizez = 1,
const bool  compute_sqrt = true 
) const
inline

Definition at line 20447 of file CImg.h.

Referenced by CImg< uintT >::distance().

20449  {
20450  if (is_empty()) return *this;
20451  const int dx = dimx(), dy = dimy(), dz = dimz();
20452  CImg<floatT> res(dx,dy,dz,dim);
20453  const float maxdist = (float)std::sqrt((float)dx*dx + dy*dy + dz*dz);
20454  cimg_forV(*this,k) {
20455  bool is_isophote = false;
20456 
20457  if (depth>1) { // 3D version
20458  cimg_forYZ(*this,y,z) {
20459  if ((*this)(0,y,z,k)==isovalue) { is_isophote = true; res(0,y,z,k) = 0; } else res(0,y,z,k) = maxdist;
20460  for (int x = 1; x<dx; ++x) if ((*this)(x,y,z,k)==isovalue) { is_isophote = true; res(x,y,z,k) = 0; }
20461  else res(x,y,z,k) = res(x-1,y,z,k) + sizex;
20462  for (int x = dx-2; x>=0; --x) if (res(x+1,y,z,k)<res(x,y,z,k)) res(x,y,z,k) = res(x+1,y,z,k) + sizex;
20463  }
20464  if (!is_isophote) { res.get_shared_channel(k).fill(cimg::type<floatT>::max()); continue; }
20465  CImg<floatT> tmp(cimg::max(dy,dz));
20466  CImg<intT> s(tmp.width), t(s.width);
20467  cimg_forXZ(*this,x,z) {
20468  cimg_forY(*this,y) tmp[y] = res(x,y,z,k);
20469  int q = s[0] = t[0] = 0;
20470  for (int y = 1; y<dy; ++y) {
20471  const float val = tmp[y], val2 = val*val;
20472  while (q>=0 && _distance_f(t[q],s[q],cimg::sqr(tmp[s[q]]),sizey)>_distance_f(t[q],y,val2,sizey)) --q;
20473  if (q<0) { q = 0; s[0] = y; }
20474  else {
20475  const int w = 1 + _distance_sep(s[q],y,(int)cimg::sqr(tmp[s[q]]),(int)val2,sizey);
20476  if (w<dy) { s[++q] = y; t[q] = w; }
20477  }
20478  }
20479  for (int y = dy - 1; y>=0; --y) {
20480  res(x,y,z,k) = _distance_f(y,s[q],cimg::sqr(tmp[s[q]]),sizey);
20481  if (y==t[q]) --q;
20482  }
20483  }
20484  cimg_forXY(*this,x,y) {
20485  cimg_forZ(*this,z) tmp[z] = res(x,y,z,k);
20486  int q = s[0] = t[0] = 0;
20487  for (int z = 1; z<dz; ++z) {
20488  const float val = tmp[z];
20489  while (q>=0 && _distance_f(t(q),s[q],tmp[s[q]],sizez)>_distance_f(t[q],z,tmp[z],sizez)) --q;
20490  if (q<0) { q = 0; s[0] = z; }
20491  else {
20492  const int w = 1 + _distance_sep(s[q],z,(int)tmp[s[q]],(int)val,sizez);
20493  if (w<dz) { s[++q] = z; t[q] = w; }
20494  }
20495  }
20496  for (int z = dz - 1; z>=0; --z) {
20497  const float val = _distance_f(z,s[q],tmp[s[q]],sizez);
20498  res(x,y,z,k) = compute_sqrt?(float)std::sqrt(val):val;
20499  if (z==t[q]) --q;
20500  }
20501  }
20502  } else { // 2D version (with small optimizations)
20503  cimg_forX(*this,x) {
20504  const T *ptrs = ptr(x,0,0,k);
20505  float *ptrd = res.ptr(x,0,0,k), d = *ptrd = *ptrs==isovalue?(is_isophote=true),0:maxdist;
20506  for (int y = 1; y<dy; ++y) { ptrs+=width; ptrd+=width; d = *ptrd = *ptrs==isovalue?(is_isophote=true),0:d+sizey; }
20507  for (int y = dy - 2; y>=0; --y) { ptrd-=width; if (d<*ptrd) *ptrd = (d+=sizey); else d = *ptrd; }
20508  }
20509  if (!is_isophote) { res.get_shared_channel(k).fill(cimg::type<floatT>::max()); continue; }
20510  CImg<floatT> tmp(dx);
20511  CImg<intT> s(dx), t(dx);
20512  cimg_forY(*this,y) {
20513  float *ptmp = tmp.ptr();
20514  std::memcpy(ptmp,res.ptr(0,y,0,k),sizeof(float)*dx);
20515  int q = s[0] = t[0] = 0;
20516  for (int x = 1; x<dx; ++x) {
20517  const float val = *(++ptmp), val2 = val*val;
20518  while (q>=0 && _distance_f(t[q],s[q],cimg::sqr(tmp[s[q]]),sizex)>_distance_f(t[q],x,val2,sizex)) --q;
20519  if (q<0) { q = 0; s[0] = x; }
20520  else {
20521  const int w = 1 + _distance_sep(s[q],x,(int)cimg::sqr(tmp[s[q]]),(int)val2,sizex);
20522  if (w<dx) { q++; s[q] = x; t[q] = w; }
20523  }
20524  }
20525  float *pres = res.ptr(0,y,0,k) + width;
20526  for (int x = dx - 1; x>=0; --x) {
20527  const float val = _distance_f(x,s[q],cimg::sqr(tmp[s[q]]),sizex);
20528  *(--pres) = compute_sqrt?(float)std::sqrt(val):val;
20529  if (x==t[q]) --q;
20530  }
20531  }
20532  }
20533  }
20534  return res;
20535  }
#define cimg_forX(img, x)
Definition: CImg.h:593
const NT & d
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
#define cimg_forYZ(img, y, z)
Definition: CImg.h:599
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
static float _distance_f(const int x, const int i, const float gi2, const float fact)
Definition: CImg.h:20537
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
#define cimg_forV(img, v)
Definition: CImg.h:596
NT dy
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
NT q
T sqr(const T val)
Return the square of a number.
Definition: CImg.h:4717
#define cimg_forZ(img, z)
Definition: CImg.h:595
#define cimg_forY(img, y)
Definition: CImg.h:594
static int _distance_sep(const int i, const int u, const int gi2, const int gu2, const float fact)
Definition: CImg.h:20541
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forXZ(img, x, z)
Definition: CImg.h:598

Here is the caller graph for this function:

CImg<Tfloat> get_distance_hamilton ( const unsigned int  nb_iter,
const float  band_size = 0,
const float  precision = 0.5f 
) const
inline

Definition at line 20590 of file CImg.h.

20590  {
20591  return CImg<Tfloat>(*this,false).distance_hamilton(nb_iter,band_size,precision);
20592  }
CImg< T > & distance_hamilton(const unsigned int nb_iter, const float band_size=0, const float precision=0.5f)
Compute distance function from 0-valued isophotes by the application of an Hamilton-Jacobi PDE...
Definition: CImg.h:20547
CImg<_cimg_Tt> get_div ( const CImg< t > &  img) const
inline

Definition at line 12717 of file CImg.h.

12717  {
12718  return CImg<_cimg_Tt>(*this,false).div(img);
12719  }
CImg< T > & div(const CImg< t > &img)
Pointwise division between two images.
Definition: CImg.h:12704
CImg<T> get_edge_tensors ( const float  sharpness = 0.7f,
const float  anisotropy = 0.3f,
const float  alpha = 0.6f,
const float  sigma = 1.1f,
const bool  is_sqrt = false 
) const
inline

Definition at line 20322 of file CImg.h.

Referenced by CImg< uintT >::blur_anisotropic().

20323  {
20324  return (+*this).edge_tensors(sharpness,anisotropy,alpha,sigma,is_sqrt);
20325  }

Here is the caller graph for this function:

CImgList<Tfloat> get_eigen ( ) const
inline

Definition at line 13695 of file CImg.h.

13695  {
13696  CImgList<Tfloat> res(2);
13697  eigen(res[0],res[1]);
13698  return res;
13699  }
const CImg< T > & eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a matrix.
Definition: CImg.h:13660
CImg<floatT> get_elevation3d ( CImgList< tf > &  primitives,
CImgList< tc > &  colors,
const CImg< te > &  elevation 
) const
inline

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

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(points3d,faces3d,colors3d);
ref_elevation3d.jpg

Definition at line 21187 of file CImg.h.

21187  {
21188  if (is_empty()) return *this;
21189  if (!is_sameXY(elevation) || elevation.depth>1 || elevation.dim>1)
21190  throw CImgArgumentException("CImg<%s>::get_elevation3d() : Elevation image (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
21191  "have incompatible sizes.",pixel_type(),
21192  elevation.width,elevation.height,elevation.depth,elevation.dim,elevation.data,
21194  float m, M = (float)maxmin(m);
21195  if (M==m) ++M;
21196  colors.assign();
21197  const unsigned int size_x1 = width - 1, size_y1 = height - 1;
21198  for (unsigned int y = 0; y<size_y1; ++y)
21199  for (unsigned int x = 0; x<size_x1; x++) {
21200  const unsigned char
21201  r = (unsigned char)(((*this)(x,y,0) - m)*255/(M-m)),
21202  g = dim>1?(unsigned char)(((*this)(x,y,1) - m)*255/(M-m)):r,
21203  b = dim>2?(unsigned char)(((*this)(x,y,2) - m)*255/(M-m)):(dim>1?0:r);
21204  CImg<tc>::vector((tc)r,(tc)g,(tc)b).transfer_to(colors);
21205  }
21206  const typename CImg<te>::_marching2d_func func(elevation);
21207  return elevation3d(primitives,func,0,0,width-1.0f,height-1.0f,width,height);
21208  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int REAL * x
Definition: read.cpp:74
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
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.
Definition: CImg.h:21284
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_equalize ( const unsigned int  nblevels,
const T  val_min = (T)0,
const T  val_max = (T)0 
) const
inline

Definition at line 15321 of file CImg.h.

15321  {
15322  return (+*this).equalize(nblevels,val_min,val_max);
15323  }
CImg<_cimg_Tt> get_erode ( const CImg< t > &  mask,
const unsigned int  cond = 1,
const bool  weighted_erosion = false 
) const
inline

Definition at line 18920 of file CImg.h.

Referenced by CImg< uintT >::erode(), and CImg< uintT >::get_erode().

18921  {
18922  if (is_empty()) return *this;
18923  if (!mask || mask.dim!=1)
18924  throw CImgArgumentException("CImg<%s>::erode() : Specified mask (%u,%u,%u,%u,%p) is not a scalar image.",
18925  pixel_type(),mask.width,mask.height,mask.depth,mask.dim,mask.data);
18926  typedef _cimg_Tt Tt;
18927  CImg<Tt> dest(width,height,depth,dim);
18928  const int
18929  mx2 = mask.dimx()/2, my2 = mask.dimy()/2, mz2 = mask.dimz()/2,
18930  mx1 = mx2 - 1 + (mask.dimx()%2), my1 = my2 - 1 + (mask.dimy()%2), mz1 = mz2 - 1 + (mask.dimz()%2),
18931  mxe = dimx() - mx2, mye = dimy() - my2, mze = dimz() - mz2;
18932  cimg_forV(*this,v)
18933  if (!weighted_erosion) { // Classical erosion
18934  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
18935  Tt min_val = cimg::type<Tt>::max();
18936  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18937  const Tt cval = (Tt)(*this)(x+xm,y+ym,z+zm,v);
18938  if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18939  }
18940  dest(x,y,z,v) = min_val;
18941  }
18942  if (cond)
18943  cimg_forYZV(*this,y,z,v)
18944  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18945  Tt min_val = cimg::type<Tt>::max();
18946  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18947  const T cval = (Tt)_atXYZ(x+xm,y+ym,z+zm,v);
18948  if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18949  }
18950  dest(x,y,z,v) = min_val;
18951  }
18952  else
18953  cimg_forYZV(*this,y,z,v)
18954  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18955  Tt min_val = cimg::type<Tt>::max();
18956  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18957  const T cval = (Tt)atXYZ(x+xm,y+ym,z+zm,v,0);
18958  if (mask(mx1+xm,my1+ym,mz1+zm) && cval<min_val) min_val = cval;
18959  }
18960  dest(x,y,z,v) = min_val;
18961  }
18962  } else { // Weighted erosion
18963  for (int z = mz1; z<mze; ++z) for (int y = my1; y<mye; ++y) for (int x = mx1; x<mxe; ++x) {
18964  Tt min_val = cimg::type<Tt>::max();
18965  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18966  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
18967  const Tt cval = (Tt)((*this)(x+xm,y+ym,z+zm,v) + mval);
18968  if (mval && cval<min_val) min_val = cval;
18969  }
18970  dest(x,y,z,v) = min_val;
18971  }
18972  if (cond)
18973  cimg_forYZV(*this,y,z,v)
18974  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18975  Tt min_val = cimg::type<Tt>::max();
18976  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18977  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
18978  const Tt cval = (Tt)(_atXYZ(x+xm,y+ym,z+zm,v) + mval);
18979  if (mval && cval<min_val) min_val = cval;
18980  }
18981  dest(x,y,z,v) = min_val;
18982  }
18983  else
18984  cimg_forYZV(*this,y,z,v)
18985  for (int x = 0; x<dimx(); (y<my1 || y>=mye || z<mz1 || z>=mze)?++x:((x<mx1-1 || x>=mxe)?++x:(x=mxe))) {
18986  Tt min_val = cimg::type<Tt>::max();
18987  for (int zm = -mz1; zm<=mz2; ++zm) for (int ym = -my1; ym<=my2; ++ym) for (int xm = -mx1; xm<=mx2; ++xm) {
18988  const t mval = mask(mx1+xm,my1+ym,mz1+zm);
18989  const Tt cval = (Tt)(atXYZ(x+xm,y+ym,z+zm,v,0) + mval);
18990  if (mval && cval<min_val) min_val = cval;
18991  }
18992  dest(x,y,z,v) = min_val;
18993  }
18994  }
18995  return dest;
18996  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
void int int REAL * x
Definition: read.cpp:74
#define _cimg_Tt
Definition: CImg.h:2300
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
#define cimg_forV(img, v)
Definition: CImg.h:596
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
Definition: CImg.h:11257
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

CImg<T> get_erode ( const unsigned int  n,
const unsigned int  cond = 1 
) const
inline

Definition at line 19004 of file CImg.h.

19004  {
19005  static CImg<T> mask;
19006  if (n<2) return *this;
19007  if (mask.width!=n) mask.assign(n,n,1,1,1);
19008  const CImg<T> res = get_erode(mask,cond,false);
19009  if (n>20) mask.assign();
19010  return res;
19011  }
CImg< _cimg_Tt > get_erode(const CImg< t > &mask, const unsigned int cond=1, const bool weighted_erosion=false) const
Definition: CImg.h:18920
const NT & n
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
CImg<Tfloat> get_exp ( ) const
inline

Definition at line 12545 of file CImg.h.

Referenced by cimg_library::exp().

12545  {
12546  return CImg<Tfloat>(*this,false).exp();
12547  }
CImg< T > & exp()
Compute the exponential of each pixel value.
Definition: CImg.h:12540

Here is the caller graph for this function:

CImgList<Tfloat> get_FFT ( const char  axis,
const bool  invert = false 
) const
inline

Compute a 1D Fast Fourier Transform, along a specified axis.

Definition at line 20818 of file CImg.h.

20818  {
20819  CImgList<Tfloat> res(*this,CImg<Tfloat>());
20820  CImg<Tfloat>::FFT(res[0],res[1],axis,invert);
20821  return res;
20822  }
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
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.
Definition: CImg.h:20832
CImgList<Tfloat> get_FFT ( const bool  invert = false) const
inline

Compute a N-D Fast-Fourier Transform.

Definition at line 20825 of file CImg.h.

20825  {
20826  CImgList<Tfloat> res(*this,CImg<Tfloat>());
20827  CImg<Tfloat>::FFT(res[0],res[1],invert);
20828  return res;
20829  }
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
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.
Definition: CImg.h:20832
CImg<T> get_fill ( const T  val) const
inline

Definition at line 14439 of file CImg.h.

14439  {
14440  return CImg<T>(width,height,depth,dim).fill(val);
14441  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const T  val0,
const T  val1 
) const
inline

Definition at line 14452 of file CImg.h.

14452  {
14453  return CImg<T>(width,height,depth,dim).fill(val0,val1);
14454  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const T  val0,
const T  val1,
const T  val2 
) const
inline

Definition at line 14469 of file CImg.h.

14469  {
14470  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2);
14471  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3 
) const
inline

Definition at line 14487 of file CImg.h.

14487  {
14488  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3);
14489  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3,
const T  val4 
) const
inline

Definition at line 14506 of file CImg.h.

14506  {
14507  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4);
14508  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const T  val0,
const T  val1,
const T  val2,
const T  val3,
const T  val4,
const T  val5 
) const
inline

Definition at line 14528 of file CImg.h.

14528  {
14529  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5);
14530  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14551 of file CImg.h.

14551  {
14552  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6);
14553  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14577 of file CImg.h.

14578  {
14579  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7);
14580  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14606 of file CImg.h.

14607  {
14608  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8);
14609  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14635 of file CImg.h.

14636  {
14637  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9);
14638  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14666 of file CImg.h.

14667  {
14668  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10);
14669  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14697 of file CImg.h.

14698  {
14699  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11);
14700  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14730 of file CImg.h.

14731  {
14732  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12);
14733  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14765 of file CImg.h.

14767  {
14768  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14769  val13);
14770  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14803 of file CImg.h.

14805  {
14806  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14807  val13,val14);
14808  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 14842 of file CImg.h.

14844  {
14845  return CImg<T>(width,height,depth,dim).fill(val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,
14846  val13,val14,val15);
14847  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_fill ( const char *const  values,
const bool  repeat_values 
) const
inline

Definition at line 14879 of file CImg.h.

14879  {
14880  return (+*this).fill(values,repeat_values);
14881  }
CImg<T> get_fill ( const CImg< t > &  values,
const bool  repeat_values = true 
) const
inline

Definition at line 14894 of file CImg.h.

14894  {
14895  return repeat_values?CImg<T>(width,height,depth,dim).fill(values,repeat_values):(+*this).fill(values,repeat_values);
14896  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImgList<Tfloat> get_gradient ( const char *const  axes = 0,
const int  scheme = 3 
) const
inline

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.

Definition at line 20014 of file CImg.h.

20014  {
20015  CImgList<Tfloat> grad(2,width,height,depth,dim);
20016  bool threed = false;
20017  if (axes) {
20018  for (unsigned int a = 0; axes[a]; ++a) {
20019  const char axis = cimg::uncase(axes[a]);
20020  switch (axis) {
20021  case 'x' : case 'y' : break;
20022  case 'z' : threed = true; break;
20023  default :
20024  throw CImgArgumentException("CImg<%s>::get_gradient() : Unknown specified axis '%c'.",
20025  pixel_type(),axis);
20026  }
20027  }
20028  } else threed = (depth>1);
20029  if (threed) {
20030  CImg<Tfloat>(width,height,depth,dim).transfer_to(grad);
20031  switch (scheme) { // Compute 3D gradient
20032  case -1 : { // backward finite differences
20033  CImg_3x3x3(I,T);
20034  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20035  grad[0](x,y,z,k) = (Tfloat)Iccc - Ipcc;
20036  grad[1](x,y,z,k) = (Tfloat)Iccc - Icpc;
20037  grad[2](x,y,z,k) = (Tfloat)Iccc - Iccp;
20038  }
20039  } break;
20040  case 1 : { // forward finite differences
20041  CImg_2x2x2(I,T);
20042  cimg_forV(*this,k) cimg_for2x2x2(*this,x,y,z,k,I) {
20043  grad[0](x,y,z,k) = (Tfloat)Incc - Iccc;
20044  grad[1](x,y,z,k) = (Tfloat)Icnc - Iccc;
20045  grad[2](x,y,z,k) = (Tfloat)Iccn - Iccc;
20046  }
20047  } break;
20048  case 4 : { // using Deriche filter with low standard variation
20049  grad[0] = get_deriche(0,1,'x');
20050  grad[1] = get_deriche(0,1,'y');
20051  grad[2] = get_deriche(0,1,'z');
20052  } break;
20053  default : { // central finite differences
20054  CImg_3x3x3(I,T);
20055  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20056  grad[0](x,y,z,k) = 0.5f*((Tfloat)Incc - Ipcc);
20057  grad[1](x,y,z,k) = 0.5f*((Tfloat)Icnc - Icpc);
20058  grad[2](x,y,z,k) = 0.5f*((Tfloat)Iccn - Iccp);
20059  }
20060  }
20061  }
20062  } else switch (scheme) { // Compute 2D-gradient
20063  case -1 : { // backward finite differences
20064  CImg_3x3(I,T);
20065  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) {
20066  grad[0](x,y,z,k) = (Tfloat)Icc - Ipc;
20067  grad[1](x,y,z,k) = (Tfloat)Icc - Icp;
20068  }
20069  } break;
20070  case 1 : { // forward finite differences
20071  CImg_2x2(I,T);
20072  cimg_forZV(*this,z,k) cimg_for2x2(*this,x,y,z,k,I) {
20073  grad[0](x,y,0,k) = (Tfloat)Inc - Icc;
20074  grad[1](x,y,z,k) = (Tfloat)Icn - Icc;
20075  }
20076  } break;
20077  case 2 : { // using Sobel mask
20078  CImg_3x3(I,T);
20079  const Tfloat a = 1, b = 2;
20080  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) {
20081  grad[0](x,y,z,k) = -a*Ipp - b*Ipc - a*Ipn + a*Inp + b*Inc + a*Inn;
20082  grad[1](x,y,z,k) = -a*Ipp - b*Icp - a*Inp + a*Ipn + b*Icn + a*Inn;
20083  }
20084  } break;
20085  case 3 : { // using rotation invariant mask
20086  CImg_3x3(I,T);
20087  const Tfloat a = (Tfloat)(0.25f*(2-std::sqrt(2.0f))), b = (Tfloat)(0.5f*(std::sqrt(2.0f)-1));
20088  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) {
20089  grad[0](x,y,z,k) = -a*Ipp - b*Ipc - a*Ipn + a*Inp + b*Inc + a*Inn;
20090  grad[1](x,y,z,k) = -a*Ipp - b*Icp - a*Inp + a*Ipn + b*Icn + a*Inn;
20091  }
20092  } break;
20093  case 4 : { // using Deriche filter with low standard variation
20094  grad[0] = get_deriche(0,1,'x');
20095  grad[1] = get_deriche(0,1,'y');
20096  } break;
20097  default : { // central finite differences
20098  CImg_3x3(I,T);
20099  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) {
20100  grad[0](x,y,z,k) = 0.5f*((Tfloat)Inc - Ipc);
20101  grad[1](x,y,z,k) = 0.5f*((Tfloat)Icn - Icp);
20102  }
20103  }
20104  }
20105  if (!axes) return grad;
20106  CImgList<Tfloat> res;
20107  for (unsigned int l = 0; axes[l]; ++l) {
20108  const char axis = cimg::uncase(axes[l]);
20109  switch (axis) {
20110  case 'x' : res.insert(grad[0]); break;
20111  case 'y' : res.insert(grad[1]); break;
20112  case 'z' : res.insert(grad[2]); break;
20113  }
20114  }
20115  grad.assign();
20116  return res;
20117  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
double sqrt(double d)
Definition: double.h:73
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const int scheme
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
CImg< Tfloat > get_deriche(const float sigma, const int order=0, const char axis='x', const bool cond=true) const
Definition: CImg.h:19203
#define cimg_for2x2(img, x, y, z, v, I)
Definition: CImg.h:1053
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
#define CImg_2x2(I, T)
Definition: CImg.h:415
#define CImg_2x2x2(I, T)
Definition: CImg.h:451
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
#define cimg_for2x2x2(img, x, y, z, v, I)
Definition: CImg.h:1774
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<Tfloat> get_haar ( const char  axis,
const bool  invert = false,
const unsigned int  nb_scales = 1 
) const
inline

Definition at line 20604 of file CImg.h.

Referenced by CImg< uintT >::get_haar(), and CImg< uintT >::haar().

20604  {
20605  if (is_empty() || !nb_scales) return *this;
20606  CImg<Tfloat> res;
20607 
20608  if (nb_scales==1) {
20609  switch (cimg::uncase(axis)) { // Single scale transform
20610  case 'x' : {
20611  const unsigned int w = width/2;
20612  if (w) {
20613  if (w%2)
20614  throw CImgInstanceException("CImg<%s>::haar() : Sub-image width = %u is not even at a particular scale (=%u).",
20615  pixel_type(),w);
20616  res.assign(width,height,depth,dim);
20617  if (invert) cimg_forYZV(*this,y,z,v) { // Inverse transform along X
20618  for (unsigned int x = 0, xw = w, x2 = 0; x<w; ++x, ++xw) {
20619  const Tfloat val0 = (Tfloat)(*this)(x,y,z,v), val1 = (Tfloat)(*this)(xw,y,z,v);
20620  res(x2++,y,z,v) = val0 - val1;
20621  res(x2++,y,z,v) = val0 + val1;
20622  }
20623  } else cimg_forYZV(*this,y,z,v) { // Direct transform along X
20624  for (unsigned int x = 0, xw = w, x2 = 0; x<w; ++x, ++xw) {
20625  const Tfloat val0 = (Tfloat)(*this)(x2++,y,z,v), val1 = (Tfloat)(*this)(x2++,y,z,v);
20626  res(x,y,z,v) = (val0 + val1)/2;
20627  res(xw,y,z,v) = (val1 - val0)/2;
20628  }
20629  }
20630  } else return *this;
20631  } break;
20632  case 'y' : {
20633  const unsigned int h = height/2;
20634  if (h) {
20635  if (h%2)
20636  throw CImgInstanceException("CImg<%s>::haar() : Sub-image height = %u is not even at a particular scale.",
20637  pixel_type(),h);
20638  res.assign(width,height,depth,dim);
20639  if (invert) cimg_forXZV(*this,x,z,v) { // Inverse transform along Y
20640  for (unsigned int y = 0, yh = h, y2 = 0; y<h; ++y, ++yh) {
20641  const Tfloat val0 = (Tfloat)(*this)(x,y,z,v), val1 = (Tfloat)(*this)(x,yh,z,v);
20642  res(x,y2++,z,v) = val0 - val1;
20643  res(x,y2++,z,v) = val0 + val1;
20644  }
20645  } else cimg_forXZV(*this,x,z,v) {
20646  for (unsigned int y = 0, yh = h, y2 = 0; y<h; ++y, ++yh) { // Direct transform along Y
20647  const Tfloat val0 = (Tfloat)(*this)(x,y2++,z,v), val1 = (Tfloat)(*this)(x,y2++,z,v);
20648  res(x,y,z,v) = (val0 + val1)/2;
20649  res(x,yh,z,v) = (val1 - val0)/2;
20650  }
20651  }
20652  } else return *this;
20653  } break;
20654  case 'z' : {
20655  const unsigned int d = depth/2;
20656  if (d) {
20657  if (d%2)
20658  throw CImgInstanceException("CImg<%s>::haar() : Sub-image depth = %u is not even at a particular scale.",
20659  pixel_type(),d);
20660  res.assign(width,height,depth,dim);
20661  if (invert) cimg_forXYV(*this,x,y,v) { // Inverse transform along Z
20662  for (unsigned int z = 0, zd = d, z2 = 0; z<d; ++z, ++zd) {
20663  const Tfloat val0 = (Tfloat)(*this)(x,y,z,v), val1 = (Tfloat)(*this)(x,y,zd,v);
20664  res(x,y,z2++,v) = val0 - val1;
20665  res(x,y,z2++,v) = val0 + val1;
20666  }
20667  } else cimg_forXYV(*this,x,y,v) {
20668  for (unsigned int z = 0, zd = d, z2 = 0; z<d; ++z, ++zd) { // Direct transform along Z
20669  const Tfloat val0 = (Tfloat)(*this)(x,y,z2++,v), val1 = (Tfloat)(*this)(x,y,z2++,v);
20670  res(x,y,z,v) = (val0 + val1)/2;
20671  res(x,y,zd,v) = (val1 - val0)/2;
20672  }
20673  }
20674  } else return *this;
20675  } break;
20676  default :
20677  throw CImgArgumentException("CImg<%s>::haar() : Invalid axis '%c', must be 'x','y' or 'z'.",
20678  pixel_type(),axis);
20679  }
20680  } else { // Multi-scale version
20681  if (invert) {
20682  res.assign(*this);
20683  switch (cimg::uncase(axis)) {
20684  case 'x' : {
20685  unsigned int w = width;
20686  for (unsigned int s=1; w && s<nb_scales; ++s) w/=2;
20687  for (w=w?w:1; w<=width; w*=2) res.draw_image(res.get_crop(0,w-1).get_haar('x',true,1));
20688  } break;
20689  case 'y' : {
20690  unsigned int h = width;
20691  for (unsigned int s=1; h && s<nb_scales; ++s) h/=2;
20692  for (h=h?h:1; h<=height; h*=2) res.draw_image(res.get_crop(0,0,width-1,h-1).get_haar('y',true,1));
20693  } break;
20694  case 'z' : {
20695  unsigned int d = depth;
20696  for (unsigned int s=1; d && s<nb_scales; ++s) d/=2;
20697  for (d=d?d:1; d<=depth; d*=2) res.draw_image(res.get_crop(0,0,0,width-1,height-1,d-1).get_haar('z',true,1));
20698  } break;
20699  default :
20700  throw CImgArgumentException("CImg<%s>::haar() : Invalid axis '%c', must be 'x','y' or 'z'.",
20701  pixel_type(),axis);
20702  }
20703  } else { // Direct transform
20704  res = get_haar(axis,false,1);
20705  switch (cimg::uncase(axis)) {
20706  case 'x' : {
20707  for (unsigned int s=1, w=width/2; w && s<nb_scales; ++s, w/=2) res.draw_image(res.get_crop(0,w-1).get_haar('x',false,1));
20708  } break;
20709  case 'y' : {
20710  for (unsigned int s=1, h=height/2; h && s<nb_scales; ++s, h/=2) res.draw_image(res.get_crop(0,0,width-1,h-1).get_haar('y',false,1));
20711  } break;
20712  case 'z' : {
20713  for (unsigned int s=1, d=depth/2; d && s<nb_scales; ++s, d/=2) res.draw_image(res.get_crop(0,0,0,width-1,height-1,d-1).get_haar('z',false,1));
20714  } break;
20715  default :
20716  throw CImgArgumentException("CImg<%s>::haar() : Invalid axis '%c', must be 'x','y' or 'z'.",
20717  pixel_type(),axis);
20718  }
20719  }
20720  }
20721  return res;
20722  }
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
const NT & d
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg< Tfloat > get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const
Definition: CImg.h:20604
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

CImg<Tfloat> get_haar ( const bool  invert = false,
const unsigned int  nb_scales = 1 
) const
inline

Definition at line 20733 of file CImg.h.

20733  {
20734  CImg<Tfloat> res;
20735 
20736  if (nb_scales==1) { // Single scale transform
20737  if (width>1) get_haar('x',invert,1).transfer_to(res);
20738  if (height>1) { if (res) res.get_haar('y',invert,1).transfer_to(res); else get_haar('y',invert,1).transfer_to(res); }
20739  if (depth>1) { if (res) res.get_haar('z',invert,1).transfer_to(res); else get_haar('z',invert,1).transfer_to(res); }
20740  if (res) return res;
20741  } else { // Multi-scale transform
20742  if (invert) { // Inverse transform
20743  res.assign(*this);
20744  if (width>1) {
20745  if (height>1) {
20746  if (depth>1) {
20747  unsigned int w = width, h = height, d = depth; for (unsigned int s=1; w && h && d && s<nb_scales; ++s) { w/=2; h/=2; d/=2; }
20748  for (w=w?w:1, h=h?h:1, d=d?d:1; w<=width && h<=height && d<=depth; w*=2, h*=2, d*=2)
20749  res.draw_image(res.get_crop(0,0,0,w-1,h-1,d-1).get_haar(true,1));
20750  } else {
20751  unsigned int w = width, h = height; for (unsigned int s=1; w && h && s<nb_scales; ++s) { w/=2; h/=2; }
20752  for (w=w?w:1, h=h?h:1; w<=width && h<=height; w*=2, h*=2)
20753  res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).get_haar(true,1));
20754  }
20755  } else {
20756  if (depth>1) {
20757  unsigned int w = width, d = depth; for (unsigned int s=1; w && d && s<nb_scales; ++s) { w/=2; d/=2; }
20758  for (w=w?w:1, d=d?d:1; w<=width && d<=depth; w*=2, d*=2)
20759  res.draw_image(res.get_crop(0,0,0,w-1,0,d-1).get_haar(true,1));
20760  } else {
20761  unsigned int w = width; for (unsigned int s=1; w && s<nb_scales; ++s) w/=2;
20762  for (w=w?w:1; w<=width; w*=2)
20763  res.draw_image(res.get_crop(0,0,0,w-1,0,0).get_haar(true,1));
20764  }
20765  }
20766  } else {
20767  if (height>1) {
20768  if (depth>1) {
20769  unsigned int h = height, d = depth; for (unsigned int s=1; h && d && s<nb_scales; ++s) { h/=2; d/=2; }
20770  for (h=h?h:1, d=d?d:1; h<=height && d<=depth; h*=2, d*=2)
20771  res.draw_image(res.get_crop(0,0,0,0,h-1,d-1).get_haar(true,1));
20772  } else {
20773  unsigned int h = height; for (unsigned int s=1; h && s<nb_scales; ++s) h/=2;
20774  for (h=h?h:1; h<=height; h*=2)
20775  res.draw_image(res.get_crop(0,0,0,0,h-1,0).get_haar(true,1));
20776  }
20777  } else {
20778  if (depth>1) {
20779  unsigned int d = depth; for (unsigned int s=1; d && s<nb_scales; ++s) d/=2;
20780  for (d=d?d:1; d<=depth; d*=2)
20781  res.draw_image(res.get_crop(0,0,0,0,0,d-1).get_haar(true,1));
20782  } else return *this;
20783  }
20784  }
20785  } else { // Direct transform
20786  res = get_haar(false,1);
20787  if (width>1) {
20788  if (height>1) {
20789  if (depth>1) for (unsigned int s=1, w=width/2, h=height/2, d=depth/2; w && h && d && s<nb_scales; ++s, w/=2, h/=2, d/=2)
20790  res.draw_image(res.get_crop(0,0,0,w-1,h-1,d-1).haar(false,1));
20791  else for (unsigned int s=1, w=width/2, h=height/2; w && h && s<nb_scales; ++s, w/=2, h/=2)
20792  res.draw_image(res.get_crop(0,0,0,w-1,h-1,0).haar(false,1));
20793  } else {
20794  if (depth>1) for (unsigned int s=1, w=width/2, d=depth/2; w && d && s<nb_scales; ++s, w/=2, d/=2)
20795  res.draw_image(res.get_crop(0,0,0,w-1,0,d-1).haar(false,1));
20796  else for (unsigned int s=1, w=width/2; w && s<nb_scales; ++s, w/=2)
20797  res.draw_image(res.get_crop(0,0,0,w-1,0,0).haar(false,1));
20798  }
20799  } else {
20800  if (height>1) {
20801  if (depth>1) for (unsigned int s=1, h=height/2, d=depth/2; h && d && s<nb_scales; ++s, h/=2, d/=2)
20802  res.draw_image(res.get_crop(0,0,0,0,h-1,d-1).haar(false,1));
20803  else for (unsigned int s=1, h=height/2; h && s<nb_scales; ++s, h/=2)
20804  res.draw_image(res.get_crop(0,0,0,0,h-1,0).haar(false,1));
20805  } else {
20806  if (depth>1) for (unsigned int s=1, d=depth/2; d && s<nb_scales; ++s, d/=2)
20807  res.draw_image(res.get_crop(0,0,0,0,0,d-1).haar(false,1));
20808  else return *this;
20809  }
20810  }
20811  }
20812  return res;
20813  }
20814  return *this;
20815  }
const NT & d
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< Tfloat > get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const
Definition: CImg.h:20604
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImgList<Tfloat> get_hessian ( const char *const  axes = 0) const
inline

Get components of the Hessian matrix of an image.

Definition at line 20120 of file CImg.h.

20120  {
20121  const char *naxes = axes, *const def_axes2d = "xxxyyy", *const def_axes3d = "xxxyxzyyyzzz";
20122  if (!axes) naxes = depth>1?def_axes3d:def_axes2d;
20123  CImgList<Tfloat> res;
20124  const unsigned int lmax = std::strlen(naxes);
20125  if (lmax%2)
20126  throw CImgArgumentException("CImg<%s>::get_hessian() : Incomplete parameter axes = '%s'.",
20127  pixel_type(),naxes);
20128  res.assign(lmax/2,width,height,depth,dim);
20129  if (!cimg::strcasecmp(naxes,def_axes3d)) { // Default 3D version
20130  CImg_3x3x3(I,T);
20131  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20132  res[0](x,y,z,k) = (Tfloat)Ipcc + Incc - 2*Iccc; // Ixx
20133  res[1](x,y,z,k) = 0.25f*((Tfloat)Ippc + Innc - Ipnc - Inpc); // Ixy
20134  res[2](x,y,z,k) = 0.25f*((Tfloat)Ipcp + Incn - Ipcn - Incp); // Ixz
20135  res[3](x,y,z,k) = (Tfloat)Icpc + Icnc - 2*Iccc; // Iyy
20136  res[4](x,y,z,k) = 0.25f*((Tfloat)Icpp + Icnn - Icpn - Icnp); // Iyz
20137  res[5](x,y,z,k) = (Tfloat)Iccn + Iccp - 2*Iccc; // Izz
20138  }
20139  } else if (!cimg::strcasecmp(naxes,def_axes2d)) { // Default 2D version
20140  CImg_3x3(I,T);
20141  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
20142  res[0](x,y,0,k) = (Tfloat)Ipc + Inc - 2*Icc; // Ixx
20143  res[1](x,y,0,k) = 0.25f*((Tfloat)Ipp + Inn - Ipn - Inp); // Ixy
20144  res[2](x,y,0,k) = (Tfloat)Icp + Icn - 2*Icc; // Iyy
20145  }
20146  } else for (unsigned int l = 0; l<lmax; ) { // Version with custom axes.
20147  const unsigned int l2 = l/2;
20148  char axis1 = naxes[l++], axis2 = naxes[l++];
20149  if (axis1>axis2) cimg::swap(axis1,axis2);
20150  bool valid_axis = false;
20151  if (axis1=='x' && axis2=='x') { // Ixx
20152  valid_axis = true; CImg_3x3(I,T);
20153  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = (Tfloat)Ipc + Inc - 2*Icc;
20154  }
20155  else if (axis1=='x' && axis2=='y') { // Ixy
20156  valid_axis = true; CImg_3x3(I,T);
20157  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = 0.25f*((Tfloat)Ipp + Inn - Ipn - Inp);
20158  }
20159  else if (axis1=='x' && axis2=='z') { // Ixz
20160  valid_axis = true; CImg_3x3x3(I,T);
20161  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = 0.25f*((Tfloat)Ipcp + Incn - Ipcn - Incp);
20162  }
20163  else if (axis1=='y' && axis2=='y') { // Iyy
20164  valid_axis = true; CImg_3x3(I,T);
20165  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = (Tfloat)Icp + Icn - 2*Icc;
20166  }
20167  else if (axis1=='y' && axis2=='z') { // Iyz
20168  valid_axis = true; CImg_3x3x3(I,T);
20169  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = 0.25f*((Tfloat)Icpp + Icnn - Icpn - Icnp);
20170  }
20171  else if (axis1=='z' && axis2=='z') { // Izz
20172  valid_axis = true; CImg_3x3x3(I,T);
20173  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) res[l2](x,y,z,k) = (Tfloat)Iccn + Iccp - 2*Iccc;
20174  }
20175  else if (!valid_axis) throw CImgArgumentException("CImg<%s>::get_hessian() : Invalid parameter axes = '%s'.",
20176  pixel_type(),naxes);
20177  }
20178  return res;
20179  }
if(dy > dx)
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
CImgList< Tfloat > get_hessian(const char *const axes=0) const
Get components of the Hessian matrix of an image.
Definition: CImg.h:20120
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
void int int REAL * x
Definition: read.cpp:74
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<floatT> get_histogram ( const unsigned int  nb_levels,
const T  value_min = (T)0,
const T  value_max = (T)0 
) const
inline

Definition at line 15273 of file CImg.h.

Referenced by CImg< uintT >::equalize(), and CImg< uintT >::histogram().

15273  {
15274  if (is_empty()) return CImg<floatT>();
15275  if (!nb_levels)
15276  throw CImgArgumentException("CImg<%s>::histogram() : Cannot compute an histogram with 0 levels",
15277  pixel_type());
15278  T vmin = value_min, vmax = value_max;
15279  CImg<floatT> res(nb_levels,1,1,1,0);
15280  if (vmin>=vmax && vmin==0) vmin = minmax(vmax);
15281  if (vmin<vmax) cimg_for(*this,ptr,T) {
15282  const T val = *ptr;
15283  if (val>=vmin && val<=vmax) ++res[val==vmax?nb_levels-1:(int)((val-vmin)*nb_levels/(vmax-vmin))];
15284  } else res[0]+=size();
15285  return res;
15286  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
Definition: CImg.h:12920
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<Tfloat> get_HSItoRGB ( ) const
inline

Definition at line 16019 of file CImg.h.

16019  {
16020  return CImg< Tuchar>(*this,false).HSItoRGB();
16021  }
CImg< T > & HSItoRGB()
Convert color pixels from (H,S,I) to (R,G,B).
Definition: CImg.h:15982
CImg<Tuchar> get_HSLtoRGB ( ) const
inline

Definition at line 15942 of file CImg.h.

15942  {
15943  return CImg<Tuchar>(*this,false).HSLtoRGB();
15944  }
CImg< T > & HSLtoRGB()
Convert color pixels from (H,S,L) to (R,G,B).
Definition: CImg.h:15911
CImg<Tuchar> get_HSVtoRGB ( ) const
inline

Definition at line 15865 of file CImg.h.

15865  {
15866  return CImg<Tuchar>(*this,false).HSVtoRGB();
15867  }
CImg< T > & HSVtoRGB()
Convert color pixels from (H,S,V) to (R,G,B).
Definition: CImg.h:15826
CImg<T> get_identity_matrix ( ) const
inline

Definition at line 13420 of file CImg.h.

13420  {
13422  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & identity_matrix()
Get an identity matrix having same dimension than instance image.
Definition: CImg.h:13416
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
CImg<typename cimg::superset<t,unsigned int>::type> get_index ( const CImg< t > &  palette,
const bool  dithering = false,
const bool  map_indexes = true 
) const
inline

Definition at line 15349 of file CImg.h.

Referenced by CImg< uintT >::index().

15349  {
15350  typedef typename cimg::superset<t,unsigned int>::type tuint;
15351  if (is_empty()) return CImg<tuint>();
15352  if (palette.dim!=dim)
15353  throw CImgArgumentException("CImg<%s>::index() : Palette (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
15354  "have incompatible sizes.",pixel_type(),
15355  palette.width,palette.height,palette.depth,palette.dim,palette.data,
15357  const unsigned int whz = width*height*depth, pwhz = palette.width*palette.height*palette.depth;
15358  CImg<tuint> res(width,height,depth,map_indexes?dim:1);
15359  tuint *ptrd = res.data;
15360  if (dithering) { // Dithered versions.
15361  Tfloat valm = 0, valM = (Tfloat)maxmin(valm);
15362  if (valm==valM && valm>=0 && valM<=255) { valm = 0; valM = 255; }
15363  CImg<Tfloat> cache = get_crop(-1,0,0,0,width,1,0,dim-1);
15364  Tfloat *cache_current = cache.ptr(1,0,0,0), *cache_next = cache.ptr(1,1,0,0);
15365  const unsigned int cwhz = cache.width*cache.height*cache.depth;
15366  switch (dim) {
15367  case 1 : { // Optimized for scalars.
15368  cimg_forYZ(*this,y,z) {
15369  if (y<dimy()-2) {
15370  Tfloat *ptrc0 = cache_next; const T *ptrs0 = ptr(0,y+1,z,0);
15371  cimg_forX(*this,x) *(ptrc0++) = (Tfloat)*(ptrs0++);
15372  }
15373  Tfloat *ptrs0 = cache_current, *ptrsn0 = cache_next;
15374  cimg_forX(*this,x) {
15375  const Tfloat _val0 = (Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0;
15376  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15377  for (const t *ptrp0 = palette.data, *ptrp_end = ptrp0 + pwhz; ptrp0<ptrp_end; ) {
15378  const Tfloat pval0 = (Tfloat)*(ptrp0++) - val0, dist = pval0*pval0;
15379  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15380  }
15381  const Tfloat err0 = ((*(ptrs0++)=val0) - (Tfloat)*ptrmin0)/16;
15382  *ptrs0 += 7*err0; *(ptrsn0-1) += 3*err0; *(ptrsn0++) += 5*err0; *ptrsn0 += err0;
15383  if (map_indexes) *(ptrd++) = (tuint)*ptrmin0; else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15384  }
15385  cimg::swap(cache_current,cache_next);
15386  }
15387  } break;
15388  case 2 : { // Optimized for 2D vectors.
15389  tuint *ptrd1 = ptrd + whz;
15390  cimg_forYZ(*this,y,z) {
15391  if (y<dimy()-2) {
15392  Tfloat *ptrc0 = cache_next, *ptrc1 = ptrc0 + cwhz;
15393  const T *ptrs0 = ptr(0,y+1,z,0), *ptrs1 = ptrs0 + whz;
15394  cimg_forX(*this,x) { *(ptrc0++) = (Tfloat)*(ptrs0++); *(ptrc1++) = (Tfloat)*(ptrs1++); }
15395  }
15396  Tfloat
15397  *ptrs0 = cache_current, *ptrs1 = ptrs0 + cwhz,
15398  *ptrsn0 = cache_next, *ptrsn1 = ptrsn0 + cwhz;
15399  cimg_forX(*this,x) {
15400  const Tfloat
15401  _val0 = (Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0,
15402  _val1 = (Tfloat)*ptrs1, val1 = _val1<valm?valm:_val1>valM?valM:_val1;
15403  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15404  for (const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15405  const Tfloat
15406  pval0 = (Tfloat)*(ptrp0++) - val0, pval1 = (Tfloat)*(ptrp1++) - val1,
15407  dist = pval0*pval0 + pval1*pval1;
15408  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15409  }
15410  const t *const ptrmin1 = ptrmin0 + pwhz;
15411  const Tfloat
15412  err0 = ((*(ptrs0++)=val0) - (Tfloat)*ptrmin0)/16,
15413  err1 = ((*(ptrs1++)=val1) - (Tfloat)*ptrmin1)/16;
15414  *ptrs0 += 7*err0; *ptrs1 += 7*err1;
15415  *(ptrsn0-1) += 3*err0; *(ptrsn1-1) += 3*err1;
15416  *(ptrsn0++) += 5*err0; *(ptrsn1++) += 5*err1;
15417  *ptrsn0 += err0; *ptrsn1 += err1;
15418  if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*ptrmin1; }
15419  else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15420  }
15421  cimg::swap(cache_current,cache_next);
15422  }
15423  } break;
15424  case 3 : { // Optimized for 3D vectors (colors).
15425  tuint *ptrd1 = ptrd + whz, *ptrd2 = ptrd1 + whz;
15426  cimg_forYZ(*this,y,z) {
15427  if (y<dimy()-2) {
15428  Tfloat *ptrc0 = cache_next, *ptrc1 = ptrc0 + cwhz, *ptrc2 = ptrc1 + cwhz;
15429  const T *ptrs0 = ptr(0,y+1,z,0), *ptrs1 = ptrs0 + whz, *ptrs2 = ptrs1 + whz;
15430  cimg_forX(*this,x) { *(ptrc0++) = (Tfloat)*(ptrs0++); *(ptrc1++) = (Tfloat)*(ptrs1++); *(ptrc2++) = (Tfloat)*(ptrs2++); }
15431  }
15432  Tfloat
15433  *ptrs0 = cache_current, *ptrs1 = ptrs0 + cwhz, *ptrs2 = ptrs1 + cwhz,
15434  *ptrsn0 = cache_next, *ptrsn1 = ptrsn0 + cwhz, *ptrsn2 = ptrsn1 + cwhz;
15435  cimg_forX(*this,x) {
15436  const Tfloat
15437  _val0 = (Tfloat)*ptrs0, val0 = _val0<valm?valm:_val0>valM?valM:_val0,
15438  _val1 = (Tfloat)*ptrs1, val1 = _val1<valm?valm:_val1>valM?valM:_val1,
15439  _val2 = (Tfloat)*ptrs2, val2 = _val2<valm?valm:_val2>valM?valM:_val2;
15440  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15441  for (const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15442  const Tfloat
15443  pval0 = (Tfloat)*(ptrp0++) - val0, pval1 = (Tfloat)*(ptrp1++) - val1, pval2 = (Tfloat)*(ptrp2++) - val2,
15444  dist = pval0*pval0 + pval1*pval1 + pval2*pval2;
15445  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15446  }
15447  const t *const ptrmin1 = ptrmin0 + pwhz, *const ptrmin2 = ptrmin1 + pwhz;
15448  const Tfloat
15449  err0 = ((*(ptrs0++)=val0) - (Tfloat)*ptrmin0)/16,
15450  err1 = ((*(ptrs1++)=val1) - (Tfloat)*ptrmin1)/16,
15451  err2 = ((*(ptrs2++)=val2) - (Tfloat)*ptrmin2)/16;
15452  *ptrs0 += 7*err0; *ptrs1 += 7*err1; *ptrs2 += 7*err2;
15453  *(ptrsn0-1) += 3*err0; *(ptrsn1-1) += 3*err1; *(ptrsn2-1) += 3*err2;
15454  *(ptrsn0++) += 5*err0; *(ptrsn1++) += 5*err1; *(ptrsn2++) += 5*err2;
15455  *ptrsn0 += err0; *ptrsn1 += err1; *ptrsn2 += err2;
15456  if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*ptrmin1; *(ptrd2++) = (tuint)*ptrmin2; }
15457  else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15458  }
15459  cimg::swap(cache_current,cache_next);
15460  }
15461  } break;
15462  default : // Generic version
15463  cimg_forYZ(*this,y,z) {
15464  if (y<dimy()-2) {
15465  Tfloat *ptrc = cache_next;
15466  cimg_forV(*this,k) {
15467  Tfloat *_ptrc = ptrc; const T *_ptrs = ptr(0,y+1,z,k);
15468  cimg_forX(*this,x) *(_ptrc++) = (Tfloat)*(_ptrs++);
15469  ptrc+=cwhz;
15470  }
15471  }
15472  Tfloat *ptrs = cache_current, *ptrsn = cache_next;
15473  cimg_forX(*this,x) {
15474  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin = palette.data;
15475  for (const t *ptrp = palette.data, *ptrp_end = ptrp + pwhz; ptrp<ptrp_end; ++ptrp) {
15476  Tfloat dist = 0; Tfloat *_ptrs = ptrs; const t *_ptrp = ptrp;
15477  cimg_forV(*this,k) {
15478  const Tfloat _val = *_ptrs, val = _val<valm?valm:_val>valM?valM:_val;
15479  dist += cimg::sqr((*_ptrs=val) - (Tfloat)*_ptrp); _ptrs+=cwhz; _ptrp+=pwhz;
15480  }
15481  if (dist<distmin) { ptrmin = ptrp; distmin = dist; }
15482  }
15483  const t *_ptrmin = ptrmin; Tfloat *_ptrs = ptrs++, *_ptrsn = (ptrsn++)-1;
15484  cimg_forV(*this,k) {
15485  const Tfloat err = (*(_ptrs++) - (Tfloat)*_ptrmin)/16;
15486  *_ptrs += 7*err; *(_ptrsn++) += 3*err; *(_ptrsn++) += 5*err; *_ptrsn += err;
15487  _ptrmin+=pwhz; _ptrs+=cwhz-1; _ptrsn+=cwhz-2;
15488  }
15489  if (map_indexes) { tuint *_ptrd = ptrd++; cimg_forV(*this,k) { *_ptrd = (tuint)*ptrmin; _ptrd+=whz; ptrmin+=pwhz; }}
15490  else *(ptrd++) = (tuint)(ptrmin - palette.data);
15491  }
15492  cimg::swap(cache_current,cache_next);
15493  }
15494  }
15495  } else { // Non-dithered versions
15496  switch (dim) {
15497  case 1 : { // Optimized for scalars.
15498  for (const T *ptrs0 = data, *ptrs_end = ptrs0 + whz; ptrs0<ptrs_end; ) {
15499  const Tfloat val0 = (Tfloat)*(ptrs0++);
15500  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15501  for (const t *ptrp0 = palette.data, *ptrp_end = ptrp0 + pwhz; ptrp0<ptrp_end; ) {
15502  const Tfloat pval0 = (Tfloat)*(ptrp0++) - val0, dist = pval0*pval0;
15503  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15504  }
15505  if (map_indexes) *(ptrd++) = (tuint)*ptrmin0; else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15506  }
15507  } break;
15508  case 2 : { // Optimized for 2D vectors.
15509  tuint *ptrd1 = ptrd + whz;
15510  for (const T *ptrs0 = data, *ptrs1 = ptrs0 + whz, *ptrs_end = ptrs1; ptrs0<ptrs_end; ) {
15511  const Tfloat val0 = (Tfloat)*(ptrs0++), val1 = (Tfloat)*(ptrs1++);
15512  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15513  for (const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15514  const Tfloat
15515  pval0 = (Tfloat)*(ptrp0++) - val0, pval1 = (Tfloat)*(ptrp1++) - val1,
15516  dist = pval0*pval0 + pval1*pval1;
15517  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15518  }
15519  if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*(ptrmin0 + pwhz); }
15520  else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15521  }
15522  } break;
15523  case 3 : { // Optimized for 3D vectors (colors).
15524  tuint *ptrd1 = ptrd + whz, *ptrd2 = ptrd1 + whz;
15525  for (const T *ptrs0 = data, *ptrs1 = ptrs0 + whz, *ptrs2 = ptrs1 + whz, *ptrs_end = ptrs1; ptrs0<ptrs_end; ) {
15526  const Tfloat val0 = (Tfloat)*(ptrs0++), val1 = (Tfloat)*(ptrs1++), val2 = (Tfloat)*(ptrs2++);
15527  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin0 = palette.data;
15528  for (const t *ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz, *ptrp_end = ptrp1; ptrp0<ptrp_end; ) {
15529  const Tfloat
15530  pval0 = (Tfloat)*(ptrp0++) - val0, pval1 = (Tfloat)*(ptrp1++) - val1, pval2 = (Tfloat)*(ptrp2++) - val2,
15531  dist = pval0*pval0 + pval1*pval1 + pval2*pval2;
15532  if (dist<distmin) { ptrmin0 = ptrp0 - 1; distmin = dist; }
15533  }
15534  if (map_indexes) { *(ptrd++) = (tuint)*ptrmin0; *(ptrd1++) = (tuint)*(ptrmin0 + pwhz); *(ptrd2++) = (tuint)*(ptrmin0 + 2*pwhz); }
15535  else *(ptrd++) = (tuint)(ptrmin0 - palette.data);
15536  }
15537  } break;
15538  default : // Generic version.
15539  for (const T *ptrs = data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ++ptrs) {
15540  Tfloat distmin = cimg::type<Tfloat>::max(); const t *ptrmin = palette.data;
15541  for (const t *ptrp = palette.data, *ptrp_end = ptrp + pwhz; ptrp<ptrp_end; ++ptrp) {
15542  Tfloat dist = 0; const T *_ptrs = ptrs; const t *_ptrp = ptrp;
15543  cimg_forV(*this,k) { dist += cimg::sqr((Tfloat)*_ptrs - (Tfloat)*_ptrp); _ptrs+=whz; _ptrp+=pwhz; }
15544  if (dist<distmin) { ptrmin = ptrp; distmin = dist; }
15545  }
15546  if (map_indexes) { tuint *_ptrd = ptrd++; cimg_forV(*this,k) { *_ptrd = (tuint)*ptrmin; _ptrd+=whz; ptrmin+=pwhz; }}
15547  else *(ptrd++) = (tuint)(ptrmin - palette.data);
15548  }
15549  }
15550  }
15551  return res;
15552  }
#define cimg_forX(img, x)
Definition: CImg.h:593
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define cimg_forYZ(img, y, z)
Definition: CImg.h:599
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
T sqr(const T val)
Return the square of a number.
Definition: CImg.h:4717
long double dist(long double *coord1, long double *coord2, int size)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_invert ( const bool  use_LU = true) const
inline

Definition at line 13538 of file CImg.h.

Referenced by cimg_library::invert(), and cimg_library::operator/().

13538  {
13539  return CImg<Tfloat>(*this,false).invert(use_LU);
13540  }
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474

Here is the caller graph for this function:

CImg<T> get_invert_endianness ( ) const
inline

Definition at line 14956 of file CImg.h.

14956  {
14957  return (+*this).invert_endianness();
14958  }
CImg<floatT> get_isocurve3d ( CImgList< tf > &  primitives,
const float  isovalue,
const int  size_x = -100,
const int  size_y = -100 
) const
inline

Create and return a isocurve of the instance image 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_isocurve3d(faces3d,100);
CImg<unsigned char>().display_object3d(points3d,faces3d,colors3d);
ref_isocurve3d.jpg

Definition at line 21228 of file CImg.h.

21229  {
21230  if (dim>1)
21231  throw CImgInstanceException("CImg<%s>::get_isocurve3d() : Instance image (%u,%u,%u,%u,%p) is not scalar.",
21233  primitives.assign();
21234  if (is_empty()) return *this;
21235  CImg<floatT> vertices;
21236  if ((size_x==-100 && size_y==-100) || (size_x==dimx() && size_y==dimy())) {
21237  const _marching2d_func func(*this);
21238  vertices = isocurve3d(primitives,func,isovalue,0,0,dimx()-1.0f,dimy()-1.0f,size_x,size_y);
21239  } else {
21240  const _marching2d_func_float func(*this);
21241  vertices = isocurve3d(primitives,func,isovalue,0,0,dimx()-1.0f,dimy()-1.0f,size_x,size_y);
21242  }
21243  return vertices;
21244  }
static CImg< floatT > isocurve3d(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 isocurve as a 3D object.
Definition: CImg.h:21328
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Create and return a isosurface of the instance image 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(points3d,faces3d,colors3d);
ref_isosurface3d.jpg

Definition at line 21264 of file CImg.h.

21265  {
21266  if (dim>1)
21267  throw CImgInstanceException("CImg<%s>::get_isosurface3d() : Instance image (%u,%u,%u,%u,%p) is not scalar.",
21269  primitives.assign();
21270  if (is_empty()) return *this;
21271  CImg<floatT> vertices;
21272  if ((size_x==-100 && size_y==-100 && size_z==-100) || (size_x==dimx() && size_y==dimy() && size_z==dimz())) {
21273  const _marching3d_func func(*this);
21274  vertices = isosurface3d(primitives,func,isovalue,0,0,0,dimx()-1.0f,dimy()-1.0f,dimz()-1.0f,size_x,size_y,size_z);
21275  } else {
21276  const _marching3d_func_float func(*this);
21277  vertices = isosurface3d(primitives,func,isovalue,0,0,0,dimx()-1.0f,dimy()-1.0f,dimz()-1.0f,size_x,size_y,size_z);
21278  }
21279  return vertices;
21280  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
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.
Definition: CImg.h:21460
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<uintT> get_label_regions ( ) const
inline

Definition at line 15638 of file CImg.h.

Referenced by CImg< uintT >::label_regions().

15638  {
15639 #define _cimg_get_label_test(p,q) { \
15640  flag = true; \
15641  const T *ptr1 = ptr(x,y) + siz, *ptr2 = ptr(p,q) + siz; \
15642  for (unsigned int i = dim; flag && i; --i) { ptr1-=wh; ptr2-=wh; flag = (*ptr1==*ptr2); } \
15643 }
15644  if (depth>1)
15645  throw CImgInstanceException("CImg<%s>::label_regions() : Instance image must be a 2D image");
15646  CImg<uintT> res(width,height,depth,1,0);
15647  unsigned int label = 1;
15648  const unsigned int wh = width*height, siz = width*height*dim;
15649  const int W1 = dimx()-1, H1 = dimy()-1;
15650  bool flag;
15651  cimg_forXY(*this,x,y) {
15652  bool done = false;
15653  if (y) {
15655  if (flag) {
15656  const unsigned int lab = (res(x,y) = res(x,y-1));
15657  done = true;
15658  if (x && res(x-1,y)!=lab) {
15660  if (flag) {
15661  const unsigned int lold = res(x-1,y), *const cptr = res.ptr(x,y);
15662  for (unsigned int *ptr = res.ptr(); ptr<cptr; ++ptr) if (*ptr==lold) *ptr = lab;
15663  }
15664  }
15665  }
15666  }
15667  if (x && !done) { _cimg_get_label_test(x-1,y); if (flag) { res(x,y) = res(x-1,y); done = true; }}
15668  if (!done) res(x,y) = label++;
15669  }
15670  for (int y = H1; y>=0; --y) for (int x=W1; x>=0; --x) {
15671  bool done = false;
15672  if (y<H1) {
15674  if (flag) {
15675  const unsigned int lab = (res(x,y) = res(x,y+1));
15676  done = true;
15677  if (x<W1 && res(x+1,y)!=lab) {
15679  if (flag) {
15680  const unsigned int lold = res(x+1,y), *const cptr = res.ptr(x,y);
15681  for (unsigned int *ptr = res.ptr()+res.size()-1; ptr>cptr; --ptr) if (*ptr==lold) *ptr = lab;
15682  }
15683  }
15684  }
15685  }
15686  if (x<W1 && !done) { _cimg_get_label_test(x+1,y); if (flag) res(x,y) = res(x+1,y); done = true; }
15687  }
15688  const unsigned int lab0 = res.max()+1;
15689  label = lab0;
15690  cimg_foroff(res,off) { // Relabel regions
15691  const unsigned int lab = res[off];
15692  if (lab<lab0) { cimg_for(res,ptr,unsigned int) if (*ptr==lab) *ptr = label; ++label; }
15693  }
15694  return (res-=lab0);
15695  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
#define cimg_foroff(img, off)
Definition: CImg.h:590
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define _cimg_get_label_test(p, q)

Here is the caller graph for this function:

CImg<Tuchar> get_LabtoRGB ( ) const
inline

Definition at line 16423 of file CImg.h.

16423  {
16424  return CImg<Tuchar>(*this,false).LabtoRGB();
16425  }
CImg< T > & LabtoRGB()
Convert a (L,a,b) image to a (R,G,B) one.
Definition: CImg.h:16419
CImg<Tfloat> get_LabtoXYZ ( ) const
inline

Definition at line 16354 of file CImg.h.

16354  {
16355  return CImg<Tfloat>(*this,false).LabtoXYZ();
16356  }
CImg< T > & LabtoXYZ()
Convert (L,a,b) pixels of a color image into the (X,Y,Z) color space.
Definition: CImg.h:16323
CImg<T> get_line ( const unsigned int  y0) const
inline

Definition at line 18425 of file CImg.h.

18425  {
18426  return get_lines(y0,y0);
18427  }
CImg< T > get_lines(const unsigned int y0, const unsigned int y1) const
Definition: CImg.h:18434
CImg<T> get_lines ( const unsigned int  y0,
const unsigned int  y1 
) const
inline

Definition at line 18434 of file CImg.h.

Referenced by CImg< uintT >::get_line(), and CImg< uintT >::lines().

18434  {
18435  return get_crop(0,(int)y0,0,0,dimx()-1,(int)y1,dimz()-1,dimv()-1);
18436  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

static CImg<T> get_load ( const char *const  filename)
inlinestatic

Definition at line 29261 of file CImg.h.

29261  {
29262  return CImg<T>().load(filename);
29263  }
CImg< T > & load(const char *const filename)
Load an image from a file.
Definition: CImg.h:29130
static CImg<T> get_load_analyze ( const char *const  filename,
float *const  voxsize = 0 
)
inlinestatic

Definition at line 30412 of file CImg.h.

30412  {
30413  return CImg<T>().load_analyze(filename,voxsize);
30414  }
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
Definition: CImg.h:30408
static CImg<T> get_load_analyze ( std::FILE *const  file,
float *const  voxsize = 0 
)
inlinestatic

Definition at line 30421 of file CImg.h.

30421  {
30422  return CImg<T>().load_analyze(file,voxsize);
30423  }
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
Definition: CImg.h:30408
static CImg<T> get_load_ascii ( const char *const  filename)
inlinestatic

Definition at line 29270 of file CImg.h.

29270  {
29271  return CImg<T>().load_ascii(filename);
29272  }
CImg< T > & load_ascii(const char *const filename)
Load an image from an ASCII file.
Definition: CImg.h:29266
static CImg<T> get_load_ascii ( std::FILE *const  file)
inlinestatic

Definition at line 29279 of file CImg.h.

29279  {
29280  return CImg<T>().load_ascii(file);
29281  }
CImg< T > & load_ascii(const char *const filename)
Load an image from an ASCII file.
Definition: CImg.h:29266
static CImg<T> get_load_bmp ( const char *const  filename)
inlinestatic

Definition at line 29366 of file CImg.h.

29366  {
29367  return CImg<T>().load_bmp(filename);
29368  }
CImg< T > & load_bmp(const char *const filename)
Load an image from a BMP file.
Definition: CImg.h:29362
static CImg<T> get_load_bmp ( std::FILE *const  file)
inlinestatic

Definition at line 29375 of file CImg.h.

29375  {
29376  return CImg<T>().load_bmp(file);
29377  }
CImg< T > & load_bmp(const char *const filename)
Load an image from a BMP file.
Definition: CImg.h:29362
static CImg<T> get_load_cimg ( const char *const  filename,
const char  axis = 'z',
const char  align = 'p' 
)
inlinestatic

Definition at line 30538 of file CImg.h.

30538  {
30539  return CImg<T>().load_cimg(filename,axis,align);
30540  }
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
Definition: CImg.h:30531
static CImg<T> get_load_cimg ( std::FILE *const  file,
const char  axis = 'z',
const char  align = 'p' 
)
inlinestatic

Definition at line 30550 of file CImg.h.

30550  {
30551  return CImg<T>().load_cimg(file,axis,align);
30552  }
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
Definition: CImg.h:30531
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  v0,
const unsigned int  x1,
const unsigned int  y1,
const unsigned int  z1,
const unsigned int  v1,
const char  axis = 'z',
const char  align = 'p' 
)
inlinestatic

Definition at line 30566 of file CImg.h.

30570  {
30571  return CImg<T>().load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align);
30572  }
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
Definition: CImg.h:30531
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  v0,
const unsigned int  x1,
const unsigned int  y1,
const unsigned int  z1,
const unsigned int  v1,
const char  axis = 'z',
const char  align = 'p' 
)
inlinestatic

Definition at line 30586 of file CImg.h.

30590  {
30591  return CImg<T>().load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1,axis,align);
30592  }
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
Definition: CImg.h:30531
static CImg<T> get_load_dcraw_external ( const char *const  filename)
inlinestatic

Definition at line 31388 of file CImg.h.

31388  {
31389  return CImg<T>().load_dcraw_external(filename);
31390  }
CImg< T > & load_dcraw_external(const char *const filename)
Load a RAW Color Camera image file, using external tool &#39;dcraw&#39;.
Definition: CImg.h:31359
static CImg<T> get_load_dlm ( const char *const  filename)
inlinestatic

Definition at line 29318 of file CImg.h.

29318  {
29319  return CImg<T>().load_dlm(filename);
29320  }
CImg< T > & load_dlm(const char *const filename)
Load an image from a DLM file.
Definition: CImg.h:29314
static CImg<T> get_load_dlm ( std::FILE *const  file)
inlinestatic

Definition at line 29327 of file CImg.h.

29327  {
29328  return CImg<T>().load_dlm(file);
29329  }
CImg< T > & load_dlm(const char *const filename)
Load an image from a DLM file.
Definition: CImg.h:29314
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 char  align = 'p' 
)
inlinestatic

Definition at line 30991 of file CImg.h.

Referenced by CImg< uintT >::load_ffmpeg().

30993  {
30994  return CImgList<T>().load_ffmpeg(filename,first_frame,last_frame,step_frame,pixel_format,resume).get_append(axis,align);
30995  }
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 char align='p')
Load a video sequence using FFMPEG av&#39;s libraries.
Definition: CImg.h:30985

Here is the caller graph for this function:

static CImg<T> get_load_ffmpeg_external ( const char *const  filename,
const char  axis = 'z',
const char  align = 'p' 
)
inlinestatic

Definition at line 31216 of file CImg.h.

Referenced by CImg< uintT >::load_ffmpeg_external().

31216  {
31217  return CImgList<T>().load_ffmpeg_external(filename).get_append(axis,align);
31218  }
CImg< T > & load_ffmpeg_external(const char *const filename, const char axis='z', const char align='p')
Load a video sequence using FFMPEG&#39;s external tool &#39;ffmpeg&#39;.
Definition: CImg.h:31212

Here is the caller graph for this function:

static CImg<T> get_load_graphicsmagick_external ( const char *const  filename)
inlinestatic

Definition at line 31250 of file CImg.h.

31250  {
31251  return CImg<T>().load_graphicsmagick_external(filename);
31252  }
CImg< T > & load_graphicsmagick_external(const char *const filename)
Load an image using GraphicsMagick&#39;s external tool &#39;gm&#39;.
Definition: CImg.h:31221
static CImg<T> get_load_gzip_external ( const char *const  filename)
inlinestatic

Definition at line 31286 of file CImg.h.

31286  {
31287  return CImg<T>().load_gzip_external(filename);
31288  }
CImg< T > & load_gzip_external(const char *const filename)
Load a gzipped image file, using external tool &#39;gunzip&#39;.
Definition: CImg.h:31255
static CImg<T> get_load_imagemagick_external ( const char *const  filename)
inlinestatic

Definition at line 31320 of file CImg.h.

31320  {
31321  return CImg<T>().load_imagemagick_external(filename);
31322  }
CImg< T > & load_imagemagick_external(const char *const filename)
Load an image using ImageMagick&#39;s external tool &#39;convert&#39;.
Definition: CImg.h:31291
static CImg<T> get_load_inr ( const char *const  filename,
float *const  voxsize = 0 
)
inlinestatic

Definition at line 30599 of file CImg.h.

30599  {
30600  return CImg<T>().load_inr(filename,voxsize);
30601  }
CImg< T > & load_inr(const char *const filename, float *const voxsize=0)
Load an image from an INRIMAGE-4 file.
Definition: CImg.h:30595
static CImg<T> get_load_inr ( std::FILE *const  file,
float *  voxsize = 0 
)
inlinestatic

Definition at line 30608 of file CImg.h.

30608  {
30609  return CImg<T>().load_inr(file,voxsize);
30610  }
CImg< T > & load_inr(const char *const filename, float *const voxsize=0)
Load an image from an INRIMAGE-4 file.
Definition: CImg.h:30595
static CImg<T> get_load_jpeg ( const char *const  filename)
inlinestatic

Definition at line 29497 of file CImg.h.

29497  {
29498  return CImg<T>().load_jpeg(filename);
29499  }
CImg< T > & load_jpeg(const char *const filename)
Load an image from a JPEG file.
Definition: CImg.h:29493
static CImg<T> get_load_jpeg ( std::FILE *const  file)
inlinestatic

Definition at line 29506 of file CImg.h.

29506  {
29507  return CImg<T>().load_jpeg(file);
29508  }
CImg< T > & load_jpeg(const char *const filename)
Load an image from a JPEG file.
Definition: CImg.h:29493
static CImg<T> get_load_magick ( const char *const  filename)
inlinestatic

Definition at line 29646 of file CImg.h.

29646  {
29647  return CImg<T>().load_magick(filename);
29648  }
CImg< T > & load_magick(const char *const filename)
Load an image from a file, using Magick++ library.
Definition: CImg.h:29585
static CImg<T> get_load_medcon_external ( const char *const  filename)
inlinestatic

Definition at line 31354 of file CImg.h.

31354  {
31355  return CImg<T>().load_medcon_external(filename);
31356  }
CImg< T > & load_medcon_external(const char *const filename)
Load a DICOM image file, using XMedcon&#39;s external tool &#39;medcon&#39;.
Definition: CImg.h:31325
static CImg<T> get_load_off ( const char *const  filename,
CImgList< tf > &  primitives,
CImgList< tc > &  colors 
)
inlinestatic

Definition at line 31034 of file CImg.h.

31034  {
31035  return CImg<T>().load_off(filename,primitives,colors);
31036  }
CImg< T > & load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Load a 3D object from a .OFF file.
Definition: CImg.h:31029
static CImg<T> get_load_off ( std::FILE *const  file,
CImgList< tf > &  primitives,
CImgList< tc > &  colors 
)
inlinestatic

Definition at line 31045 of file CImg.h.

31045  {
31046  return CImg<T>().load_off(file,primitives,colors);
31047  }
CImg< T > & load_off(const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Load a 3D object from a .OFF file.
Definition: CImg.h:31029
static CImg<T> get_load_other ( const char *const  filename)
inlinestatic

Definition at line 31416 of file CImg.h.

31416  {
31417  return CImg<T>().load_other(filename);
31418  }
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
static CImg<T> get_load_pandore ( const char *const  filename)
inlinestatic

Definition at line 30705 of file CImg.h.

30705  {
30706  return CImg<T>().load_pandore(filename);
30707  }
CImg< T > & load_pandore(const char *const filename)
Load an image from a PANDORE file.
Definition: CImg.h:30701
static CImg<T> get_load_pandore ( std::FILE *const  file)
inlinestatic

Definition at line 30714 of file CImg.h.

30714  {
30715  return CImg<T>().load_pandore(file);
30716  }
CImg< T > & load_pandore(const char *const filename)
Load an image from a PANDORE file.
Definition: CImg.h:30701
static CImg<T> get_load_parrec ( const char *const  filename,
const char  axis = 'v',
const char  align = 'p' 
)
inlinestatic

Definition at line 30923 of file CImg.h.

30923  {
30924  return CImg<T>().load_parrec(filename,axis,align);
30925  }
CImg< T > & load_parrec(const char *const filename, const char axis='v', const char align='p')
Load an image from a PAR-REC (Philips) file.
Definition: CImg.h:30916
static CImg<T> get_load_png ( const char *const  filename)
inlinestatic

Definition at line 29655 of file CImg.h.

29655  {
29656  return CImg<T>().load_png(filename);
29657  }
CImg< T > & load_png(const char *const filename)
Load an image from a PNG file.
Definition: CImg.h:29651
static CImg<T> get_load_png ( std::FILE *const  file)
inlinestatic

Definition at line 29664 of file CImg.h.

29664  {
29665  return CImg<T>().load_png(file);
29666  }
CImg< T > & load_png(const char *const filename)
Load an image from a PNG file.
Definition: CImg.h:29651
static CImg<T> get_load_pnm ( const char *const  filename)
inlinestatic

Definition at line 29816 of file CImg.h.

29816  {
29817  return CImg<T>().load_pnm(filename);
29818  }
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
static CImg<T> get_load_pnm ( std::FILE *const  file)
inlinestatic

Definition at line 29825 of file CImg.h.

29825  {
29826  return CImg<T>().load_pnm(file);
29827  }
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
static CImg<T> get_load_raw ( const char *const  filename,
const unsigned int  sizex,
const unsigned int  sizey = 1,
const unsigned int  sizez = 1,
const unsigned int  sizev = 1,
const bool  multiplexed = false,
const bool  invert_endianness = false 
)
inlinestatic

Definition at line 30935 of file CImg.h.

30938  {
30939  return CImg<T>().load_raw(filename,sizex,sizey,sizez,sizev,multiplexed,invert_endianness);
30940  }
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
Definition: CImg.h:14951
CImg< T > & load_raw(const char *const filename, const unsigned int sizex, 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.
Definition: CImg.h:30928
static CImg<T> get_load_raw ( std::FILE *const  file,
const unsigned int  sizex,
const unsigned int  sizey = 1,
const unsigned int  sizez = 1,
const unsigned int  sizev = 1,
const bool  multiplexed = false,
const bool  invert_endianness = false 
)
inlinestatic

Definition at line 30950 of file CImg.h.

30953  {
30954  return CImg<T>().load_raw(file,sizex,sizey,sizez,sizev,multiplexed,invert_endianness);
30955  }
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
Definition: CImg.h:14951
CImg< T > & load_raw(const char *const filename, const unsigned int sizex, 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.
Definition: CImg.h:30928
static CImg<T> get_load_rgb ( const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inlinestatic

Definition at line 29953 of file CImg.h.

29953  {
29954  return CImg<T>().load_rgb(filename,dimw,dimh);
29955  }
CImg< T > & load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGB file.
Definition: CImg.h:29949
static CImg<T> get_load_rgb ( std::FILE *const  file,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inlinestatic

Definition at line 29962 of file CImg.h.

29962  {
29963  return CImg<T>().load_rgb(file,dimw,dimh);
29964  }
CImg< T > & load_rgb(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGB file.
Definition: CImg.h:29949
static CImg<T> get_load_rgba ( const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inlinestatic

Definition at line 29999 of file CImg.h.

29999  {
30000  return CImg<T>().load_rgba(filename,dimw,dimh);
30001  }
CImg< T > & load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGBA file.
Definition: CImg.h:29995
static CImg<T> get_load_rgba ( std::FILE *const  file,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inlinestatic

Definition at line 30008 of file CImg.h.

30008  {
30009  return CImg<T>().load_rgba(file,dimw,dimh);
30010  }
CImg< T > & load_rgba(const char *const filename, const unsigned int dimw, const unsigned int dimh=1)
Load an image from a RGBA file.
Definition: CImg.h:29995
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 
)
inlinestatic

Definition at line 30086 of file CImg.h.

30088  {
30089  return CImg<T>().load_tiff(filename,first_frame,last_frame,step_frame);
30090  }
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.
Definition: CImg.h:30043
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 char  align = 'p' 
)
inlinestatic

Definition at line 31005 of file CImg.h.

Referenced by CImg< uintT >::load_yuv().

31008  {
31009  return CImgList<T>().load_yuv(filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb).get_append(axis,align);
31010  }
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 char align='p')
Load an image sequence from a YUV file.
Definition: CImg.h:30998

Here is the caller graph for this function:

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 char  align = 'p' 
)
inlinestatic

Definition at line 31020 of file CImg.h.

31023  {
31024  return CImgList<T>().load_yuv(file,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb).get_append(axis,align);
31025  }
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 char align='p')
Load an image sequence from a YUV file.
Definition: CImg.h:30998
CImg<Tfloat> get_log ( ) const
inline

Definition at line 12555 of file CImg.h.

Referenced by cimg_library::log().

12555  {
12556  return CImg<Tfloat>(*this,false).log();
12557  }
CImg< T > & log()
Compute the log of each each pixel value.
Definition: CImg.h:12550

Here is the caller graph for this function:

CImg<Tfloat> get_log10 ( ) const
inline

Definition at line 12565 of file CImg.h.

Referenced by cimg_library::log10().

12565  {
12566  return CImg<Tfloat>(*this,false).log10();
12567  }
CImg< T > & log10()
Compute the log10 of each each pixel value.
Definition: CImg.h:12560

Here is the caller graph for this function:

CImg<t> get_map ( const CImg< t > &  palette) const
inline

Definition at line 15576 of file CImg.h.

Referenced by CImg< uintT >::map().

15576  {
15577  if (dim!=1 && palette.dim!=1)
15578  throw CImgArgumentException("CImg<%s>::map() : Palette (%u,%u,%u,%u,%p) and instance image (%u,%u,%u,%u,%p) "
15579  "have incompatible sizes.",pixel_type(),
15580  palette.width,palette.height,palette.depth,palette.dim,palette.data,
15582  const unsigned int whz = width*height*depth, pwhz = palette.width*palette.height*palette.depth;
15583  CImg<t> res(width,height,depth,palette.dim==1?dim:palette.dim);
15584  switch (palette.dim) {
15585  case 1 : { // Optimized for scalars.
15586  const T *ptrs = data + whz*dim;
15587  cimg_for(res,ptrd,t) {
15588  const unsigned int _ind = (unsigned int)*(--ptrs), ind = _ind<pwhz?_ind:0;
15589  *ptrd = palette[ind];
15590  }
15591  } break;
15592  case 2 : { // Optimized for 2D vectors.
15593  const t *const ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz;
15594  t *ptrd0 = res.data, *ptrd1 = ptrd0 + whz;
15595  for (const T *ptrs = data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15596  const unsigned int _ind = (unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15597  *(ptrd0++) = ptrp0[ind]; *(ptrd1++) = ptrp1[ind];
15598  }
15599  } break;
15600  case 3 : { // Optimized for 3D vectors (colors).
15601  const t *const ptrp0 = palette.data, *ptrp1 = ptrp0 + pwhz, *ptrp2 = ptrp1 + pwhz;
15602  t *ptrd0 = res.data, *ptrd1 = ptrd0 + whz, *ptrd2 = ptrd1 + whz;
15603  for (const T *ptrs = data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15604  const unsigned int _ind = (unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15605  *(ptrd0++) = ptrp0[ind]; *(ptrd1++) = ptrp1[ind]; *(ptrd2++) = ptrp2[ind];
15606  }
15607  } break;
15608  default : { // Generic version.
15609  t *ptrd = res.data;
15610  for (const T *ptrs = data, *ptrs_end = ptrs + whz; ptrs<ptrs_end; ) {
15611  const unsigned int _ind = (unsigned int)*(ptrs++), ind = _ind<pwhz?_ind:0;
15612  const t *ptrp = palette.data + ind;
15613  t *_ptrd = ptrd++; cimg_forV(res,k) { *_ptrd = *ptrp; _ptrd+=whz; ptrp+=pwhz; }
15614  }
15615  }
15616  }
15617  return res;
15618  }
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T> get_matrix ( ) const
inline

Definition at line 13367 of file CImg.h.

13367  {
13368  return (+*this).matrix();
13369  }
CImg<T> get_matrix_at ( const unsigned int  x = 0,
const unsigned int  y = 0,
const unsigned int  z = 0 
) const
inline

Return a new image corresponding to the square matrix located at (x,y,z) of the current vector-valued image.

Definition at line 13281 of file CImg.h.

13281  {
13282  const int n = (int)std::sqrt((double)dim);
13283  CImg<T> dest(n,n);
13284  cimg_forV(*this,k) dest[k]=(*this)(x,y,z,k);
13285  return dest;
13286  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
double sqrt(double d)
Definition: double.h:73
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_max ( const T  val) const
inline

Definition at line 12835 of file CImg.h.

12835  {
12836  return (+*this).max(val);
12837  }
CImg<_cimg_Tt> get_max ( const CImg< t > &  img) const
inline

Definition at line 12850 of file CImg.h.

12850  {
12851  return CImg<_cimg_Tt>(*this,false).max(img);
12852  }
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
CImg<Tfloat> get_max ( const char *const  expression) const
inline

Definition at line 12876 of file CImg.h.

12876  {
12877  return CImg<Tfloat>(*this,false).max(expression);
12878  }
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
CImg<T> get_min ( const T  val) const
inline

Definition at line 12784 of file CImg.h.

12784  {
12785  return (+*this).min(val);
12786  }
CImg<_cimg_Tt> get_min ( const CImg< t > &  img) const
inline

Definition at line 12799 of file CImg.h.

12799  {
12800  return CImg<_cimg_Tt>(*this,false).min(img);
12801  }
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
CImg<Tfloat> get_min ( const char *const  expression) const
inline

Definition at line 12825 of file CImg.h.

12825  {
12826  return CImg<Tfloat>(*this,false).min(expression);
12827  }
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
CImg<T> get_mirror ( const char  axis) const
inline

Definition at line 17212 of file CImg.h.

Referenced by CImg< uintT >::get_convolve().

17212  {
17213  return (+*this).mirror(axis);
17214  }

Here is the caller graph for this function:

CImg<_cimg_Tt> get_mul ( const CImg< t > &  img) const
inline

Definition at line 12698 of file CImg.h.

12698  {
12699  return CImg<_cimg_Tt>(*this,false).mul(img);
12700  }
CImg< T > & mul(const CImg< t > &img)
Pointwise multiplication between two images.
Definition: CImg.h:12685
CImg<T> get_noise ( const double  sigma,
const unsigned int  noise_type = 0 
) const
inline

Definition at line 15055 of file CImg.h.

15055  {
15056  return (+*this).noise(sigma,noise_type);
15057  }
CImg<Tfloat> get_norm ( const int  norm_type = 2) const
inline

Definition at line 15131 of file CImg.h.

Referenced by CImg< uintT >::norm().

15131  {
15132  if (is_empty()) return *this;
15133  if (dim==1) return get_abs();
15134  CImg<Tfloat> res(width,height,depth);
15135  switch (norm_type) {
15136  case -1 : { // Linf norm
15137  cimg_forXYZ(*this,x,y,z) {
15138  Tfloat n = 0; cimg_forV(*this,v) {
15139  const Tfloat tmp = (Tfloat)cimg::abs((*this)(x,y,z,v));
15140  if (tmp>n) n=tmp; res(x,y,z) = n;
15141  }
15142  }
15143  } break;
15144  case 1 : { // L1 norm
15145  cimg_forXYZ(*this,x,y,z) {
15146  Tfloat n = 0; cimg_forV(*this,v) n+=cimg::abs((*this)(x,y,z,v)); res(x,y,z) = n;
15147  }
15148  } break;
15149  default : { // L2 norm
15150  cimg_forXYZ(*this,x,y,z) {
15151  Tfloat n = 0; cimg_forV(*this,v) n+=(*this)(x,y,z,v)*(*this)(x,y,z,v); res(x,y,z) = (Tfloat)std::sqrt((double)n);
15152  }
15153  }
15154  }
15155  return res;
15156  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
const NT & n
CImg< Tfloat > get_abs() const
Definition: CImg.h:12575
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_normalize ( const T  value_min,
const T  value_max 
) const
inline

Definition at line 15083 of file CImg.h.

15083  {
15084  return CImg<Tfloat>(*this,false).normalize((Tfloat)value_min,(Tfloat)value_max);
15085  }
CImg< T > & normalize()
Normalize multi-valued pixels of the instance image, with respect to their L2-norm.
Definition: CImg.h:15099
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
CImg<Tfloat> get_normalize ( ) const
inline

Definition at line 15110 of file CImg.h.

15110  {
15111  return CImg<Tfloat>(*this,false).normalize();
15112  }
CImg< T > & normalize()
Normalize multi-valued pixels of the instance image, with respect to their L2-norm.
Definition: CImg.h:15099
CImg<T> get_permute_axes ( const char *  order) const
inline

Definition at line 17604 of file CImg.h.

Referenced by CImg< uintT >::get_transpose(), and CImg< uintT >::permute_axes().

17604  {
17605  const T foo = (T)0;
17606  return _get_permute_axes(order,foo);
17607  }
CImg< t > _get_permute_axes(const char *permut, const t &) const
Definition: CImg.h:17431

Here is the caller graph for this function:

CImg<Tfloat> get_pow ( const double  p) const
inline

Definition at line 12733 of file CImg.h.

12733  {
12734  return CImg<Tfloat>(*this,false).pow(p);
12735  }
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
CImg<Tfloat> get_pow ( const CImg< t > &  img) const
inline

Definition at line 12748 of file CImg.h.

12748  {
12749  return CImg<Tfloat>(*this,false).pow(img);
12750  }
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
CImg<Tfloat> get_pow ( const char *const  expression) const
inline

Definition at line 12774 of file CImg.h.

12774  {
12775  return CImg<Tfloat>(*this,false).pow(expression);
12776  }
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
CImg<T> get_projections2d ( const unsigned int  x0,
const unsigned int  y0,
const unsigned int  z0,
const int  dx = -100,
const int  dy = -100,
const int  dz = -100 
) const
inline

Definition at line 18151 of file CImg.h.

Referenced by CImg< uintT >::_get_select(), and CImg< uintT >::projections2d().

18152  {
18153  if (is_empty()) return *this;
18154  const unsigned int
18155  nx0 = (x0>=width)?width-1:x0,
18156  ny0 = (y0>=height)?height-1:y0,
18157  nz0 = (z0>=depth)?depth-1:z0;
18158  CImg<T>
18159  imgxy(width,height,1,dim),
18160  imgzy(depth,height,1,dim),
18161  imgxz(width,depth,1,dim);
18162  cimg_forXYV(*this,x,y,k) imgxy(x,y,k) = (*this)(x,y,nz0,k);
18163  cimg_forYZV(*this,y,z,k) imgzy(z,y,k) = (*this)(nx0,y,z,k);
18164  cimg_forXZV(*this,x,z,k) imgxz(x,z,k) = (*this)(x,ny0,z,k);
18165  imgxy.resize(dx,dy,1,dim,1);
18166  imgzy.resize(dz,dy,1,dim,1);
18167  imgxz.resize(dx,dz,1,dim,1);
18168  return CImg<T>(imgxy.width + imgzy.width,imgxy.height + imgxz.height,1,dim,0).
18169  draw_image(imgxy).draw_image(imgxy.width,imgzy).draw_image(0,imgxy.height,imgxz);
18170  }
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
Definition: CImg.h:16630
void int int REAL * x
Definition: read.cpp:74
CImg()
Default constructor.
Definition: CImg.h:9857
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606

Here is the caller graph for this function:

CImg<Tfloat> get_pseudoinvert ( ) const
inline

Definition at line 13547 of file CImg.h.

Referenced by cimg_library::pseudoinvert(), and CImg< uintT >::pseudoinvert().

13547  {
13548  CImg<Tfloat> U, S, V;
13549  SVD(U,S,V);
13550  cimg_forX(V,x) {
13551  const Tfloat s = S(x), invs = s!=0?1/s:(Tfloat)0;
13552  cimg_forY(V,y) V(x,y)*=invs;
13553  }
13554  return V*U.transpose();
13555  }
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
CImg< T > & transpose()
Transpose the current matrix.
Definition: CImg.h:13441
void int int REAL * x
Definition: read.cpp:74
const CImg< T > & SVD(CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
Compute the SVD of a general matrix.
Definition: CImg.h:13843
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forY(img, y)
Definition: CImg.h:594

Here is the caller graph for this function:

CImg<T> get_quantize ( const unsigned int  n,
const bool  keep_range = true 
) const
inline

Definition at line 15215 of file CImg.h.

15215  {
15216  return (+*this).quantize(n,keep_range);
15217  }
const NT & n
CImg<T> get_rand ( const T  val_min,
const T  val_max 
) const
inline

Definition at line 14967 of file CImg.h.

14967  {
14968  return (+*this).rand(val_min,val_max);
14969  }
CImg<T> get_resize ( const int  pdx,
const int  pdy = -100,
const int  pdz = -100,
const int  pdv = -100,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
) const
inline

Definition at line 16650 of file CImg.h.

Referenced by CImg< uintT >::__draw_object3d(), CImg< uintT >::_display_object3d(), CImg< uintT >::_save_off(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_resize(), and CImg< uintT >::resize().

16651  {
16652  if (!pdx || !pdy || !pdz || !pdv) return CImg<T>();
16653  const unsigned int
16654  tdx = pdx<0?-pdx*width/100:pdx,
16655  tdy = pdy<0?-pdy*height/100:pdy,
16656  tdz = pdz<0?-pdz*depth/100:pdz,
16657  tdv = pdv<0?-pdv*dim/100:pdv,
16658  dx = tdx?tdx:1,
16659  dy = tdy?tdy:1,
16660  dz = tdz?tdz:1,
16661  dv = tdv?tdv:1;
16662  if (width==dx && height==dy && depth==dz && dim==dv) return +*this;
16663  if (is_empty()) return CImg<T>(dx,dy,dz,dv,0);
16664 
16665  CImg<T> res;
16666  switch (interpolation_type) {
16667  case -1 : // Raw resizing
16668  std::memcpy(res.assign(dx,dy,dz,dv,0).data,data,sizeof(T)*cimg::min(size(),(unsigned int)dx*dy*dz*dv));
16669  break;
16670 
16671  case 0 : { // No interpolation
16672  const unsigned int bx = width-1, by = height-1, bz = depth-1, bv = dim-1;
16673  res.assign(dx,dy,dz,dv);
16674  switch (border_condition) {
16675  case 1 : {
16676  if (center) {
16677  const int
16678  x0 = (res.dimx() - dimx())/2,
16679  y0 = (res.dimy() - dimy())/2,
16680  z0 = (res.dimz() - dimz())/2,
16681  v0 = (res.dimv() - dimv())/2,
16682  x1 = x0 + (int)bx,
16683  y1 = y0 + (int)by,
16684  z1 = z0 + (int)bz,
16685  v1 = v0 + (int)bv;
16686  res.draw_image(x0,y0,z0,v0,*this);
16687  cimg_for_outXYZV(res,x0,y0,z0,v0,x1,y1,z1,v1,x,y,z,v) res(x,y,z,v) = _atXYZV(x - x0,y - y0,z - z0,v - v0);
16688  } else {
16689  res.draw_image(*this);
16690  cimg_for_outXYZV(res,0,0,0,0,bx,by,bz,bv,x,y,z,v) res(x,y,z,v) = _atXYZV(x,y,z,v);
16691  }
16692  } break;
16693  case 2 : {
16694  int nx0 = 0, ny0 = 0, nz0 = 0, nv0 = 0;
16695  if (center) {
16696  const int
16697  x0 = (res.dimx() - dimx())/2,
16698  y0 = (res.dimy() - dimy())/2,
16699  z0 = (res.dimz() - dimz())/2,
16700  v0 = (res.dimv() - dimv())/2;
16701  nx0 = x0>0?x0-(1+x0/width)*width:x0;
16702  ny0 = y0>0?y0-(1+y0/height)*height:y0;
16703  nz0 = z0>0?z0-(1+z0/depth)*depth:z0;
16704  nv0 = v0>0?v0-(1+v0/dim)*dim:v0;
16705  }
16706  for (int k = nv0; k<(int)dv; k+=dimv())
16707  for (int z = nz0; z<(int)dz; z+=dimz())
16708  for (int y = ny0; y<(int)dy; y+=dimy())
16709  for (int x = nx0; x<(int)dx; x+=dimx()) res.draw_image(x,y,z,k,*this);
16710  } break;
16711  default : {
16712  res.fill(0);
16713  if (center) res.draw_image((res.dimx()-dimx())/2,(res.dimy()-dimy())/2,(res.dimz()-dimz())/2,(res.dimv()-dimv())/2,*this);
16714  else res.draw_image(*this);
16715  }
16716  }
16717  } break;
16718 
16719  case 1 : { // Nearest-neighbor interpolation
16720  res.assign(dx,dy,dz,dv);
16721  unsigned int
16722  *const offx = new unsigned int[dx],
16723  *const offy = new unsigned int[dy+1],
16724  *const offz = new unsigned int[dz+1],
16725  *const offv = new unsigned int[dv+1],
16726  *poffx, *poffy, *poffz, *poffv,
16727  curr, old;
16728  const unsigned int wh = width*height, whd = width*height*depth, rwh = dx*dy, rwhd = dx*dy*dz;
16729  poffx = offx; curr = 0; cimg_forX(res,x) { old = curr; curr = (x+1)*width/dx; *(poffx++) = (unsigned int)curr - (unsigned int)old; }
16730  poffy = offy; curr = 0; cimg_forY(res,y) { old = curr; curr = (y+1)*height/dy; *(poffy++) = width*((unsigned int)curr - (unsigned int)old); } *poffy = 0;
16731  poffz = offz; curr = 0; cimg_forZ(res,z) { old = curr; curr = (z+1)*depth/dz; *(poffz++) = wh*((unsigned int)curr - (unsigned int)old); } *poffz = 0;
16732  poffv = offv; curr = 0; cimg_forV(res,k) { old = curr; curr = (k+1)*dim/dv; *(poffv++) = whd*((unsigned int)curr - (unsigned int)old); } *poffv = 0;
16733  T *ptrd = res.data;
16734  const T* ptrv = data;
16735  poffv = offv;
16736  for (unsigned int k = 0; k<dv; ) {
16737  const T *ptrz = ptrv;
16738  poffz = offz;
16739  for (unsigned int z = 0; z<dz; ) {
16740  const T *ptry = ptrz;
16741  poffy = offy;
16742  for (unsigned int y = 0; y<dy; ) {
16743  const T *ptrx = ptry;
16744  poffx = offx;
16745  cimg_forX(res,x) { *(ptrd++) = *ptrx; ptrx+=*(poffx++); }
16746  ++y;
16747  unsigned int dy = *(poffy++);
16748  for (;!dy && y<dy; std::memcpy(ptrd,ptrd - dx,sizeof(T)*dx), ++y, ptrd+=dx, dy=*(poffy++)) {}
16749  ptry+=dy;
16750  }
16751  ++z;
16752  unsigned int dz = *(poffz++);
16753  for (;!dz && z<dz; std::memcpy(ptrd,ptrd-rwh,sizeof(T)*rwh), ++z, ptrd+=rwh, dz=*(poffz++)) {}
16754  ptrz+=dz;
16755  }
16756  ++k;
16757  unsigned int dv = *(poffv++);
16758  for (;!dv && k<dv; std::memcpy(ptrd,ptrd-rwhd,sizeof(T)*rwhd), ++k, ptrd+=rwhd, dv=*(poffv++)) {}
16759  ptrv+=dv;
16760  }
16761  delete[] offx; delete[] offy; delete[] offz; delete[] offv;
16762  } break;
16763 
16764  case 2 : { // Moving average
16765  bool instance_first = true;
16766  if (dx!=width) {
16767  CImg<Tfloat> tmp(dx,height,depth,dim,0);
16768  for (unsigned int a = width*dx, b = width, c = dx, s = 0, t = 0; a; ) {
16769  const unsigned int d = cimg::min(b,c);
16770  a-=d; b-=d; c-=d;
16771  cimg_forYZV(tmp,y,z,v) tmp(t,y,z,v)+=(Tfloat)(*this)(s,y,z,v)*d;
16772  if (!b) { cimg_forYZV(tmp,y,z,v) tmp(t,y,z,v)/=width; ++t; b = width; }
16773  if (!c) { ++s; c = dx; }
16774  }
16775  tmp.transfer_to(res);
16776  instance_first = false;
16777  }
16778  if (dy!=height) {
16779  CImg<Tfloat> tmp(dx,dy,depth,dim,0);
16780  for (unsigned int a = height*dy, b = height, c = dy, s = 0, t = 0; a; ) {
16781  const unsigned int d = cimg::min(b,c);
16782  a-=d; b-=d; c-=d;
16783  if (instance_first) cimg_forXZV(tmp,x,z,v) tmp(x,t,z,v)+=(Tfloat)(*this)(x,s,z,v)*d;
16784  else cimg_forXZV(tmp,x,z,v) tmp(x,t,z,v)+=(Tfloat)res(x,s,z,v)*d;
16785  if (!b) { cimg_forXZV(tmp,x,z,v) tmp(x,t,z,v)/=height; ++t; b = height; }
16786  if (!c) { ++s; c = dy; }
16787  }
16788  tmp.transfer_to(res);
16789  instance_first = false;
16790  }
16791  if (dz!=depth) {
16792  CImg<Tfloat> tmp(dx,dy,dz,dim,0);
16793  for (unsigned int a = depth*dz, b = depth, c = dz, s = 0, t = 0; a; ) {
16794  const unsigned int d = cimg::min(b,c);
16795  a-=d; b-=d; c-=d;
16796  if (instance_first) cimg_forXYV(tmp,x,y,v) tmp(x,y,t,v)+=(Tfloat)(*this)(x,y,s,v)*d;
16797  else cimg_forXYV(tmp,x,y,v) tmp(x,y,t,v)+=(Tfloat)res(x,y,s,v)*d;
16798  if (!b) { cimg_forXYV(tmp,x,y,v) tmp(x,y,t,v)/=depth; ++t; b = depth; }
16799  if (!c) { ++s; c = dz; }
16800  }
16801  tmp.transfer_to(res);
16802  instance_first = false;
16803  }
16804  if (dv!=dim) {
16805  CImg<Tfloat> tmp(dx,dy,dz,dv,0);
16806  for (unsigned int a = dim*dv, b = dim, c = dv, s = 0, t = 0; a; ) {
16807  const unsigned int d = cimg::min(b,c);
16808  a-=d; b-=d; c-=d;
16809  if (instance_first) cimg_forXYZ(tmp,x,y,z) tmp(x,y,z,t)+=(Tfloat)(*this)(x,y,z,s)*d;
16810  else cimg_forXYZ(tmp,x,y,z) tmp(x,y,z,t)+=(Tfloat)res(x,y,z,s)*d;
16811  if (!b) { cimg_forXYZ(tmp,x,y,z) tmp(x,y,z,t)/=dim; ++t; b = dim; }
16812  if (!c) { ++s; c = dv; }
16813  }
16814  tmp.transfer_to(res);
16815  instance_first = false;
16816  }
16817  } break;
16818 
16819  case 3 : { // Linear interpolation
16820  const unsigned int dimmax = cimg::max(dx,dy,dz,dv);
16821  const float
16822  sx = (border_condition<0 && dx>width )?(dx>1?(width-1.0f)/(dx-1) :0):(float)width/dx,
16823  sy = (border_condition<0 && dy>height)?(dy>1?(height-1.0f)/(dy-1):0):(float)height/dy,
16824  sz = (border_condition<0 && dz>depth )?(dz>1?(depth-1.0f)/(dz-1) :0):(float)depth/dz,
16825  sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(float)dim/dv;
16826 
16827  unsigned int *const off = new unsigned int[dimmax], *poff;
16828  float *const foff = new float[dimmax], *pfoff, old, curr;
16829  CImg<T> resx, resy, resz, resv;
16830  T *ptrd;
16831 
16832  if (dx!=width) {
16833  if (width==1) resx = get_resize(dx,height,depth,dim,1,0);
16834  else {
16835  resx.assign(dx,height,depth,dim);
16836  curr = old = 0; poff = off; pfoff = foff;
16837  cimg_forX(resx,x) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sx; *(poff++) = (unsigned int)curr-(unsigned int)old; }
16838  ptrd = resx.data;
16839  const T *ptrs0 = data;
16840  cimg_forYZV(resx,y,z,k) {
16841  poff = off; pfoff = foff;
16842  const T *ptrs = ptrs0, *const ptrsmax = ptrs0 + (width-1);
16843  cimg_forX(resx,x) {
16844  const float alpha = *(pfoff++);
16845  const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+1):(border_condition?val1:(T)0);
16846  *(ptrd++) = (T)((1-alpha)*val1 + alpha*val2);
16847  ptrs+=*(poff++);
16848  }
16849  ptrs0+=width;
16850  }
16851  }
16852  } else resx.assign(*this,true);
16853 
16854  if (dy!=height) {
16855  if (height==1) resy = resx.get_resize(dx,dy,depth,dim,1,0);
16856  else {
16857  resy.assign(dx,dy,depth,dim);
16858  curr = old = 0; poff = off; pfoff = foff;
16859  cimg_forY(resy,y) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sy; *(poff++) = dx*((unsigned int)curr-(unsigned int)old); }
16860  cimg_forXZV(resy,x,z,k) {
16861  ptrd = resy.ptr(x,0,z,k);
16862  const T *ptrs = resx.ptr(x,0,z,k), *const ptrsmax = ptrs + (height-1)*dx;
16863  poff = off; pfoff = foff;
16864  cimg_forY(resy,y) {
16865  const float alpha = *(pfoff++);
16866  const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+dx):(border_condition?val1:(T)0);
16867  *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16868  ptrd+=dx;
16869  ptrs+=*(poff++);
16870  }
16871  }
16872  }
16873  resx.assign();
16874  } else resy.assign(resx,true);
16875 
16876  if (dz!=depth) {
16877  if (depth==1) resz = resy.get_resize(dx,dy,dz,dim,1,0);
16878  else {
16879  const unsigned int wh = dx*dy;
16880  resz.assign(dx,dy,dz,dim);
16881  curr = old = 0; poff = off; pfoff = foff;
16882  cimg_forZ(resz,z) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sz; *(poff++) = wh*((unsigned int)curr-(unsigned int)old); }
16883  cimg_forXYV(resz,x,y,k) {
16884  ptrd = resz.ptr(x,y,0,k);
16885  const T *ptrs = resy.ptr(x,y,0,k), *const ptrsmax = ptrs + (depth-1)*wh;
16886  poff = off; pfoff = foff;
16887  cimg_forZ(resz,z) {
16888  const float alpha = *(pfoff++);
16889  const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+wh):(border_condition?val1:(T)0);
16890  *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16891  ptrd+=wh;
16892  ptrs+=*(poff++);
16893  }
16894  }
16895  }
16896  resy.assign();
16897  } else resz.assign(resy,true);
16898 
16899  if (dv!=dim) {
16900  if (dim==1) resv = resz.get_resize(dx,dy,dz,dv,1,0);
16901  else {
16902  const unsigned int whd = dx*dy*dz;
16903  resv.assign(dx,dy,dz,dv);
16904  curr = old = 0; poff = off; pfoff = foff;
16905  cimg_forV(resv,k) { *(pfoff++) = curr-(unsigned int)curr; old = curr; curr+=sv; *(poff++) = whd*((unsigned int)curr-(unsigned int)old); }
16906  cimg_forXYZ(resv,x,y,z) {
16907  ptrd = resv.ptr(x,y,z,0);
16908  const T *ptrs = resz.ptr(x,y,z,0), *const ptrsmax = ptrs + (dim-1)*whd;
16909  poff = off; pfoff = foff;
16910  cimg_forV(resv,k) {
16911  const float alpha = *(pfoff++);
16912  const T val1 = *ptrs, val2 = ptrs<ptrsmax?*(ptrs+whd):(border_condition?val1:(T)0);
16913  *ptrd = (T)((1-alpha)*val1 + alpha*val2);
16914  ptrd+=whd;
16915  ptrs+=*(poff++);
16916  }
16917  }
16918  }
16919  resz.assign();
16920  } else resv.assign(resz,true);
16921 
16922  delete[] off; delete[] foff;
16923  return resv.is_shared?(resz.is_shared?(resy.is_shared?(resx.is_shared?(+(*this)):resx):resy):resz):resv;
16924  } break;
16925 
16926  case 4 : { // Grid filling
16927  res.assign(dx,dy,dz,dv,0);
16928  cimg_forXYZV(*this,x,y,z,k) res(x*dx/width,y*dy/height,z*dz/depth,k*dv/dim) = (*this)(x,y,z,k);
16929  } break;
16930 
16931  case 5 : { // Cubic interpolation
16932  const float
16933  sx = (border_condition<0 && dx>width )?(dx>1?(width-1.0f)/(dx-1) :0):(float)width/dx,
16934  sy = (border_condition<0 && dy>height)?(dy>1?(height-1.0f)/(dy-1):0):(float)height/dy,
16935  sz = (border_condition<0 && dz>depth )?(dz>1?(depth-1.0f)/(dz-1) :0):(float)depth/dz,
16936  sv = (border_condition<0 && dv>dim )?(dv>1?(dim-1.0f)/(dv-1) :0):(float)dim/dv;
16937  res.assign(dx,dy,dz,dv);
16938  T *ptrd = res.ptr();
16939  float cx, cy, cz, ck = 0;
16940  cimg_forV(res,k) { cz = 0;
16941  cimg_forZ(res,z) { cy = 0;
16942  cimg_forY(res,y) { cx = 0;
16943  cimg_forX(res,x) {
16944  *(ptrd++) = (T)(border_condition?_cubic_atXY(cx,cy,(int)cz,(int)ck):cubic_atXY(cx,cy,(int)cz,(int)ck,0));
16945  cx+=sx;
16946  } cy+=sy;
16947  } cz+=sz;
16948  } ck+=sv;
16949  }
16950  } break;
16951 
16952  default : // Invalid interpolation method
16953  throw CImgArgumentException("CImg<%s>::resize() : Invalid interpolation_type %d "
16954  "(should be { -1=raw, 0=zero, 1=nearest, 2=average, 3=linear, 4=grid, 5=bicubic}).",
16955  pixel_type(),interpolation_type);
16956  }
16957  return res;
16958  }
if(dy > dx)
#define cimg_forXZV(img, x, z, v)
Definition: CImg.h:605
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_forX(img, x)
Definition: CImg.h:593
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
const NT & d
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define cimg_forXYV(img, x, y, v)
Definition: CImg.h:604
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_for_outXYZV(img, x0, y0, z0, v0, x1, y1, z1, v1, x, y, z, v)
Definition: CImg.h:665
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
Tfloat _cubic_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Definition: CImg.h:11644
#define cimg_forV(img, v)
Definition: CImg.h:596
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
T & _atXYZV(const int x, const int y, const int z, const int v)
Definition: CImg.h:11246
NT dy
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
Tfloat cubic_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using cubic interpolation and Dirichlet boundary conditions.
Definition: CImg.h:11590
#define cimg_forZ(img, z)
Definition: CImg.h:595
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<T> get_resize ( const CImg< t > &  src,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
) const
inline

Definition at line 16981 of file CImg.h.

16982  {
16983  return get_resize(src.width,src.height,src.depth,src.dim,interpolation_type,border_condition,center);
16984  }
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
CImg<T> get_resize ( const CImgDisplay disp,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
) const
inline

Definition at line 17005 of file CImg.h.

17006  {
17007  return get_resize(disp.width,disp.height,depth,dim,interpolation_type,border_condition,center);
17008  }
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_resize_doubleXY ( ) const
inline

Definition at line 17039 of file CImg.h.

Referenced by CImg< uintT >::resize_doubleXY().

17039  {
17040 #define _cimg_gs2x_for3(bound,i) \
17041  for (int i = 0, _p1##i = 0, \
17042  _n1##i = 1>=(bound)?(int)(bound)-1:1; \
17043  _n1##i<(int)(bound) || i==--_n1##i; \
17044  _p1##i = i++, ++_n1##i, ptrd1+=(res).width, ptrd2+=(res).width)
17045 
17046 #define _cimg_gs2x_for3x3(img,x,y,z,v,I) \
17047  _cimg_gs2x_for3((img).height,y) for (int x = 0, \
17048  _p1##x = 0, \
17049  _n1##x = (int)( \
17050  (I[1] = (img)(0,_p1##y,z,v)), \
17051  (I[3] = I[4] = (img)(0,y,z,v)), \
17052  (I[7] = (img)(0,_n1##y,z,v)), \
17053  1>=(img).width?(int)((img).width)-1:1); \
17054  (_n1##x<(int)((img).width) && ( \
17055  (I[2] = (img)(_n1##x,_p1##y,z,v)), \
17056  (I[5] = (img)(_n1##x,y,z,v)), \
17057  (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
17058  x==--_n1##x; \
17059  I[1] = I[2], \
17060  I[3] = I[4], I[4] = I[5], \
17061  I[7] = I[8], \
17062  _p1##x = x++, ++_n1##x)
17063 
17064  if (is_empty()) return *this;
17065  CImg<T> res(2*width,2*height,depth,dim);
17066  CImg_3x3(I,T);
17067  cimg_forZV(*this,z,k) {
17068  T
17069  *ptrd1 = res.ptr(0,0,0,k),
17070  *ptrd2 = ptrd1 + res.width;
17071  _cimg_gs2x_for3x3(*this,x,y,0,k,I) {
17072  if (Icp!=Icn && Ipc!=Inc) {
17073  *(ptrd1++) = Ipc==Icp?Ipc:Icc;
17074  *(ptrd1++) = Icp==Inc?Inc:Icc;
17075  *(ptrd2++) = Ipc==Icn?Ipc:Icc;
17076  *(ptrd2++) = Icn==Inc?Inc:Icc;
17077  } else { *(ptrd1++) = Icc; *(ptrd1++) = Icc; *(ptrd2++) = Icc; *(ptrd2++) = Icc; }
17078  }
17079  }
17080  return res;
17081  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define _cimg_gs2x_for3x3(img, x, y, z, v, I)
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T> get_resize_halfXY ( ) const
inline

Definition at line 17015 of file CImg.h.

Referenced by CImg< uintT >::resize_halfXY().

17015  {
17016  if (is_empty()) return *this;
17017  const Tfloat mask[9] = { 0.07842776544f, 0.1231940459f, 0.07842776544f,
17018  0.1231940459f, 0.1935127547f, 0.1231940459f,
17019  0.07842776544f, 0.1231940459f, 0.07842776544f };
17020  T I[9] = { 0 };
17021  CImg<T> dest(width/2,height/2,depth,dim);
17022  cimg_forZV(*this,z,k) cimg_for3x3(*this,x,y,z,k,I)
17023  if (x%2 && y%2) dest(x/2,y/2,z,k) = (T)
17024  (I[0]*mask[0] + I[1]*mask[1] + I[2]*mask[2] +
17025  I[3]*mask[3] + I[4]*mask[4] + I[5]*mask[5] +
17026  I[6]*mask[6] + I[7]*mask[7] + I[8]*mask[8]);
17027  return dest;
17028  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
std::vector< std::vector< bool > > mask
Masks the points that are shared (true) share (false) not shared.
Definition: hdf2pltV2.C:62
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_resize_object3d ( const float  sx,
const float  sy = -100,
const float  sz = -100 
) const
inline

Definition at line 21120 of file CImg.h.

21120  {
21121  return CImg<Tfloat>(*this,false).resize_object3d(sx,sy,sz);
21122  }
CImg< T > resize_object3d() const
Resize a 3D object so that its max dimension if one.
Definition: CImg.h:21125
CImg<Tfloat> get_resize_object3d ( ) const
inline

Definition at line 21137 of file CImg.h.

21137  {
21138  return CImg<Tfloat>(*this,false).resize_object3d();
21139  }
CImg< T > resize_object3d() const
Resize a 3D object so that its max dimension if one.
Definition: CImg.h:21125
CImg<T> get_resize_tripleXY ( ) const
inline

Definition at line 17092 of file CImg.h.

Referenced by CImg< uintT >::resize_tripleXY().

17092  {
17093 #define _cimg_gs3x_for3(bound,i) \
17094  for (int i = 0, _p1##i = 0, \
17095  _n1##i = 1>=(bound)?(int)(bound)-1:1; \
17096  _n1##i<(int)(bound) || i==--_n1##i; \
17097  _p1##i = i++, ++_n1##i, ptrd1+=2*(res).width, ptrd2+=2*(res).width, ptrd3+=2*(res).width)
17098 
17099 #define _cimg_gs3x_for3x3(img,x,y,z,v,I) \
17100  _cimg_gs3x_for3((img).height,y) for (int x = 0, \
17101  _p1##x = 0, \
17102  _n1##x = (int)( \
17103  (I[0] = I[1] = (img)(0,_p1##y,z,v)), \
17104  (I[3] = I[4] = (img)(0,y,z,v)), \
17105  (I[6] = I[7] = (img)(0,_n1##y,z,v)), \
17106  1>=(img).width?(int)((img).width)-1:1); \
17107  (_n1##x<(int)((img).width) && ( \
17108  (I[2] = (img)(_n1##x,_p1##y,z,v)), \
17109  (I[5] = (img)(_n1##x,y,z,v)), \
17110  (I[8] = (img)(_n1##x,_n1##y,z,v)),1)) || \
17111  x==--_n1##x; \
17112  I[0] = I[1], I[1] = I[2], \
17113  I[3] = I[4], I[4] = I[5], \
17114  I[6] = I[7], I[7] = I[8], \
17115  _p1##x = x++, ++_n1##x)
17116 
17117  if (is_empty()) return *this;
17118  CImg<T> res(3*width,3*height,depth,dim);
17119  CImg_3x3(I,T);
17120  cimg_forZV(*this,z,k) {
17121  T
17122  *ptrd1 = res.ptr(0,0,0,k),
17123  *ptrd2 = ptrd1 + res.width,
17124  *ptrd3 = ptrd2 + res.width;
17125  _cimg_gs3x_for3x3(*this,x,y,0,k,I) {
17126  if (Icp != Icn && Ipc != Inc) {
17127  *(ptrd1++) = Ipc==Icp?Ipc:Icc;
17128  *(ptrd1++) = (Ipc==Icp && Icc!=Inp) || (Icp==Inc && Icc!=Ipp)?Icp:Icc;
17129  *(ptrd1++) = Icp==Inc?Inc:Icc;
17130  *(ptrd2++) = (Ipc==Icp && Icc!=Ipn) || (Ipc==Icn && Icc!=Ipp)?Ipc:Icc;
17131  *(ptrd2++) = Icc;
17132  *(ptrd2++) = (Icp==Inc && Icc!=Inn) || (Icn==Inc && Icc!=Inp)?Inc:Icc;
17133  *(ptrd3++) = Ipc==Icn?Ipc:Icc;
17134  *(ptrd3++) = (Ipc==Icn && Icc!=Inn) || (Icn==Inc && Icc!=Ipn)?Icn:Icc;
17135  *(ptrd3++) = Icn==Inc?Inc:Icc;
17136  } else {
17137  *(ptrd1++) = Icc; *(ptrd1++) = Icc; *(ptrd1++) = Icc;
17138  *(ptrd2++) = Icc; *(ptrd2++) = Icc; *(ptrd2++) = Icc;
17139  *(ptrd3++) = Icc; *(ptrd3++) = Icc; *(ptrd3++) = Icc;
17140  }
17141  }
17142  }
17143  return res;
17144  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define _cimg_gs3x_for3x3(img, x, y, z, v, I)
#define CImg_3x3(I, T)
Definition: CImg.h:421
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T> get_RGBtoBayer ( ) const
inline

Definition at line 16471 of file CImg.h.

Referenced by CImg< uintT >::RGBtoBayer().

16471  {
16472  if (is_empty()) return *this;
16473  if (dim!=3)
16474  throw CImgInstanceException("CImg<%s>::RGBtoBayer() : Input image dimension is dim=%u, "
16475  "should be a (R,G,B) image (dim=3)",
16476  pixel_type(),dim);
16477  CImg<T> res(width,height,depth,1);
16478  const T *pR = ptr(0,0,0,0), *pG = ptr(0,0,0,1), *pB = ptr(0,0,0,2);
16479  T *ptrd = res.data;
16480  cimg_forXYZ(*this,x,y,z) {
16481  if (y%2) {
16482  if (x%2) *(ptrd++) = *pB;
16483  else *(ptrd++) = *pG;
16484  } else {
16485  if (x%2) *(ptrd++) = *pG;
16486  else *(ptrd++) = *pR;
16487  }
16488  ++pR; ++pG; ++pB;
16489  }
16490  return res;
16491  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tfloat> get_RGBtoCMY ( ) const
inline

Definition at line 16149 of file CImg.h.

16149  {
16150  return CImg<Tfloat>(*this,false).RGBtoCMY();
16151  }
CImg< T > & RGBtoCMY()
Convert color pixels from (R,G,B) to (C,M,Y).
Definition: CImg.h:16130
CImg<Tfloat> get_RGBtoCMYK ( ) const
inline

Definition at line 16450 of file CImg.h.

16450  {
16451  return CImg<Tfloat>(*this,false).RGBtoCMYK();
16452  }
CImg< T > & RGBtoCMYK()
Convert a (R,G,B) image to a (C,M,Y,K) one.
Definition: CImg.h:16446
CImg<Tfloat> get_RGBtoHSI ( ) const
inline

Definition at line 15977 of file CImg.h.

15977  {
15978  return CImg<Tfloat>(*this,false).RGBtoHSI();
15979  }
CImg< T > & RGBtoHSI()
Convert color pixels from (R,G,B) to (H,S,I).
Definition: CImg.h:15948
CImg<Tfloat> get_RGBtoHSL ( ) const
inline

Definition at line 15906 of file CImg.h.

15906  {
15907  return CImg< Tfloat>(*this,false).RGBtoHSL();
15908  }
CImg< T > & RGBtoHSL()
Convert color pixels from (R,G,B) to (H,S,L).
Definition: CImg.h:15870
CImg<Tfloat> get_RGBtoHSV ( ) const
inline

Definition at line 15821 of file CImg.h.

15821  {
15822  return CImg<Tfloat>(*this,false).RGBtoHSV();
15823  }
CImg< T > & RGBtoHSV()
Convert color pixels from (R,G,B) to (H,S,V).
Definition: CImg.h:15787
CImg<Tfloat> get_RGBtoLab ( ) const
inline

Definition at line 16414 of file CImg.h.

16414  {
16415  return CImg<Tfloat>(*this,false).RGBtoLab();
16416  }
CImg< T > & RGBtoLab()
Convert a (R,G,B) image to a (L,a,b) one.
Definition: CImg.h:16410
CImg<Tfloat> get_RGBtoxyY ( ) const
inline

Definition at line 16432 of file CImg.h.

16432  {
16433  return CImg<Tfloat>(*this,false).RGBtoxyY();
16434  }
CImg< T > & RGBtoxyY()
Convert a (R,G,B) image to a (x,y,Y) one.
Definition: CImg.h:16428
CImg<Tfloat> get_RGBtoXYZ ( ) const
inline

Definition at line 16258 of file CImg.h.

16258  {
16259  return CImg<Tfloat>(*this,false).RGBtoXYZ();
16260  }
CImg< T > & RGBtoXYZ()
Convert color pixels from (R,G,B) to (X,Y,Z)_709.
Definition: CImg.h:16239
CImg<Tuchar> get_RGBtoYCbCr ( ) const
inline

Definition at line 16046 of file CImg.h.

16046  {
16047  return CImg<Tuchar>(*this,false).RGBtoYCbCr();
16048  }
CImg< T > & RGBtoYCbCr()
Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.
Definition: CImg.h:16024
CImg<Tfloat> get_RGBtoYUV ( ) const
inline

Definition at line 16098 of file CImg.h.

16098  {
16099  return CImg<Tfloat>(*this,false).RGBtoYUV();
16100  }
CImg< T > & RGBtoYUV()
Convert color pixels from (R,G,B) to (Y,U,V).
Definition: CImg.h:16078
CImg<T> get_rotate ( const float  angle,
const unsigned int  border_conditions = 3,
const unsigned int  interpolation = 1 
) const
inline

Definition at line 17641 of file CImg.h.

Referenced by CImg< uintT >::rotate().

17641  {
17642  if (is_empty()) return *this;
17643  CImg<T> dest;
17644  const float nangle = cimg::mod(angle,360.0f);
17645  if (border_conditions!=1 && cimg::mod(nangle,90.0f)==0) { // optimized version for orthogonal angles
17646  const int wm1 = dimx()-1, hm1 = dimy()-1;
17647  const int iangle = (int)nangle/90;
17648  switch (iangle) {
17649  case 1 : {
17650  dest.assign(height,width,depth,dim);
17651  cimg_forXYZV(dest,x,y,z,v) dest(x,y,z,v) = (*this)(y,hm1-x,z,v);
17652  } break;
17653  case 2 : {
17654  dest.assign(width,height,depth,dim);
17655  cimg_forXYZV(dest,x,y,z,v) dest(x,y,z,v) = (*this)(wm1-x,hm1-y,z,v);
17656  } break;
17657  case 3 : {
17658  dest.assign(height,width,depth,dim);
17659  cimg_forXYZV(dest,x,y,z,v) dest(x,y,z,v) = (*this)(wm1-y,x,z,v);
17660  } break;
17661  default :
17662  return *this;
17663  }
17664  } else { // generic version
17665  const float
17666  rad = (float)(nangle*cimg::valuePI/180.0),
17667  ca = (float)std::cos(rad),
17668  sa = (float)std::sin(rad),
17669  ux = cimg::abs(width*ca), uy = cimg::abs(width*sa),
17670  vx = cimg::abs(height*sa), vy = cimg::abs(height*ca),
17671  w2 = 0.5f*width, h2 = 0.5f*height,
17672  dw2 = 0.5f*(ux+vx), dh2 = 0.5f*(uy+vy);
17673  dest.assign((int)(ux+vx), (int)(uy+vy),depth,dim);
17674  switch (border_conditions) {
17675  case 0 : {
17676  switch (interpolation) {
17677  case 2 : {
17678  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17679  dest(x,y,z,v) = (T)cubic_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,v,0);
17680  } break;
17681  case 1 : {
17682  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17683  dest(x,y,z,v) = (T)linear_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,v,0);
17684  } break;
17685  default : {
17686  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17687  dest(x,y,z,v) = atXY((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),(int)(h2 - (x-dw2)*sa + (y-dh2)*ca),z,v,0);
17688  }
17689  }
17690  } break;
17691  case 1 : {
17692  switch (interpolation) {
17693  case 2 : {
17694  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17695  dest(x,y,z,v) = (T)cubic_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,v);
17696  } break;
17697  case 1 : {
17698  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17699  dest(x,y,z,v) = (T)linear_atXY(w2 + (x-dw2)*ca + (y-dh2)*sa,h2 - (x-dw2)*sa + (y-dh2)*ca,z,v);
17700  } break;
17701  default : {
17702  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17703  dest(x,y,z,v) = atXY((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),(int)(h2 - (x-dw2)*sa + (y-dh2)*ca),z,v);
17704  }
17705  }
17706  } break;
17707  case 2 : {
17708  switch (interpolation) {
17709  case 2 : {
17710  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17711  dest(x,y,z,v) = (T)cubic_atXY(cimg::mod(w2 + (x-dw2)*ca + (y-dh2)*sa,(float)dimx()),
17712  cimg::mod(h2 - (x-dw2)*sa + (y-dh2)*ca,(float)dimy()),z,v);
17713  } break;
17714  case 1 : {
17715  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17716  dest(x,y,z,v) = (T)linear_atXY(cimg::mod(w2 + (x-dw2)*ca + (y-dh2)*sa,(float)dimx()),
17717  cimg::mod(h2 - (x-dw2)*sa + (y-dh2)*ca,(float)dimy()),z,v);
17718  } break;
17719  default : {
17720  cimg_forXY(dest,x,y) cimg_forZV(*this,z,v)
17721  dest(x,y,z,v) = (*this)(cimg::mod((int)(w2 + (x-dw2)*ca + (y-dh2)*sa),dimx()),
17722  cimg::mod((int)(h2 - (x-dw2)*sa + (y-dh2)*ca),dimy()),z,v);
17723  }
17724  }
17725  } break;
17726  default :
17727  throw CImgArgumentException("CImg<%s>::rotate() : Invalid border conditions %d (should be 0,1 or 2).",
17728  pixel_type(),border_conditions);
17729  }
17730  }
17731  return dest;
17732  }
const NT & d
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
NT & sin
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
void int int REAL * x
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following ** conditions
Definition: roccomf90.h:20
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
Tfloat cubic_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using cubic interpolation and Dirichlet boundary conditions.
Definition: CImg.h:11590
Tfloat linear_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinate...
Definition: CImg.h:11516
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
NT & cos
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg< T > & rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1)
Rotate an image.
Definition: CImg.h:17637

Here is the caller graph for this function:

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
inline

Definition at line 17750 of file CImg.h.

17751  {
17752  if (interpolation>2)
17753  throw CImgArgumentException("CImg<%s>::rotate() : Invalid interpolation parameter %d (should be {0=none, 1=linear or 2=cubic}).",
17754  pixel_type(),interpolation);
17755  if (is_empty()) return *this;
17756  CImg<T> dest(width,height,depth,dim);
17757  const float nangle = cimg::mod(angle,360.0f);
17758  if (border_conditions!=1 && zoom==1 && cimg::mod(nangle,90.0f)==0) { // optimized version for orthogonal angles
17759  const int iangle = (int)nangle/90;
17760  switch (iangle) {
17761  case 1 : {
17762  dest.fill(0);
17763  const unsigned int
17764  xmin = cimg::max(0,(dimx()-dimy())/2), xmax = cimg::min(width,xmin+height),
17765  ymin = cimg::max(0,(dimy()-dimx())/2), ymax = cimg::min(height,ymin+width),
17766  xoff = xmin + cimg::min(0,(dimx()-dimy())/2),
17767  yoff = ymin + cimg::min(0,(dimy()-dimx())/2);
17768  cimg_forZV(dest,z,v) for (unsigned int y = ymin; y<ymax; ++y) for (unsigned int x = xmin; x<xmax; ++x)
17769  dest(x,y,z,v) = (*this)(y-yoff,height-1-x+xoff,z,v);
17770  } break;
17771  case 2 : {
17772  cimg_forXYZV(dest,x,y,z,v) dest(x,y,z,v) = (*this)(width-1-x,height-1-y,z,v);
17773  } break;
17774  case 3 : {
17775  dest.fill(0);
17776  const unsigned int
17777  xmin = cimg::max(0,(dimx()-dimy())/2), xmax = cimg::min(width,xmin+height),
17778  ymin = cimg::max(0,(dimy()-dimx())/2), ymax = cimg::min(height,ymin+width),
17779  xoff = xmin + cimg::min(0,(dimx()-dimy())/2),
17780  yoff = ymin + cimg::min(0,(dimy()-dimx())/2);
17781  cimg_forZV(dest,z,v) for (unsigned int y = ymin; y<ymax; ++y) for (unsigned int x = xmin; x<xmax; ++x)
17782  dest(x,y,z,v) = (*this)(width-1-y+yoff,x-xoff,z,v);
17783  } break;
17784  default :
17785  return *this;
17786  }
17787  } else {
17788  const float
17789  rad = (float)((nangle*cimg::valuePI)/180.0),
17790  ca = (float)std::cos(rad)/zoom,
17791  sa = (float)std::sin(rad)/zoom;
17792  switch (border_conditions) { // generic version
17793  case 0 : {
17794  switch (interpolation) {
17795  case 2 : {
17796  cimg_forXY(dest,x,y)
17797  cimg_forZV(*this,z,v)
17798  dest(x,y,z,v) = (T)cubic_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,v,0);
17799  } break;
17800  case 1 : {
17801  cimg_forXY(dest,x,y)
17802  cimg_forZV(*this,z,v)
17803  dest(x,y,z,v) = (T)linear_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,v,0);
17804  } break;
17805  default : {
17806  cimg_forXY(dest,x,y)
17807  cimg_forZV(*this,z,v)
17808  dest(x,y,z,v) = atXY((int)(cx + (x-cx)*ca + (y-cy)*sa),(int)(cy - (x-cx)*sa + (y-cy)*ca),z,v,0);
17809  }
17810  }
17811  } break;
17812  case 1 : {
17813  switch (interpolation) {
17814  case 2 : {
17815  cimg_forXY(dest,x,y)
17816  cimg_forZV(*this,z,v)
17817  dest(x,y,z,v) = (T)cubic_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,v);
17818  } break;
17819  case 1 : {
17820  cimg_forXY(dest,x,y)
17821  cimg_forZV(*this,z,v)
17822  dest(x,y,z,v) = (T)linear_atXY(cx + (x-cx)*ca + (y-cy)*sa,cy - (x-cx)*sa + (y-cy)*ca,z,v);
17823  } break;
17824  default : {
17825  cimg_forXY(dest,x,y)
17826  cimg_forZV(*this,z,v)
17827  dest(x,y,z,v) = atXY((int)(cx + (x-cx)*ca + (y-cy)*sa),(int)(cy - (x-cx)*sa + (y-cy)*ca),z,v);
17828  }
17829  }
17830  } break;
17831  case 2 : {
17832  switch (interpolation) {
17833  case 2 : {
17834  cimg_forXY(dest,x,y)
17835  cimg_forZV(*this,z,v)
17836  dest(x,y,z,v) = (T)cubic_atXY(cimg::mod(cx + (x-cx)*ca + (y-cy)*sa,(float)dimx()),
17837  cimg::mod(cy - (x-cx)*sa + (y-cy)*ca,(float)dimy()),z,v);
17838  } break;
17839  case 1 : {
17840  cimg_forXY(dest,x,y)
17841  cimg_forZV(*this,z,v)
17842  dest(x,y,z,v) = (T)linear_atXY(cimg::mod(cx + (x-cx)*ca + (y-cy)*sa,(float)dimx()),
17843  cimg::mod(cy - (x-cx)*sa + (y-cy)*ca,(float)dimy()),z,v);
17844  } break;
17845  default : {
17846  cimg_forXY(dest,x,y)
17847  cimg_forZV(*this,z,v)
17848  dest(x,y,z,v) = (*this)(cimg::mod((int)(cx + (x-cx)*ca + (y-cy)*sa),dimx()),
17849  cimg::mod((int)(cy - (x-cx)*sa + (y-cy)*ca),dimy()),z,v);
17850  }
17851  }
17852  } break;
17853  default :
17854  throw CImgArgumentException("CImg<%s>::rotate() : Incorrect border conditions %d (should be 0,1 or 2).",
17855  pixel_type(),border_conditions);
17856  }
17857  }
17858  return dest;
17859  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
const NT & d
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
NT & sin
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
void int int REAL * x
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following ** conditions
Definition: roccomf90.h:20
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
Tfloat cubic_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using cubic interpolation and Dirichlet boundary conditions.
Definition: CImg.h:11590
Tfloat linear_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinate...
Definition: CImg.h:11516
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
NT & cos
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg< T > & rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1)
Rotate an image.
Definition: CImg.h:17637
CImg<T> get_round ( const float  x,
const unsigned int  rounding_type = 0 
) const
inline

Definition at line 14981 of file CImg.h.

14981  {
14982  return (+*this).round(x,rounding_type);
14983  }
void int int REAL * x
Definition: read.cpp:74
CImg<intT> get_select ( CImgDisplay disp,
const int  select_type = 2,
unsigned int *const  XYZ = 0,
const unsigned char *const  color = 0 
) const
inline

Simple interface to select a shape from an image.

Definition at line 28602 of file CImg.h.

Referenced by CImg< uintT >::select().

28604  {
28605  return _get_select(disp,0,select_type,XYZ,color,0,0,0);
28606  }
CImg< intT > _get_select(CImgDisplay &disp, const char *const title, const int coords_type, unsigned int *const XYZ, const unsigned char *const color, const int origX, const int origY, const int origZ) const
Definition: CImg.h:28616

Here is the caller graph for this function:

CImg<intT> get_select ( const char *const  title,
const int  select_type = 2,
unsigned int *const  XYZ = 0,
const unsigned char *const  color = 0 
) const
inline

Simple interface to select a shape from an image.

Definition at line 28609 of file CImg.h.

28611  {
28612  CImgDisplay disp;
28613  return _get_select(disp,title,select_type,XYZ,color,0,0,0);
28614  }
CImg< intT > _get_select(CImgDisplay &disp, const char *const title, const int coords_type, unsigned int *const XYZ, const unsigned char *const color, const int origX, const int origY, const int origZ) const
Definition: CImg.h:28616
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
inline

Select sub-graph in a graph.

Definition at line 28923 of file CImg.h.

28926  {
28927  if (is_empty())
28928  throw CImgInstanceException("CImg<%s>::display_graph() : Instance image (%u,%u,%u,%u,%p) is empty.",
28930  const unsigned int siz = width*height*depth, onormalization = disp.normalization;
28931  if (!disp) { char ntitle[64] = { 0 }; std::sprintf(ntitle,"CImg<%s>",pixel_type()); disp.assign(640,480,ntitle,0); }
28932  disp.show().key = disp.normalization = disp.button = disp.wheel = 0; // Must keep 'key' field unchanged.
28933  double nymin = ymin, nymax = ymax, nxmin = xmin, nxmax = xmax;
28934  if (nymin==nymax) nymin = (Tfloat)minmax(nymax);
28935  if (nymin==nymax) { --nymin; ++nymax; }
28936  if (nxmin==nxmax && nxmin==0) { nxmin = 0; nxmax = siz - 1.0; }
28937 
28938  const unsigned char black[] = { 0,0,0 }, white[] = { 255,255,255 }, gray[] = { 220,220,220 };
28939  const unsigned char gray2[] = { 110,110,110 }, ngray[] = { 35,35,35 };
28940  static unsigned int odimv = 0;
28941  static CImg<ucharT> palette;
28942  if (odimv!=dim) {
28943  odimv = dim;
28944  palette = CImg<ucharT>(3,dim,1,1,120).noise(70,1);
28945  if (dim==1) { palette[0] = palette[1] = 120; palette[2] = 200; }
28946  else {
28947  palette(0,0) = 220; palette(1,0) = 10; palette(2,0) = 10;
28948  if (dim>1) { palette(0,1) = 10; palette(1,1) = 220; palette(2,1) = 10; }
28949  if (dim>2) { palette(0,2) = 10; palette(1,2) = 10; palette(2,2) = 220; }
28950  }
28951  }
28952 
28953  CImg<ucharT> visu0, visu, graph, text, axes;
28954  const unsigned int whz = width*height*depth;
28955  int x0 = -1, x1 = -1, y0 = -1, y1 = -1, omouse_x = -2, omouse_y = -2;
28956  char message[1024] = { 0 };
28957  unsigned int okey = 0, obutton = 0;
28958  CImg_3x3(I,unsigned char);
28959 
28960  for (bool selected = false; !selected && !disp.is_closed && !okey && !disp.wheel; ) {
28961  const int mouse_x = disp.mouse_x, mouse_y = disp.mouse_y;
28962  const unsigned int key = disp.key, button = disp.button;
28963 
28964  // Generate graph representation.
28965  if (!visu0) {
28966  visu0.assign(disp.dimx(),disp.dimy(),1,3,220);
28967  const int gdimx = disp.dimx() - 32, gdimy = disp.dimy() - 32;
28968  if (gdimx>0 && gdimy>0) {
28969  graph.assign(gdimx,gdimy,1,3,255);
28970  graph.draw_grid(-10,-10,0,0,false,true,black,0.2f,0x33333333,0x33333333);
28971  cimg_forV(*this,k) graph.draw_graph(get_shared_channel(k),&palette(0,k),(plot_type!=3 || dim==1)?1:0.6f,
28972  plot_type,vertex_type,nymax,nymin,false);
28973 
28974  axes.assign(gdimx,gdimy,1,1,0);
28975  const float
28976  dx = (float)cimg::abs(nxmax-nxmin), dy = (float)cimg::abs(nymax-nymin),
28977  px = (float)std::pow(10.0,(int)std::log10(dx)-2.0),
28978  py = (float)std::pow(10.0,(int)std::log10(dy)-2.0);
28979  const CImg<Tdouble>
28980  seqx = CImg<Tdouble>::sequence(1 + gdimx/60,nxmin,nxmax).round(px),
28981  seqy = CImg<Tdouble>::sequence(1 + gdimy/60,nymax,nymin).round(py);
28982  axes.draw_axis(seqx,seqy,white);
28983  if (nymin>0) axes.draw_axis(seqx,gdimy-1,gray);
28984  if (nymax<0) axes.draw_axis(seqx,0,gray);
28985  if (nxmin>0) axes.draw_axis(0,seqy,gray);
28986  if (nxmax<0) axes.draw_axis(gdimx-1,seqy,gray);
28987 
28988  cimg_for3x3(axes,x,y,0,0,I)
28989  if (Icc) {
28990  if (Icc==255) cimg_forV(graph,k) graph(x,y,k) = 0;
28991  else cimg_forV(graph,k) graph(x,y,k) = (unsigned char)(2*graph(x,y,k)/3);
28992  }
28993  else if (Ipc || Inc || Icp || Icn || Ipp || Inn || Ipn || Inp) cimg_forV(graph,k) graph(x,y,k) = (graph(x,y,k)+255)/2;
28994 
28995  visu0.draw_image(16,16,graph);
28996  visu0.draw_line(15,15,16+gdimx,15,gray2).draw_line(16+gdimx,15,16+gdimx,16+gdimy,gray2).
28997  draw_line(16+gdimx,16+gdimy,15,16+gdimy,white).draw_line(15,16+gdimy,15,15,white);
28998  } else graph.assign();
28999  text.assign().draw_text(0,0,labelx?labelx:"X-axis",white,ngray,1);
29000  visu0.draw_image((visu0.dimx()-text.dimx())/2,visu0.dimy()-14,~text);
29001  text.assign().draw_text(0,0,labely?labely:"Y-axis",white,ngray,1).rotate(-90);
29002  visu0.draw_image(2,(visu0.dimy()-text.dimy())/2,~text);
29003  visu.assign();
29004  }
29005 
29006  // Generate and display current view.
29007  if (!visu) {
29008  visu.assign(visu0);
29009  if (graph && x0>=0 && x1>=0) {
29010  const int
29011  nx0 = x0<=x1?x0:x1,
29012  nx1 = x0<=x1?x1:x0,
29013  ny0 = y0<=y1?y0:y1,
29014  ny1 = y0<=y1?y1:y0,
29015  sx0 = 16 + nx0*(visu.dimx()-32)/whz,
29016  sx1 = 15 + (nx1+1)*(visu.dimx()-32)/whz,
29017  sy0 = 16 + ny0,
29018  sy1 = 16 + ny1;
29019 
29020  if (y0>=0 && y1>=0)
29021  visu.draw_rectangle(sx0,sy0,sx1,sy1,gray,0.5f).draw_rectangle(sx0,sy0,sx1,sy1,black,0.5f,0xCCCCCCCCU);
29022  else visu.draw_rectangle(sx0,0,sx1,visu.dimy()-17,gray,0.5f).
29023  draw_line(sx0,16,sx0,visu.dimy()-17,black,0.5f,0xCCCCCCCCU).
29024  draw_line(sx1,16,sx1,visu.dimy()-17,black,0.5f,0xCCCCCCCCU);
29025  }
29026  if (mouse_x>=16 && mouse_y>=16 && mouse_x<visu.dimx()-16 && mouse_y<visu.dimy()-16) {
29027  if (graph) visu.draw_line(mouse_x,16,mouse_x,visu.dimy()-17,black,0.5f,0x55555555U);
29028  const unsigned x = (mouse_x-16)*whz/(disp.dimx()-32);
29029  const double cx = nxmin + x*(nxmax-nxmin)/whz;
29030  if (dim>=7)
29031  std::sprintf(message,"Value[%g] = ( %g %g %g ... %g %g %g )",cx,
29032  (double)(*this)(x,0,0,0),(double)(*this)(x,0,0,1),(double)(*this)(x,0,0,2),
29033  (double)(*this)(x,0,0,dim-4),(double)(*this)(x,0,0,dim-3),(double)(*this)(x,0,0,dim-1));
29034  else {
29035  std::sprintf(message,"Value[%g] = ( ",cx);
29036  cimg_forV(*this,k) std::sprintf(message+std::strlen(message),"%g ",(double)(*this)(x,0,0,k));
29037  std::sprintf(message+std::strlen(message),")");
29038  }
29039  if (x0>=0 && x1>=0) {
29040  const int
29041  nx0 = x0<=x1?x0:x1,
29042  nx1 = x0<=x1?x1:x0,
29043  ny0 = y0<=y1?y0:y1,
29044  ny1 = y0<=y1?y1:y0;
29045  const double
29046  cx0 = nxmin + nx0*(nxmax-nxmin)/(visu.dimx()-32),
29047  cx1 = nxmin + nx1*(nxmax-nxmin)/(visu.dimx()-32),
29048  cy0 = nymax - ny0*(nymax-nymin)/(visu.dimy()-32),
29049  cy1 = nymax - ny1*(nymax-nymin)/(visu.dimy()-32);
29050  if (y0>=0 && y1>=0)
29051  std::sprintf(message+std::strlen(message)," - Range ( %g, %g ) - ( %g, %g )",cx0,cy0,cx1,cy1);
29052  else
29053  std::sprintf(message+std::strlen(message)," - Range [ %g - %g ]",cx0,cx1);
29054  }
29055  text.assign().draw_text(0,0,message,white,ngray,1);
29056  visu.draw_image((visu.dimx()-text.dimx())/2,2,~text);
29057  }
29058  visu.display(disp);
29059  }
29060 
29061  // Test keys.
29062  switch (okey = key) {
29063  case cimg::keyCTRLLEFT : okey = 0; break;
29064  case cimg::keyD : if (disp.is_keyCTRLLEFT) {
29065  disp.normalscreen().resize(CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,false),
29066  CImgDisplay::_fitscreen(3*disp.width/2,3*disp.height/2,1,128,-100,true),false).is_resized = true;
29067  disp.key = okey = 0;
29068  } break;
29069  case cimg::keyC : if (disp.is_keyCTRLLEFT) {
29070  disp.normalscreen().resize(cimg_fitscreen(2*disp.width/3,2*disp.height/3,1),false).is_resized = true;
29071  disp.key = okey = 0;
29072  } break;
29073  case cimg::keyR : if (disp.is_keyCTRLLEFT) {
29074  disp.normalscreen().resize(cimg_fitscreen(640,480,1),false).is_resized = true;
29075  disp.key = okey = 0;
29076  } break;
29077  case cimg::keyF : if (disp.is_keyCTRLLEFT) {
29078  disp.resize(disp.screen_dimx(),disp.screen_dimy(),false).toggle_fullscreen().is_resized = true;
29079  disp.key = okey = 0;
29080  } break;
29081  case cimg::keyS : if (disp.is_keyCTRLLEFT) {
29082  static unsigned int snap_number = 0;
29083  if (visu || visu0) {
29084  CImg<ucharT> &screen = visu?visu:visu0;
29085  char filename[32] = { 0 };
29086  std::FILE *file;
29087  do {
29088  std::sprintf(filename,"CImg_%.4u.bmp",snap_number++);
29089  if ((file=std::fopen(filename,"r"))!=0) std::fclose(file);
29090  } while (file);
29091  (+screen).draw_text(2,2,"Saving BMP snapshot...",black,gray,1,11).display(disp);
29092  screen.save(filename);
29093  screen.draw_text(2,2,"Snapshot '%s' saved.",black,gray,1,11,filename).display(disp);
29094  }
29095  disp.key = okey = 0;
29096  } break;
29097  }
29098 
29099  // Handle mouse motion and mouse buttons
29100  if (obutton!=button || omouse_x!=mouse_x || omouse_y!=mouse_y) {
29101  visu.assign();
29102  if (disp.mouse_x>=0 && disp.mouse_y>=0) {
29103  const int
29104  mx = (mouse_x-16)*(int)whz/(disp.dimx()-32),
29105  cx = mx<0?0:(mx>=(int)whz?whz-1:mx),
29106  my = mouse_y-16,
29107  cy = my<=0?0:(my>=(disp.dimy()-32)?(disp.dimy()-32):my);
29108  if (button&1) { if (!obutton) { x0 = cx; y0 = -1; } else { x1 = cx; y1 = -1; }}
29109  else if (button&2) { if (!obutton) { x0 = cx; y0 = cy; } else { x1 = cx; y1 = cy; }}
29110  else if (obutton) { x1 = cx; y1 = y1>=0?cy:-1; selected = true; }
29111  } else if (!button && obutton) selected = true;
29112  obutton = button; omouse_x = mouse_x; omouse_y = mouse_y;
29113  }
29114  if (disp.is_resized) { disp.resize(false); visu0.assign(); }
29115  if (visu && visu0) disp.wait();
29116  }
29117  disp.normalization = onormalization;
29118  if (x1<x0) cimg::swap(x0,x1);
29119  if (y1<y0) cimg::swap(y0,y1);
29120  disp.key = okey;
29121  return CImg<intT>(4,1,1,1,x0,y0,x1,y1);
29122  }
if(dy > dx)
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.
Definition: CImg.h:26338
CImg< T > & log10()
Compute the log10 of each each pixel value.
Definition: CImg.h:12560
static unsigned int _fitscreen(const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const int dmin=128, const int dmax=-85, const bool return_last=false)
Definition: CImg.h:6437
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
const unsigned int keyCTRLLEFT
Definition: CImg.h:2734
NT dx
cimg::superset< T, double >::type Tdouble
Definition: CImg.h:9782
#define cimg_fitscreen(dx, dy, dz)
Definition: CImg.h:6436
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const unsigned int keyC
Definition: CImg.h:2727
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
CImg< T > & noise(const double sigma, const unsigned int noise_type=0)
Add random noise to the values of the instance image.
Definition: CImg.h:15000
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
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 instance image.
Definition: CImg.h:26565
const unsigned int keyF
Definition: CImg.h:2717
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
Definition: CImg.h:12920
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
const unsigned int keyR
Definition: CImg.h:2703
CImg< T > & round(const float x, const int rounding_type=0)
Compute image with rounded pixel values.
Definition: CImg.h:14976
NT dy
const unsigned int keyS
Definition: CImg.h:2715
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 bool expand=false, const unsigned int pattern=~0U)
Draw a 1D graph on the instance image.
Definition: CImg.h:26788
CImg< T > get_shared_channel(const unsigned int v0)
Return a shared-memory image referencing one channel v0 of the instance image.
Definition: CImg.h:18573
const unsigned int keyD
Definition: CImg.h:2716
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.
Definition: CImg.h:22330
static T_Key key
Definition: vinci_lass.c:76
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg< T > & rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1)
Rotate an image.
Definition: CImg.h:17637
CImg< T > & sequence(const T a0, const T a1)
Return a N-numbered sequence vector from a0 to a1.
Definition: CImg.h:13425
CImg<T> get_sequence ( const T  a0,
const T  a1 
) const
inline

Definition at line 13436 of file CImg.h.

13436  {
13437  return (+*this).sequence(a0,a1);
13438  }
CImg<T> get_shared ( )
inline

Return a shared version of the instance image.

Definition at line 10077 of file CImg.h.

10077  {
10078  return CImg<T>(data,width,height,depth,dim,true);
10079  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
const CImg<T> get_shared ( ) const
inline

Definition at line 10081 of file CImg.h.

10081  {
10082  return CImg<T>(data,width,height,depth,dim,true);
10083  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_shared_channel ( const unsigned int  v0)
inline

Return a shared-memory image referencing one channel v0 of the instance image.

Definition at line 18573 of file CImg.h.

Referenced by CImg< uintT >::_draw_text(), CImg< uintT >::autocrop(), CImg< uintT >::draw_triangle(), and CImg< uintT >::get_select_graph().

18573  {
18574  return get_shared_channels(v0,v0);
18575  }
CImg< T > get_shared_channels(const unsigned int v0, const unsigned int v1)
Return a shared-memory image referencing a set of channels (v0-&gt;v1) of the instance image...
Definition: CImg.h:18554

Here is the caller graph for this function:

const CImg<T> get_shared_channel ( const unsigned int  v0) const
inline

Definition at line 18577 of file CImg.h.

18577  {
18578  return get_shared_channels(v0,v0);
18579  }
CImg< T > get_shared_channels(const unsigned int v0, const unsigned int v1)
Return a shared-memory image referencing a set of channels (v0-&gt;v1) of the instance image...
Definition: CImg.h:18554
CImg<T> get_shared_channels ( const unsigned int  v0,
const unsigned int  v1 
)
inline

Return a shared-memory image referencing a set of channels (v0->v1) of the instance image.

Definition at line 18554 of file CImg.h.

Referenced by CImg< uintT >::get_shared_channel().

18554  {
18555  const unsigned int beg = offset(0,0,0,v0), end = offset(0,0,0,v1);
18556  if (beg>end || beg>=size() || end>=size())
18557  throw CImgArgumentException("CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from "
18558  "a (%u,%u,%u,%u) image.",
18559  pixel_type(),width-1,height-1,depth-1,v0,v1,width,height,depth,dim);
18560  return CImg<T>(data+beg,width,height,depth,v1-v0+1,true);
18561  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T> get_shared_channels ( const unsigned int  v0,
const unsigned int  v1 
) const
inline

Definition at line 18563 of file CImg.h.

18563  {
18564  const unsigned int beg = offset(0,0,0,v0), end = offset(0,0,0,v1);
18565  if (beg>end || beg>=size() || end>=size())
18566  throw CImgArgumentException("CImg<%s>::get_shared_channels() : Cannot return a shared-memory subset (0->%u,0->%u,0->%u,%u->%u) from "
18567  "a (%u,%u,%u,%u) image.",
18568  pixel_type(),width-1,height-1,depth-1,v0,v1,width,height,depth,dim);
18569  return CImg<T>(data+beg,width,height,depth,v1-v0+1,true);
18570  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_shared_line ( const unsigned int  y0,
const unsigned int  z0 = 0,
const unsigned int  v0 = 0 
)
inline

Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image.

Definition at line 18517 of file CImg.h.

Referenced by CImg< uintT >::resize_object3d(), and CImg< uintT >::translate_object3d().

18517  {
18518  return get_shared_lines(y0,y0,z0,v0);
18519  }
CImg< T > get_shared_lines(const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing a set of lines of the instance image.
Definition: CImg.h:18496

Here is the caller graph for this function:

const CImg<T> get_shared_line ( const unsigned int  y0,
const unsigned int  z0 = 0,
const unsigned int  v0 = 0 
) const
inline

Definition at line 18521 of file CImg.h.

18521  {
18522  return get_shared_lines(y0,y0,z0,v0);
18523  }
CImg< T > get_shared_lines(const unsigned int y0, const unsigned int y1, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing a set of lines of the instance image.
Definition: CImg.h:18496
CImg<T> get_shared_lines ( const unsigned int  y0,
const unsigned int  y1,
const unsigned int  z0 = 0,
const unsigned int  v0 = 0 
)
inline

Return a shared-memory image referencing a set of lines of the instance image.

Definition at line 18496 of file CImg.h.

Referenced by CImg< uintT >::get_shared_line().

18497  {
18498  const unsigned int beg = offset(0,y0,z0,v0), end = offset(0,y1,z0,v0);
18499  if (beg>end || beg>=size() || end>=size())
18500  throw CImgArgumentException("CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from "
18501  "a (%u,%u,%u,%u) image.",
18502  pixel_type(),width-1,y0,y1,z0,v0,width,height,depth,dim);
18503  return CImg<T>(data+beg,width,y1-y0+1,1,1,true);
18504  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T> get_shared_lines ( const unsigned int  y0,
const unsigned int  y1,
const unsigned int  z0 = 0,
const unsigned int  v0 = 0 
) const
inline

Definition at line 18506 of file CImg.h.

18507  {
18508  const unsigned int beg = offset(0,y0,z0,v0), end = offset(0,y1,z0,v0);
18509  if (beg>end || beg>=size() || end>=size())
18510  throw CImgArgumentException("CImg<%s>::get_shared_lines() : Cannot return a shared-memory subset (0->%u,%u->%u,%u,%u) from "
18511  "a (%u,%u,%u,%u) image.",
18512  pixel_type(),width-1,y0,y1,z0,v0,width,height,depth,dim);
18513  return CImg<T>(data+beg,width,y1-y0+1,1,1,true);
18514  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_shared_plane ( const unsigned int  z0,
const unsigned int  v0 = 0 
)
inline

Return a shared-memory image referencing one plane (z0,v0) of the instance image.

Definition at line 18545 of file CImg.h.

18545  {
18546  return get_shared_planes(z0,z0,v0);
18547  }
CImg< T > get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0)
Return a shared memory image referencing a set of planes (z0-&gt;z1,v0) of the instance image...
Definition: CImg.h:18526
const CImg<T> get_shared_plane ( const unsigned int  z0,
const unsigned int  v0 = 0 
) const
inline

Definition at line 18549 of file CImg.h.

18549  {
18550  return get_shared_planes(z0,z0,v0);
18551  }
CImg< T > get_shared_planes(const unsigned int z0, const unsigned int z1, const unsigned int v0=0)
Return a shared memory image referencing a set of planes (z0-&gt;z1,v0) of the instance image...
Definition: CImg.h:18526
CImg<T> get_shared_planes ( const unsigned int  z0,
const unsigned int  z1,
const unsigned int  v0 = 0 
)
inline

Return a shared memory image referencing a set of planes (z0->z1,v0) of the instance image.

Definition at line 18526 of file CImg.h.

Referenced by CImg< uintT >::get_shared_plane().

18526  {
18527  const unsigned int beg = offset(0,0,z0,v0), end = offset(0,0,z1,v0);
18528  if (beg>end || beg>=size() || end>=size())
18529  throw CImgArgumentException("CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from "
18530  "a (%u,%u,%u,%u) image.",
18531  pixel_type(),width-1,height-1,z0,z1,v0,width,height,depth,dim);
18532  return CImg<T>(data+beg,width,height,z1-z0+1,1,true);
18533  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T> get_shared_planes ( const unsigned int  z0,
const unsigned int  z1,
const unsigned int  v0 = 0 
) const
inline

Definition at line 18535 of file CImg.h.

18535  {
18536  const unsigned int beg = offset(0,0,z0,v0), end = offset(0,0,z1,v0);
18537  if (beg>end || beg>=size() || end>=size())
18538  throw CImgArgumentException("CImg<%s>::get_shared_planes() : Cannot return a shared-memory subset (0->%u,0->%u,%u->%u,%u) from "
18539  "a (%u,%u,%u,%u) image.",
18540  pixel_type(),width-1,height-1,z0,z1,v0,width,height,depth,dim);
18541  return CImg<T>(data+beg,width,height,z1-z0+1,1,true);
18542  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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  v0 = 0 
)
inline

Get a shared-memory image referencing a set of points of the instance image.

Definition at line 18475 of file CImg.h.

18476  {
18477  const unsigned int beg = (unsigned int)offset(x0,y0,z0,v0), end = offset(x1,y0,z0,v0);
18478  if (beg>end || beg>=size() || end>=size())
18479  throw CImgArgumentException("CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from "
18480  "a (%u,%u,%u,%u) image.",
18481  pixel_type(),x0,x1,y0,z0,v0,width,height,depth,dim);
18482  return CImg<T>(data+beg,x1-x0+1,1,1,1,true);
18483  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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  v0 = 0 
) const
inline

Definition at line 18485 of file CImg.h.

18486  {
18487  const unsigned int beg = (unsigned int)offset(x0,y0,z0,v0), end = offset(x1,y0,z0,v0);
18488  if (beg>end || beg>=size() || end>=size())
18489  throw CImgArgumentException("CImg<%s>::get_shared_points() : Cannot return a shared-memory subset (%u->%u,%u,%u,%u) from "
18490  "a (%u,%u,%u,%u) image.",
18491  pixel_type(),x0,x1,y0,z0,v0,width,height,depth,dim);
18492  return CImg<T>(data+beg,x1-x0+1,1,1,1,true);
18493  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
int offset(const int x, const int y=0, const int z=0, const int v=0) const
Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data...
Definition: CImg.h:11147
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
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
inline

Definition at line 20000 of file CImg.h.

20000  {
20001  return (+*this).sharpen(amplitude,sharpen_type,edge,alpha,sigma);
20002  }
CImg<Tfloat> get_sin ( ) const
inline

Definition at line 12595 of file CImg.h.

Referenced by cimg_library::sin().

12595  {
12596  return CImg<Tfloat>(*this,false).sin();
12597  }
CImg< T > & sin()
Compute the sinus of each pixel value.
Definition: CImg.h:12590

Here is the caller graph for this function:

CImg<Tfloat> get_sinh ( ) const
inline

Definition at line 12625 of file CImg.h.

Referenced by cimg_library::sinh().

12625  {
12626  return CImg<Tfloat>(*this,false).sinh();
12627  }
CImg< T > & sinh()
Compute the hyperbolic sine of each pixel value.
Definition: CImg.h:12620

Here is the caller graph for this function:

CImg<T> get_slice ( const unsigned int  z0) const
inline

Definition at line 18443 of file CImg.h.

Referenced by CImg< uintT >::save_tiff().

18443  {
18444  return get_slices(z0,z0);
18445  }
CImg< T > get_slices(const unsigned int z0, const unsigned int z1) const
Definition: CImg.h:18452

Here is the caller graph for this function:

CImg<T> get_slices ( const unsigned int  z0,
const unsigned int  z1 
) const
inline

Definition at line 18452 of file CImg.h.

Referenced by CImg< uintT >::get_slice(), and CImg< uintT >::slices().

18452  {
18453  return get_crop(0,0,(int)z0,0,dimx()-1,dimy()-1,(int)z1,dimv()-1);
18454  }
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<_cimg_Ttfloat> get_solve ( const CImg< t > &  A) const
inline

Definition at line 13600 of file CImg.h.

13600  {
13601  return CImg<_cimg_Ttfloat>(*this,false).solve(A);
13602  }
CImg< T > & solve(const CImg< t > &A)
Solve a linear system AX=B where B=*this.
Definition: CImg.h:13559
rational * A
Definition: vinci_lass.c:67
CImg<_cimg_Ttfloat> get_solve_tridiagonal ( const CImg< t > &  a,
const CImg< t > &  b,
const CImg< t > &  c 
) const
inline

Definition at line 13654 of file CImg.h.

13654  {
13655  return CImg<_cimg_Ttfloat>(*this,false).solve_tridiagonal(a,b,c);
13656  }
CImg< T > & solve_tridiagonal(const CImg< t > &a, const CImg< t > &b, const CImg< t > &c)
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 ].
Definition: CImg.h:13629
CImg<T> get_sort ( CImg< t > &  permutations,
const bool  increasing = true 
) const
inline

Definition at line 13779 of file CImg.h.

13779  {
13780  return (+*this).sort(permutations,increasing);
13781  }
CImg<T> get_sort ( const bool  increasing = true) const
inline

Definition at line 13789 of file CImg.h.

13789  {
13790  return (+*this).sort(increasing);
13791  }
CImgList<T> get_split ( const char  axis,
const int  nb = 0 
) const
inline

Split image into a list.

Definition at line 18582 of file CImg.h.

Referenced by CImg< uintT >::operator<(), CImg< uintT >::save_ffmpeg(), CImg< uintT >::save_ffmpeg_external(), and CImg< uintT >::save_yuv().

18582  {
18583  CImgList<T> res;
18584  const char naxis = cimg::uncase(axis);
18585  const unsigned int nnb = (unsigned int)(nb==0?1:(nb>0?nb:-nb));
18586  if (nb<=0) switch (naxis) { // Split by bloc size
18587  case 'x': {
18588  for (unsigned int p = 0; p<width; p+=nnb) get_crop(p,0,0,0,cimg::min(p+nnb-1,width-1),height-1,depth-1,dim-1).transfer_to(res);
18589  } break;
18590  case 'y': {
18591  for (unsigned int p = 0; p<height; p+=nnb) get_crop(0,p,0,0,width-1,cimg::min(p+nnb-1,height-1),depth-1,dim-1).transfer_to(res);
18592  } break;
18593  case 'z': {
18594  for (unsigned int p = 0; p<depth; p+=nnb) get_crop(0,0,p,0,width-1,height-1,cimg::min(p+nnb-1,depth-1),dim-1).transfer_to(res);
18595  } break;
18596  default: {
18597  for (unsigned int p = 0; p<dim; p+=nnb) get_crop(0,0,0,p,width-1,height-1,depth-1,cimg::min(p+nnb-1,dim-1)).transfer_to(res);
18598  }} else { // Split by number of blocs
18599  const unsigned int siz = naxis=='x'?width:naxis=='y'?height:naxis=='z'?depth:naxis=='v'?dim:0;
18600  if (nnb>siz) throw CImgArgumentException("CImg<%s>::get_split() : Cannot split instance image (%u,%u,%u,%u,%p) along axis '%c' into %u blocs.",
18601  pixel_type(),width,height,depth,dim,data,axis,nnb);
18602  res.assign(nnb);
18603  switch (naxis) {
18604  case 'x' : {
18605  cimglist_for(res,p) get_crop(p*siz/nnb,0,0,0,(p+1)*siz/nnb-1,height-1,depth-1,dim-1).transfer_to(res[p]);
18606  } break;
18607  case 'y' : {
18608  cimglist_for(res,p) get_crop(0,p*siz/nnb,0,0,width-1,(p+1)*siz/nnb-1,depth-1,dim-1).transfer_to(res[p]);
18609  } break;
18610  case 'z' : {
18611  cimglist_for(res,p) get_crop(0,0,p*siz/nnb,0,width-1,height-1,(p+1)*siz/nnb-1,dim-1).transfer_to(res[p]);
18612  } break;
18613  default : {
18614  cimglist_for(res,p) get_crop(0,0,0,p*siz/nnb,width-1,height-1,depth-1,(p+1)*siz/nnb-1).transfer_to(res[p]);
18615  }
18616  }
18617  }
18618  return res;
18619  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > get_crop(const int x0, const int y0, const int z0, const int v0, const int x1, const int y1, const int z1, const int v1, const bool border_condition=false) const
Definition: CImg.h:18190
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
#define cimglist_for(list, l)
Definition: CImg.h:1877
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImgList<T> get_split ( const T  value,
const bool  keep_values,
const bool  shared,
const char  axis = 'y' 
) const
inline

Definition at line 18622 of file CImg.h.

18622  {
18623  CImgList<T> res;
18624  const T *ptr0 = data, *const ptr_end = data + size();
18625  while (ptr0<ptr_end) {
18626  const T *ptr1 = ptr0;
18627  while (ptr1<ptr_end && *ptr1==value) ++ptr1;
18628  const unsigned int siz0 = ptr1 - ptr0;
18629  if (siz0 && keep_values) res.insert(CImg<T>(ptr0,1,siz0,1,1,shared));
18630  ptr0 = ptr1;
18631  while (ptr1<ptr_end && *ptr1!=value) ++ptr1;
18632  const unsigned int siz1 = ptr1 - ptr0;
18633  if (siz1) res.insert(CImg<T>(ptr0,1,siz1,1,1,shared),~0U,shared);
18634  ptr0 = ptr1;
18635  }
18636  cimglist_apply(res,unroll)(axis);
18637  return res;
18638  }
CImg< T > & unroll(const char axis)
Unroll all images values into specified axis.
Definition: CImg.h:17610
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimglist_apply(list, fn)
Definition: CImg.h:1881
CImg<Tfloat> get_sqr ( ) const
inline

Definition at line 12525 of file CImg.h.

Referenced by cimg_library::sqr().

12525  {
12526  return CImg<Tfloat>(*this,false).sqr();
12527  }
CImg< T > & sqr()
Compute the square value of each pixel.
Definition: CImg.h:12520

Here is the caller graph for this function:

CImg<Tfloat> get_sqrt ( ) const
inline

Definition at line 12535 of file CImg.h.

Referenced by cimg_library::sqrt().

12535  {
12536  return CImg<Tfloat>(*this,false).sqrt();
12537  }
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530

Here is the caller graph for this function:

CImg<Tfloat> get_stats ( const unsigned int  variance_method = 1) const
inline

Definition at line 13152 of file CImg.h.

Referenced by CImg< uintT >::print(), and CImg< uintT >::stats().

13152  {
13153  if (is_empty()) return CImg<Tfloat>();
13154  const unsigned int siz = size();
13155  const T *const odata = data;
13156  const T *pm = odata, *pM = odata;
13157  Tfloat S = 0, S2 = 0;
13158  T m = *pm, M = m;
13159  cimg_for(*this,ptr,T) {
13160  const T val = *ptr;
13161  const Tfloat fval = (Tfloat)val;
13162  if (val<m) { m = val; pm = ptr; }
13163  if (val>M) { M = val; pM = ptr; }
13164  S+=fval;
13165  S2+=fval*fval;
13166  }
13167  const Tfloat
13168  mean_value = S/siz,
13169  _variance_value = variance_method==0?(S2 - S*S/siz)/siz:
13170  (variance_method==1?(siz>1?(S2 - S*S/siz)/(siz - 1):0):
13171  variance(variance_method)),
13172  variance_value = _variance_value>0?_variance_value:0;
13173  int
13174  xm = 0, ym = 0, zm = 0, vm = 0,
13175  xM = 0, yM = 0, zM = 0, vM = 0;
13176  contains(*pm,xm,ym,zm,vm);
13177  contains(*pM,xM,yM,zM,vM);
13178  return CImg<Tfloat>(1,12).fill((Tfloat)m,(Tfloat)M,mean_value,variance_value,
13179  (Tfloat)xm,(Tfloat)ym,(Tfloat)zm,(Tfloat)vm,
13180  (Tfloat)xM,(Tfloat)yM,(Tfloat)zM,(Tfloat)vM);
13181  }
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
bool contains(const T &pixel, t &x, t &y, t &z, t &v) const
Return true if specified referenced value is inside image boundaries. If true, returns pixel coordina...
Definition: CImg.h:12055
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
Tfloat variance(const unsigned int variance_method=1) const
Return the variance of the image.
Definition: CImg.h:13057

Here is the caller graph for this function:

CImg<Tfloat> get_structure_tensor ( const unsigned int  scheme = 1) const
inline

Definition at line 20186 of file CImg.h.

Referenced by CImg< uintT >::edge_tensors(), CImg< uintT >::sharpen(), and CImg< uintT >::structure_tensor().

20186  {
20187  if (is_empty()) return *this;
20188  CImg<Tfloat> res;
20189  if (depth>1) { // 3D version
20190  res.assign(width,height,depth,6,0);
20191  CImg_3x3x3(I,T);
20192  switch (scheme) {
20193  case 0 : { // classical central finite differences
20194  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20195  const Tfloat
20196  ix = 0.5f*((Tfloat)Incc - Ipcc),
20197  iy = 0.5f*((Tfloat)Icnc - Icpc),
20198  iz = 0.5f*((Tfloat)Iccn - Iccp);
20199  res(x,y,z,0)+=ix*ix;
20200  res(x,y,z,1)+=ix*iy;
20201  res(x,y,z,2)+=ix*iz;
20202  res(x,y,z,3)+=iy*iy;
20203  res(x,y,z,4)+=iy*iz;
20204  res(x,y,z,5)+=iz*iz;
20205  }
20206  } break;
20207  case 1 : { // Forward/backward finite differences (version 1).
20208  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20209  const Tfloat
20210  ixf = (Tfloat)Incc - Iccc, ixb = (Tfloat)Iccc - Ipcc,
20211  iyf = (Tfloat)Icnc - Iccc, iyb = (Tfloat)Iccc - Icpc,
20212  izf = (Tfloat)Iccn - Iccc, izb = (Tfloat)Iccc - Iccp;
20213  res(x,y,z,0) += 0.25f*(ixf*ixf + ixf*ixb + ixb*ixf + ixb*ixb);
20214  res(x,y,z,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20215  res(x,y,z,2) += 0.25f*(ixf*izf + ixf*izb + ixb*izf + ixb*izb);
20216  res(x,y,z,3) += 0.25f*(iyf*iyf + iyf*iyb + iyb*iyf + iyb*iyb);
20217  res(x,y,z,4) += 0.25f*(iyf*izf + iyf*izb + iyb*izf + iyb*izb);
20218  res(x,y,z,5) += 0.25f*(izf*izf + izf*izb + izb*izf + izb*izb);
20219  }
20220  } break;
20221  default : { // Forward/backward finite differences (version 2).
20222  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
20223  const Tfloat
20224  ixf = (Tfloat)Incc - Iccc, ixb = (Tfloat)Iccc - Ipcc,
20225  iyf = (Tfloat)Icnc - Iccc, iyb = (Tfloat)Iccc - Icpc,
20226  izf = (Tfloat)Iccn - Iccc, izb = (Tfloat)Iccc - Iccp;
20227  res(x,y,z,0) += 0.5f*(ixf*ixf + ixb*ixb);
20228  res(x,y,z,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20229  res(x,y,z,2) += 0.25f*(ixf*izf + ixf*izb + ixb*izf + ixb*izb);
20230  res(x,y,z,3) += 0.5f*(iyf*iyf + iyb*iyb);
20231  res(x,y,z,4) += 0.25f*(iyf*izf + iyf*izb + iyb*izf + iyb*izb);
20232  res(x,y,z,5) += 0.5f*(izf*izf + izb*izb);
20233  }
20234  } break;
20235  }
20236  } else { // 2D version
20237  res.assign(width,height,depth,3,0);
20238  CImg_3x3(I,T);
20239  switch (scheme) {
20240  case 0 : { // classical central finite differences
20241  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
20242  const Tfloat
20243  ix = 0.5f*((Tfloat)Inc - Ipc),
20244  iy = 0.5f*((Tfloat)Icn - Icp);
20245  res(x,y,0,0)+=ix*ix;
20246  res(x,y,0,1)+=ix*iy;
20247  res(x,y,0,2)+=iy*iy;
20248  }
20249  } break;
20250  case 1 : { // Forward/backward finite differences (version 1).
20251  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
20252  const Tfloat
20253  ixf = (Tfloat)Inc - Icc, ixb = (Tfloat)Icc - Ipc,
20254  iyf = (Tfloat)Icn - Icc, iyb = (Tfloat)Icc - Icp;
20255  res(x,y,0,0) += 0.25f*(ixf*ixf + ixf*ixb + ixb*iyf + ixb*ixb);
20256  res(x,y,0,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20257  res(x,y,0,2) += 0.25f*(iyf*iyf + iyf*iyb + iyb*iyf + iyb*iyb);
20258  }
20259  } break;
20260  default : { // Forward/backward finite differences (version 2).
20261  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
20262  const Tfloat
20263  ixf = (Tfloat)Inc - Icc, ixb = (Tfloat)Icc - Ipc,
20264  iyf = (Tfloat)Icn - Icc, iyb = (Tfloat)Icc - Icp;
20265  res(x,y,0,0) += 0.5f*(ixf*ixf + ixb*ixb);
20266  res(x,y,0,1) += 0.25f*(ixf*iyf + ixf*iyb + ixb*iyf + ixb*iyb);
20267  res(x,y,0,2) += 0.5f*(iyf*iyf + iyb*iyb);
20268  }
20269  } break;
20270  }
20271  }
20272  return res;
20273  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const int scheme
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
#define CImg_3x3(I, T)
Definition: CImg.h:421

Here is the caller graph for this function:

CImgList<Tfloat> get_SVD ( const bool  sorting = true,
const unsigned int  max_iter = 40,
const float  lambda = 0 
) const
inline

Definition at line 13985 of file CImg.h.

13986  {
13987  CImgList<Tfloat> res(3);
13988  SVD(res[0],res[1],res[2],sorting,max_iter,lambda);
13989  return res;
13990  }
const CImg< T > & SVD(CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
Compute the SVD of a general matrix.
Definition: CImg.h:13843
CImgList<Tfloat> get_symmetric_eigen ( ) const
inline

Definition at line 13760 of file CImg.h.

13760  {
13761  CImgList<Tfloat> res(2);
13762  symmetric_eigen(res[0],res[1]);
13763  return res;
13764  }
const CImg< T > & symmetric_eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a symmetric matrix.
Definition: CImg.h:13703
CImg<Tfloat> get_tan ( ) const
inline

Definition at line 12605 of file CImg.h.

Referenced by cimg_library::tan().

12605  {
12606  return CImg<Tfloat>(*this,false).tan();
12607  }
CImg< T > & tan()
Compute the tangent of each pixel.
Definition: CImg.h:12600

Here is the caller graph for this function:

CImg<Tfloat> get_tanh ( ) const
inline

Definition at line 12635 of file CImg.h.

Referenced by cimg_library::tanh().

12635  {
12636  return CImg<Tfloat>(*this,false).tanh();
12637  }
CImg< T > & tanh()
Compute the hyperbolic tangent of each pixel value.
Definition: CImg.h:12630

Here is the caller graph for this function:

CImg<T> get_tensor ( ) const
inline

Definition at line 13376 of file CImg.h.

Referenced by CImg< uintT >::tensor().

13376  {
13377  CImg<T> res;
13378  const unsigned int siz = size();
13379  switch (siz) {
13380  case 1 : break;
13381  case 3 :
13382  res.assign(2,2);
13383  res(0,0) = (*this)(0);
13384  res(1,0) = res(0,1) = (*this)(1);
13385  res(1,1) = (*this)(2);
13386  break;
13387  case 6 :
13388  res.assign(3,3);
13389  res(0,0) = (*this)(0);
13390  res(1,0) = res(0,1) = (*this)(1);
13391  res(2,0) = res(0,2) = (*this)(2);
13392  res(1,1) = (*this)(3);
13393  res(2,1) = res(1,2) = (*this)(4);
13394  res(2,2) = (*this)(5);
13395  break;
13396  default :
13397  throw CImgInstanceException("CImg<%s>::tensor() : Wrong vector dimension = %u in instance image.",
13398  pixel_type(), dim);
13399  }
13400  return res;
13401  }
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T> get_tensor_at ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0 
) const
inline

Return a new image corresponding to the diffusion tensor located at (x,y,z) of the current vector-valued image.

Definition at line 13289 of file CImg.h.

13289  {
13290  if (dim==6) return tensor((*this)(x,y,z,0),(*this)(x,y,z,1),(*this)(x,y,z,2),
13291  (*this)(x,y,z,3),(*this)(x,y,z,4),(*this)(x,y,z,5));
13292  if (dim==3) return tensor((*this)(x,y,z,0),(*this)(x,y,z,1),(*this)(x,y,z,2));
13293  return tensor((*this)(x,y,z,0));
13294  }
CImg< T > & tensor()
Realign pixel values of the instance image as a symmetric tensor.
Definition: CImg.h:13372
void int int REAL REAL * y
Definition: read.cpp:74
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> get_threshold ( const T  value,
const bool  soft_threshold = false,
const bool  strict_threshold = false 
) const
inline

Definition at line 15246 of file CImg.h.

15246  {
15247  return (+*this).threshold(value,soft_threshold,strict_threshold);
15248  }
CImg<T> get_translate ( const int  deltax,
const int  deltay = 0,
const int  deltaz = 0,
const int  deltav = 0,
const int  border_condition = 0 
) const
inline

Definition at line 17424 of file CImg.h.

17425  {
17426  return (+*this).translate(deltax,deltay,deltaz,deltav,border_condition);
17427  }
CImg<Tfloat> get_translate_object3d ( const float  tx,
const float  ty = 0,
const float  tz = 0 
) const
inline

Definition at line 21086 of file CImg.h.

21086  {
21087  return CImg<Tfloat>(*this,false).translate_object3d(tx,ty,tz);
21088  }
CImg< T > & translate_object3d()
Translate a 3D object so that it becomes centered.
Definition: CImg.h:21091
CImg<Tfloat> get_translate_object3d ( ) const
inline

Definition at line 21102 of file CImg.h.

21102  {
21103  return CImg<Tfloat>(*this,false).translate_object3d();
21104  }
CImg< T > & translate_object3d()
Translate a 3D object so that it becomes centered.
Definition: CImg.h:21091
CImg<T> get_transpose ( ) const
inline

Definition at line 13451 of file CImg.h.

Referenced by cimg_library::transpose(), and CImg< uintT >::transpose().

13451  {
13452  return get_permute_axes("yxzv");
13453  }
CImg< T > get_permute_axes(const char *order) const
Definition: CImg.h:17604

Here is the caller graph for this function:

CImg<T> get_unroll ( const char  axis) const
inline

Definition at line 17624 of file CImg.h.

Referenced by CImg< uintT >::get_vector().

17624  {
17625  return (+*this).unroll(axis);
17626  }

Here is the caller graph for this function:

CImg<T> get_vector ( ) const
inline

Definition at line 13338 of file CImg.h.

13338  {
13339  return get_unroll('y');
13340  }
CImg< T > get_unroll(const char axis) const
Definition: CImg.h:17624
CImg<T> get_vector_at ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0 
) const
inline

Return a new image corresponding to the vector located at (x,y,z) of the current vector-valued image.

Definition at line 13270 of file CImg.h.

Referenced by CImg< uintT >::draw_fill().

13270  {
13271  static CImg<T> dest;
13272  if (dest.height!=dim) dest.assign(1,dim);
13273  const unsigned int whz = width*height*depth;
13274  const T *ptrs = ptr(x,y,z);
13275  T *ptrd = dest.data;
13276  cimg_forV(*this,k) { *(ptrd++) = *ptrs; ptrs+=whz; }
13277  return dest;
13278  }
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T> get_warp ( const CImg< t > &  warp,
const bool  relative = false,
const bool  interpolation = true,
const unsigned int  border_conditions = 0 
) const
inline

Definition at line 17869 of file CImg.h.

Referenced by CImg< uintT >::warp().

17870  {
17871  if (is_empty() || !warp) return *this;
17872  if (relative && !is_sameXYZ(warp))
17873  throw CImgArgumentException("CImg<%s>::warp() : Instance image (%u,%u,%u,%u,%p) and relative warping field (%u,%u,%u,%u,%p) "
17874  "have different XYZ dimensions.",
17876  warp.width,warp.height,warp.depth,warp.dim,warp.data);
17877  CImg<T> res(warp.width,warp.height,warp.depth,dim);
17878  switch (warp.dim) {
17879  case 1 : // 1D warping.
17880  if (relative) { // Relative warp coordinates
17881  if (interpolation) switch (border_conditions) {
17882  case 2 : {
17883  cimg_forXYZV(res,x,y,z,v)
17884  res(x,y,z,v) = (T)_linear_atX(cimg::mod(x-(float)warp(x,y,z,0),(float)width),y,z,v);
17885  } break;
17886  case 1 : {
17887  cimg_forXYZV(res,x,y,z,v)
17888  res(x,y,z,v) = (T)_linear_atX(x-(float)warp(x,y,z,0),y,z,v);
17889  } break;
17890  default : {
17891  cimg_forXYZV(res,x,y,z,v)
17892  res(x,y,z,v) = (T)linear_atX(x-(float)warp(x,y,z,0),y,z,v,0);
17893  }
17894  } else switch (border_conditions) {
17895  case 2 : {
17896  cimg_forXYZV(res,x,y,z,v)
17897  res(x,y,z,v) = (*this)(cimg::mod(x-(int)warp(x,y,z,0),(int)width),y,z,v);
17898  } break;
17899  case 1 : {
17900  cimg_forXYZV(res,x,y,z,v)
17901  res(x,y,z,v) = _atX(x-(int)warp(x,y,z,0),y,z,v);
17902  } break;
17903  default : {
17904  cimg_forXYZV(res,x,y,z,v)
17905  res(x,y,z,v) = atX(x-(int)warp(x,y,z,0),y,z,v,0);
17906  }
17907  }
17908  } else { // Absolute warp coordinates
17909  if (interpolation) switch (border_conditions) {
17910  case 2 : {
17911  cimg_forXYZV(res,x,y,z,v)
17912  res(x,y,z,v) = (T)_linear_atX(cimg::mod((float)warp(x,y,z,0),(float)width),y,z,v);
17913  } break;
17914  case 1 : {
17915  cimg_forXYZV(res,x,y,z,v)
17916  res(x,y,z,v) = (T)_linear_atX((float)warp(x,y,z,0),y,z,v);
17917  } break;
17918  default : {
17919  cimg_forXYZV(res,x,y,z,v)
17920  res(x,y,z,v) = (T)linear_atX((float)warp(x,y,z,0),y,z,v,0);
17921  }
17922  } else switch (border_conditions) {
17923  case 2 : {
17924  cimg_forXYZV(res,x,y,z,v)
17925  res(x,y,z,v) = (*this)(cimg::mod((int)warp(x,y,z,0),(int)width),y,z,v);
17926  } break;
17927  case 1 : {
17928  cimg_forXYZV(res,x,y,z,v)
17929  res(x,y,z,v) = _atX((int)warp(x,y,z,0),y,z,v);
17930  } break;
17931  default : {
17932  cimg_forXYZV(res,x,y,z,v)
17933  res(x,y,z,v) = atX((int)warp(x,y,z,0),y,z,v,0);
17934  }
17935  }
17936  }
17937  break;
17938 
17939  case 2 : // 2D warping
17940  if (relative) { // Relative warp coordinates
17941  if (interpolation) switch (border_conditions) {
17942  case 2 : {
17943  cimg_forXYZV(res,x,y,z,v)
17944  res(x,y,z,v) = (T)_linear_atXY(cimg::mod(x-(float)warp(x,y,z,0),(float)width),
17945  cimg::mod(y-(float)warp(x,y,z,1),(float)height),z,v);
17946  } break;
17947  case 1 : {
17948  cimg_forXYZV(res,x,y,z,v)
17949  res(x,y,z,v) = (T)_linear_atXY(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z,v);
17950  } break;
17951  default : {
17952  cimg_forXYZV(res,x,y,z,v)
17953  res(x,y,z,v) = (T)linear_atXY(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z,v,0);
17954  }
17955  } else switch (border_conditions) {
17956  case 2 : {
17957  cimg_forXYZV(res,x,y,z,v)
17958  res(x,y,z,v) = (*this)(cimg::mod(x-(int)warp(x,y,z,0),(int)width),
17959  cimg::mod(y-(int)warp(x,y,z,1),(int)height),z,v);
17960  } break;
17961  case 1 : {
17962  cimg_forXYZV(res,x,y,z,v)
17963  res(x,y,z,v) = _atXY(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z,v);
17964  } break;
17965  default : {
17966  cimg_forXYZV(res,x,y,z,v)
17967  res(x,y,z,v) = atXY(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z,v,0);
17968  }
17969  }
17970  } else { // Absolute warp coordinates
17971  if (interpolation) switch (border_conditions) {
17972  case 2 : {
17973  cimg_forXYZV(res,x,y,z,v)
17974  res(x,y,z,v) = (T)_linear_atXY(cimg::mod((float)warp(x,y,z,0),(float)width),
17975  cimg::mod((float)warp(x,y,z,1),(float)height),z,v);
17976  } break;
17977  case 1 : {
17978  cimg_forXYZV(res,x,y,z,v)
17979  res(x,y,z,v) = (T)_linear_atXY((float)warp(x,y,z,0),(float)warp(x,y,z,1),z,v);
17980  } break;
17981  default : {
17982  cimg_forXYZV(res,x,y,z,v)
17983  res(x,y,z,v) = (T)linear_atXY((float)warp(x,y,z,0),(float)warp(x,y,z,1),z,v,0);
17984  }
17985  } else switch (border_conditions) {
17986  case 2 : {
17987  cimg_forXYZV(res,x,y,z,v)
17988  res(x,y,z,v) = (*this)(cimg::mod((int)warp(x,y,z,0),(int)width),
17989  cimg::mod((int)warp(x,y,z,1),(int)height),z,v);
17990  } break;
17991  case 1 : {
17992  cimg_forXYZV(res,x,y,z,v)
17993  res(x,y,z,v) = _atXY((int)warp(x,y,z,0),(int)warp(x,y,z,1),z,v);
17994  } break;
17995  default : {
17996  cimg_forXYZV(res,x,y,z,v)
17997  res(x,y,z,v) = atXY((int)warp(x,y,z,0),(int)warp(x,y,z,1),z,v,0);
17998  }
17999  }
18000  }
18001  break;
18002 
18003  case 3 : // 3D warping
18004  if (relative) { // Relative warp coordinates
18005  if (interpolation) switch (border_conditions) {
18006  case 2 : {
18007  cimg_forXYZV(res,x,y,z,v)
18008  res(x,y,z,v) = (T)_linear_atXYZ(cimg::mod(x-(float)warp(x,y,z,0),(float)width),
18009  cimg::mod(y-(float)warp(x,y,z,1),(float)height),
18010  cimg::mod(z-(float)warp(x,y,z,2),(float)depth),v);
18011  } break;
18012  case 1 : {
18013  cimg_forXYZV(res,x,y,z,v)
18014  res(x,y,z,v) = (T)_linear_atXYZ(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z-(float)warp(x,y,z,2),v);
18015  } break;
18016  default : {
18017  cimg_forXYZV(res,x,y,z,v)
18018  res(x,y,z,v) = (T)linear_atXYZ(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z-(float)warp(x,y,z,2),v,0);
18019  }
18020  } else switch (border_conditions) {
18021  case 2 : {
18022  cimg_forXYZV(res,x,y,z,v)
18023  res(x,y,z,v) = (*this)(cimg::mod(x-(int)warp(x,y,z,0),(int)width),
18024  cimg::mod(y-(int)warp(x,y,z,1),(int)height),
18025  cimg::mod(z-(int)warp(x,y,z,2),(int)depth),v);
18026  } break;
18027  case 1 : {
18028  cimg_forXYZV(res,x,y,z,v)
18029  res(x,y,z,v) = _atXYZ(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z-(int)warp(x,y,z,2),v);
18030  } break;
18031  default : {
18032  cimg_forXYZV(res,x,y,z,v)
18033  res(x,y,z,v) = atXYZ(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z-(int)warp(x,y,z,2),v,0);
18034  }
18035  }
18036  } else { // Absolute warp coordinates
18037  if (interpolation) switch (border_conditions) {
18038  case 2 : {
18039  cimg_forXYZV(res,x,y,z,v)
18040  res(x,y,z,v) = (T)_linear_atXYZ(cimg::mod((float)warp(x,y,z,0),(float)width),
18041  cimg::mod((float)warp(x,y,z,1),(float)height),
18042  cimg::mod((float)warp(x,y,z,2),(float)depth),v);
18043  } break;
18044  case 1 : {
18045  cimg_forXYZV(res,x,y,z,v)
18046  res(x,y,z,v) = (T)_linear_atXYZ((float)warp(x,y,z,0),(float)warp(x,y,z,1),(float)warp(x,y,z,2),v);
18047  } break;
18048  default : {
18049  cimg_forXYZV(res,x,y,z,v)
18050  res(x,y,z,v) = (T)linear_atXYZ((float)warp(x,y,z,0),(float)warp(x,y,z,1),(float)warp(x,y,z,2),v,0);
18051  }
18052  } else switch (border_conditions) {
18053  case 2 : {
18054  cimg_forXYZV(res,x,y,z,v)
18055  res(x,y,z,v) = (*this)(cimg::mod((int)warp(x,y,z,0),(int)width),
18056  cimg::mod((int)warp(x,y,z,1),(int)height),
18057  cimg::mod((int)warp(x,y,z,2),(int)depth),v);
18058  } break;
18059  case 1 : {
18060  cimg_forXYZV(res,x,y,z,v)
18061  res(x,y,z,v) = _atXYZ((int)warp(x,y,z,0),(int)warp(x,y,z,1),(int)warp(x,y,z,2),v);
18062  } break;
18063  default : {
18064  cimg_forXYZV(res,x,y,z,v)
18065  res(x,y,z,v) = atXYZ((int)warp(x,y,z,0),(int)warp(x,y,z,1),(int)warp(x,y,z,2),v,0);
18066  }
18067  }
18068  }
18069  break;
18070 
18071  default : // 4D warping
18072  if (relative) { // Relative warp coordinates
18073  if (interpolation) switch (border_conditions) {
18074  case 2 : {
18075  cimg_forXYZV(res,x,y,z,v)
18076  res(x,y,z,v) = (T)_linear_atXYZV(cimg::mod(x-(float)warp(x,y,z,0),(float)width),
18077  cimg::mod(y-(float)warp(x,y,z,1),(float)height),
18078  cimg::mod(z-(float)warp(x,y,z,2),(float)depth),
18079  cimg::mod(z-(float)warp(x,y,z,3),(float)dim));
18080  } break;
18081  case 1 : {
18082  cimg_forXYZV(res,x,y,z,v)
18083  res(x,y,z,v) = (T)_linear_atXYZV(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z-(float)warp(x,y,z,2),v-(float)warp(x,y,z,3));
18084  } break;
18085  default : {
18086  cimg_forXYZV(res,x,y,z,v)
18087  res(x,y,z,v) = (T)linear_atXYZV(x-(float)warp(x,y,z,0),y-(float)warp(x,y,z,1),z-(float)warp(x,y,z,2),v-(float)warp(x,y,z,3),0);
18088  }
18089  } else switch (border_conditions) {
18090  case 2 : {
18091  cimg_forXYZV(res,x,y,z,v)
18092  res(x,y,z,v) = (*this)(cimg::mod(x-(int)warp(x,y,z,0),(int)width),
18093  cimg::mod(y-(int)warp(x,y,z,1),(int)height),
18094  cimg::mod(z-(int)warp(x,y,z,2),(int)depth),
18095  cimg::mod(v-(int)warp(x,y,z,3),(int)dim));
18096  } break;
18097  case 1 : {
18098  cimg_forXYZV(res,x,y,z,v)
18099  res(x,y,z,v) = _atXYZV(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z-(int)warp(x,y,z,2),v-(int)warp(x,y,z,3));
18100  } break;
18101  default : {
18102  cimg_forXYZV(res,x,y,z,v)
18103  res(x,y,z,v) = atXYZ(x-(int)warp(x,y,z,0),y-(int)warp(x,y,z,1),z-(int)warp(x,y,z,2),v-(int)warp(x,y,z,3),0);
18104  }
18105  }
18106  } else { // Absolute warp coordinates
18107  if (interpolation) switch (border_conditions) {
18108  case 2 : {
18109  cimg_forXYZV(res,x,y,z,v)
18110  res(x,y,z,v) = (T)_linear_atXYZV(cimg::mod((float)warp(x,y,z,0),(float)width),
18111  cimg::mod((float)warp(x,y,z,1),(float)height),
18112  cimg::mod((float)warp(x,y,z,2),(float)depth),
18113  cimg::mod((float)warp(x,y,z,3),(float)dim));
18114  } break;
18115  case 1 : {
18116  cimg_forXYZV(res,x,y,z,v)
18117  res(x,y,z,v) = (T)_linear_atXYZV((float)warp(x,y,z,0),(float)warp(x,y,z,1),(float)warp(x,y,z,2),(float)warp(x,y,z,3));
18118  } break;
18119  default : {
18120  cimg_forXYZV(res,x,y,z,v)
18121  res(x,y,z,v) = (T)linear_atXYZV((float)warp(x,y,z,0),(float)warp(x,y,z,1),(float)warp(x,y,z,2),(float)warp(x,y,z,3),0);
18122  }
18123  } else switch (border_conditions) {
18124  case 2 : {
18125  cimg_forXYZV(res,x,y,z,v)
18126  res(x,y,z,v) = (*this)(cimg::mod((int)warp(x,y,z,0),(int)width),
18127  cimg::mod((int)warp(x,y,z,1),(int)height),
18128  cimg::mod((int)warp(x,y,z,2),(int)depth),
18129  cimg::mod((int)warp(x,y,z,3),(int)dim));
18130  } break;
18131  case 1 : {
18132  cimg_forXYZV(res,x,y,z,v)
18133  res(x,y,z,v) = _atXYZV((int)warp(x,y,z,0),(int)warp(x,y,z,1),(int)warp(x,y,z,2),(int)warp(x,y,z,3));
18134  } break;
18135  default : {
18136  cimg_forXYZV(res,x,y,z,v)
18137  res(x,y,z,v) = atXYZV((int)warp(x,y,z,0),(int)warp(x,y,z,1),(int)warp(x,y,z,2),(int)warp(x,y,z,3),0);
18138  }
18139  }
18140  }
18141  }
18142  return res;
18143  }
if(dy > dx)
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Tfloat linear_atX(const float fx, const int y, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first coordinate)...
Definition: CImg.h:11557
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
Tfloat _linear_atXYZV(const float fx, const float fy=0, const float fz=0, const float fv=0) const
Definition: CImg.h:11402
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Tfloat _linear_atXYZ(const float fx, const float fy=0, const float fz=0, const int v=0) const
Definition: CImg.h:11483
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
T & _atXYZ(const int x, const int y, const int z, const int v=0)
Definition: CImg.h:11281
T & _atXY(const int x, const int y, const int z=0, const int v=0)
Definition: CImg.h:11315
void int int REAL * x
Definition: read.cpp:74
T & _atX(const int x, const int y=0, const int z=0, const int v=0)
Definition: CImg.h:11347
T & atX(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the first coordinates (x).
Definition: CImg.h:11324
Tfloat _linear_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Definition: CImg.h:11537
CImg< T > & warp(const CImg< t > &warp, const bool relative=false, const bool interpolation=true, const unsigned int border_conditions=0)
Warp an image.
Definition: CImg.h:17863
T & atXYZV(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions.
Definition: CImg.h:11222
Tfloat linear_atXYZ(const float fx, const float fy, const float fz, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first three coordina...
Definition: CImg.h:11451
Tfloat linear_atXYZV(const float fx, const float fy, const float fz, const float fv, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions.
Definition: CImg.h:11356
T & _atXYZV(const int x, const int y, const int z, const int v)
Definition: CImg.h:11246
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
Tfloat _linear_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Definition: CImg.h:11575
Tfloat linear_atXY(const float fx, const float fy, const int z, const int v, const T out_val) const
Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinate...
Definition: CImg.h:11516
bool is_sameXYZ(const unsigned int dx, const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified width, height and depth.
Definition: CImg.h:11994
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
Definition: CImg.h:11257
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<Tuchar> get_xyYtoRGB ( ) const
inline

Definition at line 16441 of file CImg.h.

16441  {
16442  return CImg<Tuchar>(*this,false).xyYtoRGB();
16443  }
CImg< T > & xyYtoRGB()
Convert a (x,y,Y) image to a (R,G,B) one.
Definition: CImg.h:16437
CImg<Tfloat> get_xyYtoXYZ ( ) const
inline

Definition at line 16405 of file CImg.h.

16405  {
16406  return CImg<Tfloat>(*this,false).xyYtoXYZ();
16407  }
CImg< T > & xyYtoXYZ()
Convert (x,y,Y) pixels of a color image into the (X,Y,Z)_709 color space.
Definition: CImg.h:16385
CImg<Tfloat> get_XYZtoLab ( ) const
inline

Definition at line 16318 of file CImg.h.

16318  {
16319  return CImg<Tfloat>(*this,false).XYZtoLab();
16320  }
CImg< T > & XYZtoLab()
Convert (X,Y,Z)_709 pixels of a color image into the (L*,a*,b*) color space.
Definition: CImg.h:16290
CImg<Tuchar> get_XYZtoRGB ( ) const
inline

Definition at line 16285 of file CImg.h.

16285  {
16286  return CImg<Tuchar>(*this,false).XYZtoRGB();
16287  }
CImg< T > & XYZtoRGB()
Convert (X,Y,Z)_709 pixels of a color image into the (R,G,B) color space.
Definition: CImg.h:16263
CImg<Tfloat> get_XYZtoxyY ( ) const
inline

Definition at line 16380 of file CImg.h.

16380  {
16381  return CImg<Tfloat>(*this,false).XYZtoxyY();
16382  }
CImg< T > & XYZtoxyY()
Convert (X,Y,Z)_709 pixels of a color image into the (x,y,Y) color space.
Definition: CImg.h:16359
CImg<Tuchar> get_YCbCrtoRGB ( ) const
inline

Definition at line 16073 of file CImg.h.

16073  {
16074  return CImg<Tuchar>(*this,false).YCbCrtoRGB();
16075  }
CImg< T > & YCbCrtoRGB()
Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.
Definition: CImg.h:16051
CImg<Tuchar> get_YUVtoRGB ( ) const
inline

Definition at line 16125 of file CImg.h.

16125  {
16126  return CImg< Tuchar>(*this,false).YUVtoRGB();
16127  }
CImg< T > & YUVtoRGB()
Convert color pixels from (Y,U,V) to (R,G,B).
Definition: CImg.h:16103
CImg<T>& haar ( const char  axis,
const bool  invert = false,
const unsigned int  nb_scales = 1 
)
inline

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.

Definition at line 20600 of file CImg.h.

20600  {
20601  return get_haar(axis,invert,nb_scales).transfer_to(*this);
20602  }
CImg< Tfloat > get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const
Definition: CImg.h:20604
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
CImg<T>& haar ( const bool  invert = false,
const unsigned int  nb_scales = 1 
)
inline

Compute the Haar multiscale wavelet transform.

Parameters
invertSet inverse of direct transform.
nb_scalesNumber of scales used for the transform.

Definition at line 20729 of file CImg.h.

20729  {
20730  return get_haar(invert,nb_scales).transfer_to(*this);
20731  }
CImg< Tfloat > get_haar(const char axis, const bool invert=false, const unsigned int nb_scales=1) const
Definition: CImg.h:20604
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
CImg<T>& histogram ( const unsigned int  nb_levels,
const T  value_min = (T)0,
const T  value_max = (T)0 
)
inline

Compute the histogram of the instance image.

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
Instance image 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 instance image.
Sample code :
const CImg<float> img = CImg<float>("reference.jpg").histogram(256);
img.display_graph(0,3);
ref_histogram.jpg

Definition at line 15269 of file CImg.h.

15269  {
15270  return get_histogram(nb_levels,value_min,value_max).transfer_to(*this);
15271  }
CImg< floatT > get_histogram(const unsigned int nb_levels, const T value_min=(T) 0, const T value_max=(T) 0) const
Definition: CImg.h:15273
CImg<T>& HSItoRGB ( )
inline

Convert color pixels from (H,S,I) to (R,G,B).

Definition at line 15982 of file CImg.h.

Referenced by CImg< uintT >::get_HSItoRGB().

15982  {
15983  if (is_empty()) return *this;
15984  if (dim!=3)
15985  throw CImgInstanceException("CImg<%s>::HSItoRGB() : Input image dimension is dim=%u, "
15986  "should be a (H,S,I) image",
15987  pixel_type(),dim);
15988  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15989  for (unsigned int N = width*height*depth; N; --N) {
15990  Tfloat
15991  H = (Tfloat)*p1,
15992  S = (Tfloat)*p2,
15993  I = (Tfloat)*p3,
15994  a = I*(1-S),
15995  R = 0, G = 0, B = 0;
15996  if (H<120) {
15997  B = a;
15998  R = (Tfloat)(I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)));
15999  G = 3*I-(R+B);
16000  } else if (H<240) {
16001  H-=120;
16002  R = a;
16003  G = (Tfloat)(I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)));
16004  B = 3*I-(R+G);
16005  } else {
16006  H-=240;
16007  G = a;
16008  B = (Tfloat)(I*(1+S*std::cos(H*cimg::valuePI/180)/std::cos((60-H)*cimg::valuePI/180)));
16009  R = 3*I-(G+B);
16010  }
16011  R*=255; G*=255; B*=255;
16012  *(p1++) = (T)(R<0?0:(R>255?255:R));
16013  *(p2++) = (T)(G<0?0:(G>255?255:G));
16014  *(p3++) = (T)(B<0?0:(B>255?255:B));
16015  }
16016  return *this;
16017  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
NT & cos
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& HSLtoRGB ( )
inline

Convert color pixels from (H,S,L) to (R,G,B).

Definition at line 15911 of file CImg.h.

Referenced by CImg< uintT >::get_HSLtoRGB().

15911  {
15912  if (is_empty()) return *this;
15913  if (dim!=3)
15914  throw CImgInstanceException("CImg<%s>::HSLtoRGB() : Input image dimension is dim=%u, "
15915  "should be a (H,S,V) image",
15916  pixel_type(),dim);
15917  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15918  for (unsigned int N = width*height*depth; N; --N) {
15919  const Tfloat
15920  H = (Tfloat)*p1,
15921  S = (Tfloat)*p2,
15922  L = (Tfloat)*p3,
15923  q = 2*L<1?L*(1+S):(L+S-L*S),
15924  p = 2*L-q,
15925  h = H/360,
15926  tr = h + 1.0f/3,
15927  tg = h,
15928  tb = h - 1.0f/3,
15929  ntr = tr<0?tr+1:(tr>1?tr-1:tr),
15930  ntg = tg<0?tg+1:(tg>1?tg-1:tg),
15931  ntb = tb<0?tb+1:(tb>1?tb-1:tb),
15932  R = 255*(6*ntr<1?p+(q-p)*6*ntr:(2*ntr<1?q:(3*ntr<2?p+(q-p)*6*(2.0f/3-ntr):p))),
15933  G = 255*(6*ntg<1?p+(q-p)*6*ntg:(2*ntg<1?q:(3*ntg<2?p+(q-p)*6*(2.0f/3-ntg):p))),
15934  B = 255*(6*ntb<1?p+(q-p)*6*ntb:(2*ntb<1?q:(3*ntb<2?p+(q-p)*6*(2.0f/3-ntb):p)));
15935  *(p1++) = (T)(R<0?0:(R>255?255:R));
15936  *(p2++) = (T)(G<0?0:(G>255?255:G));
15937  *(p3++) = (T)(B<0?0:(B>255?255:B));
15938  }
15939  return *this;
15940  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
NT q
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& HSVtoRGB ( )
inline

Convert color pixels from (H,S,V) to (R,G,B).

Definition at line 15826 of file CImg.h.

Referenced by CImg< uintT >::get_HSVtoRGB().

15826  {
15827  if (is_empty()) return *this;
15828  if (dim!=3)
15829  throw CImgInstanceException("CImg<%s>::HSVtoRGB() : Input image dimension is dim=%u, "
15830  "should be a (H,S,V) image",
15831  pixel_type(),dim);
15832  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15833  for (unsigned int N = width*height*depth; N; --N) {
15834  Tfloat
15835  H = (Tfloat)*p1,
15836  S = (Tfloat)*p2,
15837  V = (Tfloat)*p3,
15838  R = 0, G = 0, B = 0;
15839  if (H==0 && S==0) R = G = B = V;
15840  else {
15841  H/=60;
15842  const int i = (int)std::floor(H);
15843  const Tfloat
15844  f = (i&1)?(H-i):(1-H+i),
15845  m = V*(1-S),
15846  n = V*(1-S*f);
15847  switch (i) {
15848  case 6 :
15849  case 0 : R = V; G = n; B = m; break;
15850  case 1 : R = n; G = V; B = m; break;
15851  case 2 : R = m; G = V; B = n; break;
15852  case 3 : R = m; G = n; B = V; break;
15853  case 4 : R = n; G = m; B = V; break;
15854  case 5 : R = V; G = m; B = n; break;
15855  }
15856  }
15857  R*=255; G*=255; B*=255;
15858  *(p1++) = (T)(R<0?0:(R>255?255:R));
15859  *(p2++) = (T)(G<0?0:(G>255?255:G));
15860  *(p3++) = (T)(B<0?0:(B>255?255:B));
15861  }
15862  return *this;
15863  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
blockLoc i
Definition: read.cpp:79
const NT & n
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& identity_matrix ( )
inline

Get an identity matrix having same dimension than instance image.

Definition at line 13416 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d(), CImg< uintT >::get_identity_matrix(), and CImg< uintT >::identity_matrix().

13416  {
13417  return identity_matrix(cimg::max(width,height)).transfer_to(*this);
13418  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & identity_matrix()
Get an identity matrix having same dimension than instance image.
Definition: CImg.h:13416
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749

Here is the caller graph for this function:

static CImg<T> identity_matrix ( const unsigned int  N)
inlinestatic

Return a NxN identity matrix.

Definition at line 14382 of file CImg.h.

14382  {
14383  CImg<T> res(N,N,1,1,0);
14384  cimg_forX(res,x) res(x,x) = 1;
14385  return res;
14386  }
#define cimg_forX(img, x)
Definition: CImg.h:593
void int int REAL * x
Definition: read.cpp:74
CImg<T>& index ( const CImg< t > &  palette,
const bool  dithering = false,
const bool  map_indexes = false 
)
inline

Index multi-valued pixels of the instance image, 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 instance image.
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 instance image.
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

Definition at line 15343 of file CImg.h.

Referenced by CImg< uintT >::default_LUT256().

15343  {
15344  return get_index(palette,dithering,map_indexes).transfer_to(*this);
15345  }
CImg< typename cimg::superset< t, unsigned int >::type > get_index(const CImg< t > &palette, const bool dithering=false, const bool map_indexes=true) const
Definition: CImg.h:15349

Here is the caller graph for this function:

CImg<T>& invert ( const bool  use_LU = true)
inline

Invert the current matrix.

Definition at line 13474 of file CImg.h.

Referenced by CImg< uintT >::FFT(), CImg< uintT >::get_FFT(), CImg< uintT >::get_haar(), CImg< uintT >::get_invert(), and CImg< uintT >::haar().

13474  {
13475  if (!is_empty()) {
13476  if (width!=height || depth!=1 || dim!=1)
13477  throw CImgInstanceException("CImg<%s>::invert() : Instance matrix (%u,%u,%u,%u,%p) is not square.",
13479 #ifdef cimg_use_lapack
13480  int INFO = (int)use_LU, N = width, LWORK = 4*N, *IPIV = new int[N];
13481  Tfloat
13482  *lapA = new Tfloat[N*N],
13483  *WORK = new Tfloat[LWORK];
13484  cimg_forXY(*this,k,l) lapA[k*N+l] = (Tfloat)((*this)(k,l));
13485  cimg::getrf(N,lapA,IPIV,INFO);
13486  if (INFO)
13487  cimg::warn("CImg<%s>::invert() : LAPACK library function dgetrf_() returned error code %d.",
13488  pixel_type(),INFO);
13489  else {
13490  cimg::getri(N,lapA,IPIV,WORK,LWORK,INFO);
13491  if (INFO)
13492  cimg::warn("CImg<%s>::invert() : LAPACK library function dgetri_() returned Error code %d",
13493  pixel_type(),INFO);
13494  }
13495  if (!INFO) cimg_forXY(*this,k,l) (*this)(k,l) = (T)(lapA[k*N+l]); else fill(0);
13496  delete[] IPIV; delete[] lapA; delete[] WORK;
13497 #else
13498  const double dete = width>3?-1.0:det();
13499  if (dete!=0.0 && width==2) {
13500  const double
13501  a = data[0], c = data[1],
13502  b = data[2], d = data[3];
13503  data[0] = (T)(d/dete); data[1] = (T)(-c/dete);
13504  data[2] = (T)(-b/dete); data[3] = (T)(a/dete);
13505  } else if (dete!=0.0 && width==3) {
13506  const double
13507  a = data[0], d = data[1], g = data[2],
13508  b = data[3], e = data[4], h = data[5],
13509  c = data[6], f = data[7], i = data[8];
13510  data[0] = (T)((i*e-f*h)/dete), data[1] = (T)((g*f-i*d)/dete), data[2] = (T)((d*h-g*e)/dete);
13511  data[3] = (T)((h*c-i*b)/dete), data[4] = (T)((i*a-c*g)/dete), data[5] = (T)((g*b-a*h)/dete);
13512  data[6] = (T)((b*f-e*c)/dete), data[7] = (T)((d*c-a*f)/dete), data[8] = (T)((a*e-d*b)/dete);
13513  } else {
13514  if (use_LU) { // LU-based inverse computation
13515  CImg<Tfloat> A(*this), indx, col(1,width);
13516  bool d;
13517  A._LU(indx,d);
13518  cimg_forX(*this,j) {
13519  col.fill(0);
13520  col(j) = 1;
13521  col._solve(A,indx);
13522  cimg_forX(*this,i) (*this)(j,i) = (T)col(i);
13523  }
13524  } else { // SVD-based inverse computation
13525  CImg<Tfloat> U(width,width), S(1,width), V(width,width);
13526  SVD(U,S,V,false);
13527  U.transpose();
13528  cimg_forY(S,k) if (S[k]!=0) S[k]=1/S[k];
13529  S.diagonal();
13530  *this = V*S*U;
13531  }
13532  }
13533 #endif
13534  }
13535  return *this;
13536  }
if(dy > dx)
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of code(though may enhance!portability between Crays and other systems)!INTEGER MPI_TAG_UB
const NT & d
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
subroutine function
Definition: TEMPLATE.F90:43
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
Tfloat det() const
Return the determinant of the image, viewed as a matrix.
Definition: CImg.h:13227
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
rational * A
Definition: vinci_lass.c:67
blockLoc i
Definition: read.cpp:79
const CImg< T > & SVD(CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
Compute the SVD of a general matrix.
Definition: CImg.h:13843
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
j indices j
Definition: Indexing.h:6
CImg< T > & invert(const bool use_LU=true)
Invert the current matrix.
Definition: CImg.h:13474
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg< T > & diagonal()
Get a diagonal matrix, whose diagonal coefficients are the coefficients of the input image...
Definition: CImg.h:13404
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& invert_endianness ( )
inline

Invert endianness of the image buffer.

Definition at line 14951 of file CImg.h.

Referenced by CImg< uintT >::get_invert_endianness(), CImg< uintT >::get_load_raw(), and CImg< uintT >::load_raw().

14951  {
14953  return *this;
14954  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
void invert_endianness(T *const buffer, const unsigned int size)
Invert endianness of a memory buffer.
Definition: CImg.h:4579
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075

Here is the caller graph for this function:

bool is_empty ( ) const
inline

Return true if current image is empty.

Definition at line 11864 of file CImg.h.

Referenced by CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_line(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_point(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_spline(), CImg< uintT >::_draw_text(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_inr(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_off(), CImg< uintT >::_save_pandore(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_raw(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append(), CImg< uintT >::append_object3d(), CImg< uintT >::atX(), CImg< uintT >::atXY(), CImg< uintT >::atXYZ(), CImg< uintT >::atXYZV(), CImg< uintT >::autocrop(), CImg< uintT >::blur(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::blur_bilateral(), CImg< uintT >::CMYtoRGB(), CImg< uintT >::contains(), CImg< uintT >::containsXYZV(), CImg< uintT >::cubic_atX(), CImg< uintT >::cubic_atXY(), CImg< uintT >::cut(), CImg< uintT >::deriche(), CImg< uintT >::det(), CImg< uintT >::display_graph(), CImg< uintT >::distance_hamilton(), CImg< uintT >::dot(), CImg< uintT >::draw_arrow(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_circle(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_plasma(), CImg< uintT >::draw_point(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_spline(), CImg< uintT >::draw_triangle(), CImg< uintT >::eigen(), CImg< uintT >::equalize(), CImg< uintT >::fill(), CImg< uintT >::get_append(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_convolve(), CImg< uintT >::get_correlate(), CImg< uintT >::get_crop(), CImg< uintT >::get_diagonal(), CImg< uintT >::get_dilate(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_distance(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_erode(), CImg< uintT >::get_haar(), CImg< uintT >::get_histogram(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_norm(), CImg< uintT >::get_projections2d(), CImg< uintT >::get_resize(), CImg< uintT >::get_resize_doubleXY(), CImg< uintT >::get_resize_halfXY(), CImg< uintT >::get_resize_tripleXY(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_rotate(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_stats(), CImg< uintT >::get_structure_tensor(), CImg< uintT >::get_warp(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::invert(), CImg< uintT >::is_object3d(), CImg< uintT >::kth_smallest(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::linear_atX(), CImg< uintT >::linear_atXY(), CImg< uintT >::linear_atXYZ(), CImg< uintT >::linear_atXYZV(), CImg< uintT >::load(), CImg< uintT >::load_other(), CImg< uintT >::magnitude(), CImg< uintT >::max(), CImg< uintT >::maxmin(), CImg< uintT >::mean(), CImg< uintT >::min(), CImg< uintT >::minmax(), CImg< uintT >::mirror(), CImg< uintT >::noise(), CImg< uintT >::normalize(), CImg< uintT >::print(), CImg< uintT >::quantize(), CImg< uintT >::resize_object3d(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::save(), CImg< uintT >::save_analyze(), CImg< uintT >::save_ffmpeg(), CImg< uintT >::save_ffmpeg_external(), CImg< uintT >::save_graphicsmagick_external(), CImg< uintT >::save_imagemagick_external(), CImg< uintT >::save_magick(), CImg< uintT >::save_medcon_external(), CImg< uintT >::save_other(), CImg< uintT >::save_tiff(), CImg< uintT >::sequence(), CImg< uintT >::sharpen(), CImg< uintT >::sort(), CImg< uintT >::sum(), CImg< uintT >::SVD(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::threshold(), CImg< uintT >::trace(), CImg< uintT >::translate(), CImg< uintT >::translate_object3d(), CImg< uintT >::value_string(), CImg< uintT >::variancemean(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().

11864  {
11865  return !(data && width && height && depth && dim);
11866  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
bool is_object3d ( const CImgList< tf > &  primitives,
const bool  check_primitives = true,
const bool  throw_exception = false,
const char *const  calling_function = 0 
) const
inline

Return true if the couple (instance,primitives) stands for a valid 3D object.

Definition at line 12122 of file CImg.h.

12123  {
12124  const char *const ncall = calling_function?calling_function:"is_object3d";
12125  if (is_empty()) { // Check for empty object.
12126  if (primitives) {
12127  if (throw_exception)
12128  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, %u primitives defined for 0 vertices.",
12129  pixel_type(),ncall,primitives.width);
12130  return false;
12131  }
12132  return true;
12133  }
12134  if (height!=3 || depth>1 || dim>1) { // Check vertices dimensions.
12135  if (throw_exception)
12136  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
12137  pixel_type(),ncall,width,height,depth,dim,data);
12138  return false;
12139  }
12140  if (check_primitives) cimglist_for(primitives,l) {
12141  const CImg<tf>& primitive = primitives[l];
12142  const unsigned int psiz = primitive.size();
12143  switch (psiz) {
12144  case 1 : { // Point.
12145  const unsigned int i0 = (unsigned int)primitive[0];
12146  if (i0>=width) {
12147  if (throw_exception)
12148  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, primitive %u = point(%u) references invalid vertice "
12149  "(%u vertices available).",pixel_type(),ncall,l,i0,width);
12150  return false;
12151  }
12152  } break;
12153  case 5 : { // Sphere.
12154  const unsigned int
12155  i0 = (unsigned int)primitive(0),
12156  i1 = (unsigned int)primitive(1),
12157  i2 = (unsigned int)primitive(2);
12158  if (i0>=width || (!i2 && i1>=width)) {
12159  if (throw_exception)
12160  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, primitive %u = sphere(%u,%u,%u) references invalid vertice "
12161  "(%u vertices available).",pixel_type(),ncall,l,i0,i1,i2,width);
12162  return false;
12163  }
12164  } break;
12165  case 2 : // Segment.
12166  case 6 : {
12167  const unsigned int
12168  i0 = (unsigned int)primitive(0),
12169  i1 = (unsigned int)primitive(1);
12170  if (i0>=width || i1>=width) {
12171  if (throw_exception)
12172  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, primitive %u = segment(%u,%u) references invalid vertice "
12173  "(%u vertices available).",pixel_type(),ncall,l,i0,i1,width);
12174  return false;
12175  }
12176  } break;
12177  case 3 : // Triangle.
12178  case 9 : {
12179  const unsigned int
12180  i0 = (unsigned int)primitive(0),
12181  i1 = (unsigned int)primitive(1),
12182  i2 = (unsigned int)primitive(2);
12183  if (i0>=width || i1>=width || i2>=width) {
12184  if (throw_exception)
12185  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, primitive %u = triangle(%u,%u,%u) references invalid vertice "
12186  "(%u vertices available).",pixel_type(),ncall,l,i0,i1,i2,width);
12187  return false;
12188  }
12189  } break;
12190  case 4 : // Rectangle
12191  case 12 : {
12192  const unsigned int
12193  i0 = (unsigned int)primitive(0),
12194  i1 = (unsigned int)primitive(1),
12195  i2 = (unsigned int)primitive(2),
12196  i3 = (unsigned int)primitive(3);
12197  if (i0>=width || i1>=width || i2>=width || i3>=width) {
12198  if (throw_exception)
12199  throw CImgArgumentException("CImg<%s>::%s() : Invalid 3D object, primitive %u = rectangle(%u,%u,%u,%u) references invalid vertice "
12200  "(%u vertices available).",pixel_type(),ncall,l,i0,i1,i2,i3,width);
12201  return false;
12202  }
12203  } break;
12204  default : return false;
12205  }
12206  }
12207  return true;
12208  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimglist_for(list, l)
Definition: CImg.h:1877
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
bool is_overlapped ( const CImg< t > &  img) const
inline

Return true if the memory buffers of the two images overlaps.

May happen when using shared images.

Definition at line 12115 of file CImg.h.

Referenced by CImg< uintT >::div(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_spline(), CImg< uintT >::draw_triangle(), CImg< uintT >::max(), CImg< uintT >::min(), CImg< uintT >::mul(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator+=(), CImg< uintT >::operator-=(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), and CImg< uintT >::pow().

12115  {
12116  const unsigned int csiz = size(), isiz = img.size();
12117  return !((void*)(data+csiz)<=(void*)img.data || (void*)data>=(void*)(img.data+isiz));
12118  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075

Here is the caller graph for this function:

bool is_sameV ( const unsigned int  dv) const
inline

Return true if image (*this) has the specified number of channels.

Definition at line 11912 of file CImg.h.

Referenced by CImg< uintT >::is_sameV(), CImg< uintT >::is_sameXV(), CImg< uintT >::is_sameXYV(), CImg< uintT >::is_sameXYZV(), CImg< uintT >::is_sameXZV(), CImg< uintT >::is_sameYV(), CImg< uintT >::is_sameYZV(), and CImg< uintT >::is_sameZV().

11912  {
11913  return (dim==dv);
11914  }
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

bool is_sameV ( const CImg< t > &  img) const
inline

Return true if images (*this) and img have same dim.

Definition at line 11918 of file CImg.h.

11918  {
11919  return is_sameV(img.dim);
11920  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameX ( const unsigned int  dx) const
inline

Return true if image (*this) has the specified width.

Definition at line 11869 of file CImg.h.

Referenced by CImg< uintT >::is_sameX(), CImg< uintT >::is_sameXV(), CImg< uintT >::is_sameXY(), and CImg< uintT >::is_sameXZ().

11869  {
11870  return (width==dx);
11871  }
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711

Here is the caller graph for this function:

bool is_sameX ( const CImg< t > &  img) const
inline

Return true if images (*this) and img have same width.

Definition at line 11875 of file CImg.h.

11875  {
11876  return is_sameX(img.width);
11877  }
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameX ( const CImgDisplay disp) const
inline

Return true if images (*this) and the display disp have same width.

Definition at line 11880 of file CImg.h.

11880  {
11881  return is_sameX(disp.width);
11882  }
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXV ( const unsigned int  dx,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified width and number of channels.

Definition at line 11950 of file CImg.h.

11950  {
11951  return (is_sameX(dx) && is_sameV(dv));
11952  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
NT dx
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXV ( const CImg< t > &  img) const
inline

Return true if images have same width and same number of channels.

Definition at line 11956 of file CImg.h.

11956  {
11957  return (is_sameX(img) && is_sameV(img));
11958  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXY ( const unsigned int  dx,
const unsigned int  dy 
) const
inline

Return true if image (*this) has the specified width and height.

Definition at line 11923 of file CImg.h.

Referenced by CImg< uintT >::__draw_object3d(), CImg< uintT >::draw_line(), CImg< uintT >::draw_triangle(), CImg< uintT >::get_elevation3d(), CImg< uintT >::is_sameXYV(), and CImg< uintT >::is_sameXYZ().

11923  {
11924  return (is_sameX(dx) && is_sameY(dy));
11925  }
NT dx
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
NT dy
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869

Here is the caller graph for this function:

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

Return true if images have same width and same height.

Definition at line 11929 of file CImg.h.

11929  {
11930  return (is_sameX(img) && is_sameY(img));
11931  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXY ( const CImgDisplay disp) const
inline

Return true if image (*this) and the display disp have same width and same height.

Definition at line 11934 of file CImg.h.

11934  {
11935  return (is_sameX(disp) && is_sameY(disp));
11936  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXYV ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified width, height and depth.

Definition at line 12005 of file CImg.h.

12005  {
12006  return (is_sameXY(dx,dy) && is_sameV(dv));
12007  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
NT dx
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
NT dy
bool is_sameXYV ( const CImg< t > &  img) const
inline

Return true if images have same width, same height and same number of channels.

Definition at line 12011 of file CImg.h.

12011  {
12012  return (is_sameXY(img) && is_sameV(img));
12013  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
bool is_sameXYZ ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz 
) const
inline

Return true if image (*this) has the specified width, height and depth.

Definition at line 11994 of file CImg.h.

Referenced by CImg< uintT >::blur_anisotropic(), CImg< uintT >::get_warp(), and CImg< uintT >::is_sameXYZV().

11994  {
11995  return (is_sameXY(dx,dy) && is_sameZ(dz));
11996  }
NT dx
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
NT dy

Here is the caller graph for this function:

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

Return true if images have same width, same height and same depth.

Definition at line 12000 of file CImg.h.

12000  {
12001  return (is_sameXY(img) && is_sameZ(img));
12002  }
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameXY(const unsigned int dx, const unsigned int dy) const
Return true if image (*this) has the specified width and height.
Definition: CImg.h:11923
bool is_sameXYZV ( const unsigned int  dx,
const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified width, height, depth and number of channels.

Definition at line 12038 of file CImg.h.

Referenced by CImg< uintT >::get_displacement_field().

12038  {
12039  return (is_sameXYZ(dx,dy,dz) && is_sameV(dv));
12040  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
NT dx
NT dy
bool is_sameXYZ(const unsigned int dx, const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified width, height and depth.
Definition: CImg.h:11994

Here is the caller graph for this function:

bool is_sameXYZV ( const CImg< t > &  img) const
inline

Return true if images (*this) and img have same width, same height, same depth and same number of channels.

Definition at line 12044 of file CImg.h.

12044  {
12045  return (is_sameXYZ(img) && is_sameV(img));
12046  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameXYZ(const unsigned int dx, const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified width, height and depth.
Definition: CImg.h:11994
bool is_sameXZ ( const unsigned int  dx,
const unsigned int  dz 
) const
inline

Return true if image (*this) has the specified width and depth.

Definition at line 11939 of file CImg.h.

Referenced by CImg< uintT >::is_sameXZV().

11939  {
11940  return (is_sameX(dx) && is_sameZ(dz));
11941  }
NT dx
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869

Here is the caller graph for this function:

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

Return true if images have same width and same depth.

Definition at line 11945 of file CImg.h.

11945  {
11946  return (is_sameX(img) && is_sameZ(img));
11947  }
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameX(const unsigned int dx) const
Return true if image (*this) has the specified width.
Definition: CImg.h:11869
bool is_sameXZV ( const unsigned int  dx,
const unsigned int  dz,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified width, height and number of channels.

Definition at line 12016 of file CImg.h.

12016  {
12017  return (is_sameXZ(dx,dz) && is_sameV(dv));
12018  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
NT dx
bool is_sameXZ(const unsigned int dx, const unsigned int dz) const
Return true if image (*this) has the specified width and depth.
Definition: CImg.h:11939
bool is_sameXZV ( const CImg< t > &  img) const
inline

Return true if images have same width, same depth and same number of channels.

Definition at line 12022 of file CImg.h.

12022  {
12023  return (is_sameXZ(img) && is_sameV(img));
12024  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameXZ(const unsigned int dx, const unsigned int dz) const
Return true if image (*this) has the specified width and depth.
Definition: CImg.h:11939
bool is_sameY ( const unsigned int  dy) const
inline

Return true if image (*this) has the specified height.

Definition at line 11885 of file CImg.h.

Referenced by CImg< uintT >::is_sameXY(), CImg< uintT >::is_sameY(), CImg< uintT >::is_sameYV(), and CImg< uintT >::is_sameYZ().

11885  {
11886  return (height==dy);
11887  }
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
NT dy

Here is the caller graph for this function:

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

Return true if images (*this) and img have same height.

Definition at line 11891 of file CImg.h.

11891  {
11892  return is_sameY(img.height);
11893  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameY ( const CImgDisplay disp) const
inline

Return true if images (*this) and the display disp have same height.

Definition at line 11896 of file CImg.h.

11896  {
11897  return is_sameY(disp.height);
11898  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameYV ( const unsigned int  dy,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified height and number of channels.

Definition at line 11972 of file CImg.h.

11972  {
11973  return (is_sameY(dy) && is_sameV(dv));
11974  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
NT dy
bool is_sameYV ( const CImg< t > &  img) const
inline

Return true if images have same height and same number of channels.

Definition at line 11978 of file CImg.h.

11978  {
11979  return (is_sameY(img) && is_sameV(img));
11980  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameYZ ( const unsigned int  dy,
const unsigned int  dz 
) const
inline

Return true if image (*this) has the specified height and depth.

Definition at line 11961 of file CImg.h.

Referenced by CImg< uintT >::is_sameYZV().

11961  {
11962  return (is_sameY(dy) && is_sameZ(dz));
11963  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
NT dy

Here is the caller graph for this function:

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

Return true if images have same height and same depth.

Definition at line 11967 of file CImg.h.

11967  {
11968  return (is_sameY(img) && is_sameZ(img));
11969  }
bool is_sameY(const unsigned int dy) const
Return true if image (*this) has the specified height.
Definition: CImg.h:11885
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameYZV ( const unsigned int  dy,
const unsigned int  dz,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified height, depth and number of channels.

Definition at line 12027 of file CImg.h.

12027  {
12028  return (is_sameYZ(dy,dz) && is_sameV(dv));
12029  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameYZ(const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified height and depth.
Definition: CImg.h:11961
NT dy
bool is_sameYZV ( const CImg< t > &  img) const
inline

Return true if images have same heigth, same depth and same number of channels.

Definition at line 12033 of file CImg.h.

12033  {
12034  return (is_sameYZ(img) && is_sameV(img));
12035  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameYZ(const unsigned int dy, const unsigned int dz) const
Return true if image (*this) has the specified height and depth.
Definition: CImg.h:11961
bool is_sameZ ( const unsigned int  dz) const
inline

Return true if image (*this) has the specified depth.

Definition at line 11901 of file CImg.h.

Referenced by CImg< uintT >::is_sameXYZ(), CImg< uintT >::is_sameXZ(), CImg< uintT >::is_sameYZ(), CImg< uintT >::is_sameZ(), and CImg< uintT >::is_sameZV().

11901  {
11902  return (depth==dz);
11903  }
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

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

Return true if images (*this) and img have same depth.

Definition at line 11907 of file CImg.h.

11907  {
11908  return is_sameZ(img.depth);
11909  }
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameZV ( const unsigned int  dz,
const unsigned int  dv 
) const
inline

Return true if image (*this) has the specified depth and number of channels.

Definition at line 11983 of file CImg.h.

11983  {
11984  return (is_sameZ(dz) && is_sameV(dv));
11985  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
bool is_sameZV ( const CImg< t > &  img) const
inline

Return true if images have same depth and same number of channels.

Definition at line 11989 of file CImg.h.

11989  {
11990  return (is_sameZ(img) && is_sameV(img));
11991  }
bool is_sameV(const unsigned int dv) const
Return true if image (*this) has the specified number of channels.
Definition: CImg.h:11912
bool is_sameZ(const unsigned int dz) const
Return true if image (*this) has the specified depth.
Definition: CImg.h:11901
static CImg<floatT> isocurve3d ( 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 
)
inlinestatic

Get isocurve as a 3D object.

Definition at line 21328 of file CImg.h.

Referenced by CImg< uintT >::get_isocurve3d(), and CImg< uintT >::isocurve3d().

21330  {
21331  static const unsigned int edges[16] = { 0x0, 0x9, 0x3, 0xa, 0x6, 0xf, 0x5, 0xc, 0xc, 0x5, 0xf, 0x6, 0xa, 0x3, 0x9, 0x0 };
21332  static const int segments[16][4] = { { -1,-1,-1,-1 }, { 0,3,-1,-1 }, { 0,1,-1,-1 }, { 1,3,-1,-1 },
21333  { 1,2,-1,-1 }, { 0,1,2,3 }, { 0,2,-1,-1 }, { 2,3,-1,-1 },
21334  { 2,3,-1,-1 }, { 0,2,-1,-1}, { 0,3,1,2 }, { 1,2,-1,-1 },
21335  { 1,3,-1,-1 }, { 0,1,-1,-1}, { 0,3,-1,-1}, { -1,-1,-1,-1 } };
21336  const unsigned int
21337  _nx = (unsigned int)(sizex>=0?sizex:((x1-x0)*-sizex/100 + 1)),
21338  _ny = (unsigned int)(sizey>=0?sizey:((y1-y0)*-sizey/100 + 1)),
21339  nx = _nx?_nx:1,
21340  ny = _ny?_ny:1,
21341  nxm1 = nx - 1,
21342  nym1 = ny - 1;
21343  primitives.assign();
21344  if (!nxm1 || !nym1) return CImg<floatT>();
21345  const float dx = (x1 - x0)/nxm1, dy = (y1 - y0)/nym1;
21346  CImgList<floatT> vertices;
21347  CImg<intT> indices1(nx,1,1,2,-1), indices2(nx,1,1,2);
21348  CImg<floatT> values1(nx), values2(nx);
21349  float X = x0, Y = y0, nX = X + dx, nY = Y + dy;
21350 
21351  // Fill first line with values
21352  cimg_forX(values1,x) { values1(x) = (float)func(X,Y); X+=dx; }
21353 
21354  // Run the marching squares algorithm
21355  for (unsigned int yi = 0, nyi = 1; yi<nym1; ++yi, ++nyi, Y=nY, nY+=dy) {
21356  X = x0; nX = X + dx;
21357  indices2.fill(-1);
21358  for (unsigned int xi = 0, nxi = 1; xi<nxm1; ++xi, ++nxi, X=nX, nX+=dx) {
21359 
21360  // Determine square configuration
21361  const float
21362  val0 = values1(xi),
21363  val1 = values1(nxi),
21364  val2 = values2(nxi) = (float)func(nX,nY),
21365  val3 = values2(xi) = (float)func(X,nY);
21366  const unsigned int
21367  configuration = (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0),
21368  edge = edges[configuration];
21369 
21370  // Compute intersection vertices
21371  if (edge) {
21372  if ((edge&1) && indices1(xi,0)<0) {
21373  const float Xi = X + (isovalue-val0)*dx/(val1-val0);
21374  indices1(xi,0) = vertices.width;
21375  CImg<floatT>::vector(Xi,Y,0).transfer_to(vertices);
21376  }
21377  if ((edge&2) && indices1(nxi,1)<0) {
21378  const float Yi = Y + (isovalue-val1)*dy/(val2-val1);
21379  indices1(nxi,1) = vertices.width;
21380  CImg<floatT>::vector(nX,Yi,0).transfer_to(vertices);
21381  }
21382  if ((edge&4) && indices2(xi,0)<0) {
21383  const float Xi = X + (isovalue-val3)*dx/(val2-val3);
21384  indices2(xi,0) = vertices.width;
21385  CImg<floatT>::vector(Xi,nY,0).transfer_to(vertices);
21386  }
21387  if ((edge&8) && indices1(xi,1)<0) {
21388  const float Yi = Y + (isovalue-val0)*dy/(val3-val0);
21389  indices1(xi,1) = vertices.width;
21390  CImg<floatT>::vector(X,Yi,0).transfer_to(vertices);
21391  }
21392 
21393  // Create segments
21394  for (const int *segment = segments[configuration]; *segment!=-1; ) {
21395  const unsigned int p0 = *(segment++), p1 = *(segment++);
21396  const tf
21397  i0 = (tf)(_marching2d_indice(p0,indices1,indices2,xi,nxi)),
21398  i1 = (tf)(_marching2d_indice(p1,indices1,indices2,xi,nxi));
21399  CImg<tf>::vector(i0,i1).transfer_to(primitives);
21400  }
21401  }
21402  }
21403  values1.swap(values2);
21404  indices1.swap(indices2);
21405  }
21406  return vertices>'x';
21407  }
#define cimg_forX(img, x)
Definition: CImg.h:593
NT dx
static int _marching2d_indice(const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int nx)
Definition: CImg.h:21418
NT p1
NT p0
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int REAL * x
Definition: read.cpp:74
NT dy

Here is the caller graph for this function:

static CImg<floatT> isocurve3d ( 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 
)
inlinestatic

Definition at line 21410 of file CImg.h.

21412  {
21413  const _marching2d_func_expr func(expression);
21414  return isocurve3d(primitives,func,isovalue,x0,y0,x1,y1,sizex,sizey);
21415  }
static CImg< floatT > isocurve3d(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 isocurve as a 3D object.
Definition: CImg.h:21328
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 
)
inlinestatic

Get isosurface as a 3D object.

Definition at line 21460 of file CImg.h.

Referenced by CImg< uintT >::get_isosurface3d(), and CImg< uintT >::isosurface3d().

21463  {
21464  static unsigned int edges[256] = {
21465  0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
21466  0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
21467  0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
21468  0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
21469  0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
21470  0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
21471  0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
21472  0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
21473  0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
21474  0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
21475  0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
21476  0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
21477  0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
21478  0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
21479  0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
21480  0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000 };
21481 
21482  static int triangles[256][16] =
21483  {{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21484  { 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21485  { 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21486  { 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
21487  { 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21488  { 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1 },
21489  { 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
21490  { 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21491  { 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21492  { 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
21493  { 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1 },
21494  { 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1 },
21495  { 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
21496  { 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1 },
21497  { 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1 }, { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1 },
21498  { 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, { 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
21499  { 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21500  { 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
21501  { 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 },
21502  { 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1 },
21503  { 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 },
21504  { 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1 },
21505  { 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1 }, { 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1 },
21506  { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, { 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1 },
21507  { 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
21508  { 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, { 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21509  { 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1 }, { 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1 },
21510  { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1 }, { 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1 },
21511  { 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1 },
21512  { 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1 }, { 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1 },
21513  { 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1 }, { 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1 },
21514  { 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1 }, { 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21515  { 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21516  { 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 },
21517  { 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1 },
21518  { 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1 },
21519  { 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 },
21520  { 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, { 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1 },
21521  { 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1 },
21522  { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1 }, { 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1 },
21523  { 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1 },
21524  { 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, { 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1 },
21525  { 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1 },
21526  { 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1 }, { 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1 },
21527  { 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, { 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1 },
21528  { 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1 }, { 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1 },
21529  { 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, { 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1 },
21530  { 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1 }, { 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1 },
21531  { 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1 },
21532  { 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1 },
21533  { 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1 },
21534  { 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1 },
21535  { 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1 },
21536  { 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, { 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1 },
21537  { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1 }, { 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1 },
21538  { 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, { 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21539  { 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1 },
21540  { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1 }, { 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1 },
21541  { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, { 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1 },
21542  { 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, { 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21543  { 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, { 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1 },
21544  { 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1 }, { 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1 },
21545  { 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1 }, { 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21546  { 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1 }, { 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21547  { 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21548  { 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 },
21549  { 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 },
21550  { 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, { 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1 },
21551  { 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
21552  { 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1 }, { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1 },
21553  { 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1 },
21554  { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1 }, { 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1 },
21555  { 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
21556  { 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1 }, { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1 },
21557  { 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1 }, { 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1 },
21558  { 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1 }, { 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1 },
21559  { 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, { 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21560  { 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1 }, { 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 },
21561  { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1 }, { 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1 },
21562  { 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1 }, { 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21563  { 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 },
21564  { 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, { 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1 },
21565  { 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, { 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1 },
21566  { 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1 }, { 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1 },
21567  { 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1 },
21568  { 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1 }, { 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1 },
21569  { 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1 }, { 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1 },
21570  { 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1 }, { 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1 },
21571  { 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1 },
21572  { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1 }, { 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1 },
21573  { 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1 }, { 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1 },
21574  { 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1 }, { 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1 },
21575  { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1 }, { 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1 },
21576  { 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1 }, { 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21577  { 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1 }, { 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1 },
21578  { 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21579  { 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1 },
21580  { 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1 }, { 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1 },
21581  { 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1 },
21582  { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1 }, { 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1 },
21583  { 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1 },
21584  { 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1 }, { 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1 },
21585  { 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1 },
21586  { 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, { 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21587  { 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1 },
21588  { 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1 }, { 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1 },
21589  { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1 }, { 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1 },
21590  { 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1 }, { 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21591  { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1 }, { 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1 },
21592  { 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1 }, { 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1 },
21593  { 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21594  { 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1 }, { 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21595  { 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, { 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1 },
21596  { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1 }, { 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1 },
21597  { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1 }, { 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1 },
21598  { 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, { 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1 },
21599  { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1 }, { 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1 },
21600  { 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1 }, { 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21601  { 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, { 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1 },
21602  { 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21603  { 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1 },
21604  { 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, { 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21605  { 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, { 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1 },
21606  { 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21607  { 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, { 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21608  { 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1 }, { 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21609  { 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
21610  { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }};
21611 
21612  const unsigned int
21613  _nx = (unsigned int)(size_x>=0?size_x:((x1-x0)*-size_x/100 + 1)),
21614  _ny = (unsigned int)(size_y>=0?size_y:((y1-y0)*-size_y/100 + 1)),
21615  _nz = (unsigned int)(size_z>=0?size_y:((z1-z0)*-size_z/100 + 1)),
21616  nx = _nx?_nx:1,
21617  ny = _ny?_ny:1,
21618  nz = _nz?_nz:1,
21619  nxm1 = nx - 1,
21620  nym1 = ny - 1,
21621  nzm1 = nz - 1;
21622  primitives.assign();
21623  if (!nxm1 || !nym1 || !nzm1) return CImg<floatT>();
21624  const float dx = (x1 - x0)/nxm1, dy = (y1 - y0)/nym1, dz = (z1 - z0)/nzm1;
21625  CImgList<floatT> vertices;
21626  CImg<intT> indices1(nx,ny,1,3,-1), indices2(indices1);
21627  CImg<floatT> values1(nx,ny), values2(nx,ny);
21628  float X = 0, Y = 0, Z = 0, nX = 0, nY = 0, nZ = 0;
21629 
21630  // Fill the first plane with function values
21631  Y = y0;
21632  cimg_forY(values1,y) {
21633  X = x0;
21634  cimg_forX(values1,x) { values1(x,y) = (float)func(X,Y,z0); X+=dx; }
21635  Y+=dy;
21636  }
21637 
21638  // Run Marching Cubes algorithm
21639  Z = z0; nZ = Z + dz;
21640  for (unsigned int zi = 0; zi<nzm1; ++zi, Z = nZ, nZ+=dz) {
21641  Y = y0; nY = Y + dy;
21642  indices2.fill(-1);
21643  for (unsigned int yi = 0, nyi = 1; yi<nym1; ++yi, ++nyi, Y = nY, nY+=dy) {
21644  X = x0; nX = X + dx;
21645  for (unsigned int xi = 0, nxi = 1; xi<nxm1; ++xi, ++nxi, X = nX, nX+=dx) {
21646 
21647  // Determine cube configuration
21648  const float
21649  val0 = values1(xi,yi),
21650  val1 = values1(nxi,yi),
21651  val2 = values1(nxi,nyi),
21652  val3 = values1(xi,nyi),
21653  val4 = values2(xi,yi) = (float)func(X,Y,nZ),
21654  val5 = values2(nxi,yi) = (float)func(nX,Y,nZ),
21655  val6 = values2(nxi,nyi) = (float)func(nX,nY,nZ),
21656  val7 = values2(xi,nyi) = (float)func(X,nY,nZ);
21657 
21658  const unsigned int configuration =
21659  (val0<isovalue?1:0) | (val1<isovalue?2:0) | (val2<isovalue?4:0) | (val3<isovalue?8:0) |
21660  (val4<isovalue?16:0) | (val5<isovalue?32:0) | (val6<isovalue?64:0) | (val7<isovalue?128:0),
21661  edge = edges[configuration];
21662 
21663  // Compute intersection vertices
21664  if (edge) {
21665  if ((edge&1) && indices1(xi,yi,0)<0) {
21666  const float Xi = X + (isovalue-val0)*dx/(val1-val0);
21667  indices1(xi,yi,0) = vertices.width;
21668  CImg<floatT>::vector(Xi,Y,Z).transfer_to(vertices);
21669  }
21670  if ((edge&2) && indices1(nxi,yi,1)<0) {
21671  const float Yi = Y + (isovalue-val1)*dy/(val2-val1);
21672  indices1(nxi,yi,1) = vertices.width;
21673  CImg<floatT>::vector(nX,Yi,Z).transfer_to(vertices);
21674  }
21675  if ((edge&4) && indices1(xi,nyi,0)<0) {
21676  const float Xi = X + (isovalue-val3)*dx/(val2-val3);
21677  indices1(xi,nyi,0) = vertices.width;
21678  CImg<floatT>::vector(Xi,nY,Z).transfer_to(vertices);
21679  }
21680  if ((edge&8) && indices1(xi,yi,1)<0) {
21681  const float Yi = Y + (isovalue-val0)*dy/(val3-val0);
21682  indices1(xi,yi,1) = vertices.width;
21683  CImg<floatT>::vector(X,Yi,Z).transfer_to(vertices);
21684  }
21685  if ((edge&16) && indices2(xi,yi,0)<0) {
21686  const float Xi = X + (isovalue-val4)*dx/(val5-val4);
21687  indices2(xi,yi,0) = vertices.width;
21688  CImg<floatT>::vector(Xi,Y,nZ).transfer_to(vertices);
21689  }
21690  if ((edge&32) && indices2(nxi,yi,1)<0) {
21691  const float Yi = Y + (isovalue-val5)*dy/(val6-val5);
21692  indices2(nxi,yi,1) = vertices.width;
21693  CImg<floatT>::vector(nX,Yi,nZ).transfer_to(vertices);
21694  }
21695  if ((edge&64) && indices2(xi,nyi,0)<0) {
21696  const float Xi = X + (isovalue-val7)*dx/(val6-val7);
21697  indices2(xi,nyi,0) = vertices.width;
21698  CImg<floatT>::vector(Xi,nY,nZ).transfer_to(vertices);
21699  }
21700  if ((edge&128) && indices2(xi,yi,1)<0) {
21701  const float Yi = Y + (isovalue-val4)*dy/(val7-val4);
21702  indices2(xi,yi,1) = vertices.width;
21703  CImg<floatT>::vector(X,Yi,nZ).transfer_to(vertices);
21704  }
21705  if ((edge&256) && indices1(xi,yi,2)<0) {
21706  const float Zi = Z+ (isovalue-val0)*dz/(val4-val0);
21707  indices1(xi,yi,2) = vertices.width;
21708  CImg<floatT>::vector(X,Y,Zi).transfer_to(vertices);
21709  }
21710  if ((edge&512) && indices1(nxi,yi,2)<0) {
21711  const float Zi = Z + (isovalue-val1)*dz/(val5-val1);
21712  indices1(nxi,yi,2) = vertices.width;
21713  CImg<floatT>::vector(nX,Y,Zi).transfer_to(vertices);
21714  }
21715  if ((edge&1024) && indices1(nxi,nyi,2)<0) {
21716  const float Zi = Z + (isovalue-val2)*dz/(val6-val2);
21717  indices1(nxi,nyi,2) = vertices.width;
21718  CImg<floatT>::vector(nX,nY,Zi).transfer_to(vertices);
21719  }
21720  if ((edge&2048) && indices1(xi,nyi,2)<0) {
21721  const float Zi = Z + (isovalue-val3)*dz/(val7-val3);
21722  indices1(xi,nyi,2) = vertices.width;
21723  CImg<floatT>::vector(X,nY,Zi).transfer_to(vertices);
21724  }
21725 
21726  // Create triangles
21727  for (const int *triangle = triangles[configuration]; *triangle!=-1; ) {
21728  const unsigned int p0 = *(triangle++), p1 = *(triangle++), p2 = *(triangle++);
21729  const tf
21730  i0 = (tf)(_marching3d_indice(p0,indices1,indices2,xi,yi,nxi,nyi)),
21731  i1 = (tf)(_marching3d_indice(p1,indices1,indices2,xi,yi,nxi,nyi)),
21732  i2 = (tf)(_marching3d_indice(p2,indices1,indices2,xi,yi,nxi,nyi));
21733  CImg<tf>::vector(i0,i2,i1).transfer_to(primitives);
21734  }
21735  }
21736  }
21737  }
21738  cimg::swap(values1,values2);
21739  cimg::swap(indices1,indices2);
21740  }
21741  return vertices>'x';
21742  }
#define cimg_forX(img, x)
Definition: CImg.h:593
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
static int _marching3d_indice(const unsigned int edge, const CImg< t > &indices1, const CImg< t > &indices2, const unsigned int x, const unsigned int y, const unsigned int nx, const unsigned int ny)
Definition: CImg.h:21754
NT p1
NT p0
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int REAL * x
Definition: read.cpp:74
NT dy
#define cimg_forY(img, y)
Definition: CImg.h:594

Here is the caller graph for this function:

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

Definition at line 21745 of file CImg.h.

21748  {
21749  const _marching3d_func_expr func(expression);
21750  return isosurface3d(primitives,func,isovalue,x0,y0,z0,x1,y1,z1,dx,dy,dz);
21751  }
NT dx
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.
Definition: CImg.h:21460
NT dy
T kth_smallest ( const unsigned int  k) const
inline

Return the kth smallest element of the image.

Definition at line 12981 of file CImg.h.

Referenced by CImg< uintT >::median().

12981  {
12982  if (is_empty())
12983  throw CImgInstanceException("CImg<%s>::kth_smallest() : Instance image (%u,%u,%u,%u,%p) is empty.",
12985  CImg<T> arr(*this);
12986  unsigned int l = 0, ir = size() - 1;
12987  for (;;) {
12988  if (ir<=l+1) {
12989  if (ir==l+1 && arr[ir]<arr[l]) cimg::swap(arr[l],arr[ir]);
12990  return arr[k];
12991  } else {
12992  const unsigned int mid = (l + ir)>>1;
12993  cimg::swap(arr[mid],arr[l+1]);
12994  if (arr[l]>arr[ir]) cimg::swap(arr[l],arr[ir]);
12995  if (arr[l+1]>arr[ir]) cimg::swap(arr[l+1],arr[ir]);
12996  if (arr[l]>arr[l+1]) cimg::swap(arr[l],arr[l+1]);
12997  unsigned int i = l + 1, j = ir;
12998  const T pivot = arr[l+1];
12999  for (;;) {
13000  do ++i; while (arr[i]<pivot);
13001  do --j; while (arr[j]>pivot);
13002  if (j<i) break;
13003  cimg::swap(arr[i],arr[j]);
13004  }
13005  arr[l+1] = arr[j];
13006  arr[j] = pivot;
13007  if (j>=k) ir = j - 1;
13008  if (j<=k) l = i;
13009  }
13010  }
13011  return 0;
13012  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& label_regions ( )
inline

Create a map of indexed labels counting disconnected regions with same intensities.

Returns
A reference to the modified instance image.
Note
Sample code :
const CImg<float> img = CImg<float>("reference.jpg").norm().quantize(4),
res = img.get_label_regions().normalize(0,255).map(palette);
(img,res).display();
ref_label_regions.jpg

Definition at line 15634 of file CImg.h.

15634  {
15635  return get_label_regions().transfer_to(*this);
15636  }
CImg< uintT > get_label_regions() const
Definition: CImg.h:15638
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
CImg<T>& LabtoRGB ( )
inline

Convert a (L,a,b) image to a (R,G,B) one.

Definition at line 16419 of file CImg.h.

Referenced by CImg< uintT >::get_LabtoRGB().

16419  {
16420  return LabtoXYZ().XYZtoRGB();
16421  }
CImg< T > & LabtoXYZ()
Convert (L,a,b) pixels of a color image into the (X,Y,Z) color space.
Definition: CImg.h:16323

Here is the caller graph for this function:

CImg<T>& LabtoXYZ ( )
inline

Convert (L,a,b) pixels of a color image into the (X,Y,Z) color space.

Definition at line 16323 of file CImg.h.

Referenced by CImg< uintT >::get_LabtoXYZ(), and CImg< uintT >::LabtoRGB().

16323  {
16324 #define _cimg_Labfi(x) ((x)>=0.206893f?((x)*(x)*(x)):(((x)-16.0f/116)/7.787f))
16325  if (is_empty()) return *this;
16326  if (dim!=3)
16327  throw CImgInstanceException("CImg<%s>::LabtoXYZ() : Input image dimension is dim=%u, "
16328  "should be a (X,Y,Z) image (dim=3)",
16329  pixel_type(),dim);
16330  const Tfloat
16331  Xn = (Tfloat)(0.412453f + 0.357580f + 0.180423f),
16332  Yn = (Tfloat)(0.212671f + 0.715160f + 0.072169f),
16333  Zn = (Tfloat)(0.019334f + 0.119193f + 0.950227f);
16334  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16335  for (unsigned int N = width*height*depth; N; --N) {
16336  const Tfloat
16337  L = (Tfloat)*p1,
16338  a = (Tfloat)*p2,
16339  b = (Tfloat)*p3,
16340  cY = (L + 16)/116,
16341  Y = (Tfloat)(Yn*_cimg_Labfi(cY)),
16342  pY = (Tfloat)std::pow(Y/Yn,(Tfloat)1/3),
16343  cX = a/500 + pY,
16344  X = Xn*cX*cX*cX,
16345  cZ = pY - b/200,
16346  Z = Zn*cZ*cZ*cZ;
16347  *(p1++) = (T)(X);
16348  *(p2++) = (T)(Y);
16349  *(p3++) = (T)(Z);
16350  }
16351  return *this;
16352  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
#define _cimg_Labfi(x)
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

Tfloat linear_atX ( const float  fx,
const int  y,
const int  z,
const int  v,
const T  out_val 
) const
inline

Read a pixel value using linear interpolation and Dirichlet boundary conditions (first coordinate).

Definition at line 11557 of file CImg.h.

Referenced by CImg< uintT >::get_warp().

11557  {
11558  const int
11559  x = (int)fx-(fx>=0?0:1), nx = x+1;
11560  const float
11561  dx = fx-x;
11562  const Tfloat
11563  Ic = (Tfloat)atX(x,y,z,v,out_val), In = (Tfloat)atXY(nx,y,z,v,out_val);
11564  return Ic + dx*(In-Ic);
11565  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
void int int REAL * x
Definition: read.cpp:74
T & atX(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the first coordinates (x).
Definition: CImg.h:11324
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781

Here is the caller graph for this function:

Tfloat linear_atX ( const float  fx,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Read a pixel value using linear interpolation and Neumann boundary conditions (first coordinate).

Definition at line 11568 of file CImg.h.

11568  {
11569  if (is_empty())
11570  throw CImgInstanceException("CImg<%s>::linear_atX() : Instance image is empty.",
11571  pixel_type());
11572  return _linear_atX(fx,y,z,v);
11573  }
void int int REAL REAL * y
Definition: read.cpp:74
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
Tfloat _linear_atX(const float fx, const int y=0, const int z=0, const int v=0) const
Definition: CImg.h:11575
Tfloat linear_atXY ( const float  fx,
const float  fy,
const int  z,
const int  v,
const T  out_val 
) const
inline

Read a pixel value using linear interpolation and Dirichlet boundary conditions (first two coordinates).

Definition at line 11516 of file CImg.h.

Referenced by CImg< uintT >::get_rotate(), and CImg< uintT >::get_warp().

11516  {
11517  const int
11518  x = (int)fx-(fx>=0?0:1), nx = x+1,
11519  y = (int)fy-(fy>=0?0:1), ny = y+1;
11520  const float
11521  dx = fx-x,
11522  dy = fy-y;
11523  const Tfloat
11524  Icc = (Tfloat)atXY(x,y,z,v,out_val), Inc = (Tfloat)atXY(nx,y,z,v,out_val),
11525  Icn = (Tfloat)atXY(x,ny,z,v,out_val), Inn = (Tfloat)atXY(nx,ny,z,v,out_val);
11526  return Icc + dx*(Inc-Icc + dy*(Icc+Inn-Icn-Inc)) + dy*(Icn-Icc);
11527  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
T & atXY(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the two first coordinates (x...
Definition: CImg.h:11292
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy

Here is the caller graph for this function:

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

Read a pixel value using linear interpolation and Neumann boundary conditions (first two coordinates).

Definition at line 11530 of file CImg.h.

11530  {
11531  if (is_empty())
11532  throw CImgInstanceException("CImg<%s>::linear_atXY() : Instance image is empty.",
11533  pixel_type());
11534  return _linear_atXY(fx,fy,z,v);
11535  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
Tfloat _linear_atXY(const float fx, const float fy, const int z=0, const int v=0) const
Definition: CImg.h:11537
Tfloat linear_atXYZ ( const float  fx,
const float  fy,
const float  fz,
const int  v,
const T  out_val 
) const
inline

Read a pixel value using linear interpolation and Dirichlet boundary conditions (first three coordinates).

Definition at line 11451 of file CImg.h.

Referenced by CImg< uintT >::get_warp().

11451  {
11452  const int
11453  x = (int)fx-(fx>=0?0:1), nx = x+1,
11454  y = (int)fy-(fy>=0?0:1), ny = y+1,
11455  z = (int)fz-(fz>=0?0:1), nz = z+1;
11456  const float
11457  dx = fx-x,
11458  dy = fy-y,
11459  dz = fz-z;
11460  const Tfloat
11461  Iccc = (Tfloat)atXYZ(x,y,z,v,out_val), Incc = (Tfloat)atXYZ(nx,y,z,v,out_val),
11462  Icnc = (Tfloat)atXYZ(x,ny,z,v,out_val), Innc = (Tfloat)atXYZ(nx,ny,z,v,out_val),
11463  Iccn = (Tfloat)atXYZ(x,y,nz,v,out_val), Incn = (Tfloat)atXYZ(nx,y,nz,v,out_val),
11464  Icnn = (Tfloat)atXYZ(x,ny,nz,v,out_val), Innn = (Tfloat)atXYZ(nx,ny,nz,v,out_val);
11465  return Iccc +
11466  dx*(Incc-Iccc +
11467  dy*(Iccc+Innc-Icnc-Incc +
11468  dz*(Iccn+Innn+Icnc+Incc-Icnn-Incn-Iccc-Innc)) +
11469  dz*(Iccc+Incn-Iccn-Incc)) +
11470  dy*(Icnc-Iccc +
11471  dz*(Iccc+Icnn-Iccn-Icnc)) +
11472  dz*(Iccn-Iccc);
11473  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
NT dy
T & atXYZ(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions for the three first coordinates (x...
Definition: CImg.h:11257

Here is the caller graph for this function:

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

Read a pixel value using linear interpolation and Neumann boundary conditions (first three coordinates).

Definition at line 11476 of file CImg.h.

11476  {
11477  if (is_empty())
11478  throw CImgInstanceException("CImg<%s>::linear_atXYZ() : Instance image is empty.",
11479  pixel_type());
11480  return _linear_atXYZ(fx,fy,fz,v);
11481  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Tfloat _linear_atXYZ(const float fx, const float fy=0, const float fz=0, const int v=0) const
Definition: CImg.h:11483
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
Tfloat linear_atXYZV ( const float  fx,
const float  fy,
const float  fz,
const float  fv,
const T  out_val 
) const
inline

Read a pixel value using linear interpolation and Dirichlet boundary conditions.

Definition at line 11356 of file CImg.h.

Referenced by CImg< uintT >::get_warp().

11356  {
11357  const int
11358  x = (int)fx-(fx>=0?0:1), nx = x+1,
11359  y = (int)fy-(fy>=0?0:1), ny = y+1,
11360  z = (int)fz-(fz>=0?0:1), nz = z+1,
11361  v = (int)fv-(fv>=0?0:1), nv = v+1;
11362  const float
11363  dx = fx-x,
11364  dy = fy-y,
11365  dz = fz-z,
11366  dv = fv-v;
11367  const Tfloat
11368  Icccc = (Tfloat)atXYZV(x,y,z,v,out_val), Inccc = (Tfloat)atXYZV(nx,y,z,v,out_val),
11369  Icncc = (Tfloat)atXYZV(x,ny,z,v,out_val), Inncc = (Tfloat)atXYZV(nx,ny,z,v,out_val),
11370  Iccnc = (Tfloat)atXYZV(x,y,nz,v,out_val), Incnc = (Tfloat)atXYZV(nx,y,nz,v,out_val),
11371  Icnnc = (Tfloat)atXYZV(x,ny,nz,v,out_val), Innnc = (Tfloat)atXYZV(nx,ny,nz,v,out_val),
11372  Icccn = (Tfloat)atXYZV(x,y,z,nv,out_val), Inccn = (Tfloat)atXYZV(nx,y,z,nv,out_val),
11373  Icncn = (Tfloat)atXYZV(x,ny,z,nv,out_val), Inncn = (Tfloat)atXYZV(nx,ny,z,nv,out_val),
11374  Iccnn = (Tfloat)atXYZV(x,y,nz,nv,out_val), Incnn = (Tfloat)atXYZV(nx,y,nz,nv,out_val),
11375  Icnnn = (Tfloat)atXYZV(x,ny,nz,nv,out_val), Innnn = (Tfloat)atXYZV(nx,ny,nz,nv,out_val);
11376  return Icccc +
11377  dx*(Inccc-Icccc +
11378  dy*(Icccc+Inncc-Icncc-Inccc +
11379  dz*(Iccnc+Innnc+Icncc+Inccc-Icnnc-Incnc-Icccc-Inncc +
11380  dv*(Iccnn+Innnn+Icncn+Inccn+Icnnc+Incnc+Icccc+Inncc-Icnnn-Incnn-Icccn-Inncn-Iccnc-Innnc-Icncc-Inccc)) +
11381  dv*(Icccn+Inncn+Icncc+Inccc-Icncn-Inccn-Icccc-Inncc)) +
11382  dz*(Icccc+Incnc-Iccnc-Inccc +
11383  dv*(Icccn+Incnn+Iccnc+Inccc-Iccnn-Inccn-Icccc-Incnc)) +
11384  dv*(Icccc+Inccn-Inccc-Icccn)) +
11385  dy*(Icncc-Icccc +
11386  dz*(Icccc+Icnnc-Iccnc-Icncc +
11387  dv*(Icccn+Icnnn+Iccnc+Icncc-Iccnn-Icncn-Icccc-Icnnc)) +
11388  dv*(Icccc+Icncn-Icncc-Icccn)) +
11389  dz*(Iccnc-Icccc +
11390  dv*(Icccc+Iccnn-Iccnc-Icccn)) +
11391  dv*(Icccn-Icccc);
11392  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T & atXYZV(const int x, const int y, const int z, const int v, const T out_val)
Read a pixel value with Dirichlet boundary conditions.
Definition: CImg.h:11222
NT dy

Here is the caller graph for this function:

Tfloat linear_atXYZV ( const float  fx,
const float  fy = 0,
const float  fz = 0,
const float  fv = 0 
) const
inline

Read a pixel value using linear interpolation and Neumann boundary conditions.

Definition at line 11395 of file CImg.h.

11395  {
11396  if (is_empty())
11397  throw CImgInstanceException("CImg<%s>::linear_atXYZV() : Instance image is empty.",
11398  pixel_type());
11399  return _linear_atXYZV(fx,fy,fz,fv);
11400  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
Tfloat _linear_atXYZV(const float fx, const float fy=0, const float fz=0, const float fv=0) const
Definition: CImg.h:11402
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg<T>& lines ( const unsigned int  y0,
const unsigned int  y1 
)
inline

Get a set of lines.

Definition at line 18430 of file CImg.h.

Referenced by CImg< uintT >::line().

18430  {
18431  return get_lines(y0,y1).transfer_to(*this);
18432  }
CImg< T > get_lines(const unsigned int y0, const unsigned int y1) const
Definition: CImg.h:18434

Here is the caller graph for this function:

CImg<T>& load ( const char *const  filename)
inline

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.

Definition at line 29130 of file CImg.h.

Referenced by CImg< uintT >::assign(), CImg< uintT >::get_load(), CImg< uintT >::load_gzip_external(), and CImg< uintT >::operator=().

29130  {
29131  if (!filename)
29132  throw CImgArgumentException("CImg<%s>::load() : Cannot load (null) filename.",
29133  pixel_type());
29134  const char *ext = cimg::split_filename(filename);
29135  const unsigned int omode = cimg::exception_mode();
29136  cimg::exception_mode() = 0;
29137  assign();
29138  try {
29139 #ifdef cimg_load_plugin
29140  cimg_load_plugin(filename);
29141 #endif
29142 #ifdef cimg_load_plugin1
29143  cimg_load_plugin1(filename);
29144 #endif
29145 #ifdef cimg_load_plugin2
29146  cimg_load_plugin2(filename);
29147 #endif
29148 #ifdef cimg_load_plugin3
29149  cimg_load_plugin3(filename);
29150 #endif
29151 #ifdef cimg_load_plugin4
29152  cimg_load_plugin4(filename);
29153 #endif
29154 #ifdef cimg_load_plugin5
29155  cimg_load_plugin5(filename);
29156 #endif
29157 #ifdef cimg_load_plugin6
29158  cimg_load_plugin6(filename);
29159 #endif
29160 #ifdef cimg_load_plugin7
29161  cimg_load_plugin7(filename);
29162 #endif
29163 #ifdef cimg_load_plugin8
29164  cimg_load_plugin8(filename);
29165 #endif
29166  // ASCII formats
29167  if (!cimg::strcasecmp(ext,"asc")) load_ascii(filename);
29168  if (!cimg::strcasecmp(ext,"dlm") ||
29169  !cimg::strcasecmp(ext,"txt")) load_dlm(filename);
29170 
29171  // 2D binary formats
29172  if (!cimg::strcasecmp(ext,"bmp")) load_bmp(filename);
29173  if (!cimg::strcasecmp(ext,"jpg") ||
29174  !cimg::strcasecmp(ext,"jpeg") ||
29175  !cimg::strcasecmp(ext,"jpe") ||
29176  !cimg::strcasecmp(ext,"jfif") ||
29177  !cimg::strcasecmp(ext,"jif")) load_jpeg(filename);
29178  if (!cimg::strcasecmp(ext,"png")) load_png(filename);
29179  if (!cimg::strcasecmp(ext,"ppm") ||
29180  !cimg::strcasecmp(ext,"pgm") ||
29181  !cimg::strcasecmp(ext,"pnm")) load_pnm(filename);
29182  if (!cimg::strcasecmp(ext,"tif") ||
29183  !cimg::strcasecmp(ext,"tiff")) load_tiff(filename);
29184  if (!cimg::strcasecmp(ext,"cr2") ||
29185  !cimg::strcasecmp(ext,"crw") ||
29186  !cimg::strcasecmp(ext,"dcr") ||
29187  !cimg::strcasecmp(ext,"mrw") ||
29188  !cimg::strcasecmp(ext,"nef") ||
29189  !cimg::strcasecmp(ext,"orf") ||
29190  !cimg::strcasecmp(ext,"pix") ||
29191  !cimg::strcasecmp(ext,"ptx") ||
29192  !cimg::strcasecmp(ext,"raf") ||
29193  !cimg::strcasecmp(ext,"srf")) load_dcraw_external(filename);
29194 
29195  // 3D binary formats
29196  if (!cimg::strcasecmp(ext,"dcm") ||
29197  !cimg::strcasecmp(ext,"dicom")) load_medcon_external(filename);
29198  if (!cimg::strcasecmp(ext,"hdr") ||
29199  !cimg::strcasecmp(ext,"nii")) load_analyze(filename);
29200  if (!cimg::strcasecmp(ext,"par") ||
29201  !cimg::strcasecmp(ext,"rec")) load_parrec(filename);
29202  if (!cimg::strcasecmp(ext,"inr")) load_inr(filename);
29203  if (!cimg::strcasecmp(ext,"pan")) load_pandore(filename);
29204  if (!cimg::strcasecmp(ext,"cimg") ||
29205  !cimg::strcasecmp(ext,"cimgz") ||
29206  !*ext) return load_cimg(filename);
29207 
29208  // Archive files
29209  if (!cimg::strcasecmp(ext,"gz")) load_gzip_external(filename);
29210 
29211  // Image sequences
29212  if (!cimg::strcasecmp(ext,"avi") ||
29213  !cimg::strcasecmp(ext,"mov") ||
29214  !cimg::strcasecmp(ext,"asf") ||
29215  !cimg::strcasecmp(ext,"divx") ||
29216  !cimg::strcasecmp(ext,"flv") ||
29217  !cimg::strcasecmp(ext,"mpg") ||
29218  !cimg::strcasecmp(ext,"m1v") ||
29219  !cimg::strcasecmp(ext,"m2v") ||
29220  !cimg::strcasecmp(ext,"m4v") ||
29221  !cimg::strcasecmp(ext,"mjp") ||
29222  !cimg::strcasecmp(ext,"mkv") ||
29223  !cimg::strcasecmp(ext,"mpe") ||
29224  !cimg::strcasecmp(ext,"movie") ||
29225  !cimg::strcasecmp(ext,"ogm") ||
29226  !cimg::strcasecmp(ext,"qt") ||
29227  !cimg::strcasecmp(ext,"rm") ||
29228  !cimg::strcasecmp(ext,"vob") ||
29229  !cimg::strcasecmp(ext,"wmv") ||
29230  !cimg::strcasecmp(ext,"xvid") ||
29231  !cimg::strcasecmp(ext,"mpeg")) load_ffmpeg(filename);
29232  if (is_empty()) throw CImgIOException("CImg<%s>::load()",pixel_type());
29233  } catch (CImgException& e) {
29234  if (!cimg::strncasecmp(e.message,"cimg::fopen()",13)) {
29235  cimg::exception_mode() = omode;
29236  throw CImgIOException("CImg<%s>::load() : File '%s' cannot be opened.",pixel_type(),filename);
29237  } else try {
29238  const char *const ftype = cimg::file_type(0,filename);
29239  assign();
29240  if (!cimg::strcasecmp(ftype,"pnm")) load_pnm(filename);
29241  if (!cimg::strcasecmp(ftype,"bmp")) load_bmp(filename);
29242  if (!cimg::strcasecmp(ftype,"jpeg")) load_jpeg(filename);
29243  if (!cimg::strcasecmp(ftype,"pan")) load_pandore(filename);
29244  if (!cimg::strcasecmp(ftype,"png")) load_png(filename);
29245  if (!cimg::strcasecmp(ftype,"tiff")) load_tiff(filename);
29246  if (is_empty()) throw CImgIOException("CImg<%s>::load()",pixel_type());
29247  } catch (CImgException&) {
29248  try {
29249  load_other(filename);
29250  } catch (CImgException&) {
29251  assign();
29252  }
29253  }
29254  }
29255  cimg::exception_mode() = omode;
29256  if (is_empty())
29257  throw CImgIOException("CImg<%s>::load() : File '%s', format not recognized.",pixel_type(),filename);
29258  return *this;
29259  }
CImg< T > & load_dcraw_external(const char *const filename)
Load a RAW Color Camera image file, using external tool &#39;dcraw&#39;.
Definition: CImg.h:31359
CImg< T > & load_jpeg(const char *const filename)
Load an image from a JPEG file.
Definition: CImg.h:29493
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
CImg< T > & load_dlm(const char *const filename)
Load an image from a DLM file.
Definition: CImg.h:29314
CImg< T > & load_pandore(const char *const filename)
Load an image from a PANDORE file.
Definition: CImg.h:30701
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
Definition: CImg.h:30408
CImg< T > & load_png(const char *const filename)
Load an image from a PNG file.
Definition: CImg.h:29651
CImg< T > & load_bmp(const char *const filename)
Load an image from a BMP file.
Definition: CImg.h:29362
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
CImg< T > & load_inr(const char *const filename, float *const voxsize=0)
Load an image from an INRIMAGE-4 file.
Definition: CImg.h:30595
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > & load_ascii(const char *const filename)
Load an image from an ASCII file.
Definition: CImg.h:29266
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
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 char align='p')
Load a video sequence using FFMPEG av&#39;s libraries.
Definition: CImg.h:30985
CImg< T > & load_medcon_external(const char *const filename)
Load a DICOM image file, using XMedcon&#39;s external tool &#39;medcon&#39;.
Definition: CImg.h:31325
CImg< T > & load_parrec(const char *const filename, const char axis='v', const char align='p')
Load an image from a PAR-REC (Philips) file.
Definition: CImg.h:30916
const char * file_type(std::FILE *const file, const char *const filename)
Try to guess the image format of a filename, using its magick numbers.
Definition: CImg.h:5516
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
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.
Definition: CImg.h:30043
CImg< T > & load_gzip_external(const char *const filename)
Load a gzipped image file, using external tool &#39;gunzip&#39;.
Definition: CImg.h:31255
CImg< T > & load_cimg(const char *const filename, const char axis='z', const char align='p')
Load an image (list) from a .cimg file.
Definition: CImg.h:30531

Here is the caller graph for this function:

CImg<T>& load_analyze ( const char *const  filename,
float *const  voxsize = 0 
)
inline

Load an image from an ANALYZE7.5/NIFTI file.

Definition at line 30408 of file CImg.h.

Referenced by CImg< uintT >::get_load_analyze(), CImg< uintT >::load(), and CImg< uintT >::load_medcon_external().

30408  {
30409  return _load_analyze(0,filename,voxsize);
30410  }
CImg< T > & _load_analyze(std::FILE *const file, const char *const filename, float *const voxsize=0)
Definition: CImg.h:30425

Here is the caller graph for this function:

CImg<T>& load_analyze ( std::FILE *const  file,
float *const  voxsize = 0 
)
inline

Load an image from an ANALYZE7.5/NIFTI file.

Definition at line 30417 of file CImg.h.

30417  {
30418  return _load_analyze(file,0,voxsize);
30419  }
CImg< T > & _load_analyze(std::FILE *const file, const char *const filename, float *const voxsize=0)
Definition: CImg.h:30425
CImg<T>& load_ascii ( const char *const  filename)
inline

Load an image from an ASCII file.

Definition at line 29266 of file CImg.h.

Referenced by CImg< uintT >::get_load_ascii(), and CImg< uintT >::load().

29266  {
29267  return _load_ascii(0,filename);
29268  }
CImg< T > & _load_ascii(std::FILE *const file, const char *const filename)
Definition: CImg.h:29283

Here is the caller graph for this function:

CImg<T>& load_ascii ( std::FILE *const  file)
inline

Load an image from an ASCII file.

Definition at line 29275 of file CImg.h.

29275  {
29276  return _load_ascii(file,0);
29277  }
CImg< T > & _load_ascii(std::FILE *const file, const char *const filename)
Definition: CImg.h:29283
CImg<T>& load_bmp ( const char *const  filename)
inline

Load an image from a BMP file.

Definition at line 29362 of file CImg.h.

Referenced by CImg< uintT >::get_load_bmp(), and CImg< uintT >::load().

29362  {
29363  return _load_bmp(0,filename);
29364  }
CImg< T > & _load_bmp(std::FILE *const file, const char *const filename)
Definition: CImg.h:29379

Here is the caller graph for this function:

CImg<T>& load_bmp ( std::FILE *const  file)
inline

Load an image from a BMP file.

Definition at line 29371 of file CImg.h.

29371  {
29372  return _load_bmp(file,0);
29373  }
CImg< T > & _load_bmp(std::FILE *const file, const char *const filename)
Definition: CImg.h:29379
CImg<T>& load_cimg ( const char *const  filename,
const char  axis = 'z',
const char  align = 'p' 
)
inline

Load an image (list) from a .cimg file.

Definition at line 30531 of file CImg.h.

Referenced by CImg< uintT >::get_load_cimg(), and CImg< uintT >::load().

30531  {
30532  CImgList<T> list;
30533  list.load_cimg(filename);
30534  if (list.width==1) return list[0].transfer_to(*this);
30535  return assign(list.get_append(axis,align));
30536  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103

Here is the caller graph for this function:

CImg<T>& load_cimg ( std::FILE *const  file,
const char  axis = 'z',
const char  align = 'p' 
)
inline

Load an image (list) from a .cimg file.

Definition at line 30543 of file CImg.h.

30543  {
30544  CImgList<T> list;
30545  list.load_cimg(file);
30546  if (list.width==1) return list[0].transfer_to(*this);
30547  return assign(list.get_append(axis,align));
30548  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
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  v0,
const unsigned int  x1,
const unsigned int  y1,
const unsigned int  z1,
const unsigned int  v1,
const char  axis = 'z',
const char  align = 'p' 
)
inline

Load a sub-image (list) from a .cimg file.

Definition at line 30555 of file CImg.h.

30559  {
30560  CImgList<T> list;
30561  list.load_cimg(filename,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
30562  if (list.width==1) return list[0].transfer_to(*this);
30563  return assign(list.get_append(axis,align));
30564  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
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  v0,
const unsigned int  x1,
const unsigned int  y1,
const unsigned int  z1,
const unsigned int  v1,
const char  axis = 'z',
const char  align = 'p' 
)
inline

Load a sub-image (list) from a non-compressed .cimg file.

Definition at line 30575 of file CImg.h.

30579  {
30580  CImgList<T> list;
30581  list.load_cimg(file,n0,n1,x0,y0,z0,v0,x1,y1,z1,v1);
30582  if (list.width==1) return list[0].transfer_to(*this);
30583  return assign(list.get_append(axis,align));
30584  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& load_dcraw_external ( const char *const  filename)
inline

Load a RAW Color Camera image file, using external tool 'dcraw'.

Definition at line 31359 of file CImg.h.

Referenced by CImg< uintT >::get_load_dcraw_external(), and CImg< uintT >::load().

31359  {
31360  if (!filename)
31361  throw CImgArgumentException("CImg<%s>::load_dcraw_external() : Cannot load (null) filename.",
31362  pixel_type());
31363  char command[1024] = { 0 }, filetmp[512] = { 0 };
31364  std::FILE *file = 0;
31365 #if cimg_OS==1
31366  std::sprintf(command,"%s -4 -c \"%s\"",cimg::dcraw_path(),filename);
31367  file = popen(command,"r");
31368  if (file) { load_pnm(file); pclose(file); return *this; }
31369 #endif
31370  do {
31371  std::sprintf(filetmp,"%s%c%s.ppm",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
31372  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
31373  } while (file);
31374  std::sprintf(command,"%s -4 -c \"%s\" > %s",cimg::dcraw_path(),filename,filetmp);
31375  cimg::system(command,cimg::dcraw_path());
31376  if (!(file = std::fopen(filetmp,"rb"))) {
31377  cimg::fclose(cimg::fopen(filename,"r"));
31378  throw CImgIOException("CImg<%s>::load_dcraw_external() : Failed to open image '%s'.\n\n"
31379  "Path of 'dcraw' : \"%s\"\n"
31380  "Path of temporary filename : \"%s\"",
31381  pixel_type(),filename,cimg::dcraw_path(),filetmp);
31382  } else cimg::fclose(file);
31383  load_pnm(filetmp);
31384  std::remove(filetmp);
31385  return *this;
31386  }
#define cimg_file_separator
Definition: CImg.h:144
const char * filenamerand()
Definition: CImg.h:4996
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * dcraw_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the &#39;dcraw&#39; command.
Definition: CImg.h:5439
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& load_dlm ( const char *const  filename)
inline

Load an image from a DLM file.

Definition at line 29314 of file CImg.h.

Referenced by CImg< uintT >::get_load_dlm(), and CImg< uintT >::load().

29314  {
29315  return _load_dlm(0,filename);
29316  }
CImg< T > & _load_dlm(std::FILE *const file, const char *const filename)
Definition: CImg.h:29331

Here is the caller graph for this function:

CImg<T>& load_dlm ( std::FILE *const  file)
inline

Load an image from a DLM file.

Definition at line 29323 of file CImg.h.

29323  {
29324  return _load_dlm(file,0);
29325  }
CImg< T > & _load_dlm(std::FILE *const file, const char *const filename)
Definition: CImg.h:29331
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 char  align = 'p' 
)
inline

Load a video sequence using FFMPEG av's libraries.

Definition at line 30985 of file CImg.h.

Referenced by CImg< uintT >::get_load_ffmpeg(), and CImg< uintT >::load().

30987  {
30988  return get_load_ffmpeg(filename,first_frame,last_frame,step_frame,pixel_format,resume,axis,align).transfer_to(*this);
30989  }
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 char align='p')
Definition: CImg.h:30991

Here is the caller graph for this function:

CImg<T>& load_ffmpeg_external ( const char *const  filename,
const char  axis = 'z',
const char  align = 'p' 
)
inline

Load a video sequence using FFMPEG's external tool 'ffmpeg'.

Definition at line 31212 of file CImg.h.

Referenced by CImg< uintT >::get_load_ffmpeg_external().

31212  {
31213  return get_load_ffmpeg_external(filename,axis,align).transfer_to(*this);
31214  }
static CImg< T > get_load_ffmpeg_external(const char *const filename, const char axis='z', const char align='p')
Definition: CImg.h:31216

Here is the caller graph for this function:

CImg<T>& load_graphicsmagick_external ( const char *const  filename)
inline

Load an image using GraphicsMagick's external tool 'gm'.

Definition at line 31221 of file CImg.h.

Referenced by CImg< uintT >::get_load_graphicsmagick_external(), and CImg< uintT >::load_other().

31221  {
31222  if (!filename)
31223  throw CImgArgumentException("CImg<%s>::load_graphicsmagick_external() : Cannot load (null) filename.",
31224  pixel_type());
31225  char command[1024] = { 0 }, filetmp[512] = { 0 };
31226  std::FILE *file = 0;
31227 #if cimg_OS==1
31228  std::sprintf(command,"%s convert \"%s\" ppm:-",cimg::graphicsmagick_path(),filename);
31229  file = popen(command,"r");
31230  if (file) { load_pnm(file); pclose(file); return *this; }
31231 #endif
31232  do {
31233  std::sprintf(filetmp,"%s%c%s.ppm",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
31234  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
31235  } while (file);
31236  std::sprintf(command,"%s convert \"%s\" %s",cimg::graphicsmagick_path(),filename,filetmp);
31238  if (!(file = std::fopen(filetmp,"rb"))) {
31239  cimg::fclose(cimg::fopen(filename,"r"));
31240  throw CImgIOException("CImg<%s>::load_graphicsmagick_external() : Failed to open image '%s'.\n\n"
31241  "Path of 'GraphicsMagick's gm' : \"%s\"\n"
31242  "Path of temporary filename : \"%s\"",
31243  pixel_type(),filename,cimg::graphicsmagick_path(),filetmp);
31244  } else cimg::fclose(file);
31245  load_pnm(filetmp);
31246  std::remove(filetmp);
31247  return *this;
31248  }
#define cimg_file_separator
Definition: CImg.h:144
const char * filenamerand()
Definition: CImg.h:4996
const char * graphicsmagick_path(const char *const user_path=0, const bool reinit_path=false)
Return path of the GraphicsMagick&#39;s gm tool.
Definition: CImg.h:5198
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& load_gzip_external ( const char *const  filename)
inline

Load a gzipped image file, using external tool 'gunzip'.

Definition at line 31255 of file CImg.h.

Referenced by CImg< uintT >::get_load_gzip_external(), and CImg< uintT >::load().

31255  {
31256  if (!filename)
31257  throw CImgIOException("CImg<%s>::load_gzip_external() : Cannot load (null) filename.",
31258  pixel_type());
31259  char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
31260  const char
31261  *ext = cimg::split_filename(filename,body),
31262  *ext2 = cimg::split_filename(body,0);
31263  std::FILE *file = 0;
31264  do {
31265  if (!cimg::strcasecmp(ext,"gz")) {
31266  if (*ext2) std::sprintf(filetmp,"%s%c%s.%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext2);
31267  else std::sprintf(filetmp,"%s%c%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
31268  } else {
31269  if (*ext) std::sprintf(filetmp,"%s%c%s.%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext);
31270  else std::sprintf(filetmp,"%s%c%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
31271  }
31272  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
31273  } while (file);
31274  std::sprintf(command,"%s -c \"%s\" > %s",cimg::gunzip_path(),filename,filetmp);
31275  cimg::system(command);
31276  if (!(file = std::fopen(filetmp,"rb"))) {
31277  cimg::fclose(cimg::fopen(filename,"r"));
31278  throw CImgIOException("CImg<%s>::load_gzip_external() : File '%s' cannot be opened.",
31279  pixel_type(),filename);
31280  } else cimg::fclose(file);
31281  load(filetmp);
31282  std::remove(filetmp);
31283  return *this;
31284  }
#define cimg_file_separator
Definition: CImg.h:144
const char * gunzip_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the &#39;gunzip&#39; command.
Definition: CImg.h:5408
const char * filenamerand()
Definition: CImg.h:4996
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & load(const char *const filename)
Load an image from a file.
Definition: CImg.h:29130
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& load_imagemagick_external ( const char *const  filename)
inline

Load an image using ImageMagick's external tool 'convert'.

Definition at line 31291 of file CImg.h.

Referenced by CImg< uintT >::get_load_imagemagick_external(), and CImg< uintT >::load_other().

31291  {
31292  if (!filename)
31293  throw CImgArgumentException("CImg<%s>::load_imagemagick_external() : Cannot load (null) filename.",
31294  pixel_type());
31295  char command[1024] = { 0 }, filetmp[512] = { 0 };
31296  std::FILE *file = 0;
31297 #if cimg_OS==1
31298  std::sprintf(command,"%s \"%s\" ppm:-",cimg::imagemagick_path(),filename);
31299  file = popen(command,"r");
31300  if (file) { load_pnm(file); pclose(file); return *this; }
31301 #endif
31302  do {
31303  std::sprintf(filetmp,"%s%c%s.ppm",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
31304  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
31305  } while (file);
31306  std::sprintf(command,"%s \"%s\" %s",cimg::imagemagick_path(),filename,filetmp);
31308  if (!(file = std::fopen(filetmp,"rb"))) {
31309  cimg::fclose(cimg::fopen(filename,"r"));
31310  throw CImgIOException("CImg<%s>::load_imagemagick_external() : Failed to open image '%s'.\n\n"
31311  "Path of 'ImageMagick's convert' : \"%s\"\n"
31312  "Path of temporary filename : \"%s\"",
31313  pixel_type(),filename,cimg::imagemagick_path(),filetmp);
31314  } else cimg::fclose(file);
31315  load_pnm(filetmp);
31316  std::remove(filetmp);
31317  return *this;
31318  }
#define cimg_file_separator
Definition: CImg.h:144
const char * filenamerand()
Definition: CImg.h:4996
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & load_pnm(const char *const filename)
Load an image from a PNM file.
Definition: CImg.h:29812
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * imagemagick_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the ImageMagick&#39;s convert tool.
Definition: CImg.h:5094
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& load_inr ( const char *const  filename,
float *const  voxsize = 0 
)
inline

Load an image from an INRIMAGE-4 file.

Definition at line 30595 of file CImg.h.

Referenced by CImg< uintT >::get_load_inr(), and CImg< uintT >::load().

30595  {
30596  return _load_inr(0,filename,voxsize);
30597  }
CImg< T > & _load_inr(std::FILE *const file, const char *const filename, float *const voxsize)
Definition: CImg.h:30659

Here is the caller graph for this function:

CImg<T>& load_inr ( std::FILE *const  file,
float *const  voxsize = 0 
)
inline

Load an image from an INRIMAGE-4 file.

Definition at line 30604 of file CImg.h.

30604  {
30605  return _load_inr(file,0,voxsize);
30606  }
CImg< T > & _load_inr(std::FILE *const file, const char *const filename, float *const voxsize)
Definition: CImg.h:30659
CImg<T>& load_jpeg ( const char *const  filename)
inline

Load an image from a JPEG file.

Definition at line 29493 of file CImg.h.

Referenced by CImg< uintT >::get_load_jpeg(), and CImg< uintT >::load().

29493  {
29494  return _load_jpeg(0,filename);
29495  }
CImg< T > & _load_jpeg(std::FILE *const file, const char *const filename)
Definition: CImg.h:29510

Here is the caller graph for this function:

CImg<T>& load_jpeg ( std::FILE *const  file)
inline

Load an image from a JPEG file.

Definition at line 29502 of file CImg.h.

29502  {
29503  return _load_jpeg(file,0);
29504  }
CImg< T > & _load_jpeg(std::FILE *const file, const char *const filename)
Definition: CImg.h:29510
CImg<T>& load_magick ( const char *const  filename)
inline

Load an image from a file, using Magick++ library.

Definition at line 29585 of file CImg.h.

Referenced by CImg< uintT >::get_load_magick(), and CImg< uintT >::load_other().

29585  {
29586  if (!filename)
29587  throw CImgArgumentException("CImg<%s>::load_magick() : Cannot load (null) filename.",
29588  pixel_type());
29589 #ifdef cimg_use_magick
29590  Magick::Image image(filename);
29591  const unsigned int W = image.size().width(), H = image.size().height();
29592  switch (image.type()) {
29593  case Magick::PaletteMatteType :
29594  case Magick::TrueColorMatteType :
29595  case Magick::ColorSeparationType : {
29596  assign(W,H,1,4);
29597  T *rdata = ptr(0,0,0,0), *gdata = ptr(0,0,0,1), *bdata = ptr(0,0,0,2), *adata = ptr(0,0,0,3);
29598  Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29599  for (unsigned int off = W*H; off; --off) {
29600  *(rdata++) = (T)(pixels->red);
29601  *(gdata++) = (T)(pixels->green);
29602  *(bdata++) = (T)(pixels->blue);
29603  *(adata++) = (T)(pixels->opacity);
29604  ++pixels;
29605  }
29606  } break;
29607  case Magick::PaletteType :
29608  case Magick::TrueColorType : {
29609  assign(W,H,1,3);
29610  T *rdata = ptr(0,0,0,0), *gdata = ptr(0,0,0,1), *bdata = ptr(0,0,0,2);
29611  Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29612  for (unsigned int off = W*H; off; --off) {
29613  *(rdata++) = (T)(pixels->red);
29614  *(gdata++) = (T)(pixels->green);
29615  *(bdata++) = (T)(pixels->blue);
29616  ++pixels;
29617  }
29618  } break;
29619  case Magick::GrayscaleMatteType : {
29620  assign(W,H,1,2);
29621  T *data = ptr(0,0,0,0), *adata = ptr(0,0,0,1);
29622  Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29623  for (unsigned int off = W*H; off; --off) {
29624  *(data++) = (T)(pixels->red);
29625  *(adata++) = (T)(pixels->opacity);
29626  ++pixels;
29627  }
29628  } break;
29629  default : {
29630  assign(W,H,1,1);
29631  T *data = ptr(0,0,0,0);
29632  Magick::PixelPacket *pixels = image.getPixels(0,0,W,H);
29633  for (unsigned int off = W*H; off; --off) {
29634  *(data++) = (T)(pixels->red);
29635  ++pixels;
29636  }
29637  }
29638  }
29639 #else
29640  throw CImgIOException("CImg<%s>::load_magick() : File '%s', Magick++ library has not been linked.",
29641  pixel_type(),filename);
29642 #endif
29643  return *this;
29644  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& load_medcon_external ( const char *const  filename)
inline

Load a DICOM image file, using XMedcon's external tool 'medcon'.

Definition at line 31325 of file CImg.h.

Referenced by CImg< uintT >::get_load_medcon_external(), and CImg< uintT >::load().

31325  {
31326  if (!filename)
31327  throw CImgArgumentException("CImg<%s>::load_medcon_external() : Cannot load (null) filename.",
31328  pixel_type());
31329  char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
31330  cimg::fclose(cimg::fopen(filename,"r"));
31331  std::FILE *file = 0;
31332  do {
31333  std::sprintf(filetmp,"%s.hdr",cimg::filenamerand());
31334  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
31335  } while (file);
31336  std::sprintf(command,"%s -w -c anlz -o %s -f %s",cimg::medcon_path(),filetmp,filename);
31337  cimg::system(command);
31338  cimg::split_filename(filetmp,body);
31339  std::sprintf(command,"m000-%s.hdr",body);
31340  file = std::fopen(command,"rb");
31341  if (!file) {
31342  throw CImgIOException("CImg<%s>::load_medcon_external() : Failed to open image '%s'.\n\n"
31343  "Path of 'medcon' : \"%s\"\n"
31344  "Path of temporary filename : \"%s\"",
31345  pixel_type(),filename,cimg::medcon_path(),filetmp);
31346  } else cimg::fclose(file);
31347  load_analyze(command);
31348  std::remove(command);
31349  std::sprintf(command,"m000-%s.img",body);
31350  std::remove(command);
31351  return *this;
31352  }
const char * filenamerand()
Definition: CImg.h:4996
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
CImg< T > & load_analyze(const char *const filename, float *const voxsize=0)
Load an image from an ANALYZE7.5/NIFTI file.
Definition: CImg.h:30408
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const char * medcon_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path of the XMedcon tool.
Definition: CImg.h:5302
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

CImg<T>& load_off ( const char *const  filename,
CImgList< tf > &  primitives,
CImgList< tc > &  colors 
)
inline

Load a 3D object from a .OFF file.

Definition at line 31029 of file CImg.h.

Referenced by CImg< uintT >::get_load_off().

31029  {
31030  return _load_off(0,filename,primitives,colors);
31031  }
CImg< T > & _load_off(std::FILE *const file, const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Definition: CImg.h:31050

Here is the caller graph for this function:

CImg<T>& load_off ( std::FILE *const  file,
CImgList< tf > &  primitives,
CImgList< tc > &  colors 
)
inline

Load a 3D object from a .OFF file.

Definition at line 31040 of file CImg.h.

31040  {
31041  return _load_off(file,0,primitives,colors);
31042  }
CImg< T > & _load_off(std::FILE *const file, const char *const filename, CImgList< tf > &primitives, CImgList< tc > &colors)
Definition: CImg.h:31050
CImg<T>& load_other ( const char *const  filename)
inline

Load an image using ImageMagick's or GraphicsMagick's executables.

Definition at line 31393 of file CImg.h.

Referenced by CImg< uintT >::_load_bmp(), CImg< uintT >::_load_jpeg(), CImg< uintT >::_load_png(), CImg< uintT >::get_load_other(), CImg< uintT >::load(), and CImg< uintT >::load_tiff().

31393  {
31394  if (!filename)
31395  throw CImgArgumentException("CImg<%s>::load_other() : Cannot load (null) filename.",
31396  pixel_type());
31397  const unsigned int omode = cimg::exception_mode();
31398  cimg::exception_mode() = 0;
31399  try { load_magick(filename); }
31400  catch (CImgException&) {
31401  try { load_imagemagick_external(filename); }
31402  catch (CImgException&) {
31403  try { load_graphicsmagick_external(filename); }
31404  catch (CImgException&) {
31405  assign();
31406  }
31407  }
31408  }
31409  cimg::exception_mode() = omode;
31410  if (is_empty())
31411  throw CImgIOException("CImg<%s>::load_other() : File '%s' cannot be opened.",
31412  pixel_type(),filename);
31413  return *this;
31414  }
CImg< T > & load_graphicsmagick_external(const char *const filename)
Load an image using GraphicsMagick&#39;s external tool &#39;gm&#39;.
Definition: CImg.h:31221
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > & load_imagemagick_external(const char *const filename)
Load an image using ImageMagick&#39;s external tool &#39;convert&#39;.
Definition: CImg.h:31291
CImg< T > & load_magick(const char *const filename)
Load an image from a file, using Magick++ library.
Definition: CImg.h:29585

Here is the caller graph for this function:

CImg<T>& load_pandore ( const char *const  filename)
inline

Load an image from a PANDORE file.

Definition at line 30701 of file CImg.h.

Referenced by CImg< uintT >::get_load_pandore(), and CImg< uintT >::load().

30701  {
30702  return _load_pandore(0,filename);
30703  }
CImg< T > & _load_pandore(std::FILE *const file, const char *const filename)
Definition: CImg.h:30718

Here is the caller graph for this function:

CImg<T>& load_pandore ( std::FILE *const  file)
inline

Load an image from a PANDORE file.

Definition at line 30710 of file CImg.h.

30710  {
30711  return _load_pandore(file,0);
30712  }
CImg< T > & _load_pandore(std::FILE *const file, const char *const filename)
Definition: CImg.h:30718
CImg<T>& load_parrec ( const char *const  filename,
const char  axis = 'v',
const char  align = 'p' 
)
inline

Load an image from a PAR-REC (Philips) file.

Definition at line 30916 of file CImg.h.

Referenced by CImg< uintT >::get_load_parrec(), and CImg< uintT >::load().

30916  {
30917  CImgList<T> list;
30918  list.load_parrec(filename);
30919  if (list.width==1) return list[0].transfer_to(*this);
30920  return assign(list.get_append(axis,align));
30921  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103

Here is the caller graph for this function:

CImg<T>& load_png ( const char *const  filename)
inline

Load an image from a PNG file.

Definition at line 29651 of file CImg.h.

Referenced by CImg< uintT >::get_load_png(), and CImg< uintT >::load().

29651  {
29652  return _load_png(0,filename);
29653  }
CImg< T > & _load_png(std::FILE *const file, const char *const filename)
Definition: CImg.h:29669

Here is the caller graph for this function:

CImg<T>& load_png ( std::FILE *const  file)
inline

Load an image from a PNG file.

Definition at line 29660 of file CImg.h.

29660  {
29661  return _load_png(file,0);
29662  }
CImg< T > & _load_png(std::FILE *const file, const char *const filename)
Definition: CImg.h:29669
CImg<T>& load_pnm ( const char *const  filename)
inline

Load an image from a PNM file.

Definition at line 29812 of file CImg.h.

Referenced by CImg< uintT >::get_load_pnm(), CImg< uintT >::load(), CImg< uintT >::load_dcraw_external(), CImg< uintT >::load_graphicsmagick_external(), and CImg< uintT >::load_imagemagick_external().

29812  {
29813  return _load_pnm(0,filename);
29814  }
CImg< T > & _load_pnm(std::FILE *const file, const char *const filename)
Definition: CImg.h:29829

Here is the caller graph for this function:

CImg<T>& load_pnm ( std::FILE *const  file)
inline

Load an image from a PNM file.

Definition at line 29821 of file CImg.h.

29821  {
29822  return _load_pnm(file,0);
29823  }
CImg< T > & _load_pnm(std::FILE *const file, const char *const filename)
Definition: CImg.h:29829
CImg<T>& load_raw ( const char *const  filename,
const unsigned int  sizex,
const unsigned int  sizey = 1,
const unsigned int  sizez = 1,
const unsigned int  sizev = 1,
const bool  multiplexed = false,
const bool  invert_endianness = false 
)
inline

Load an image from a .RAW file.

Definition at line 30928 of file CImg.h.

Referenced by CImg< uintT >::get_load_raw().

30931  {
30932  return _load_raw(0,filename,sizex,sizey,sizez,sizev,multiplexed,invert_endianness);
30933  }
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
Definition: CImg.h:14951
CImg< T > & _load_raw(std::FILE *const file, const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int sizez, const unsigned int sizev, const bool multiplexed, const bool invert_endianness)
Definition: CImg.h:30957

Here is the caller graph for this function:

CImg<T>& load_raw ( std::FILE *const  file,
const unsigned int  sizex,
const unsigned int  sizey = 1,
const unsigned int  sizez = 1,
const unsigned int  sizev = 1,
const bool  multiplexed = false,
const bool  invert_endianness = false 
)
inline

Load an image from a .RAW file.

Definition at line 30943 of file CImg.h.

30946  {
30947  return _load_raw(file,0,sizex,sizey,sizez,sizev,multiplexed,invert_endianness);
30948  }
CImg< T > & invert_endianness()
Invert endianness of the image buffer.
Definition: CImg.h:14951
CImg< T > & _load_raw(std::FILE *const file, const char *const filename, const unsigned int sizex, const unsigned int sizey, const unsigned int sizez, const unsigned int sizev, const bool multiplexed, const bool invert_endianness)
Definition: CImg.h:30957
CImg<T>& load_rgb ( const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inline

Load an image from a RGB file.

Definition at line 29949 of file CImg.h.

Referenced by CImg< uintT >::get_load_rgb().

29949  {
29950  return _load_rgb(0,filename,dimw,dimh);
29951  }
CImg< T > & _load_rgb(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
Definition: CImg.h:29966

Here is the caller graph for this function:

CImg<T>& load_rgb ( std::FILE *const  file,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inline

Load an image from a RGB file.

Definition at line 29958 of file CImg.h.

29958  {
29959  return _load_rgb(file,0,dimw,dimh);
29960  }
CImg< T > & _load_rgb(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
Definition: CImg.h:29966
CImg<T>& load_rgba ( const char *const  filename,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inline

Load an image from a RGBA file.

Definition at line 29995 of file CImg.h.

Referenced by CImg< uintT >::get_load_rgba().

29995  {
29996  return _load_rgba(0,filename,dimw,dimh);
29997  }
CImg< T > & _load_rgba(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
Definition: CImg.h:30012

Here is the caller graph for this function:

CImg<T>& load_rgba ( std::FILE *const  file,
const unsigned int  dimw,
const unsigned int  dimh = 1 
)
inline

Load an image from a RGBA file.

Definition at line 30004 of file CImg.h.

30004  {
30005  return _load_rgba(file,0,dimw,dimh);
30006  }
CImg< T > & _load_rgba(std::FILE *const file, const char *const filename, const unsigned int dimw, const unsigned int dimh)
Definition: CImg.h:30012
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 
)
inline

Load an image from a TIFF file.

Definition at line 30043 of file CImg.h.

Referenced by CImg< uintT >::get_load_tiff(), and CImg< uintT >::load().

30045  {
30046  if (!filename)
30047  throw CImgArgumentException("CImg<%s>::load_tiff() : Cannot load (null) filename.",
30048  pixel_type());
30049  const unsigned int
30050  nfirst_frame = first_frame<last_frame?first_frame:last_frame,
30051  nstep_frame = step_frame?step_frame:1;
30052  unsigned int nlast_frame = first_frame<last_frame?last_frame:first_frame;
30053 
30054 #ifndef cimg_use_tiff
30055  if (nfirst_frame || nlast_frame!=~0U || nstep_frame>1)
30056  throw CImgArgumentException("CImg<%s>::load_tiff() : File '%s', reading sub-images from a tiff file requires the use of libtiff.\n"
30057  "('cimg_use_tiff' must be defined).",
30058  pixel_type(),filename);
30059  return load_other(filename);
30060 #else
30061  TIFF *tif = TIFFOpen(filename,"r");
30062  if (tif) {
30063  unsigned int nb_images = 0;
30064  do ++nb_images; while (TIFFReadDirectory(tif));
30065  if (nfirst_frame>=nb_images || (nlast_frame!=~0U && nlast_frame>=nb_images))
30066  cimg::warn("CImg<%s>::load_tiff() : File '%s' contains %u image(s), specified frame range is [%u,%u] (step %u).",
30067  pixel_type(),filename,nb_images,nfirst_frame,nlast_frame,nstep_frame);
30068  if (nfirst_frame>=nb_images) return assign();
30069  if (nlast_frame>=nb_images) nlast_frame = nb_images-1;
30070  TIFFSetDirectory(tif,0);
30071  CImg<T> frame;
30072  for (unsigned int l = nfirst_frame; l<=nlast_frame; l+=nstep_frame) {
30073  frame._load_tiff(tif,l);
30074  if (l==nfirst_frame) assign(frame.width,frame.height,1+(nlast_frame-nfirst_frame)/nstep_frame,frame.dim);
30075  if (frame.width>width || frame.height>height || frame.dim>dim)
30076  resize(cimg::max(frame.width,width),cimg::max(frame.height,height),-100,cimg::max(frame.dim,dim),0);
30077  draw_image(0,0,(l-nfirst_frame)/nstep_frame,frame);
30078  }
30079  TIFFClose(tif);
30080  } else throw CImgException("CImg<%s>::load_tiff() : File '%s' cannot be opened.",
30081  pixel_type(),filename);
30082  return *this;
30083 #endif
30084  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
CImg< T > & draw_image(const int x0, const int y0, const int z0, const int v0, const CImg< t > &sprite, const float opacity=1)
Draw an image.
Definition: CImg.h:26116
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & load_other(const char *const filename)
Load an image using ImageMagick&#39;s or GraphicsMagick&#39;s executables.
Definition: CImg.h:31393
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
Definition: CImg.h:16630
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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 char  align = 'p' 
)
inline

Load an image sequence from a YUV file.

Definition at line 30998 of file CImg.h.

Referenced by CImg< uintT >::get_load_yuv().

31001  {
31002  return get_load_yuv(filename,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb,axis,align).transfer_to(*this);
31003  }
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 char align='p')
Definition: CImg.h:31005

Here is the caller graph for this function:

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 char  align = 'p' 
)
inline

Load an image sequence from a YUV file.

Definition at line 31013 of file CImg.h.

31016  {
31017  return get_load_yuv(file,sizex,sizey,first_frame,last_frame,step_frame,yuv2rgb,axis,align).transfer_to(*this);
31018  }
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 char align='p')
Definition: CImg.h:31005
CImg<T>& log ( )
inline

Compute the log of each each pixel value.

Definition at line 12550 of file CImg.h.

Referenced by CImg< uintT >::get_log().

12550  {
12551  cimg_for(*this,ptr,T) (*ptr) = (T)std::log((double)(*ptr));
12552  return *this;
12553  }
CImg< _cimg_Tfloat > log(const CImg< T > &instance)
Definition: CImg.h:6021
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& log10 ( )
inline

Compute the log10 of each each pixel value.

Definition at line 12560 of file CImg.h.

Referenced by CImg< uintT >::get_log10().

12560  {
12561  cimg_for(*this,ptr,T) (*ptr) = (T)std::log10((double)(*ptr));
12562  return *this;
12563  }
CImg< _cimg_Tfloat > log10(const CImg< T > &instance)
Definition: CImg.h:6026
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

static CImg<T> logo40x38 ( )
inlinestatic

Definition at line 33848 of file CImg.h.

33848  {
33849  static bool first_time = true;
33850  static CImg<T> res(40,38,1,3);
33851  if (first_time) {
33852  const unsigned char *ptrs = cimg::logo40x38;
33853  T *ptr1 = res.ptr(0,0,0,0), *ptr2 = res.ptr(0,0,0,1), *ptr3 = res.ptr(0,0,0,2);
33854  for (unsigned int off = 0; off<res.width*res.height;) {
33855  const unsigned char n = *(ptrs++), r = *(ptrs++), g = *(ptrs++), b = *(ptrs++);
33856  for (unsigned int l = 0; l<n; ++off, ++l) { *(ptr1++) = (T)r; *(ptr2++) = (T)g; *(ptr3++) = (T)b; }
33857  }
33858  first_time = false;
33859  }
33860  return res;
33861  }
const unsigned char logo40x38[4576]
Definition: CImg.h:4440
const NT & n
Tfloat magnitude ( const int  magnitude_type = 2) const
inline

Return the norm of the current vector/matrix. ntype = norm type (0=L2, 1=L1, -1=Linf).

Definition at line 13191 of file CImg.h.

Referenced by c3d6nm().

13191  {
13192  if (is_empty())
13193  throw CImgInstanceException("CImg<%s>::magnitude() : Instance object (%u,%u,%u,%u,%p) is empty.",
13195  Tfloat res = 0;
13196  switch (magnitude_type) {
13197  case -1 : {
13198  cimg_foroff(*this,off) {
13199  const Tfloat tmp = cimg::abs((Tfloat)data[off]);
13200  if (tmp>res) res = tmp;
13201  }
13202  return res;
13203  } break;
13204  case 1 : {
13205  cimg_foroff(*this,off) res+=cimg::abs((Tfloat)data[off]);
13206  return res;
13207  } break;
13208  case 2 : return (Tfloat)std::sqrt(dot(*this)); break;
13209  default :
13210  throw CImgArgumentException("CImg<%s>::magnitude() : Incorrect parameter 'magnitude_type=%d' (correct values are -1,1 or 2).",
13211  pixel_type(),magnitude_type);
13212  }
13213  return 0;
13214  }
const NT & d
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
Tfloat magnitude(const int magnitude_type=2) const
Return the norm of the current vector/matrix. ntype = norm type (0=L2, 1=L1, -1=Linf).
Definition: CImg.h:13191
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
Tfloat dot(const CImg< t > &img) const
Return the dot product of the current vector/matrix with the vector/matrix img.
Definition: CImg.h:13256
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
#define cimg_foroff(img, off)
Definition: CImg.h:590
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& map ( const CImg< t > &  palette)
inline

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

Parameters
paletteMulti-valued palette used for mapping the indexes.
Returns
A reference to the modified instance image.
Note
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

Definition at line 15571 of file CImg.h.

Referenced by v3d4_r_bar().

15571  {
15572  return get_map(palette).transfer_to(*this);
15573  }
CImg< t > get_map(const CImg< t > &palette) const
Definition: CImg.h:15576

Here is the caller graph for this function:

CImg<T>& matrix ( )
inline

Realign pixel values of the instance image as a square matrix.

Definition at line 13343 of file CImg.h.

Referenced by CImg< uintT >::diagonal(), CImg< uintT >::get_matrix(), huang_const_model(), CImg< uintT >::rotation_matrix(), CImg< uintT >::tensor(), testconst(), and v3d10_nl_huang().

13343  {
13344  const unsigned int siz = size();
13345  switch (siz) {
13346  case 1 : break;
13347  case 4 : width = height = 2; break;
13348  case 9 : width = height = 3; break;
13349  case 16 : width = height = 4; break;
13350  case 25 : width = height = 5; break;
13351  case 36 : width = height = 6; break;
13352  case 49 : width = height = 7; break;
13353  case 64 : width = height = 8; break;
13354  case 81 : width = height = 9; break;
13355  case 100 : width = height = 10; break;
13356  default : {
13357  unsigned int i = 11, i2 = i*i;
13358  while (i2<siz) { i2+=2*i+1; ++i; }
13359  if (i2==siz) width = height = i;
13360  else throw CImgInstanceException("CImg<%s>::matrix() : Image size = %u is not a square number",
13361  pixel_type(),siz);
13362  }
13363  }
13364  return *this;
13365  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

static CImg<T> matrix ( const T &  a0)
inlinestatic

Return a 1x1 square matrix with specified coefficients.

Definition at line 14289 of file CImg.h.

14289  {
14290  return vector(a0);
14291  }
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
static CImg<T> matrix ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3 
)
inlinestatic

Return a 2x2 square matrix with specified coefficients.

Definition at line 14294 of file CImg.h.

14295  {
14296  static CImg<T> r(2,2); T *ptr = r.data;
14297  *(ptr++) = a0; *(ptr++) = a1;
14298  *(ptr++) = a2; *(ptr++) = a3;
14299  return r;
14300  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a 3x3 square matrix with specified coefficients.

Definition at line 14303 of file CImg.h.

14305  {
14306  static CImg<T> r(3,3); T *ptr = r.data;
14307  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2;
14308  *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5;
14309  *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8;
14310  return r;
14311  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a 4x4 square matrix with specified coefficients.

Definition at line 14314 of file CImg.h.

14317  {
14318  static CImg<T> r(4,4); T *ptr = r.data;
14319  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14320  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14321  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14322  *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15;
14323  return r;
14324  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a 5x5 square matrix with specified coefficients.

Definition at line 14327 of file CImg.h.

14331  {
14332  static CImg<T> r(5,5); T *ptr = r.data;
14333  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4;
14334  *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7; *(ptr++) = a8; *(ptr++) = a9;
14335  *(ptr++) = a10; *(ptr++) = a11; *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14;
14336  *(ptr++) = a15; *(ptr++) = a16; *(ptr++) = a17; *(ptr++) = a18; *(ptr++) = a19;
14337  *(ptr++) = a20; *(ptr++) = a21; *(ptr++) = a22; *(ptr++) = a23; *(ptr++) = a24;
14338  return r;
14339  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& max ( const T  val)
inline

Pointwise max operator between an image and a value.

Definition at line 12830 of file CImg.h.

Referenced by CImg< uintT >::get_label_regions(), and CImg< uintT >::get_max().

12830  {
12831  cimg_for(*this,ptr,T) (*ptr) = cimg::max(*ptr,val);
12832  return *this;
12833  }
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& max ( const CImg< t > &  img)
inline

Pointwise max operator between two images.

Definition at line 12841 of file CImg.h.

12841  {
12842  if (is_overlapped(img)) return max(+img);
12843  t *ptrs = img.data;
12844  T *ptrf = data + cimg::min(size(),img.size());
12845  for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = cimg::max((T)*(ptrs++),*ptrd);
12846  return *this;
12847  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
CImg<T>& max ( const char *const  expression)
inline

Pointwise max operator between an image and a string.

Definition at line 12855 of file CImg.h.

12855  {
12856  const unsigned int omode = cimg::exception_mode();
12857  cimg::exception_mode() = 0;
12858  try {
12859  _cimg_math_parser mp(expression,"max");
12860  T *ptrd = data;
12861  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)cimg::max(*ptrd,(T)mp.eval(*this,x,y,z,v)); ++ptrd; }
12862  } catch (CImgException&) {
12863  CImg<T> values(width,height,depth,dim);
12864  try {
12865  values.fill(expression,true);
12866  } catch (CImgException&) {
12867  cimg::exception_mode() = omode;
12868  values.load(expression);
12869  }
12870  max(values);
12871  }
12872  cimg::exception_mode() = omode;
12873  return *this;
12874  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
T& max ( void  )
inline

Return a reference to the maximum pixel value of the instance image.

Definition at line 12900 of file CImg.h.

Referenced by CImg< uintT >::_quicksort(), CImg< uintT >::get_max(), CImg< uintT >::max(), and CImg< uintT >::noise().

12900  {
12901  if (is_empty())
12902  throw CImgInstanceException("CImg<%s>::max() : Instance image is empty.",pixel_type());
12903  T *ptrmax = data;
12904  T max_value = *ptrmax;
12905  cimg_for(*this,ptr,T) if ((*ptr)>max_value) max_value = *(ptrmax=ptr);
12906  return *ptrmax;
12907  }
if(dy > dx)
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

const T& max ( void  ) const
inline

Definition at line 12909 of file CImg.h.

12909  {
12910  if (is_empty())
12911  throw CImgInstanceException("CImg<%s>::max() : Instance image is empty.",pixel_type());
12912  const T *ptrmax = data;
12913  T max_value = *ptrmax;
12914  cimg_for(*this,ptr,T) if ((*ptr)>max_value) max_value = *(ptrmax=ptr);
12915  return *ptrmax;
12916  }
if(dy > dx)
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
T& maxmin ( t &  min_val)
inline

Return a reference to the maximum pixel value and return also the minimum pixel value.

Definition at line 12951 of file CImg.h.

Referenced by CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::blur_bilateral(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_index(), CImg< uintT >::normalize(), CImg< uintT >::quantize(), CImg< uintT >::save_magick(), and CImg< uintT >::sharpen().

12951  {
12952  if (is_empty())
12953  throw CImgInstanceException("CImg<%s>::maxmin() : Instance image is empty.",pixel_type());
12954  T *ptrmax = data;
12955  T max_value = *ptrmax, min_value = max_value;
12956  cimg_for(*this,ptr,T) {
12957  const T val = *ptr;
12958  if (val>max_value) { max_value = val; ptrmax = ptr; }
12959  if (val<min_value) min_value = val;
12960  }
12961  min_val = (t)min_value;
12962  return *ptrmax;
12963  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

const T& maxmin ( t &  min_val) const
inline

Definition at line 12966 of file CImg.h.

12966  {
12967  if (is_empty())
12968  throw CImgInstanceException("CImg<%s>::maxmin() : Instance image is empty.",pixel_type());
12969  const T *ptrmax = data;
12970  T max_value = *ptrmax, min_value = max_value;
12971  cimg_for(*this,ptr,T) {
12972  const T val = *ptr;
12973  if (val>max_value) { max_value = val; ptrmax = ptr; }
12974  if (val<min_value) min_value = val;
12975  }
12976  min_val = (t)min_value;
12977  return *ptrmax;
12978  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
Tfloat mean ( ) const
inline

Return the mean pixel value of the instance image.

Definition at line 13032 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d().

13032  {
13033  if (is_empty())
13034  throw CImgInstanceException("CImg<%s>::mean() : Instance image is empty.",pixel_type());
13035  Tfloat val = 0;
13036  cimg_for(*this,ptr,T) val+=*ptr;
13037  return val/size();
13038  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

T median ( ) const
inline

Return the median value of the image.

Definition at line 13015 of file CImg.h.

13015  {
13016  const unsigned int s = size();
13017  const T res = kth_smallest(s>>1);
13018  return (s%2)?res:((res+kth_smallest((s>>1)-1))/2);
13019  }
double s
Definition: blastest.C:80
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
T kth_smallest(const unsigned int k) const
Return the kth smallest element of the image.
Definition: CImg.h:12981
CImg<T>& min ( const T  val)
inline

Pointwise min operator between an image and a value.

Definition at line 12779 of file CImg.h.

Referenced by CImg< uintT >::get_min().

12779  {
12780  cimg_for(*this,ptr,T) (*ptr) = cimg::min(*ptr,val);
12781  return *this;
12782  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& min ( const CImg< t > &  img)
inline

Pointwise min operator between two images.

Definition at line 12790 of file CImg.h.

12790  {
12791  if (is_overlapped(img)) return min(+img);
12792  t *ptrs = img.data;
12793  T *ptrf = data + cimg::min(size(),img.size());
12794  for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = cimg::min((T)*(ptrs++),*ptrd);
12795  return *this;
12796  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T>& min ( const char *const  expression)
inline

Pointwise min operator between an image and a string.

Definition at line 12804 of file CImg.h.

12804  {
12805  const unsigned int omode = cimg::exception_mode();
12806  cimg::exception_mode() = 0;
12807  try {
12808  _cimg_math_parser mp(expression,"min");
12809  T *ptrd = data;
12810  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)cimg::min(*ptrd,(T)mp.eval(*this,x,y,z,v)); ++ptrd; }
12811  } catch (CImgException&) {
12812  CImg<T> values(width,height,depth,dim);
12813  try {
12814  values.fill(expression,true);
12815  } catch (CImgException&) {
12816  cimg::exception_mode() = omode;
12817  values.load(expression);
12818  }
12819  min(values);
12820  }
12821  cimg::exception_mode() = omode;
12822  return *this;
12823  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
T& min ( )
inline

Return a reference to the minimum pixel value of the instance image.

Definition at line 12881 of file CImg.h.

Referenced by CImg< uintT >::_quicksort(), CImg< uintT >::get_min(), CImg< uintT >::min(), and CImg< uintT >::noise().

12881  {
12882  if (is_empty())
12883  throw CImgInstanceException("CImg<%s>::min() : Instance image is empty.",pixel_type());
12884  T *ptrmin = data;
12885  T min_value = *ptrmin;
12886  cimg_for(*this,ptr,T) if ((*ptr)<min_value) min_value = *(ptrmin=ptr);
12887  return *ptrmin;
12888  }
if(dy > dx)
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

const T& min ( ) const
inline

Definition at line 12890 of file CImg.h.

12890  {
12891  if (is_empty())
12892  throw CImgInstanceException("CImg<%s>::min() : Instance image is empty.",pixel_type());
12893  const T *ptrmin = data;
12894  T min_value = *ptrmin;
12895  cimg_for(*this,ptr,T) if ((*ptr)<min_value) min_value = *(ptrmin=ptr);
12896  return *ptrmin;
12897  }
if(dy > dx)
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
T& minmax ( t &  max_val)
inline

Return a reference to the minimum pixel value and return also the maximum pixel value.

Definition at line 12920 of file CImg.h.

Referenced by CImg< uintT >::equalize(), CImg< uintT >::get_histogram(), CImg< uintT >::get_select_graph(), and CImg< uintT >::noise().

12920  {
12921  if (is_empty())
12922  throw CImgInstanceException("CImg<%s>::minmax() : Instance image is empty.",pixel_type());
12923  T *ptrmin = data;
12924  T min_value = *ptrmin, max_value = min_value;
12925  cimg_for(*this,ptr,T) {
12926  const T val = *ptr;
12927  if (val<min_value) { min_value = val; ptrmin = ptr; }
12928  if (val>max_value) max_value = val;
12929  }
12930  max_val = (t)max_value;
12931  return *ptrmin;
12932  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

const T& minmax ( t &  max_val) const
inline

Definition at line 12935 of file CImg.h.

12935  {
12936  if (is_empty())
12937  throw CImgInstanceException("CImg<%s>::minmax() : Instance image is empty.",pixel_type());
12938  const T *ptrmin = data;
12939  T min_value = *ptrmin, max_value = min_value;
12940  cimg_for(*this,ptr,T) {
12941  const T val = *ptr;
12942  if (val<min_value) { min_value = val; ptrmin = ptr; }
12943  if (val>max_value) max_value = val;
12944  }
12945  max_val = (t)max_value;
12946  return *ptrmin;
12947  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& mirror ( const char  axis)
inline

Mirror an image along the specified axis.

Definition at line 17147 of file CImg.h.

Referenced by CImg< uintT >::_load_bmp(), and CImg< uintT >::get_mirror().

17147  {
17148  if (is_empty()) return *this;
17149  T *pf, *pb, *buf = 0;
17150  switch (cimg::uncase(axis)) {
17151  case 'x' : {
17152  pf = data; pb = ptr(width-1);
17153  const unsigned int width2 = width/2;
17154  for (unsigned int yzv = 0; yzv<height*depth*dim; ++yzv) {
17155  for (unsigned int x = 0; x<width2; ++x) { const T val = *pf; *(pf++) = *pb; *(pb--) = val; }
17156  pf+=width - width2;
17157  pb+=width + width2;
17158  }
17159  } break;
17160  case 'y' : {
17161  buf = new T[width];
17162  pf = data; pb = ptr(0,height-1);
17163  const unsigned int height2 = height/2;
17164  for (unsigned int zv = 0; zv<depth*dim; ++zv) {
17165  for (unsigned int y = 0; y<height2; ++y) {
17166  std::memcpy(buf,pf,width*sizeof(T));
17167  std::memcpy(pf,pb,width*sizeof(T));
17168  std::memcpy(pb,buf,width*sizeof(T));
17169  pf+=width;
17170  pb-=width;
17171  }
17172  pf+=width*(height - height2);
17173  pb+=width*(height + height2);
17174  }
17175  } break;
17176  case 'z' : {
17177  buf = new T[width*height];
17178  pf = data; pb = ptr(0,0,depth-1);
17179  const unsigned int depth2 = depth/2;
17180  cimg_forV(*this,v) {
17181  for (unsigned int z = 0; z<depth2; ++z) {
17182  std::memcpy(buf,pf,width*height*sizeof(T));
17183  std::memcpy(pf,pb,width*height*sizeof(T));
17184  std::memcpy(pb,buf,width*height*sizeof(T));
17185  pf+=width*height;
17186  pb-=width*height;
17187  }
17188  pf+=width*height*(depth - depth2);
17189  pb+=width*height*(depth + depth2);
17190  }
17191  } break;
17192  case 'v' : {
17193  buf = new T[width*height*depth];
17194  pf = data; pb = ptr(0,0,0,dim-1);
17195  const unsigned int dim2 = dim/2;
17196  for (unsigned int v = 0; v<dim2; ++v) {
17197  std::memcpy(buf,pf,width*height*depth*sizeof(T));
17198  std::memcpy(pf,pb,width*height*depth*sizeof(T));
17199  std::memcpy(pb,buf,width*height*depth*sizeof(T));
17200  pf+=width*height*depth;
17201  pb-=width*height*depth;
17202  }
17203  } break;
17204  default :
17205  throw CImgArgumentException("CImg<%s>::mirror() : unknow axis '%c', must be 'x','y','z' or 'v'.",
17206  pixel_type(),axis);
17207  }
17208  if (buf) delete[] buf;
17209  return *this;
17210  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forV(img, v)
Definition: CImg.h:596
char uncase(const char x)
Remove the &#39;case&#39; of an ASCII character.
Definition: CImg.h:4888
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

Tfloat MSE ( const CImg< t > &  img) const
inline

Compute the MSE (Mean-Squared Error) between two images.

Definition at line 13113 of file CImg.h.

Referenced by CImg< uintT >::PSNR().

13113  {
13114  if (img.size()!=size())
13115  throw CImgArgumentException("CImg<%s>::MSE() : Instance image (%u,%u,%u,%u) and given image (%u,%u,%u,%u) have different dimensions.",
13116  pixel_type(),width,height,depth,dim,img.width,img.height,img.depth,img.dim);
13117 
13118  Tfloat vMSE = 0;
13119  const t* ptr2 = img.end();
13120  cimg_for(*this,ptr1,T) {
13121  const Tfloat diff = (Tfloat)*ptr1 - (Tfloat)*(--ptr2);
13122  vMSE += diff*diff;
13123  }
13124  vMSE/=img.size();
13125  return vMSE;
13126  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& mul ( const CImg< t > &  img)
inline

Pointwise multiplication between two images.

Definition at line 12685 of file CImg.h.

Referenced by CImg< uintT >::get_mul(), and CImg< uintT >::mul().

12685  {
12686  const unsigned int siz = size(), isiz = img.size();
12687  if (siz && isiz) {
12688  if (is_overlapped(img)) return mul(+img);
12689  T *ptrd = data, *const ptrd_end = data + siz;
12690  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
12691  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd * *(ptrs++));
12692  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd * *(ptrs++));
12693  }
12694  return *this;
12695  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
CImg< T > & mul(const CImg< t > &img)
Pointwise multiplication between two images.
Definition: CImg.h:12685
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n

Here is the caller graph for this function:

CImg<T>& noise ( const double  sigma,
const unsigned int  noise_type = 0 
)
inline

Add random noise to the values of the instance image.

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 instance image.
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 instance image.
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_noise(40);
(img,res.normalize(0,255)).display();
ref_noise.jpg

Definition at line 15000 of file CImg.h.

Referenced by CImg< uintT >::get_noise(), and CImg< uintT >::get_select_graph().

15000  {
15001  if (!is_empty()) {
15002  double nsigma = sigma, max = (double)cimg::type<T>::max(), min = (double)cimg::type<T>::min();
15003  Tfloat m = 0, M = 0;
15004  if (nsigma==0 && noise_type!=3) return *this;
15005  if (nsigma<0 || noise_type==2) m = (Tfloat)minmax(M);
15006  if (nsigma<0) nsigma = -nsigma*(M-m)/100.0;
15007  switch (noise_type) {
15008  case 0 : { // Gaussian noise
15009  cimg_for(*this,ptr,T) {
15010  double val = *ptr + nsigma*cimg::grand();
15011  if (val>max) val = max;
15012  if (val<min) val = min;
15013  *ptr = (T)val;
15014  }
15015  } break;
15016  case 1 : { // Uniform noise
15017  cimg_for(*this,ptr,T) {
15018  double val = *ptr + nsigma*cimg::crand();
15019  if (val>max) val = max;
15020  if (val<min) val = min;
15021  *ptr = (T)val;
15022  }
15023  } break;
15024  case 2 : { // Salt & Pepper noise
15025  if (nsigma<0) nsigma = -nsigma;
15026  if (M==m) { m = 0; M = (float)(cimg::type<T>::is_float()?1:cimg::type<T>::max()); }
15027  cimg_for(*this,ptr,T) if (cimg::rand()*100<nsigma) *ptr = (T)(cimg::rand()<0.5?M:m);
15028  } break;
15029 
15030  case 3 : { // Poisson Noise
15031  cimg_for(*this,ptr,T) *ptr = (T)cimg::prand(*ptr);
15032  } break;
15033 
15034  case 4 : { // Rice noise
15035  const double sqrt2 = (double)std::sqrt(2.0);
15036  cimg_for(*this,ptr,T) {
15037  const double
15038  val0 = (double)*ptr/sqrt2,
15039  re = val0 + nsigma*cimg::grand(),
15040  im = val0 + nsigma*cimg::grand();
15041  double val = std::sqrt(re*re + im*im);
15042  if (val>max) val = max;
15043  if (val<min) val = min;
15044  *ptr = (T)val;
15045  }
15046  } break;
15047  default :
15048  throw CImgArgumentException("CImg<%s>::noise() : Invalid noise type %d "
15049  "(should be {0=Gaussian, 1=Uniform, 2=Salt&Pepper, 3=Poisson}).",pixel_type(),noise_type);
15050  }
15051  }
15052  return *this;
15053  }
if(dy > dx)
unsigned int prand(const double z)
Return a random variable following a Poisson distribution of parameter z.
Definition: CImg.h:4856
double grand()
Return a random variable following a gaussian distribution and a standard deviation of 1...
Definition: CImg.h:4845
T & min()
Return a reference to the minimum pixel value of the instance image.
Definition: CImg.h:12881
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double sqrt(double d)
Definition: double.h:73
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg< T > & rand(const T val_min, const T val_max)
Fill the instance image with random values between specified range.
Definition: CImg.h:14961
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
double crand()
Return a random variable between [-1,1] with respect to an uniform distribution.
Definition: CImg.h:4840
T & minmax(t &max_val)
Return a reference to the minimum pixel value and return also the maximum pixel value.
Definition: CImg.h:12920
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& norm ( const int  norm_type = 2)
inline

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

Parameters
norm_typeType of computed vector norm (can be 0=Linf, 1=L1 or 2=L2).
Returns
A reference to the modified instance image.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_norm();
(img,res.normalize(0,255)).display();
ref_norm.jpg

Definition at line 15127 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), CImg< uintT >::_get_select(), and CImg< uintT >::rotation_matrix().

15127  {
15128  return get_norm(norm_type).transfer_to(*this);
15129  }
CImg< Tfloat > get_norm(const int norm_type=2) const
Definition: CImg.h:15131

Here is the caller graph for this function:

CImg<T>& normalize ( const T  value_min,
const T  value_max 
)
inline

Linearly normalize values of the instance image 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 instance image.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_normalize(160,220);
(img,res).display();
ref_normalize2.jpg

Definition at line 15073 of file CImg.h.

15073  {
15074  if (is_empty()) return *this;
15075  const T a = value_min<value_max?value_min:value_max, b = value_min<value_max?value_max:value_min;
15076  T m, M = maxmin(m);
15077  const Tfloat fm = (Tfloat)m, fM = (Tfloat)M;
15078  if (m==M) return fill(0);
15079  if (m!=a || M!=b) cimg_for(*this,ptr,T) *ptr = (T)((*ptr-fm)/(fM-fm)*(b-a)+a);
15080  return *this;
15081  }
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& normalize ( )
inline

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

Returns
A reference to the modified instance image.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_normalize();
(img,res.normalize(0,255)).display();
ref_normalize.jpg

Definition at line 15099 of file CImg.h.

Referenced by CImg< uintT >::get_normalize().

15099  {
15100  cimg_forXYZ(*this,x,y,z) {
15101  float n = 0;
15102  cimg_forV(*this,v) n+=(float)((*this)(x,y,z,v)*(*this)(x,y,z,v));
15103  n = (float)std::sqrt(n);
15104  if (n>0) cimg_forV(*this,v) (*this)(x,y,z,v) = (T)((*this)(x,y,z,v)/n);
15105  else cimg_forV(*this,v) (*this)(x,y,z,v) = 0;
15106  }
15107  return *this;
15108  }
if(dy > dx)
void int int REAL REAL * y
Definition: read.cpp:74
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > & sqrt()
Compute the square root of each pixel value.
Definition: CImg.h:12530
void int int REAL * x
Definition: read.cpp:74
const NT & n
#define cimg_forV(img, v)
Definition: CImg.h:596

Here is the caller graph for this function:

int offset ( const int  x,
const int  y = 0,
const int  z = 0,
const int  v = 0 
) const
inline

Return the offset of the pixel coordinates (x,y,z,v) with respect to the data pointer data.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.
zZ-coordinate of the pixel.
vV-coordinate of the pixel.
  • No checking is done on the validity of the given coordinates.
Example:
CImg<float> img(100,100,1,3,0); // Define a 100x100 color image with float-valued black pixels.
long off = img.offset(10,10,0,2); // Get the offset of the blue value of the pixel located at (10,10).
float val = img[off]; // Get the blue value of the pixel.

Definition at line 11147 of file CImg.h.

Referenced by CImg< uintT >::_load_bmp(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), and CImg< uintT >::get_shared_points().

11147  {
11148  return x + y*width + z*width*height + v*width*height*depth;
11149  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733

Here is the caller graph for this function:

operator bool ( ) const
inline

Return true if image is not empty.

Definition at line 10461 of file CImg.h.

10461  {
10462  return data && width && height && depth && dim;
10463  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
bool operator!= ( const CImg< t > &  img) const
inline

Operator!=().

Definition at line 11007 of file CImg.h.

11007  {
11008  return !((*this)==img);
11009  }
CImg<_cimg_Tt> operator% ( const t  val) const
inline

Operator%().

Definition at line 10814 of file CImg.h.

10814  {
10815  return CImg<_cimg_Tt>(*this,false)%=val;
10816  }
CImg<Tfloat> operator% ( const char *const  expression) const
inline

Operator%().

Definition at line 10819 of file CImg.h.

10819  {
10820  return CImg<Tfloat>(*this,false)%=expression;
10821  }
CImg<_cimg_Tt> operator% ( const CImg< t > &  img) const
inline

Operator%().

Definition at line 10825 of file CImg.h.

10825  {
10826  return CImg<_cimg_Tt>(*this,false)%=img;
10827  }
CImg<T>& operator%= ( const t  val)
inline

Operator%=().

Definition at line 10775 of file CImg.h.

10775  {
10776  cimg_for(*this,ptr,T) (*ptr) = (T)cimg::mod(*ptr,(T)val);
10777  return *this;
10778  }
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator%= ( const char *const  expression)
inline

Operator%=().

Definition at line 10781 of file CImg.h.

10781  {
10782  const unsigned int omode = cimg::exception_mode();
10783  cimg::exception_mode() = 0;
10784  try {
10785  _cimg_math_parser mp(expression,"operator%=");
10786  T *ptrd = data;
10787  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)cimg::mod(*ptrd,(T)mp.eval(*this,x,y,z,v)); ++ptrd; }
10788  } catch (CImgException&) {
10789  cimg::exception_mode() = omode;
10790  CImg<T> values(width,height,depth,dim);
10791  values = expression;
10792  *this%=values;
10793  }
10794  cimg::exception_mode() = omode;
10795  return *this;
10796  }
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator%= ( const CImg< t > &  img)
inline

Operator%=().

Definition at line 10800 of file CImg.h.

10800  {
10801  const unsigned int siz = size(), isiz = img.size();
10802  if (siz && isiz) {
10803  if (is_overlapped(img)) return *this%=+img;
10804  T *ptrd = data, *const ptrd_end = data + siz;
10805  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10806  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = cimg::mod(*ptrd,(T)*(ptrs++));
10807  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = cimg::mod(*ptrd,(T)*(ptrs++));
10808  }
10809  return *this;
10810  }
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
CImg<T> operator& ( const t  val) const
inline

Operator&().

Definition at line 10870 of file CImg.h.

10870  {
10871  return (+*this)&=val;
10872  }
CImg<T>& operator&= ( const t  val)
inline

Operator&=().

Definition at line 10831 of file CImg.h.

10831  {
10832  cimg_for(*this,ptr,T) *ptr = (T)((unsigned long)*ptr & (unsigned long)val);
10833  return *this;
10834  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator&= ( const char *const  expression)
inline

Operator&=().

Definition at line 10837 of file CImg.h.

10837  {
10838  const unsigned int omode = cimg::exception_mode();
10839  cimg::exception_mode() = 0;
10840  try {
10841  _cimg_math_parser mp(expression,"operator&=");
10842  T *ptrd = data;
10843  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)((unsigned long)*ptrd & (unsigned long)mp.eval(*this,x,y,z,v)); ++ptrd; }
10844  } catch (CImgException&) {
10845  cimg::exception_mode() = omode;
10846  CImg<T> values(width,height,depth,dim);
10847  values = expression;
10848  *this&=values;
10849  }
10850  cimg::exception_mode() = omode;
10851  return *this;
10852  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator&= ( const CImg< t > &  img)
inline

Operator&=().

Definition at line 10856 of file CImg.h.

10856  {
10857  const unsigned int siz = size(), isiz = img.size();
10858  if (siz && isiz) {
10859  if (is_overlapped(img)) return *this&=+img;
10860  T *ptrd = data, *const ptrd_end = data + siz;
10861  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10862  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd & (unsigned long)*(ptrs++));
10863  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd & (unsigned long)*(ptrs++));
10864  }
10865  return *this;
10866  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
T& operator() ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  v = 0 
)
inline

Fast access to pixel value for reading or writing.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.
zZ-coordinate of the pixel.
vV-coordinate of the pixel.
  • If one image dimension is equal to 1, it can be omitted in the coordinate list (see example below).
  • If the macro 'cimg_debug'>=3, boundary checking is performed and warning messages may appear (but function performances decrease).
example:
CImg<float> img(100,100,1,3,0); // Define a 100x100 color image with float-valued black pixels.
const float valR = img(10,10,0,0); // Read the red component at coordinates (10,10).
const float valG = img(10,10,0,1); // Read the green component at coordinates (10,10)
const float valB = img(10,10,2); // Read the blue component at coordinates (10,10) (Z-coordinate omitted here).
const float avg = (valR + valG + valB)/3; // Compute average pixel value.
img(10,10,0) = img(10,10,1) = img(10,10,2) = avg; // Replace the pixel (10,10) by the average grey value.

Definition at line 10451 of file CImg.h.

10451  {
10452  return data[x + y*width + z*width*height + v*width*height*depth];
10453  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
const T& operator() ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  v = 0 
) const
inline

Definition at line 10455 of file CImg.h.

10455  {
10456  return data[x + y*width + z*width*height + v*width*height*depth];
10457  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<_cimg_Tt> operator* ( const t  val) const
inline

Operator*().

Definition at line 10701 of file CImg.h.

10701  {
10702  return CImg<_cimg_Tt>(*this,false)*=val;
10703  }
CImg<Tfloat> operator* ( const char *const  expression) const
inline

Operator*().

Definition at line 10706 of file CImg.h.

10706  {
10707  return CImg<Tfloat>(*this,false)*=expression;
10708  }
CImg<_cimg_Tt> operator* ( const CImg< t > &  img) const
inline

Operator*().

Definition at line 10712 of file CImg.h.

10712  {
10713  if (width!=img.height || depth!=1 || dim!=1)
10714  throw CImgArgumentException("operator*() : can't multiply a matrix image (%u,%u,%u,%u) by a matrix image (%u,%u,%u,%u)",
10715  width,height,depth,dim,img.width,img.height,img.depth,img.dim);
10716  CImg<_cimg_Tt> res(img.width,height);
10717  _cimg_Tt val;
10718 #ifdef cimg_use_openmp
10719 #pragma omp parallel for if (size()>=1000 && img.size()>=1000) private(val)
10720 #endif
10721  cimg_forXY(res,i,j) { val = 0; cimg_forX(*this,k) val+=(*this)(k,j)*img(i,k); res(i,j) = val; }
10722  return res;
10723  }
#define cimg_forX(img, x)
Definition: CImg.h:593
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
blockLoc i
Definition: read.cpp:79
#define _cimg_Tt
Definition: CImg.h:2300
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
j indices j
Definition: Indexing.h:6
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator*= ( const t  val)
inline

Operator*=().

Definition at line 10670 of file CImg.h.

10670  {
10671  cimg_for(*this,ptr,T) (*ptr) = (T)((*ptr)*val);
10672  return *this;
10673  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator*= ( const char *const  expression)
inline

Operator*=().

Definition at line 10676 of file CImg.h.

10676  {
10677  const unsigned int omode = cimg::exception_mode();
10678  cimg::exception_mode() = 0;
10679  try {
10680  _cimg_math_parser mp(expression,"operator*=");
10681  T *ptrd = data;
10682  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)(*ptrd * mp.eval(*this,x,y,z,v)); ++ptrd; }
10683  } catch (CImgException&) {
10684  cimg::exception_mode() = omode;
10685  CImg<Tfloat> values(width,height,depth,dim);
10686  values = expression;
10687  *this*=values;
10688  }
10689  cimg::exception_mode() = omode;
10690  return *this;
10691  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator*= ( const CImg< t > &  img)
inline

Operator*=().

Definition at line 10695 of file CImg.h.

10695  {
10696  return ((*this)*img).transfer_to(*this);
10697  }
CImg<T> operator+ ( ) const
inline

Operator+() (unary).

Remarks
  • This operator always returns a non-shared copy of an image.

Definition at line 10573 of file CImg.h.

10573  {
10574  return CImg<T>(*this,false);
10575  }
CImg<_cimg_Tt> operator+ ( const t  val) const
inline

Operator+().

Definition at line 10579 of file CImg.h.

10579  {
10580  return CImg<_cimg_Tt>(*this,false)+=val;
10581  }
CImg<Tfloat> operator+ ( const char *const  expression) const
inline

Operator+().

Definition at line 10584 of file CImg.h.

10584  {
10585  return CImg<Tfloat>(*this,false)+=expression;
10586  }
CImg<_cimg_Tt> operator+ ( const CImg< t > &  img) const
inline

Operator+().

Definition at line 10590 of file CImg.h.

10590  {
10591  return CImg<_cimg_Tt>(*this,false)+=img;
10592  }
CImg<T>& operator++ ( )
inline

Operator++() (prefix).

Definition at line 10556 of file CImg.h.

10556  {
10557  cimg_for(*this,ptr,T) ++(*ptr);
10558  return *this;
10559  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T> operator++ ( int  )
inline

Operator++() (postfix).

Definition at line 10562 of file CImg.h.

10562  {
10563  const CImg<T> copy(*this,false);
10564  ++*this;
10565  return copy;
10566  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
CImg<T>& operator+= ( const t  val)
inline

Operator+=().

Definition at line 10518 of file CImg.h.

10518  {
10519  cimg_for(*this,ptr,T) (*ptr) = (T)((*ptr) + val);
10520  return *this;
10521  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator+= ( const char *const  expression)
inline

Operator+=().

Definition at line 10524 of file CImg.h.

10524  {
10525  const unsigned int omode = cimg::exception_mode();
10526  cimg::exception_mode() = 0;
10527  try {
10528  _cimg_math_parser mp(expression,"operator+=");
10529  T *ptrd = data;
10530  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)(*ptrd + mp.eval(*this,x,y,z,v)); ++ptrd; }
10531  } catch (CImgException&) {
10532  cimg::exception_mode() = omode;
10533  CImg<T> values(width,height,depth,dim);
10534  values = expression;
10535  *this+=values;
10536  }
10537  cimg::exception_mode() = omode;
10538  return *this;
10539  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator+= ( const CImg< t > &  img)
inline

Operator+=().

Definition at line 10543 of file CImg.h.

10543  {
10544  const unsigned int siz = size(), isiz = img.size();
10545  if (siz && isiz) {
10546  if (is_overlapped(img)) return *this+=+img;
10547  T *ptrd = data, *const ptrd_end = data + siz;
10548  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10549  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd + *(ptrs++));
10550  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd + *(ptrs++));
10551  }
10552  return *this;
10553  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
CImgList<_cimg_Tt> operator, ( const CImg< t > &  img) const
inline

Operator,().

Definition at line 11013 of file CImg.h.

11013  {
11014  return CImgList<_cimg_Tt>(*this,img);
11015  }
CImgList<_cimg_Tt> operator, ( CImgList< t > &  list) const
inline

Operator,().

Definition at line 11019 of file CImg.h.

11019  {
11020  return CImgList<_cimg_Tt>(list).insert(*this,0);
11021  }
CImg<T> operator- ( void  ) const
inline

Operator-() (unary).

Definition at line 10647 of file CImg.h.

10647  {
10648  return CImg<T>(width,height,depth,dim,(T)0)-=*this;
10649  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<_cimg_Tt> operator- ( const t  val) const
inline

Operator-().

Definition at line 10653 of file CImg.h.

10653  {
10654  return CImg<_cimg_Tt>(*this,false)-=val;
10655  }
CImg<Tfloat> operator- ( const char *const  expression) const
inline

Operator-().

Definition at line 10658 of file CImg.h.

10658  {
10659  return CImg<Tfloat>(*this,false)-=expression;
10660  }
CImg<_cimg_Tt> operator- ( const CImg< t > &  img) const
inline

Operator-().

Definition at line 10664 of file CImg.h.

10664  {
10665  return CImg<_cimg_Tt>(*this,false)-=img;
10666  }
CImg<T>& operator-- ( )
inline

Operator–() (prefix).

Definition at line 10634 of file CImg.h.

10634  {
10635  cimg_for(*this,ptr,T) *ptr = *ptr-(T)1;
10636  return *this;
10637  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T> operator-- ( int  )
inline

Operator–() (postfix).

Definition at line 10640 of file CImg.h.

10640  {
10641  const CImg<T> copy(*this,false);
10642  --*this;
10643  return copy;
10644  }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
Definition: roccomf90.h:20
CImg<T>& operator-= ( const t  val)
inline

Operator-=().

Definition at line 10596 of file CImg.h.

10596  {
10597  cimg_for(*this,ptr,T) (*ptr) = (T)((*ptr)-val);
10598  return *this;
10599  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator-= ( const char *const  expression)
inline

Operator-=().

Definition at line 10602 of file CImg.h.

10602  {
10603  const unsigned int omode = cimg::exception_mode();
10604  cimg::exception_mode() = 0;
10605  try {
10606  _cimg_math_parser mp(expression,"operator-=");
10607  T *ptrd = data;
10608  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)(*ptrd - mp.eval(*this,x,y,z,v)); ++ptrd; }
10609  } catch (CImgException&) {
10610  cimg::exception_mode() = omode;
10611  CImg<T> values(width,height,depth,dim);
10612  values = expression;
10613  *this-=values;
10614  }
10615  cimg::exception_mode() = omode;
10616  return *this;
10617  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator-= ( const CImg< t > &  img)
inline

Operator-=().

Definition at line 10621 of file CImg.h.

10621  {
10622  const unsigned int siz = size(), isiz = img.size();
10623  if (siz && isiz) {
10624  if (is_overlapped(img)) return *this-=+img;
10625  T *ptrd = data, *const ptrd_end = data + siz;
10626  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10627  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)(*ptrd - *(ptrs++));
10628  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)(*ptrd - *(ptrs++));
10629  }
10630  return *this;
10631  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
CImg<_cimg_Tt> operator/ ( const t  val) const
inline

Operator/().

Definition at line 10758 of file CImg.h.

10758  {
10759  return CImg<_cimg_Tt>(*this,false)/=val;
10760  }
CImg<Tfloat> operator/ ( const char *const  expression) const
inline

Operator/().

Definition at line 10763 of file CImg.h.

10763  {
10764  return CImg<Tfloat>(*this,false)/=expression;
10765  }
CImg<_cimg_Tt> operator/ ( const CImg< t > &  img) const
inline

Operator/().

Definition at line 10769 of file CImg.h.

10769  {
10770  return (*this)*img.get_invert();
10771  }
CImg<T>& operator/= ( const t  val)
inline

Operator/=().

Definition at line 10727 of file CImg.h.

10727  {
10728  cimg_for(*this,ptr,T) (*ptr) = (T)((*ptr)/val);
10729  return *this;
10730  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator/= ( const char *const  expression)
inline

Operator/=().

Definition at line 10733 of file CImg.h.

10733  {
10734  const unsigned int omode = cimg::exception_mode();
10735  cimg::exception_mode() = 0;
10736  try {
10737  _cimg_math_parser mp(expression,"operator/=");
10738  T *ptrd = data;
10739  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)(*ptrd / mp.eval(*this,x,y,z,v)); ++ptrd; }
10740  } catch (CImgException&) {
10741  cimg::exception_mode() = omode;
10742  CImg<Tfloat> values(width,height,depth,dim);
10743  values = expression;
10744  *this/=values;
10745  }
10746  cimg::exception_mode() = omode;
10747  return *this;
10748  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator/= ( const CImg< t > &  img)
inline

Operator/=().

Definition at line 10752 of file CImg.h.

10752  {
10753  return (*this*img.get_invert()).transfer_to(*this);
10754  }
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
CImgList<T> operator< ( const char  axis) const
inline

Operator<().

Definition at line 11024 of file CImg.h.

11024  {
11025  return get_split(axis);
11026  }
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
Definition: CImg.h:18582
CImg<T> operator<< ( const int  n) const
inline

Operator<<().

Definition at line 10979 of file CImg.h.

10979  {
10980  return (+*this)<<=n;
10981  }
const NT & n
CImg<T>& operator<<= ( const int  n)
inline

Operator<<=().

Definition at line 10973 of file CImg.h.

10973  {
10974  cimg_for(*this,ptr,T) *ptr = (T)(((long)*ptr)<<n);
10975  return *this;
10976  }
const NT & n
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator= ( const T  val)
inline

Operator=().

Assignment operator. Fill all pixels of the instance image with the same value. The image size is not modified.

Definition at line 10470 of file CImg.h.

10470  {
10471  return fill(val);
10472  }
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
CImg<T>& operator= ( const char *const  expression)
inline

Operator=().

Assignment operator. If expression is a formula or a list of values, the image pixels are filled according to the expression and the image size is not modified. If expression is a filename, the image is replaced by the input file data (so image size is modified).

Definition at line 10482 of file CImg.h.

10482  {
10483  const unsigned int omode = cimg::exception_mode();
10484  cimg::exception_mode() = 0;
10485  try {
10486  fill(expression,true);
10487  } catch (CImgException&) {
10488  cimg::exception_mode() = omode;
10489  load(expression);
10490  }
10491  cimg::exception_mode() = omode;
10492  return *this;
10493  }
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
CImg< T > & load(const char *const filename)
Load an image from a file.
Definition: CImg.h:29130
CImg<T>& operator= ( const CImg< t > &  img)
inline

Operator=().

Assignement operator. If instance image is non-shared, replace the instance image by a copy of the argument image. If instance image is shared, replace the image content by the content of the argument image.

Definition at line 10502 of file CImg.h.

10502  {
10503  return assign(img);
10504  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& operator= ( const CImg< T > &  img)
inline

Definition at line 10506 of file CImg.h.

10506  {
10507  return assign(img);
10508  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg<T>& operator= ( const CImgDisplay disp)
inline

Operator=().

Definition at line 10511 of file CImg.h.

10511  {
10512  disp.snapshot(*this);
10513  return *this;
10514  }
bool operator== ( const CImg< t > &  img) const
inline

Operator==().

Definition at line 10996 of file CImg.h.

10996  {
10997  const unsigned int siz = size();
10998  bool vequal = true;
10999  if (siz!=img.size()) return false;
11000  t *ptrs = img.data + siz;
11001  for (T *ptrd = data + siz; vequal && ptrd>data; vequal = vequal && ((*(--ptrd))==(*(--ptrs)))) {}
11002  return vequal;
11003  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg<T> operator>> ( const int  n) const
inline

Operator>>().

Definition at line 10990 of file CImg.h.

10990  {
10991  return (+*this)>>=n;
10992  }
const NT & n
CImg<T>& operator>>= ( const int  n)
inline

Operator>>=().

Definition at line 10984 of file CImg.h.

10984  {
10985  cimg_for(*this,ptr,T) *ptr = (T)(((long)*ptr)>>n);
10986  return *this;
10987  }
const NT & n
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
T& operator[] ( const unsigned int  off)
inline

Fast access to pixel value for reading or writing, using an offset to the image pixel.

Parameters
offOffset of the pixel according to the begining of the pixel buffer, given by ptr().
  • If the macro 'cimg_debug'>=3, boundary checking is performed and warning messages may appear (but function performances decrease).
  • As pixel values are aligned in memory, this operator can sometime useful to access values easier than with operator()() (see example below).
example:
CImg<float> vec(1,10); // Define a vector of float values (10 lines, 1 row).
const float val1 = vec(0,4); // Get the fifth element using operator()().
const float val2 = vec[4]; // Get the fifth element using operator[]. Here, val2==val1.

Definition at line 10405 of file CImg.h.

10405  {
10406  return data[off];
10407  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
const T& operator[] ( const unsigned int  off) const
inline

Definition at line 10409 of file CImg.h.

10409  {
10410  return data[off];
10411  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
CImg<T> operator^ ( const t  val) const
inline

Operator^().

Definition at line 10960 of file CImg.h.

10960  {
10961  return (+*this)^=val;
10962  }
CImg<T>& operator^= ( const t  val)
inline

Operator^=().

Definition at line 10921 of file CImg.h.

10921  {
10922  cimg_for(*this,ptr,T) *ptr = (T)((unsigned long)*ptr ^ (unsigned long)val);
10923  return *this;
10924  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator^= ( const char *const  expression)
inline

Operator^=().

Definition at line 10927 of file CImg.h.

10927  {
10928  const unsigned int omode = cimg::exception_mode();
10929  cimg::exception_mode() = 0;
10930  try {
10931  _cimg_math_parser mp(expression,"operator^=");
10932  T *ptrd = data;
10933  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)((unsigned long)*ptrd ^ (unsigned long)mp.eval(*this,x,y,z,v)); ++ptrd; }
10934  } catch (CImgException&) {
10935  cimg::exception_mode() = omode;
10936  CImg<T> values(width,height,depth,dim);
10937  values = expression;
10938  *this^=values;
10939  }
10940  cimg::exception_mode() = omode;
10941  return *this;
10942  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator^= ( const CImg< t > &  img)
inline

Operator^=().

Definition at line 10946 of file CImg.h.

10946  {
10947  const unsigned int siz = size(), isiz = img.size();
10948  if (siz && isiz) {
10949  if (is_overlapped(img)) return *this^=+img;
10950  T *ptrd = data, *const ptrd_end = data + siz;
10951  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10952  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd ^ (unsigned long)*(ptrs++));
10953  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd ^ (unsigned long)*(ptrs++));
10954  }
10955  return *this;
10956  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
CImg<T> operator| ( const t  val) const
inline

Operator|().

Definition at line 10915 of file CImg.h.

10915  {
10916  return (+*this)|=val;
10917  }
CImg<T>& operator|= ( const t  val)
inline

Operator|=().

Definition at line 10876 of file CImg.h.

10876  {
10877  cimg_for(*this,ptr,T) *ptr = (T)((unsigned long)*ptr | (unsigned long)val);
10878  return *this;
10879  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& operator|= ( const char *const  expression)
inline

Operator|=().

Definition at line 10882 of file CImg.h.

10882  {
10883  const unsigned int omode = cimg::exception_mode();
10884  cimg::exception_mode() = 0;
10885  try {
10886  _cimg_math_parser mp(expression,"operator|=");
10887  T *ptrd = data;
10888  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)((unsigned long)*ptrd | (unsigned long)mp.eval(*this,x,y,z,v)); ++ptrd; }
10889  } catch (CImgException&) {
10890  cimg::exception_mode() = omode;
10891  CImg<T> values(width,height,depth,dim);
10892  values = expression;
10893  *this|=values;
10894  }
10895  cimg::exception_mode() = omode;
10896  return *this;
10897  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& operator|= ( const CImg< t > &  img)
inline

Operator|=().

Definition at line 10901 of file CImg.h.

10901  {
10902  const unsigned int siz = size(), isiz = img.size();
10903  if (siz && isiz) {
10904  if (is_overlapped(img)) return *this|=+img;
10905  T *ptrd = data, *const ptrd_end = data + siz;
10906  if (siz>isiz) for (unsigned int n = siz/isiz; n; --n)
10907  for (const t *ptrs = img.data, *ptrs_end = ptrs + isiz; ptrs<ptrs_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd | (unsigned long)*(ptrs++));
10908  for (const t *ptrs = img.data; ptrd<ptrd_end; ++ptrd) *ptrd = (T)((unsigned long)*ptrd | (unsigned long)*(ptrs++));
10909  }
10910  return *this;
10911  }
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
const NT & n
CImg<T> operator~ ( ) const
inline

Operator~().

Definition at line 10965 of file CImg.h.

10965  {
10966  CImg<T> res(width,height,depth,dim);
10967  const T *ptrs = end();
10968  cimg_for(res,ptrd,T) { const unsigned long val = (unsigned long)*(--ptrs); *ptrd = (T)~val; }
10969  return res;
10970  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& permute_axes ( const char *  order)
inline

Permute axes order.

This function permutes image axes.

Parameters
permut= String describing the permutation (4 characters).

Definition at line 17600 of file CImg.h.

17600  {
17601  return get_permute_axes(order).transfer_to(*this);
17602  }
CImg< T > get_permute_axes(const char *order) const
Definition: CImg.h:17604
static const char* pixel_type ( )
inlinestatic

Return the type of the pixel values.

Returns
a string describing the type of the image pixels (template parameter T).
  • The string returned may contains spaces ("unsigned char").
  • If the template parameter T does not correspond to a registered type, the string "unknown" is returned.

Definition at line 11041 of file CImg.h.

Referenced by CImg< uintT >::_autocrop(), CImg< T >::_cimg_math_parser::_cimg_math_parser(), CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_line(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_point(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_spline(), CImg< uintT >::_draw_text(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_load_analyze(), CImg< uintT >::_load_ascii(), CImg< uintT >::_load_bmp(), CImg< uintT >::_load_dlm(), CImg< uintT >::_load_inr(), CImg< uintT >::_load_inr_header(), CImg< uintT >::_load_jpeg(), CImg< uintT >::_load_off(), CImg< uintT >::_load_pandore(), CImg< uintT >::_load_png(), CImg< uintT >::_load_pnm(), CImg< uintT >::_load_raw(), CImg< uintT >::_load_rgb(), CImg< uintT >::_load_rgba(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_inr(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_off(), CImg< uintT >::_save_pandore(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_raw(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append_object3d(), CImg< uintT >::assign(), CImg< uintT >::at(), CImg< uintT >::atX(), CImg< uintT >::atXY(), CImg< uintT >::atXYZ(), CImg< uintT >::atXYZV(), CImg< uintT >::autocrop(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::CImg(), CImg< uintT >::CMYtoRGB(), CImg< T >::_cimg_math_parser::compile(), CImg< uintT >::cross(), CImg< uintT >::cubic_atX(), CImg< uintT >::cubic_atXY(), CImg< uintT >::deriche(), CImg< uintT >::det(), CImg< uintT >::display_graph(), CImg< uintT >::dot(), CImg< uintT >::draw_circle(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_point(), CImg< uintT >::draw_polygon(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_spline(), CImg< uintT >::draw_triangle(), CImg< uintT >::eigen(), CImg< uintT >::elevation3d(), CImg< T >::_cimg_math_parser::eval(), CImg< uintT >::eval(), CImg< uintT >::FFT(), CImg< uintT >::fill(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_convolve(), CImg< uintT >::get_correlate(), CImg< uintT >::get_dijkstra(), CImg< uintT >::get_dilate(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_erode(), CImg< uintT >::get_gradient(), CImg< uintT >::get_haar(), CImg< uintT >::get_hessian(), CImg< uintT >::get_histogram(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_map(), CImg< uintT >::get_resize(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_rotate(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_tensor(), CImg< uintT >::get_warp(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::invert(), CImg< uintT >::is_object3d(), CImg< uintT >::kth_smallest(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::linear_atX(), CImg< uintT >::linear_atXY(), CImg< uintT >::linear_atXYZ(), CImg< uintT >::linear_atXYZV(), CImg< uintT >::load(), CImg< uintT >::load_dcraw_external(), CImg< uintT >::load_graphicsmagick_external(), CImg< uintT >::load_gzip_external(), CImg< uintT >::load_imagemagick_external(), CImg< uintT >::load_magick(), CImg< uintT >::load_medcon_external(), CImg< uintT >::load_other(), CImg< uintT >::load_tiff(), CImg< uintT >::magnitude(), CImg< uintT >::matrix(), CImg< uintT >::max(), CImg< uintT >::maxmin(), CImg< uintT >::mean(), CImg< uintT >::min(), CImg< uintT >::minmax(), CImg< uintT >::mirror(), CImg< uintT >::MSE(), CImg< uintT >::noise(), CImg< uintT >::print(), CImg< uintT >::quantize(), CImg< uintT >::resize_object3d(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::save(), CImg< uintT >::save_analyze(), CImg< uintT >::save_ffmpeg(), CImg< uintT >::save_ffmpeg_external(), CImg< uintT >::save_graphicsmagick_external(), CImg< uintT >::save_gzip_external(), CImg< uintT >::save_imagemagick_external(), CImg< uintT >::save_magick(), CImg< uintT >::save_medcon_external(), CImg< uintT >::save_other(), CImg< uintT >::save_tiff(), CImg< uintT >::solve(), CImg< uintT >::solve_tridiagonal(), CImg< uintT >::sum(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::trace(), CImg< uintT >::translate_object3d(), CImg< uintT >::unroll(), CImg< uintT >::variancemean(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().

11041  {
11042  return cimg::type<T>::string();
11043  }
static const char * string()
Definition: CImg.h:2085
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,
const bool  double_sided = false 
)
inlinestatic

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.
double_sidedDetermine if the plane primitives must be double-sided or not.
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(points3d,faces3d);
ref_plane3d.jpg

Definition at line 21972 of file CImg.h.

21975  {
21976  primitives.assign();
21977  if (!subdivisions_x || !subdivisions_y) return CImg<floatT>();
21978  CImgList<floatT> vertices;
21979  const unsigned int w = subdivisions_x + 1, h = subdivisions_y + 1;
21980  const float fx = (float)size_x/w, fy = (float)size_y/h;
21981  for (unsigned int y = 0; y<h; ++y) for (unsigned int x = 0; x<w; ++x)
21982  CImg<floatT>::vector(fx*x,fy*y,0).transfer_to(vertices);
21983  for (unsigned int y = 0; y<subdivisions_y; ++y) for (unsigned int x = 0; x<subdivisions_x; ++x) {
21984  const int off1 = x+y*w, off2 = x+1+y*w, off3 = x+1+(y+1)*w, off4 = x+(y+1)*w;
21985  CImg<tf>::vector(off1,off4,off3,off2).transfer_to(primitives);
21986  if (double_sided) CImg<tf>::vector(off1,off2,off3,off4).transfer_to(primitives);
21987  }
21988  return vertices>'x';
21989  }
void int int REAL REAL * y
Definition: read.cpp:74
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int REAL * x
Definition: read.cpp:74
CImg<T>& pow ( const double  p)
inline

Compute the power by p of each pixel value.

Definition at line 12722 of file CImg.h.

Referenced by CImg< uintT >::get_pow(), and CImg< uintT >::pow().

12722  {
12723  if (p==0) return fill(1);
12724  if (p==0.5) { cimg_for(*this,ptr,T) { const T val = *ptr; *ptr = (T)std::sqrt((double)val); } return *this; }
12725  if (p==1) return *this;
12726  if (p==2) { cimg_for(*this,ptr,T) { const T val = *ptr; *ptr = val*val; } return *this; }
12727  if (p==3) { cimg_for(*this,ptr,T) { const T val = *ptr; *ptr = val*val*val; } return *this; }
12728  if (p==4) { cimg_for(*this,ptr,T) { const T val = *ptr; *ptr = val*val*val*val; } return *this; }
12729  cimg_for(*this,ptr,T) (*ptr) = (T)std::pow((double)(*ptr),p);
12730  return *this;
12731  }
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
double sqrt(double d)
Definition: double.h:73
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
double pow(double value, const Exponent &exp)

Here is the caller graph for this function:

CImg<T>& pow ( const CImg< t > &  img)
inline

Compute the power of each pixel value.

Definition at line 12739 of file CImg.h.

12739  {
12740  if (is_overlapped(img)) return pow(+img);
12741  t *ptrs = img.data;
12742  T *ptrf = data + cimg::min(size(),img.size());
12743  for (T* ptrd = data; ptrd<ptrf; ++ptrd) (*ptrd) = (T)std::pow((double)*ptrd,(double)(*(ptrs++)));
12744  return *this;
12745  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
bool is_overlapped(const CImg< t > &img) const
Return true if the memory buffers of the two images overlaps.
Definition: CImg.h:12115
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
double pow(double value, const Exponent &exp)
CImg<T>& pow ( const char *const  expression)
inline

Compute the power of each pixel value.

Definition at line 12753 of file CImg.h.

12753  {
12754  const unsigned int omode = cimg::exception_mode();
12755  cimg::exception_mode() = 0;
12756  try {
12757  _cimg_math_parser mp(expression,"pow");
12758  T *ptrd = data;
12759  cimg_forXYZV(*this,x,y,z,v) { *ptrd = (T)std::pow((double)*ptrd,mp.eval(*this,x,y,z,v)); ++ptrd; }
12760  } catch (CImgException&) {
12761  CImg<Tfloat> values(width,height,depth,dim);
12762  try {
12763  values.fill(expression,true);
12764  } catch (CImgException&) {
12765  cimg::exception_mode() = omode;
12766  values.load(expression);
12767  }
12768  pow(values);
12769  }
12770  cimg::exception_mode() = omode;
12771  return *this;
12772  }
CImg< T > & pow(const double p)
Compute the power by p of each pixel value.
Definition: CImg.h:12722
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
#define cimg_forXYZV(img, x, y, z, v)
Definition: CImg.h:607
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
const CImg<T>& print ( const char *  title = 0,
const bool  display_stats = true 
) const
inline

Display informations about the image on the standard error output.

Parameters
titleName for the considered image (optional).
display_statsCompute and display image statistics (optional).

Definition at line 31432 of file CImg.h.

Referenced by CImg< uintT >::_display().

31432  {
31433  int xm = 0, ym = 0, zm = 0, vm = 0, xM = 0, yM = 0, zM = 0, vM = 0;
31434  static CImg<doubleT> st;
31435  if (!is_empty() && display_stats) {
31436  st = get_stats();
31437  xm = (int)st[4]; ym = (int)st[5], zm = (int)st[6], vm = (int)st[7];
31438  xM = (int)st[8]; yM = (int)st[9], zM = (int)st[10], vM = (int)st[11];
31439  }
31440  const unsigned int siz = size(), msiz = siz*sizeof(T), siz1 = siz-1;
31441  const unsigned int mdisp = msiz<8*1024?0:(msiz<8*1024*1024?1:2), width1 = width-1;
31442  char ntitle[64] = { 0 };
31443  if (!title) std::sprintf(ntitle,"CImg<%s>",pixel_type());
31444  std::fprintf(cimg_stdout,"%s: this = %p, size = (%u,%u,%u,%u) [%u %s], data = (%s*)%p..%p (%s) = [ ",
31445  title?title:ntitle,(void*)this,width,height,depth,dim,
31446  mdisp==0?msiz:(mdisp==1?(msiz>>10):(msiz>>20)),
31447  mdisp==0?"b":(mdisp==1?"Kb":"Mb"),
31448  pixel_type(),(void*)begin(),(void*)((char*)end()-1),
31449  is_shared?"shared":"not shared");
31450  if (!is_empty()) cimg_foroff(*this,off) {
31451  std::fprintf(cimg_stdout,cimg::type<T>::format(),cimg::type<T>::format(data[off]));
31452  if (off!=siz1) std::fprintf(cimg_stdout,"%s",off%width==width1?" ; ":" ");
31453  if (off==7 && siz>16) { off = siz1-8; if (off!=7) std::fprintf(cimg_stdout,"... "); }
31454  }
31455  if (!is_empty() && display_stats)
31456  std::fprintf(cimg_stdout," ], min = %g, max = %g, mean = %g, std = %g, coords(min) = (%u,%u,%u,%u), coords(max) = (%u,%u,%u,%u).\n",
31457  st[0],st[1],st[2],std::sqrt(st[3]),xm,ym,zm,vm,xM,yM,zM,vM);
31458  else std::fprintf(cimg_stdout,"%s].\n",is_empty()?"":" ");
31459  return *this;
31460  }
iterator begin()
Return an iterator to the first image pixel.
Definition: CImg.h:11152
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
CImg< Tfloat > get_stats(const unsigned int variance_method=1) const
Definition: CImg.h:13152
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
iterator end()
Return an iterator pointing after the last image pixel (STL-compliant name).
Definition: CImg.h:11161
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_foroff(img, off)
Definition: CImg.h:590
#define cimg_stdout
Definition: CImg.h:136
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& projections2d ( const unsigned int  x0,
const unsigned int  y0,
const unsigned int  z0,
const int  dx = -100,
const int  dy = -100,
const int  dz = -100 
)
inline

Return a 2D representation of a 3D image, with three slices.

Definition at line 18146 of file CImg.h.

18147  {
18148  return get_projections2d(x0,y0,z0,dx,dy,dz).transfer_to(*this);
18149  }
NT dx
CImg< T > get_projections2d(const unsigned int x0, const unsigned int y0, const unsigned int z0, const int dx=-100, const int dy=-100, const int dz=-100) const
Definition: CImg.h:18151
NT dy
CImg<T>& pseudoinvert ( )
inline

Compute the pseudo-inverse (Moore-Penrose) of the matrix.

Definition at line 13543 of file CImg.h.

13543  {
13544  return get_pseudoinvert().transfer_to(*this);
13545  }
CImg< Tfloat > get_pseudoinvert() const
Definition: CImg.h:13547
Tfloat PSNR ( const CImg< t > &  img,
const Tfloat  valmax = (Tfloat)255 
) const
inline

Compute the PSNR between two images.

Definition at line 13130 of file CImg.h.

13130  {
13131  const Tfloat vMSE = (Tfloat)std::sqrt(MSE(img));
13132  return (vMSE!=0)?(Tfloat)(20*std::log10(valmax/vMSE)):(Tfloat)(cimg::type<Tfloat>::max());
13133  }
double sqrt(double d)
Definition: double.h:73
Tfloat MSE(const CImg< t > &img) const
Compute the MSE (Mean-Squared Error) between two images.
Definition: CImg.h:13113
CImg< _cimg_Tfloat > log10(const CImg< T > &instance)
Definition: CImg.h:6026
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T* ptr ( )
inline

Return a pointer to the pixel buffer.

Definition at line 11080 of file CImg.h.

Referenced by CImg< uintT >::_draw_scanline(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_load_ascii(), CImg< uintT >::_load_jpeg(), CImg< uintT >::_load_png(), CImg< uintT >::_load_pnm(), CImg< uintT >::_load_rgb(), CImg< uintT >::_load_rgba(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::abs(), CImg< uintT >::acos(), CImg< uintT >::asin(), CImg< uintT >::atan(), CImg< uintT >::CMYtoRGB(), CImg< uintT >::cos(), CImg< uintT >::cosh(), CImg< uintT >::cut(), CImg< uintT >::deriche(), CImg< uintT >::display_graph(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_point(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::equalize(), CImg< uintT >::exp(), CImg< uintT >::fill(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_distance(), CImg< uintT >::get_histogram(), CImg< uintT >::get_index(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_stats(), CImg< uintT >::get_vector_at(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::load_magick(), CImg< uintT >::log(), CImg< uintT >::log10(), CImg< uintT >::matrix(), CImg< uintT >::max(), CImg< uintT >::maxmin(), CImg< uintT >::mean(), CImg< uintT >::min(), CImg< uintT >::minmax(), CImg< uintT >::mirror(), CImg< uintT >::noise(), CImg< uintT >::normalize(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator*=(), CImg< uintT >::operator++(), CImg< uintT >::operator+=(), CImg< uintT >::operator--(), CImg< uintT >::operator-=(), CImg< uintT >::operator/=(), CImg< uintT >::operator<<=(), CImg< uintT >::operator>>=(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::pow(), CImg< uintT >::quantize(), CImg< uintT >::rand(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::round(), CImg< uintT >::save_magick(), CImg< uintT >::sequence(), CImg< uintT >::set_vector_at(), CImg< uintT >::sin(), CImg< uintT >::sinh(), CImg< uintT >::sqr(), CImg< uintT >::sqrt(), CImg< uintT >::sum(), CImg< uintT >::tan(), CImg< uintT >::tanh(), CImg< uintT >::threshold(), CImg< uintT >::translate(), CImg< uintT >::value_string(), CImg< uintT >::variancemean(), CImg< uintT >::vector(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().

11080  {
11081  return data;
11082  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
const T* ptr ( ) const
inline

Definition at line 11084 of file CImg.h.

11084  {
11085  return data;
11086  }
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
T* ptr ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  v = 0 
)
inline

Return a pointer to the pixel value located at (x,y,z,v).

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.
zZ-coordinate of the pixel.
vV-coordinate of the pixel.
  • When called without parameters, ptr() returns a pointer to the begining of the pixel buffer.
  • If the macro 'cimg_debug'>=3, boundary checking is performed and warning messages may appear if given coordinates are outside the image range (but function performances decrease).
example:
CImg<float> img(100,100,1,1,0); // Define a 100x100 greyscale image with float-valued pixels.
float *ptr = ptr(10,10); // Get a pointer to the pixel located at (10,10).
float val = *ptr; // Get the pixel value.

Definition at line 11122 of file CImg.h.

11122  {
11123  return data + x + y*width + z*width*height + v*width*height*depth;
11124  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
const T* ptr ( const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0,
const unsigned int  v = 0 
) const
inline

Definition at line 11126 of file CImg.h.

11126  {
11127  return data + x + y*width + z*width*height + v*width*height*depth;
11128  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
CImg<T>& quantize ( const unsigned int  nb_levels,
const bool  keep_range = true 
)
inline

Uniformly quantize values of the instance image 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 instance image.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_quantize(4);
(img,res).display();
ref_quantize.jpg

Definition at line 15197 of file CImg.h.

Referenced by CImg< uintT >::get_quantize().

15197  {
15198  if (is_empty()) return *this;
15199  if (!nb_levels)
15200  throw CImgArgumentException("CImg<%s>::quantize() : Cannot quantize image to 0 values.",
15201  pixel_type());
15202  Tfloat m, M = (Tfloat)maxmin(m), range = M - m;
15203  if (range>0) {
15204  if (keep_range) cimg_for(*this,ptr,T) {
15205  const unsigned int val = (unsigned int)((*ptr-m)*nb_levels/range);
15206  *ptr = (T)(m + cimg::min(val,nb_levels-1)*range/nb_levels);
15207  } else cimg_for(*this,ptr,T) {
15208  const unsigned int val = (unsigned int)((*ptr-m)*nb_levels/range);
15209  *ptr = (T)cimg::min(val,nb_levels-1);
15210  }
15211  }
15212  return *this;
15213  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

static CImg<Tuchar> rainbow_LUT256 ( )
inlinestatic

Return a rainbow indexed color palette with 256 (R,G,B) entries.

Returns
An instance of a rainbow color palette with 256 (R,G,B) colors.
ref_rainbow_LUT256.jpg

Definition at line 15738 of file CImg.h.

15738  {
15739  static CImg<Tuchar> palette;
15740  if (!palette) {
15741  CImg<Tint> tmp(1,256,1,3,1);
15742  tmp.get_shared_channel(0).sequence(0,359);
15743  palette = tmp.HSVtoRGB();
15744  }
15745  return palette;
15746  }
CImg<T>& rand ( const T  val_min,
const T  val_max 
)
inline

Fill the instance image with random values between specified range.

Definition at line 14961 of file CImg.h.

Referenced by CImg< uintT >::get_rand().

14961  {
14962  const float delta = (float)val_max - (float)val_min;
14963  cimg_for(*this,ptr,T) *ptr = (T)(val_min + cimg::rand()*delta);
14964  return *this;
14965  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
double rand()
Return a random variable between [0,1] with respect to an uniform distribution.
Definition: CImg.h:4833

Here is the caller graph for this function:

CImg<T>& resize ( const int  pdx,
const int  pdy = -100,
const int  pdz = -100,
const int  pdv = -100,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
)
inline

Resize an image.

Parameters
pdxNumber of columns (new size along the X-axis).
pdyNumber of rows (new size along the Y-axis).
pdzNumber of slices (new size along the Z-axis).
pdvNumber of vector-channels (new size along the V-axis).
interpolation_typeMethod of interpolation :
  • -1 = no interpolation : raw memory resizing.
  • 0 = no interpolation : additional space is filled according to border_condition.
  • 1 = bloc interpolation (nearest point).
  • 2 = moving average interpolation.
  • 3 = linear interpolation.
  • 4 = grid interpolation.
  • 5 = bi-cubic interpolation.
border_conditionBorder condition type.
centerSet 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).

Definition at line 16630 of file CImg.h.

Referenced by CImg< uintT >::_load_dlm(), CImg< T >::_cimg_math_parser::compile(), CImg< uintT >::load_tiff(), CImg< T >::_cimg_math_parser::opcode(), and CImg< uintT >::resize().

16631  {
16632  if (!pdx || !pdy || !pdz || !pdv) return assign();
16633  const unsigned int
16634  tdx = pdx<0?-pdx*width/100:pdx,
16635  tdy = pdy<0?-pdy*height/100:pdy,
16636  tdz = pdz<0?-pdz*depth/100:pdz,
16637  tdv = pdv<0?-pdv*dim/100:pdv,
16638  dx = tdx?tdx:1,
16639  dy = tdy?tdy:1,
16640  dz = tdz?tdz:1,
16641  dv = tdv?tdv:1;
16642  if (width==dx && height==dy && depth==dz && dim==dv) return *this;
16643  if (interpolation_type==-1 && dx*dy*dz*dv==size()) {
16644  width = dx; height = dy; depth = dz; dim = dv;
16645  return *this;
16646  }
16647  return get_resize(dx,dy,dz,dv,interpolation_type,border_condition,center).transfer_to(*this);
16648  }
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > get_resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false) const
Definition: CImg.h:16650
NT dy
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& resize ( const CImg< t > &  src,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
)
inline

Resize an image.

Parameters
srcImage giving the geometry of the resize.
interpolation_typeInterpolation method :
  • 1 = raw memory
  • 0 = no interpolation : additional space is filled with 0.
  • 1 = bloc interpolation (nearest point).
  • 2 = mosaic : image is repeated if necessary.
  • 3 = linear interpolation.
  • 4 = grid interpolation.
  • 5 = bi-cubic interpolation.
border_conditionBorder condition type.
Note
If pd[x,y,z,v]<0, it corresponds to a percentage of the original size (the default value is -100).

Definition at line 16975 of file CImg.h.

16976  {
16977  return resize(src.width,src.height,src.depth,src.dim,interpolation_type,border_condition,center);
16978  }
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
Definition: CImg.h:16630
CImg<T>& resize ( const CImgDisplay disp,
const int  interpolation_type = 1,
const int  border_condition = -1,
const bool  center = false 
)
inline

Resize an image.

Parameters
disp= Display giving the geometry of the resize.
interpolation_type= Resizing type :
  • 0 = no interpolation : additional space is filled with 0.
  • 1 = bloc interpolation (nearest point).
  • 2 = mosaic : image is repeated if necessary.
  • 3 = linear interpolation.
  • 4 = grid interpolation.
  • 5 = bi-cubic interpolation.
  • 6 = moving average (best quality for photographs)
border_conditionBorder condition type.
Note
If pd[x,y,z,v]<0, it corresponds to a percentage of the original size (the default value is -100).

Definition at line 17000 of file CImg.h.

17001  {
17002  return resize(disp.width,disp.height,depth,dim,interpolation_type,border_condition,center);
17003  }
CImg< T > & resize(const int pdx, const int pdy=-100, const int pdz=-100, const int pdv=-100, const int interpolation_type=1, const int border_condition=-1, const bool center=false)
Resize an image.
Definition: CImg.h:16630
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& resize_doubleXY ( )
inline

Upscale an image by a factor 2x.

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

Definition at line 17035 of file CImg.h.

17035  {
17036  return get_resize_doubleXY().transfer_to(*this);
17037  }
CImg< T > get_resize_doubleXY() const
Definition: CImg.h:17039
CImg<T>& resize_halfXY ( )
inline

Half-resize an image, using a special optimized filter.

Definition at line 17011 of file CImg.h.

17011  {
17012  return get_resize_halfXY().transfer_to(*this);
17013  }
CImg< T > get_resize_halfXY() const
Definition: CImg.h:17015
CImg<T>& resize_object3d ( const float  sx,
const float  sy = -100,
const float  sz = -100 
)
inline

Resize a 3D object.

Definition at line 21107 of file CImg.h.

21107  {
21108  if (is_empty()) return *this;
21109  if (height!=3 || depth>1 || dim>1)
21110  throw CImgInstanceException("CImg<%s>::resize_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21112  CImg<T> xcoords = get_shared_line(0), ycoords = get_shared_line(1), zcoords = get_shared_line(2);
21113  float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21114  if (xm<xM) { if (sx>0) xcoords*=sx/(xM-xm); else xcoords*=-sx/100; }
21115  if (ym<yM) { if (sy>0) ycoords*=sy/(yM-ym); else ycoords*=-sy/100; }
21116  if (zm<zM) { if (sz>0) zcoords*=sz/(zM-zm); else zcoords*=-sz/100; }
21117  return *this;
21118  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image...
Definition: CImg.h:18517
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T> resize_object3d ( ) const
inline

Resize a 3D object so that its max dimension if one.

Definition at line 21125 of file CImg.h.

Referenced by CImg< uintT >::get_resize_object3d().

21125  {
21126  if (is_empty()) return *this;
21127  if (height!=3 || depth>1 || dim>1)
21128  throw CImgInstanceException("CImg<%s>::resize_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21130  CImg<T> xcoords = get_shared_line(0), ycoords = get_shared_line(1), zcoords = get_shared_line(2);
21131  float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21132  const float dx = xM - xm, dy = yM - ym, dz = zM - zm, dmax = cimg::max(dx,dy,dz);
21133  if (dmax>0) { xcoords/=dmax; ycoords/=dmax; zcoords/=dmax; }
21134  return *this;
21135  }
NT dx
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
NT dy
CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image...
Definition: CImg.h:18517
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& resize_tripleXY ( )
inline

Upscale an image by a factor 3x.

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

Definition at line 17088 of file CImg.h.

17088  {
17089  return get_resize_tripleXY().transfer_to(*this);
17090  }
CImg< T > get_resize_tripleXY() const
Definition: CImg.h:17092
CImg<T>& RGBtoBayer ( )
inline

Convert a (R,G,B) image to a Bayer-coded representation.

Note
First (upper-left) pixel if the red component of the pixel color.

Definition at line 16467 of file CImg.h.

16467  {
16468  return get_RGBtoBayer().transfer_to(*this);
16469  }
CImg< T > get_RGBtoBayer() const
Definition: CImg.h:16471
CImg<T>& RGBtoCMY ( )
inline

Convert color pixels from (R,G,B) to (C,M,Y).

Definition at line 16130 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoCMY(), and CImg< uintT >::RGBtoCMYK().

16130  {
16131  if (is_empty()) return *this;
16132  if (dim!=3)
16133  throw CImgInstanceException("CImg<%s>::RGBtoCMY() : Input image dimension is dim=%u, "
16134  "should be a (R,G,B) image (dim=3)",
16135  pixel_type(),dim);
16136  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16137  for (unsigned int N = width*height*depth; N; --N) {
16138  const Tfloat
16139  R = (Tfloat)*p1/255,
16140  G = (Tfloat)*p2/255,
16141  B = (Tfloat)*p3/255;
16142  *(p1++) = (T)(1 - R);
16143  *(p2++) = (T)(1 - G);
16144  *(p3++) = (T)(1 - B);
16145  }
16146  return *this;
16147  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoCMYK ( )
inline

Convert a (R,G,B) image to a (C,M,Y,K) one.

Definition at line 16446 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoCMYK().

16446  {
16447  return RGBtoCMY().CMYtoCMYK();
16448  }
CImg< T > & RGBtoCMY()
Convert color pixels from (R,G,B) to (C,M,Y).
Definition: CImg.h:16130

Here is the caller graph for this function:

CImg<T>& RGBtoHSI ( )
inline

Convert color pixels from (R,G,B) to (H,S,I).

Reference: "Digital Image Processing, 2nd. edition", R. Gonzalez and R. Woods. Prentice Hall, 2002.

Definition at line 15948 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoHSI().

15948  {
15949  if (is_empty()) return *this;
15950  if (dim!=3)
15951  throw CImgInstanceException("CImg<%s>::RGBtoHSI() : Input image dimension is dim=%u, "
15952  "should be a (R,G,B) image.",
15953  pixel_type(),dim);
15954  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15955  for (unsigned int N = width*height*depth; N; --N) {
15956  const Tfloat
15957  R = (Tfloat)*p1,
15958  G = (Tfloat)*p2,
15959  B = (Tfloat)*p3,
15960  nR = (R<0?0:(R>255?255:R))/255,
15961  nG = (G<0?0:(G>255?255:G))/255,
15962  nB = (B<0?0:(B>255?255:B))/255,
15963  m = cimg::min(nR,nG,nB),
15964  theta = (Tfloat)(std::acos(0.5f*((nR-nG)+(nR-nB))/std::sqrt(std::pow(nR-nG,2)+(nR-nB)*(nG-nB)))*180/cimg::valuePI),
15965  sum = nR + nG + nB;
15966  Tfloat H = 0, S = 0, I = 0;
15967  if (theta>0) H = (nB<=nG)?theta:360-theta;
15968  if (sum>0) S = 1 - 3/sum*m;
15969  I = sum/3;
15970  *(p1++) = (T)H;
15971  *(p2++) = (T)S;
15972  *(p3++) = (T)I;
15973  }
15974  return *this;
15975  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoHSL ( )
inline

Convert color pixels from (R,G,B) to (H,S,L).

Definition at line 15870 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoHSL().

15870  {
15871  if (is_empty()) return *this;
15872  if (dim!=3)
15873  throw CImgInstanceException("CImg<%s>::RGBtoHSL() : Input image dimension is dim=%u, "
15874  "should be a (R,G,B) image.",
15875  pixel_type(),dim);
15876  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15877  for (unsigned int N = width*height*depth; N; --N) {
15878  const Tfloat
15879  R = (Tfloat)*p1,
15880  G = (Tfloat)*p2,
15881  B = (Tfloat)*p3,
15882  nR = (R<0?0:(R>255?255:R))/255,
15883  nG = (G<0?0:(G>255?255:G))/255,
15884  nB = (B<0?0:(B>255?255:B))/255,
15885  m = cimg::min(nR,nG,nB),
15886  M = cimg::max(nR,nG,nB),
15887  L = (m+M)/2;
15888  Tfloat H = 0, S = 0;
15889  if (M==m) H = S = 0;
15890  else {
15891  const Tfloat
15892  f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)),
15893  i = (nR==m)?3.0f:((nG==m)?5.0f:1.0f);
15894  H = (i-f/(M-m));
15895  if (H>=6) H-=6;
15896  H*=60;
15897  S = (2*L<=1)?((M-m)/(M+m)):((M-m)/(2-M-m));
15898  }
15899  *(p1++) = (T)H;
15900  *(p2++) = (T)S;
15901  *(p3++) = (T)L;
15902  }
15903  return *this;
15904  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
blockLoc i
Definition: read.cpp:79
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoHSV ( )
inline

Convert color pixels from (R,G,B) to (H,S,V).

Definition at line 15787 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoHSV().

15787  {
15788  if (is_empty()) return *this;
15789  if (dim!=3)
15790  throw CImgInstanceException("CImg<%s>::RGBtoHSV() : Input image dimension is dim=%u, "
15791  "should be a (R,G,B) image.",
15792  pixel_type(),dim);
15793  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
15794  for (unsigned int N = width*height*depth; N; --N) {
15795  const Tfloat
15796  R = (Tfloat)*p1,
15797  G = (Tfloat)*p2,
15798  B = (Tfloat)*p3,
15799  nR = (R<0?0:(R>255?255:R))/255,
15800  nG = (G<0?0:(G>255?255:G))/255,
15801  nB = (B<0?0:(B>255?255:B))/255,
15802  m = cimg::min(nR,nG,nB),
15803  M = cimg::max(nR,nG,nB);
15804  Tfloat H = 0, S = 0;
15805  if (M!=m) {
15806  const Tfloat
15807  f = (nR==m)?(nG-nB):((nG==m)?(nB-nR):(nR-nG)),
15808  i = (Tfloat)((nR==m)?3:((nG==m)?5:1));
15809  H = (i-f/(M-m));
15810  if (H>=6) H-=6;
15811  H*=60;
15812  S = (M-m)/M;
15813  }
15814  *(p1++) = (T)H;
15815  *(p2++) = (T)S;
15816  *(p3++) = (T)M;
15817  }
15818  return *this;
15819  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
blockLoc i
Definition: read.cpp:79
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoLab ( )
inline

Convert a (R,G,B) image to a (L,a,b) one.

Definition at line 16410 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoLab().

16410  {
16411  return RGBtoXYZ().XYZtoLab();
16412  }
CImg< T > & RGBtoXYZ()
Convert color pixels from (R,G,B) to (X,Y,Z)_709.
Definition: CImg.h:16239

Here is the caller graph for this function:

CImg<T>& RGBtoxyY ( )
inline

Convert a (R,G,B) image to a (x,y,Y) one.

Definition at line 16428 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoxyY().

16428  {
16429  return RGBtoXYZ().XYZtoxyY();
16430  }
CImg< T > & RGBtoXYZ()
Convert color pixels from (R,G,B) to (X,Y,Z)_709.
Definition: CImg.h:16239

Here is the caller graph for this function:

CImg<T>& RGBtoXYZ ( )
inline

Convert color pixels from (R,G,B) to (X,Y,Z)_709.

Definition at line 16239 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoXYZ(), CImg< uintT >::RGBtoLab(), and CImg< uintT >::RGBtoxyY().

16239  {
16240  if (is_empty()) return *this;
16241  if (dim!=3)
16242  throw CImgInstanceException("CImg<%s>::RGBtoXYZ() : Input image dimension is dim=%u, "
16243  "should be a (R,G,B) image (dim=3)",
16244  pixel_type(),dim);
16245  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16246  for (unsigned int N = width*height*depth; N; --N) {
16247  const Tfloat
16248  R = (Tfloat)*p1/255,
16249  G = (Tfloat)*p2/255,
16250  B = (Tfloat)*p3/255;
16251  *(p1++) = (T)(0.412453f*R + 0.357580f*G + 0.180423f*B);
16252  *(p2++) = (T)(0.212671f*R + 0.715160f*G + 0.072169f*B);
16253  *(p3++) = (T)(0.019334f*R + 0.119193f*G + 0.950227f*B);
16254  }
16255  return *this;
16256  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoYCbCr ( )
inline

Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.

Definition at line 16024 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoYCbCr().

16024  {
16025  if (is_empty()) return *this;
16026  if (dim!=3)
16027  throw CImgInstanceException("CImg<%s>::RGBtoYCbCr() : Input image dimension is dim=%u, "
16028  "should be a (R,G,B) image (dim=3)",
16029  pixel_type(),dim);
16030  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16031  for (unsigned int N = width*height*depth; N; --N) {
16032  const Tfloat
16033  R = (Tfloat)*p1,
16034  G = (Tfloat)*p2,
16035  B = (Tfloat)*p3,
16036  Y = (66*R + 129*G + 25*B + 128)/256 + 16,
16037  Cb = (-38*R - 74*G + 112*B + 128)/256 + 128,
16038  Cr = (112*R - 94*G - 18*B + 128)/256 + 128;
16039  *(p1++) = (T)(Y<0?0:(Y>255?255:Y));
16040  *(p2++) = (T)(Cb<0?0:(Cb>255?255:Cb));
16041  *(p3++) = (T)(Cr<0?0:(Cr>255?255:Cr));
16042  }
16043  return *this;
16044  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& RGBtoYUV ( )
inline

Convert color pixels from (R,G,B) to (Y,U,V).

Definition at line 16078 of file CImg.h.

Referenced by CImg< uintT >::get_RGBtoYUV().

16078  {
16079  if (is_empty()) return *this;
16080  if (dim!=3)
16081  throw CImgInstanceException("CImg<%s>::RGBtoYUV() : Input image dimension is dim=%u, "
16082  "should be a (R,G,B) image (dim=3)",
16083  pixel_type(),dim);
16084  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16085  for (unsigned int N = width*height*depth; N; --N) {
16086  const Tfloat
16087  R = (Tfloat)*p1/255,
16088  G = (Tfloat)*p2/255,
16089  B = (Tfloat)*p3/255,
16090  Y = 0.299f*R + 0.587f*G + 0.114f*B;
16091  *(p1++) = (T)Y;
16092  *(p2++) = (T)(0.492f*(B-Y));
16093  *(p3++) = (T)(0.877*(R-Y));
16094  }
16095  return *this;
16096  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& rotate ( const float  angle,
const unsigned int  border_conditions = 3,
const unsigned int  interpolation = 1 
)
inline

Rotate an image.

Parameters
angle= rotation angle (in degrees).
cond= rotation type. can be :
  • 0 = zero-value at borders
  • 1 = nearest pixel.
  • 2 = Fourier style.
Note
Returned image will probably have a different size than the instance image *this.

Definition at line 17637 of file CImg.h.

Referenced by rflo_findsourcecell(), rflo_modinterfacessolver::RFLO_FindSourceCell::rflo_findsourcecell(), rflo_findsourcecellinvert(), rflo_modinterfacessolver::RFLO_FindSourceCellInvert::rflo_findsourcecellinvert(), and rflo_findsourceregions().

17637  {
17638  return get_rotate(angle,border_conditions,interpolation).transfer_to(*this);
17639  }
CImg< T > get_rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1) const
Definition: CImg.h:17641
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61

Here is the caller graph for this function:

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

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

Definition at line 17745 of file CImg.h.

17746  {
17747  return get_rotate(angle,cx,cy,zoom,border_conditions,interpolation).transfer_to(*this);
17748  }
CImg< T > get_rotate(const float angle, const unsigned int border_conditions=3, const unsigned int interpolation=1) const
Definition: CImg.h:17641
double angle(Vector_3< double > v1, Vector_3< double > v2)
Compute the angle between two vectors.
Definition: geometry.C:61
static CImg<T> rotation_matrix ( const float  x,
const float  y,
const float  z,
const float  w,
const bool  quaternion_data = false 
)
inlinestatic

Return a 3x3 rotation matrix along the (x,y,z)-axis with an angle w.

Definition at line 14395 of file CImg.h.

Referenced by CImg< uintT >::_display_object3d().

14395  {
14396  float X,Y,Z,W;
14397  if (!quaternion_data) {
14398  const float norm = (float)std::sqrt(x*x + y*y + z*z),
14399  nx = norm>0?x/norm:0,
14400  ny = norm>0?y/norm:0,
14401  nz = norm>0?z/norm:1,
14402  nw = norm>0?w:0,
14403  sina = (float)std::sin(nw/2),
14404  cosa = (float)std::cos(nw/2);
14405  X = nx*sina;
14406  Y = ny*sina;
14407  Z = nz*sina;
14408  W = cosa;
14409  } else {
14410  const float norm = (float)std::sqrt(x*x + y*y + z*z + w*w);
14411  if (norm>0) { X = x/norm; Y = y/norm; Z = z/norm; W = w/norm; }
14412  else { X = Y = Z = 0; W = 1; }
14413  }
14414  const float xx = X*X, xy = X*Y, xz = X*Z, xw = X*W, yy = Y*Y, yz = Y*Z, yw = Y*W, zz = Z*Z, zw = Z*W;
14415  return CImg<T>::matrix((T)(1-2*(yy+zz)), (T)(2*(xy+zw)), (T)(2*(xz-yw)),
14416  (T)(2*(xy-zw)), (T)(1-2*(xx+zz)), (T)(2*(yz+xw)),
14417  (T)(2*(xz+yw)), (T)(2*(yz-xw)), (T)(1-2*(xx+yy)));
14418  }
void int int REAL REAL * y
Definition: read.cpp:74
double sqrt(double d)
Definition: double.h:73
CImg< T > & norm(const int norm_type=2)
Compute L2-norm of each multi-valued pixel of the instance image.
Definition: CImg.h:15127
void int int int REAL REAL REAL * z
Definition: write.cpp:76
NT & sin
void int int REAL * x
Definition: read.cpp:74
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
NT & cos

Here is the caller graph for this function:

CImg<T>& round ( const float  x,
const int  rounding_type = 0 
)
inline

Compute image with rounded pixel values.

Parameters
xRounding precision.
rounding_typeRoundin type, can be 0 (nearest), 1 (forward), -1(backward).

Definition at line 14976 of file CImg.h.

Referenced by CImg< uintT >::draw_axis(), and CImg< uintT >::get_round().

14976  {
14977  cimg_for(*this,ptr,T) (*ptr) = (T)cimg::round(*ptr,x,rounding_type);
14978  return *this;
14979  }
double round(const double x, const double y, const int rounding_type=0)
Return a rounded number.
Definition: CImg.h:4871
void int int REAL * x
Definition: read.cpp:74
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

const CImg<T>& save ( const char *const  filename,
const int  number = -1 
) const
inline

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.

Definition at line 32256 of file CImg.h.

Referenced by CImg< uintT >::_get_select(), and CImg< uintT >::save_gzip_external().

32256  {
32257  if (is_empty())
32258  throw CImgInstanceException("CImg<%s>::save() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32259  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
32260  if (!filename)
32261  throw CImgArgumentException("CImg<%s>::save() : Instance image (%u,%u,%u,%u,%p) cannot be saved as a (null) filename.",
32263  const char *ext = cimg::split_filename(filename);
32264  char nfilename[1024] = { 0 };
32265  const char *const fn = (number>=0)?cimg::number_filename(filename,number,6,nfilename):filename;
32266 #ifdef cimg_save_plugin
32267  cimg_save_plugin(fn);
32268 #endif
32269 #ifdef cimg_save_plugin1
32270  cimg_save_plugin1(fn);
32271 #endif
32272 #ifdef cimg_save_plugin2
32273  cimg_save_plugin2(fn);
32274 #endif
32275 #ifdef cimg_save_plugin3
32276  cimg_save_plugin3(fn);
32277 #endif
32278 #ifdef cimg_save_plugin4
32279  cimg_save_plugin4(fn);
32280 #endif
32281 #ifdef cimg_save_plugin5
32282  cimg_save_plugin5(fn);
32283 #endif
32284 #ifdef cimg_save_plugin6
32285  cimg_save_plugin6(fn);
32286 #endif
32287 #ifdef cimg_save_plugin7
32288  cimg_save_plugin7(fn);
32289 #endif
32290 #ifdef cimg_save_plugin8
32291  cimg_save_plugin8(fn);
32292 #endif
32293  // ASCII formats
32294  if (!cimg::strcasecmp(ext,"asc")) return save_ascii(fn);
32295  if (!cimg::strcasecmp(ext,"dlm") ||
32296  !cimg::strcasecmp(ext,"txt")) return save_dlm(fn);
32297  if (!cimg::strcasecmp(ext,"cpp") ||
32298  !cimg::strcasecmp(ext,"hpp") ||
32299  !cimg::strcasecmp(ext,"h") ||
32300  !cimg::strcasecmp(ext,"c")) return save_cpp(fn);
32301 
32302  // 2D binary formats
32303  if (!cimg::strcasecmp(ext,"bmp")) return save_bmp(fn);
32304  if (!cimg::strcasecmp(ext,"jpg") ||
32305  !cimg::strcasecmp(ext,"jpeg") ||
32306  !cimg::strcasecmp(ext,"jpe") ||
32307  !cimg::strcasecmp(ext,"jfif") ||
32308  !cimg::strcasecmp(ext,"jif")) return save_jpeg(fn);
32309  if (!cimg::strcasecmp(ext,"rgb")) return save_rgb(fn);
32310  if (!cimg::strcasecmp(ext,"rgba")) return save_rgba(fn);
32311  if (!cimg::strcasecmp(ext,"png")) return save_png(fn);
32312  if (!cimg::strcasecmp(ext,"pgm") ||
32313  !cimg::strcasecmp(ext,"ppm") ||
32314  !cimg::strcasecmp(ext,"pnm")) return save_pnm(fn);
32315  if (!cimg::strcasecmp(ext,"tif") ||
32316  !cimg::strcasecmp(ext,"tiff")) return save_tiff(fn);
32317 
32318  // 3D binary formats
32319  if (!cimg::strcasecmp(ext,"cimgz")) return save_cimg(fn,true);
32320  if (!cimg::strcasecmp(ext,"cimg") || !*ext) return save_cimg(fn,false);
32321  if (!cimg::strcasecmp(ext,"dcm")) return save_medcon_external(fn);
32322  if (!cimg::strcasecmp(ext,"hdr") ||
32323  !cimg::strcasecmp(ext,"nii")) return save_analyze(fn);
32324  if (!cimg::strcasecmp(ext,"inr")) return save_inr(fn);
32325  if (!cimg::strcasecmp(ext,"pan")) return save_pandore(fn);
32326  if (!cimg::strcasecmp(ext,"raw")) return save_raw(fn);
32327 
32328  // Archive files
32329  if (!cimg::strcasecmp(ext,"gz")) return save_gzip_external(fn);
32330 
32331  // Image sequences
32332  if (!cimg::strcasecmp(ext,"yuv")) return save_yuv(fn,true);
32333  if (!cimg::strcasecmp(ext,"avi") ||
32334  !cimg::strcasecmp(ext,"mov") ||
32335  !cimg::strcasecmp(ext,"asf") ||
32336  !cimg::strcasecmp(ext,"divx") ||
32337  !cimg::strcasecmp(ext,"flv") ||
32338  !cimg::strcasecmp(ext,"mpg") ||
32339  !cimg::strcasecmp(ext,"m1v") ||
32340  !cimg::strcasecmp(ext,"m2v") ||
32341  !cimg::strcasecmp(ext,"m4v") ||
32342  !cimg::strcasecmp(ext,"mjp") ||
32343  !cimg::strcasecmp(ext,"mkv") ||
32344  !cimg::strcasecmp(ext,"mpe") ||
32345  !cimg::strcasecmp(ext,"movie") ||
32346  !cimg::strcasecmp(ext,"ogm") ||
32347  !cimg::strcasecmp(ext,"qt") ||
32348  !cimg::strcasecmp(ext,"rm") ||
32349  !cimg::strcasecmp(ext,"vob") ||
32350  !cimg::strcasecmp(ext,"wmv") ||
32351  !cimg::strcasecmp(ext,"xvid") ||
32352  !cimg::strcasecmp(ext,"mpeg")) return save_ffmpeg(fn);
32353  return save_other(fn);
32354  }
const CImg< T > & save_tiff(const char *const filename) const
Save a file in TIFF format.
Definition: CImg.h:33198
const CImg< T > & save_dlm(const char *const filename) const
Save the image as a DLM file.
Definition: CImg.h:32448
const CImg< T > & save_other(const char *const filename, const unsigned int quality=100) const
Definition: CImg.h:33819
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
Definition: CImg.h:33284
const CImg< T > & save_gzip_external(const char *const filename) const
Save an image as a gzipped file, using external tool &#39;gzip&#39;.
Definition: CImg.h:33718
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
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
Save the image as a video sequence file, using FFMPEG library.
Definition: CImg.h:33574
const CImg< T > & save_pnm(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save the image as a PNM file.
Definition: CImg.h:32992
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
const CImg< T > & save_yuv(const char *const filename, const bool rgb2yuv=true) const
Save the image as a YUV video sequence file.
Definition: CImg.h:33594
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const CImg< T > & save_raw(const char *const filename, const bool multiplexed=false) const
Save the image as a RAW file.
Definition: CImg.h:33564
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
char * number_filename(const char *const filename, const int number, const unsigned int n, char *const string)
Create a numbered version of a filename.
Definition: CImg.h:5483
const CImg< T > & save_bmp(const char *const filename) const
Save the image as a BMP file.
Definition: CImg.h:32544
const CImg< T > & save_inr(const char *const filename, const float *const voxsize=0) const
Save the image as an INRIMAGE-4 file.
Definition: CImg.h:33362
const CImg< T > & save_cpp(const char *const filename) const
Save the image as a CPP source file.
Definition: CImg.h:32412
const CImg< T > & save_rgba(const char *const filename) const
Save the image as a RGBA file.
Definition: CImg.h:33115
const CImg< T > & save_png(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save a file in PNG format.
Definition: CImg.h:32890
const CImg< T > & save_jpeg(const char *const filename, const unsigned int quality=100) const
Save a file in JPEG format.
Definition: CImg.h:32644
const CImg< T > & save_ascii(const char *const filename) const
Save the image as an ASCII file (ASCII Raw + simple header).
Definition: CImg.h:32376
const CImg< T > & save_pandore(const char *const filename, const unsigned int colorspace=0) const
Save the image as a PANDORE-5 file.
Definition: CImg.h:33533
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
const CImg< T > & save_medcon_external(const char *const filename) const
Save an image as a Dicom file (need &#39;(X)Medcon&#39; : http://xmedcon.sourceforge.net ) ...
Definition: CImg.h:33784
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
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.
Definition: CImg.h:33219
const CImg< T > & save_rgb(const char *const filename) const
Save the image as a RGB file.
Definition: CImg.h:33048
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_analyze ( const char *const  filename,
const float *const  voxsize = 0 
) const
inline

Save the image as an ANALYZE7.5 or NIFTI file.

Definition at line 33219 of file CImg.h.

Referenced by CImg< uintT >::save(), and CImg< uintT >::save_medcon_external().

33219  {
33220  if (is_empty())
33221  throw CImgInstanceException("CImg<%s>::save_analyze() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33222  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33223  if (!filename)
33224  throw CImgArgumentException("CImg<%s>::save_analyze() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33226  std::FILE *file;
33227  char header[348] = { 0 }, hname[1024] = { 0 }, iname[1024] = { 0 };
33228  const char *ext = cimg::split_filename(filename);
33229  short datatype=-1;
33230  std::memset(header,0,348);
33231  if (!ext[0]) { std::sprintf(hname,"%s.hdr",filename); std::sprintf(iname,"%s.img",filename); }
33232  if (!cimg::strncasecmp(ext,"hdr",3)) {
33233  std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(iname+std::strlen(iname)-3,"img");
33234  }
33235  if (!cimg::strncasecmp(ext,"img",3)) {
33236  std::strcpy(hname,filename); std::strcpy(iname,filename); std::sprintf(hname+std::strlen(iname)-3,"hdr");
33237  }
33238  if (!cimg::strncasecmp(ext,"nii",3)) {
33239  std::strcpy(hname,filename); iname[0] = 0;
33240  }
33241  ((int*)(header))[0] = 348;
33242  std::sprintf(header+4,"CImg");
33243  std::sprintf(header+14," ");
33244  ((short*)(header+36))[0] = 4096;
33245  ((char*)(header+38))[0] = 114;
33246  ((short*)(header+40))[0] = 4;
33247  ((short*)(header+40))[1] = width;
33248  ((short*)(header+40))[2] = height;
33249  ((short*)(header+40))[3] = depth;
33250  ((short*)(header+40))[4] = dim;
33251  if (!cimg::strcasecmp(pixel_type(),"bool")) datatype = 2;
33252  if (!cimg::strcasecmp(pixel_type(),"unsigned char")) datatype = 2;
33253  if (!cimg::strcasecmp(pixel_type(),"char")) datatype = 2;
33254  if (!cimg::strcasecmp(pixel_type(),"unsigned short")) datatype = 4;
33255  if (!cimg::strcasecmp(pixel_type(),"short")) datatype = 4;
33256  if (!cimg::strcasecmp(pixel_type(),"unsigned int")) datatype = 8;
33257  if (!cimg::strcasecmp(pixel_type(),"int")) datatype = 8;
33258  if (!cimg::strcasecmp(pixel_type(),"unsigned long")) datatype = 8;
33259  if (!cimg::strcasecmp(pixel_type(),"long")) datatype = 8;
33260  if (!cimg::strcasecmp(pixel_type(),"float")) datatype = 16;
33261  if (!cimg::strcasecmp(pixel_type(),"double")) datatype = 64;
33262  if (datatype<0)
33263  throw CImgIOException("CImg<%s>::save_analyze() : Cannot save image '%s' since pixel type (%s)"
33264  "is not handled in Analyze7.5 specifications.\n",
33265  pixel_type(),filename,pixel_type());
33266  ((short*)(header+70))[0] = datatype;
33267  ((short*)(header+72))[0] = sizeof(T);
33268  ((float*)(header+112))[0] = 1;
33269  ((float*)(header+76))[0] = 0;
33270  if (voxsize) {
33271  ((float*)(header+76))[1] = voxsize[0];
33272  ((float*)(header+76))[2] = voxsize[1];
33273  ((float*)(header+76))[3] = voxsize[2];
33274  } else ((float*)(header+76))[1] = ((float*)(header+76))[2] = ((float*)(header+76))[3] = 1;
33275  file = cimg::fopen(hname,"wb");
33276  cimg::fwrite(header,348,file);
33277  if (iname[0]) { cimg::fclose(file); file = cimg::fopen(iname,"wb"); }
33278  cimg::fwrite(data,size(),file);
33279  cimg::fclose(file);
33280  return *this;
33281  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
int strncasecmp(const char *const s1, const char *const s2, const int l)
Compare the first n characters of two C-strings, ignoring the case.
Definition: CImg.h:4915
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_ascii ( const char *const  filename) const
inline

Save the image as an ASCII file (ASCII Raw + simple header).

Definition at line 32376 of file CImg.h.

Referenced by CImg< uintT >::save().

32376  {
32377  return _save_ascii(0,filename);
32378  }
const CImg< T > & _save_ascii(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32357

Here is the caller graph for this function:

const CImg<T>& save_ascii ( std::FILE *const  file) const
inline

Save the image as an ASCII file (ASCII Raw + simple header).

Definition at line 32381 of file CImg.h.

32381  {
32382  return _save_ascii(file,0);
32383  }
const CImg< T > & _save_ascii(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32357
const CImg<T>& save_bmp ( const char *const  filename) const
inline

Save the image as a BMP file.

Definition at line 32544 of file CImg.h.

Referenced by CImg< uintT >::save().

32544  {
32545  return _save_bmp(0,filename);
32546  }
const CImg< T > & _save_bmp(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32458

Here is the caller graph for this function:

const CImg<T>& save_bmp ( std::FILE *const  file) const
inline

Save the image as a BMP file.

Definition at line 32549 of file CImg.h.

32549  {
32550  return _save_bmp(file,0);
32551  }
const CImg< T > & _save_bmp(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32458
const CImg<T>& save_cimg ( const char *const  filename,
const bool  compress = false 
) const
inline

Save the image as a .cimg file.

Definition at line 33284 of file CImg.h.

Referenced by CImg< uintT >::save(), and CImg< uintT >::save_cimg().

33284  {
33285  CImgList<T>(*this,true).save_cimg(filename,compress);
33286  return *this;
33287  }
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
Definition: CImg.h:33284

Here is the caller graph for this function:

const CImg<T>& save_cimg ( std::FILE *const  file,
const bool  compress = false 
) const
inline

Definition at line 33290 of file CImg.h.

33290  {
33291  CImgList<T>(*this,true).save_cimg(file,compress);
33292  return *this;
33293  }
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
Definition: CImg.h:33284
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  v0 
) const
inline

Insert the image into an existing .cimg file, at specified coordinates.

Definition at line 33296 of file CImg.h.

33299  {
33300  CImgList<T>(*this,true).save_cimg(filename,n0,x0,y0,z0,v0);
33301  return *this;
33302  }
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
Definition: CImg.h:33284
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  v0 
) const
inline

Insert the image into an existing .cimg file, at specified coordinates.

Definition at line 33305 of file CImg.h.

33308  {
33309  CImgList<T>(*this,true).save_cimg(file,n0,x0,y0,z0,v0);
33310  return *this;
33311  }
const CImg< T > & save_cimg(const char *const filename, const bool compress=false) const
Save the image as a .cimg file.
Definition: CImg.h:33284
const CImg<T>& save_cpp ( const char *const  filename) const
inline

Save the image as a CPP source file.

Definition at line 32412 of file CImg.h.

Referenced by CImg< uintT >::save().

32412  {
32413  return _save_cpp(0,filename);
32414  }
const CImg< T > & _save_cpp(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32386

Here is the caller graph for this function:

const CImg<T>& save_cpp ( std::FILE *const  file) const
inline

Save the image as a CPP source file.

Definition at line 32417 of file CImg.h.

32417  {
32418  return _save_cpp(file,0);
32419  }
const CImg< T > & _save_cpp(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32386
const CImg<T>& save_dlm ( const char *const  filename) const
inline

Save the image as a DLM file.

Definition at line 32448 of file CImg.h.

Referenced by CImg< uintT >::save().

32448  {
32449  return _save_dlm(0,filename);
32450  }
const CImg< T > & _save_dlm(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32422

Here is the caller graph for this function:

const CImg<T>& save_dlm ( std::FILE *const  file) const
inline

Save the image as a DLM file.

Definition at line 32453 of file CImg.h.

32453  {
32454  return _save_dlm(file,0);
32455  }
const CImg< T > & _save_dlm(std::FILE *const file, const char *const filename) const
Definition: CImg.h:32422
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  dv = 1 
)
inlinestatic

Save an empty .cimg file with specified dimensions.

Definition at line 33314 of file CImg.h.

33316  {
33317  return CImgList<T>::save_empty_cimg(filename,1,dx,dy,dz,dv);
33318  }
NT dx
static void save_empty_cimg(const char *const filename, const unsigned int nb, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Create an empty .cimg file with specified dimensions.
Definition: CImg.h:36901
NT dy
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  dv = 1 
)
inlinestatic

Save an empty .cimg file with specified dimensions.

Definition at line 33321 of file CImg.h.

33323  {
33324  return CImgList<T>::save_empty_cimg(file,1,dx,dy,dz,dv);
33325  }
NT dx
static void save_empty_cimg(const char *const filename, const unsigned int nb, const unsigned int dx, const unsigned int dy=1, const unsigned int dz=1, const unsigned int dv=1)
Create an empty .cimg file with specified dimensions.
Definition: CImg.h:36901
NT dy
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
inline

Save the image as a video sequence file, using FFMPEG library.

Definition at line 33574 of file CImg.h.

Referenced by CImg< uintT >::save().

33575  {
33576  if (is_empty())
33577  throw CImgInstanceException("CImg<%s>::save_ffmpeg() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33578  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33579  if (!filename)
33580  throw CImgArgumentException("CImg<%s>::save_ffmpeg() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33582  if (!fps)
33583  throw CImgArgumentException("CImg<%s>::save_ffmpeg() : File '%s', specified framerate is 0.",
33584  pixel_type(),filename);
33585 #ifndef cimg_use_ffmpeg
33586  return save_ffmpeg_external(filename,first_frame,last_frame);
33587 #else
33588  get_split('z').save_ffmpeg(filename,first_frame,last_frame,fps);
33589 #endif
33590  return *this;
33591  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
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
Save the image as a video sequence file, using the external tool &#39;ffmpeg&#39;.
Definition: CImg.h:33670
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
Definition: CImg.h:18582
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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
inline

Save the image as a video sequence file, using the external tool 'ffmpeg'.

Definition at line 33670 of file CImg.h.

Referenced by CImg< uintT >::save_ffmpeg().

33671  {
33672  if (is_empty())
33673  throw CImgInstanceException("CImg<%s>::save_ffmpeg_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33674  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33675  if (!filename)
33676  throw CImgArgumentException("CImg<%s>::save_ffmpeg_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33678  get_split('z').save_ffmpeg_external(filename,first_frame,last_frame,codec);
33679  return *this;
33680  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
Definition: CImg.h:18582
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

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

Definition at line 33689 of file CImg.h.

Referenced by CImg< uintT >::save_other().

33689  {
33690  if (is_empty())
33691  throw CImgInstanceException("CImg<%s>::save_graphicsmagick_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33692  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33693  if (!filename)
33694  throw CImgArgumentException("CImg<%s>::save_graphicsmagick_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33696  char command[1024] = { 0 }, filetmp[512] = { 0 };
33697  std::FILE *file;
33698  do {
33699  if (dim==1) std::sprintf(filetmp,"%s%c%s.pgm",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
33700  else std::sprintf(filetmp,"%s%c%s.ppm",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
33701  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
33702  } while (file);
33703  save_pnm(filetmp);
33704  std::sprintf(command,"%s -quality %u%% %s \"%s\"",cimg::graphicsmagick_path(),quality,filetmp,filename);
33705  cimg::system(command);
33706  file = std::fopen(filename,"rb");
33707  if (!file)
33708  throw CImgIOException("CImg<%s>::save_graphicsmagick_external() : Failed to save image '%s'.\n\n"
33709  "Path of 'gm' : \"%s\"\n"
33710  "Path of temporary filename : \"%s\"\n",
33711  pixel_type(),filename,cimg::graphicsmagick_path(),filetmp);
33712  if (file) cimg::fclose(file);
33713  std::remove(filetmp);
33714  return *this;
33715  }
#define cimg_file_separator
Definition: CImg.h:144
const char * filenamerand()
Definition: CImg.h:4996
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const char * graphicsmagick_path(const char *const user_path=0, const bool reinit_path=false)
Return path of the GraphicsMagick&#39;s gm tool.
Definition: CImg.h:5198
const CImg< T > & save_pnm(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save the image as a PNM file.
Definition: CImg.h:32992
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_gzip_external ( const char *const  filename) const
inline

Save an image as a gzipped file, using external tool 'gzip'.

Definition at line 33718 of file CImg.h.

Referenced by CImg< uintT >::save().

33718  {
33719  if (!filename)
33720  throw CImgIOException("CImg<%s>::save_gzip_external() : Cannot save (null) filename.",
33721  pixel_type());
33722  char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
33723  const char
33724  *ext = cimg::split_filename(filename,body),
33725  *ext2 = cimg::split_filename(body,0);
33726  std::FILE *file;
33727  do {
33728  if (!cimg::strcasecmp(ext,"gz")) {
33729  if (*ext2) std::sprintf(filetmp,"%s%c%s.%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext2);
33730  else std::sprintf(filetmp,"%s%c%s.cimg",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
33731  } else {
33732  if (*ext) std::sprintf(filetmp,"%s%c%s.%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext);
33733  else std::sprintf(filetmp,"%s%c%s.cimg",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
33734  }
33735  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
33736  } while (file);
33737  save(filetmp);
33738  std::sprintf(command,"%s -c %s > \"%s\"",cimg::gzip_path(),filetmp,filename);
33739  cimg::system(command);
33740  file = std::fopen(filename,"rb");
33741  if (!file)
33742  throw CImgIOException("CImgList<%s>::save_gzip_external() : File '%s' cannot be saved.",
33743  pixel_type(),filename);
33744  else cimg::fclose(file);
33745  std::remove(filetmp);
33746  return *this;
33747  }
#define cimg_file_separator
Definition: CImg.h:144
const char * gzip_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the &#39;gzip&#39; command.
Definition: CImg.h:5377
const char * filenamerand()
Definition: CImg.h:4996
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int strcasecmp(const char *const s1, const char *const s2)
Compare two C-strings, ignoring the case.
Definition: CImg.h:4928
const CImg< T > & save(const char *const filename, const int number=-1) const
Save the image as a file.
Definition: CImg.h:32256
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the caller graph for this function:

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

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

Definition at line 33756 of file CImg.h.

Referenced by CImg< uintT >::save_other().

33756  {
33757  if (is_empty())
33758  throw CImgInstanceException("CImg<%s>::save_imagemagick_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33759  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33760  if (!filename)
33761  throw CImgArgumentException("CImg<%s>::save_imagemagick_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33763  char command[1024] = { 0 }, filetmp[512] = { 0 };
33764  std::FILE *file;
33765  do {
33766  std::sprintf(filetmp,"%s%c%s.%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),dim==1?"pgm":"ppm");
33767  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
33768  } while (file);
33769  save_pnm(filetmp);
33770  std::sprintf(command,"%s -quality %u%% %s \"%s\"",cimg::imagemagick_path(),quality,filetmp,filename);
33771  cimg::system(command);
33772  file = std::fopen(filename,"rb");
33773  if (!file)
33774  throw CImgIOException("CImg<%s>::save_imagemagick_external() : Failed to save image '%s'.\n\n"
33775  "Path of 'convert' : \"%s\"\n"
33776  "Path of temporary filename : \"%s\"\n",
33777  pixel_type(),filename,cimg::imagemagick_path(),filetmp);
33778  if (file) cimg::fclose(file);
33779  std::remove(filetmp);
33780  return *this;
33781  }
#define cimg_file_separator
Definition: CImg.h:144
const char * filenamerand()
Definition: CImg.h:4996
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const CImg< T > & save_pnm(const char *const filename, const unsigned int bytes_per_pixel=0) const
Save the image as a PNM file.
Definition: CImg.h:32992
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
const char * temporary_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to store temporary files.
Definition: CImg.h:5017
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * imagemagick_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path to the ImageMagick&#39;s convert tool.
Definition: CImg.h:5094
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_inr ( const char *const  filename,
const float *const  voxsize = 0 
) const
inline

Save the image as an INRIMAGE-4 file.

Definition at line 33362 of file CImg.h.

Referenced by CImg< uintT >::save().

33362  {
33363  return _save_inr(0,filename,voxsize);
33364  }
const CImg< T > & _save_inr(std::FILE *const file, const char *const filename, const float *const voxsize) const
Definition: CImg.h:33328

Here is the caller graph for this function:

const CImg<T>& save_inr ( std::FILE *const  file,
const float *const  voxsize = 0 
) const
inline

Save the image as an INRIMAGE-4 file.

Definition at line 33367 of file CImg.h.

33367  {
33368  return _save_inr(file,0,voxsize);
33369  }
const CImg< T > & _save_inr(std::FILE *const file, const char *const filename, const float *const voxsize) const
Definition: CImg.h:33328
const CImg<T>& save_jpeg ( const char *const  filename,
const unsigned int  quality = 100 
) const
inline

Save a file in JPEG format.

Definition at line 32644 of file CImg.h.

Referenced by CImg< uintT >::save().

32644  {
32645  return _save_jpeg(0,filename,quality);
32646  }
const CImg< T > & _save_jpeg(std::FILE *const file, const char *const filename, const unsigned int quality) const
Definition: CImg.h:32554

Here is the caller graph for this function:

const CImg<T>& save_jpeg ( std::FILE *const  file,
const unsigned int  quality = 100 
) const
inline

Save a file in JPEG format.

Definition at line 32649 of file CImg.h.

32649  {
32650  return _save_jpeg(file,0,quality);
32651  }
const CImg< T > & _save_jpeg(std::FILE *const file, const char *const filename, const unsigned int quality) const
Definition: CImg.h:32554
const CImg<T>& save_magick ( const char *const  filename,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Save the image using built-in ImageMagick++ library.

Definition at line 32654 of file CImg.h.

Referenced by CImg< uintT >::save_other().

32654  {
32655  if (is_empty())
32656  throw CImgInstanceException("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
32657  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
32658  if (!filename)
32659  throw CImgArgumentException("CImg<%s>::save_magick() : Instance image (%u,%u,%u,%u,%p), specified file is (null).",
32661  unsigned int foo = bytes_per_pixel; foo = 0;
32662 #ifdef cimg_use_magick
32663  double stmin, stmax = (double)maxmin(stmin);
32664  if (depth>1)
32665  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is volumetric. Only the first slice will be saved.",
32666  pixel_type(),filename,width,height,depth,dim,data);
32667  if (dim>3)
32668  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) is multispectral. Only the three first channels will be saved.",
32669  pixel_type(),filename,width,height,depth,dim,data);
32670  if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
32671  cimg::warn("CImg<%s>::save_magick() : File '%s', instance image (%u,%u,%u,%u,%p) has pixel values in [%g,%g]. Probable type overflow.",
32672  pixel_type(),filename,width,height,depth,dim,data,stmin,stmax);
32673  Magick::Image image(Magick::Geometry(width,height),"black");
32674  image.type(Magick::TrueColorType);
32675  image.depth(bytes_per_pixel?(8*bytes_per_pixel):(stmax>=256?16:8));
32676  const T
32677  *rdata = ptr(0,0,0,0),
32678  *gdata = dim>1?ptr(0,0,0,1):0,
32679  *bdata = dim>2?ptr(0,0,0,2):0;
32680  Magick::PixelPacket *pixels = image.getPixels(0,0,width,height);
32681  switch (dim) {
32682  case 1 : // Scalar images
32683  for (unsigned int off = width*height; off; --off) {
32684  pixels->red = pixels->green = pixels->blue = (Magick::Quantum)*(rdata++);
32685  ++pixels;
32686  }
32687  break;
32688  case 2 : // RG images
32689  for (unsigned int off = width*height; off; --off) {
32690  pixels->red = (Magick::Quantum)*(rdata++);
32691  pixels->green = (Magick::Quantum)*(gdata++);
32692  pixels->blue = 0; ++pixels;
32693  }
32694  break;
32695  default : // RGB images
32696  for (unsigned int off = width*height; off; --off) {
32697  pixels->red = (Magick::Quantum)*(rdata++);
32698  pixels->green = (Magick::Quantum)*(gdata++);
32699  pixels->blue = (Magick::Quantum)*(bdata++);
32700  ++pixels;
32701  }
32702  }
32703  image.syncPixels();
32704  image.write(filename);
32705 #else
32706  throw CImgIOException("CImg<%s>::save_magick() : File '%s', Magick++ library has not been linked.",
32707  pixel_type(),filename);
32708 #endif
32709  return *this;
32710  }
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_medcon_external ( const char *const  filename) const
inline

Save an image as a Dicom file (need '(X)Medcon' : http://xmedcon.sourceforge.net )

Definition at line 33784 of file CImg.h.

Referenced by CImg< uintT >::save().

33784  {
33785  if (is_empty())
33786  throw CImgInstanceException("CImg<%s>::save_medcon_external() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33787  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33788  if (!filename)
33789  throw CImgArgumentException("CImg<%s>::save_medcon_external() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33791 
33792  char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
33793  std::FILE *file;
33794  do {
33795  std::sprintf(filetmp,"%s.hdr",cimg::filenamerand());
33796  if ((file=std::fopen(filetmp,"rb"))!=0) std::fclose(file);
33797  } while (file);
33798  save_analyze(filetmp);
33799  std::sprintf(command,"%s -w -c dicom -o %s -f %s",cimg::medcon_path(),filename,filetmp);
33800  cimg::system(command);
33801  std::remove(filetmp);
33802  cimg::split_filename(filetmp,body);
33803  std::sprintf(filetmp,"%s.img",body);
33804  std::remove(filetmp);
33805  std::sprintf(command,"m000-%s",filename);
33806  file = std::fopen(command,"rb");
33807  if (!file) {
33808  cimg::fclose(cimg::fopen(filename,"r"));
33809  throw CImgIOException("CImg<%s>::save_medcon_external() : Failed to save image '%s'.\n\n"
33810  "Path of 'medcon' : \"%s\"\n"
33811  "Path of temporary filename : \"%s\"",
33812  pixel_type(),filename,cimg::medcon_path(),filetmp);
33813  } else cimg::fclose(file);
33814  std::rename(command,filename);
33815  return *this;
33816  }
const char * filenamerand()
Definition: CImg.h:4996
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
const char * medcon_path(const char *const user_path=0, const bool reinit_path=false)
Return or set path of the XMedcon tool.
Definition: CImg.h:5302
int system(const char *const command, const char *const module_name=0)
Definition: CImg.h:4491
const char * split_filename(const char *const filename, char *const body=0)
Split a filename into two strings &#39;body&#39; and &#39;extension&#39;.
Definition: CImg.h:5470
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
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.
Definition: CImg.h:33219
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_off ( const char *const  filename,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors 
) const
inline

Save OFF files.

Definition at line 33657 of file CImg.h.

33658  {
33659  return _save_off(0,filename,primitives,colors);
33660  }
const CImg< T > & _save_off(std::FILE *const file, const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
Definition: CImg.h:33607
const CImg<T>& save_off ( std::FILE *const  file,
const CImgList< tf > &  primitives,
const CImgList< tc > &  colors 
) const
inline

Save OFF files.

Definition at line 33664 of file CImg.h.

33665  {
33666  return _save_off(file,0,primitives,colors);
33667  }
const CImg< T > & _save_off(std::FILE *const file, const char *const filename, const CImgList< tf > &primitives, const CImgList< tc > &colors) const
Definition: CImg.h:33607
const CImg<T>& save_other ( const char *const  filename,
const unsigned int  quality = 100 
) const
inline

Definition at line 33819 of file CImg.h.

Referenced by CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_png(), CImg< uintT >::save(), and CImg< uintT >::save_tiff().

33819  {
33820  if (is_empty())
33821  throw CImgInstanceException("CImg<%s>::save_other() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33822  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33823  if (!filename)
33824  throw CImgIOException("CImg<%s>::save_other() : Instance image (%u,%u,%u,%u,%p), specified filename is (null).",
33825  pixel_type());
33826  const unsigned int omode = cimg::exception_mode();
33827  bool is_saved = true;
33828  cimg::exception_mode() = 0;
33829  try { save_magick(filename); }
33830  catch (CImgException&) {
33831  try { save_imagemagick_external(filename,quality); }
33832  catch (CImgException&) {
33833  try { save_graphicsmagick_external(filename,quality); }
33834  catch (CImgException&) {
33835  is_saved = false;
33836  }
33837  }
33838  }
33839  cimg::exception_mode() = omode;
33840  if (!is_saved)
33841  throw CImgIOException("CImg<%s>::save_other() : File '%s' cannot be saved.\n"
33842  "Check you have either the ImageMagick or GraphicsMagick package installed.",
33843  pixel_type(),filename);
33844  return *this;
33845  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const CImg< T > & save_imagemagick_external(const char *const filename, const unsigned int quality=100) const
Save the image using ImageMagick&#39;s convert.
Definition: CImg.h:33756
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int & exception_mode()
Get/set the current CImg exception mode.
Definition: CImg.h:1940
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
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.
Definition: CImg.h:32654
const CImg< T > & save_graphicsmagick_external(const char *const filename, const unsigned int quality=100) const
Save the image using GraphicsMagick&#39;s gm.
Definition: CImg.h:33689
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_pandore ( const char *const  filename,
const unsigned int  colorspace = 0 
) const
inline

Save the image as a PANDORE-5 file.

Definition at line 33533 of file CImg.h.

Referenced by CImg< uintT >::save().

33533  {
33534  return _save_pandore(0,filename,colorspace);
33535  }
const CImg< T > & _save_pandore(std::FILE *const file, const char *const filename, const unsigned int colorspace) const
Definition: CImg.h:33385

Here is the caller graph for this function:

const CImg<T>& save_pandore ( std::FILE *const  file,
const unsigned int  colorspace = 0 
) const
inline

Save the image as a PANDORE-5 file.

Definition at line 33538 of file CImg.h.

33538  {
33539  return _save_pandore(file,0,colorspace);
33540  }
const CImg< T > & _save_pandore(std::FILE *const file, const char *const filename, const unsigned int colorspace) const
Definition: CImg.h:33385
const CImg<T>& save_png ( const char *const  filename,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Save a file in PNG format.

Definition at line 32890 of file CImg.h.

Referenced by CImg< uintT >::save().

32890  {
32891  return _save_png(0,filename,bytes_per_pixel);
32892  }
const CImg< T > & _save_png(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
Definition: CImg.h:32714

Here is the caller graph for this function:

const CImg<T>& save_png ( std::FILE *const  file,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Save a file in PNG format.

Definition at line 32895 of file CImg.h.

32895  {
32896  return _save_png(file,0,bytes_per_pixel);
32897  }
const CImg< T > & _save_png(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
Definition: CImg.h:32714
const CImg<T>& save_pnm ( const char *const  filename,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Save the image as a PNM file.

Definition at line 32992 of file CImg.h.

Referenced by CImg< uintT >::save(), CImg< uintT >::save_graphicsmagick_external(), and CImg< uintT >::save_imagemagick_external().

32992  {
32993  return _save_pnm(0,filename,bytes_per_pixel);
32994  }
const CImg< T > & _save_pnm(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
Definition: CImg.h:32900

Here is the caller graph for this function:

const CImg<T>& save_pnm ( std::FILE *const  file,
const unsigned int  bytes_per_pixel = 0 
) const
inline

Save the image as a PNM file.

Definition at line 32997 of file CImg.h.

32997  {
32998  return _save_pnm(file,0,bytes_per_pixel);
32999  }
const CImg< T > & _save_pnm(std::FILE *const file, const char *const filename, const unsigned int bytes_per_pixel=0) const
Definition: CImg.h:32900
const CImg<T>& save_raw ( const char *const  filename,
const bool  multiplexed = false 
) const
inline

Save the image as a RAW file.

Definition at line 33564 of file CImg.h.

Referenced by CImg< uintT >::save().

33564  {
33565  return _save_raw(0,filename,multiplexed);
33566  }
const CImg< T > & _save_raw(std::FILE *const file, const char *const filename, const bool multiplexed) const
Definition: CImg.h:33543

Here is the caller graph for this function:

const CImg<T>& save_raw ( std::FILE *const  file,
const bool  multiplexed = false 
) const
inline

Save the image as a RAW file.

Definition at line 33569 of file CImg.h.

33569  {
33570  return _save_raw(file,0,multiplexed);
33571  }
const CImg< T > & _save_raw(std::FILE *const file, const char *const filename, const bool multiplexed) const
Definition: CImg.h:33543
const CImg<T>& save_rgb ( const char *const  filename) const
inline

Save the image as a RGB file.

Definition at line 33048 of file CImg.h.

Referenced by CImg< uintT >::save().

33048  {
33049  return _save_rgb(0,filename);
33050  }
const CImg< T > & _save_rgb(std::FILE *const file, const char *const filename) const
Definition: CImg.h:33002

Here is the caller graph for this function:

const CImg<T>& save_rgb ( std::FILE *const  file) const
inline

Save the image as a RGB file.

Definition at line 33053 of file CImg.h.

33053  {
33054  return _save_rgb(file,0);
33055  }
const CImg< T > & _save_rgb(std::FILE *const file, const char *const filename) const
Definition: CImg.h:33002
const CImg<T>& save_rgba ( const char *const  filename) const
inline

Save the image as a RGBA file.

Definition at line 33115 of file CImg.h.

Referenced by CImg< uintT >::save().

33115  {
33116  return _save_rgba(0,filename);
33117  }
const CImg< T > & _save_rgba(std::FILE *const file, const char *const filename) const
Definition: CImg.h:33058

Here is the caller graph for this function:

const CImg<T>& save_rgba ( std::FILE *const  file) const
inline

Save the image as a RGBA file.

Definition at line 33120 of file CImg.h.

33120  {
33121  return _save_rgba(file,0);
33122  }
const CImg< T > & _save_rgba(std::FILE *const file, const char *const filename) const
Definition: CImg.h:33058
const CImg<T>& save_tiff ( const char *const  filename) const
inline

Save a file in TIFF format.

Definition at line 33198 of file CImg.h.

Referenced by CImg< uintT >::save().

33198  {
33199  if (is_empty())
33200  throw CImgInstanceException("CImg<%s>::save_tiff() : File '%s', instance image (%u,%u,%u,%u,%p) is empty.",
33201  pixel_type(),filename?filename:"(null)",width,height,depth,dim,data);
33202  if (!filename)
33203  throw CImgArgumentException("CImg<%s>::save_tiff() : Specified filename is (null) for instance image (%u,%u,%u,%u,%p).",
33205 #ifdef cimg_use_tiff
33206  TIFF *tif = TIFFOpen(filename,"w");
33207  if (tif) {
33208  cimg_forZ(*this,z) get_slice(z)._save_tiff(tif,z);
33209  TIFFClose(tif);
33210  } else throw CImgException("CImg<%s>::save_tiff() : File '%s', error while opening file stream for writing.",
33211  pixel_type(),filename);
33212 #else
33213  return save_other(filename);
33214 #endif
33215  return *this;
33216  }
const CImg< T > & save_tiff(const char *const filename) const
Save a file in TIFF format.
Definition: CImg.h:33198
const CImg< T > & save_other(const char *const filename, const unsigned int quality=100) const
Definition: CImg.h:33819
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< T > get_slice(const unsigned int z0) const
Definition: CImg.h:18443
CImg()
Default constructor.
Definition: CImg.h:9857
#define cimg_forZ(img, z)
Definition: CImg.h:595
for(;;)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& save_yuv ( const char *const  filename,
const bool  rgb2yuv = true 
) const
inline

Save the image as a YUV video sequence file.

Definition at line 33594 of file CImg.h.

Referenced by CImg< uintT >::save().

33594  {
33595  get_split('z').save_yuv(filename,rgb2yuv);
33596  return *this;
33597  }
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
Definition: CImg.h:18582

Here is the caller graph for this function:

const CImg<T>& save_yuv ( std::FILE *const  file,
const bool  rgb2yuv = true 
) const
inline

Save the image as a YUV video sequence file.

Definition at line 33600 of file CImg.h.

33600  {
33601  get_split('z').save_yuv(file,rgb2yuv);
33602  return *this;
33603  }
CImgList< T > get_split(const char axis, const int nb=0) const
Split image into a list.
Definition: CImg.h:18582
CImg<T>& select ( CImgDisplay disp,
const int  select_type = 2,
unsigned int *const  XYZ = 0,
const unsigned char *const  color = 0 
)
inline

Simple interface to select a shape from an image.

Parameters
selectionArray of 6 values containing the selection result
coords_typeDetermine shape type 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.

Definition at line 28588 of file CImg.h.

Referenced by plag_rflo_modstats::plag_rflo_commstatbuffwrapper(), and plag_rflo_modstats::plag_rflo_sendstatbuffwrapper().

28590  {
28591  return get_select(disp,select_type,XYZ,color).transfer_to(*this);
28592  }
CImg< intT > get_select(CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
Simple interface to select a shape from an image.
Definition: CImg.h:28602

Here is the caller graph for this function:

CImg<T>& select ( const char *const  title,
const int  select_type = 2,
unsigned int *const  XYZ = 0,
const unsigned char *const  color = 0 
)
inline

Simple interface to select a shape from an image.

Definition at line 28595 of file CImg.h.

28597  {
28598  return get_select(title,select_type,XYZ,color).transfer_to(*this);
28599  }
CImg< intT > get_select(CImgDisplay &disp, const int select_type=2, unsigned int *const XYZ=0, const unsigned char *const color=0) const
Simple interface to select a shape from an image.
Definition: CImg.h:28602
CImg<T>& sequence ( const T  a0,
const T  a1 
)
inline

Return a N-numbered sequence vector from a0 to a1.

Definition at line 13425 of file CImg.h.

Referenced by CImg< uintT >::draw_grid(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_sequence(), and CImg< uintT >::sequence().

13425  {
13426  if (is_empty()) return *this;
13427  const unsigned int siz = size() - 1;
13428  T* ptr = data;
13429  if (siz) {
13430  const Tfloat delta = (Tfloat)a1 - a0;
13431  cimg_foroff(*this,l) *(ptr++) = (T)(a0 + delta*l/siz);
13432  } else *ptr = a0;
13433  return *this;
13434  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_foroff(img, off)
Definition: CImg.h:590
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

static CImg<T> sequence ( const unsigned int  N,
const T  a0,
const T  a1 
)
inlinestatic

Return a N-numbered sequence vector from a0 to a1.

Definition at line 14389 of file CImg.h.

14389  {
14390  if (N) return CImg<T>(1,N).sequence(a0,a1);
14391  return CImg<T>();
14392  }
CImg< T > & sequence(const T a0, const T a1)
Return a N-numbered sequence vector from a0 to a1.
Definition: CImg.h:13425
CImg& set_linear_atXY ( const T &  val,
const float  fx,
const float  fy = 0,
const int  z = 0,
const int  v = 0,
const bool  add = false 
)
inline

Set a pixel value, with 2D float coordinates, using linear interpolation.

Definition at line 11804 of file CImg.h.

11805  {
11806  const int
11807  x = (int)fx-(fx>=0?0:1), nx = x+1,
11808  y = (int)fy-(fy>=0?0:1), ny = y+1;
11809  const float
11810  dx = fx-x,
11811  dy = fy-y;
11812  if (z>=0 && z<dimz() && v>=0 && v<dimv()) {
11813  if (y>=0 && y<dimy()) {
11814  if (x>=0 && x<dimx()) {
11815  const float w1 = (1-dx)*(1-dy), w2 = add?1:(1-w1);
11816  (*this)(x,y,z,v) = (T)(w1*val + w2*(*this)(x,y,z,v));
11817  }
11818  if (nx>=0 && nx<dimx()) {
11819  const float w1 = dx*(1-dy), w2 = add?1:(1-w1);
11820  (*this)(nx,y,z,v) = (T)(w1*val + w2*(*this)(nx,y,z,v));
11821  }
11822  }
11823  if (ny>=0 && ny<dimy()) {
11824  if (x>=0 && x<dimx()) {
11825  const float w1 = (1-dx)*dy, w2 = add?1:(1-w1);
11826  (*this)(x,ny,z,v) = (T)(w1*val + w2*(*this)(x,ny,z,v));
11827  }
11828  if (nx>=0 && nx<dimx()) {
11829  const float w1 = dx*dy, w2 = add?1:(1-w1);
11830  (*this)(nx,ny,z,v) = (T)(w1*val + w2*(*this)(nx,ny,z,v));
11831  }
11832  }
11833  }
11834  return *this;
11835  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
NT dy
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
CImg& set_linear_atXYZ ( const T &  val,
const float  fx,
const float  fy = 0,
const float  fz = 0,
const int  v = 0,
const bool  add = false 
)
inline

Set a pixel value, with 3D float coordinates, using linear interpolation.

Definition at line 11744 of file CImg.h.

11745  {
11746  const int
11747  x = (int)fx-(fx>=0?0:1), nx = x+1,
11748  y = (int)fy-(fy>=0?0:1), ny = y+1,
11749  z = (int)fz-(fz>=0?0:1), nz = z+1;
11750  const float
11751  dx = fx-x,
11752  dy = fy-y,
11753  dz = fz-z;
11754  if (v>=0 && v<dimv()) {
11755  if (z>=0 && z<dimz()) {
11756  if (y>=0 && y<dimy()) {
11757  if (x>=0 && x<dimx()) {
11758  const float w1 = (1-dx)*(1-dy)*(1-dz), w2 = add?1:(1-w1);
11759  (*this)(x,y,z,v) = (T)(w1*val + w2*(*this)(x,y,z,v));
11760  }
11761  if (nx>=0 && nx<dimx()) {
11762  const float w1 = dx*(1-dy)*(1-dz), w2 = add?1:(1-w1);
11763  (*this)(nx,y,z,v) = (T)(w1*val + w2*(*this)(nx,y,z,v));
11764  }
11765  }
11766  if (ny>=0 && ny<dimy()) {
11767  if (x>=0 && x<dimx()) {
11768  const float w1 = (1-dx)*dy*(1-dz), w2 = add?1:(1-w1);
11769  (*this)(x,ny,z,v) = (T)(w1*val + w2*(*this)(x,ny,z,v));
11770  }
11771  if (nx>=0 && nx<dimx()) {
11772  const float w1 = dx*dy*(1-dz), w2 = add?1:(1-w1);
11773  (*this)(nx,ny,z,v) = (T)(w1*val + w2*(*this)(nx,ny,z,v));
11774  }
11775  }
11776  }
11777  if (nz>=0 && nz<dimz()) {
11778  if (y>=0 && y<dimy()) {
11779  if (x>=0 && x<dimx()) {
11780  const float w1 = (1-dx)*(1-dy), w2 = add?1:(1-w1);
11781  (*this)(x,y,nz,v) = (T)(w1*val + w2*(*this)(x,y,nz,v));
11782  }
11783  if (nx>=0 && nx<dimx()) {
11784  const float w1 = dx*(1-dy), w2 = add?1:(1-w1);
11785  (*this)(nx,y,nz,v) = (T)(w1*val + w2*(*this)(nx,y,nz,v));
11786  }
11787  }
11788  if (ny>=0 && ny<dimy()) {
11789  if (x>=0 && x<dimx()) {
11790  const float w1 = (1-dx)*dy, w2 = add?1:(1-w1);
11791  (*this)(x,ny,nz,v) = (T)(w1*val + w2*(*this)(x,ny,nz,v));
11792  }
11793  if (nx>=0 && nx<dimx()) {
11794  const float w1 = dx*dy, w2 = add?1:(1-w1);
11795  (*this)(nx,ny,nz,v) = (T)(w1*val + w2*(*this)(nx,ny,nz,v));
11796  }
11797  }
11798  }
11799  }
11800  return *this;
11801  }
void int int REAL REAL * y
Definition: read.cpp:74
NT dx
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
NT dy
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061
CImg<T>& set_matrix_at ( const CImg< t > &  mat,
const unsigned int  x = 0,
const unsigned int  y = 0,
const unsigned int  z = 0 
)
inline

Set the image vec as the square matrix-valued pixel located at (x,y,z) of the current vector-valued image.

Definition at line 13310 of file CImg.h.

13310  {
13311  return set_vector_at(mat,x,y,z);
13312  }
void int int REAL REAL * y
Definition: read.cpp:74
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...
Definition: CImg.h:13298
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg<T>& set_tensor_at ( const CImg< t > &  ten,
const unsigned int  x = 0,
const unsigned int  y = 0,
const unsigned int  z = 0 
)
inline

Set the image vec as the tensor valued pixel located at (x,y,z) of the current vector-valued image.

Definition at line 13316 of file CImg.h.

13316  {
13317  if (ten.height==2) {
13318  (*this)(x,y,z,0) = (T)ten[0];
13319  (*this)(x,y,z,1) = (T)ten[1];
13320  (*this)(x,y,z,2) = (T)ten[3];
13321  }
13322  else {
13323  (*this)(x,y,z,0) = (T)ten[0];
13324  (*this)(x,y,z,1) = (T)ten[1];
13325  (*this)(x,y,z,2) = (T)ten[2];
13326  (*this)(x,y,z,3) = (T)ten[4];
13327  (*this)(x,y,z,4) = (T)ten[5];
13328  (*this)(x,y,z,5) = (T)ten[8];
13329  }
13330  return *this;
13331  }
void int int REAL REAL * y
Definition: read.cpp:74
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg<T>& set_vector_at ( const CImg< t > &  vec,
const unsigned int  x,
const unsigned int  y = 0,
const unsigned int  z = 0 
)
inline

Set the image vec as the vector valued pixel located at (x,y,z) of the current vector-valued image.

Definition at line 13298 of file CImg.h.

Referenced by CImg< uintT >::_load_raw(), and CImg< uintT >::set_matrix_at().

13298  {
13299  if (x<width && y<height && z<depth) {
13300  const unsigned int whz = width*height*depth;
13301  const t *ptrs = vec.data;
13302  T *ptrd = ptr(x,y,z);
13303  for (unsigned int k=cimg::min((unsigned int)vec.size(),dim); k; --k) { *ptrd = (T)*(ptrs++); ptrd+=whz; }
13304  }
13305  return *this;
13306  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& sharpen ( const float  amplitude,
const bool  sharpen_type = false,
const float  edge = 1,
const float  alpha = 0,
const float  sigma = 0 
)
inline

Sharpen image using anisotropic shock filters or inverse diffusion.

Definition at line 19922 of file CImg.h.

Referenced by CImg< uintT >::get_sharpen().

19922  {
19923  if (is_empty()) return *this;
19924  T valm, valM = maxmin(valm);
19925  const bool threed = (depth>1);
19926  const float nedge = 0.5f*edge;
19927  CImg<Tfloat> val, vec, veloc(width,height,depth,dim);
19928 
19929  if (threed) {
19930  CImg_3x3x3(I,T);
19931  if (sharpen_type) { // 3D Shock filter.
19932  CImg<Tfloat> G = (alpha>0?get_blur(alpha).get_structure_tensor():get_structure_tensor());
19933  if (sigma>0) G.blur(sigma);
19934 
19935  cimg_forXYZ(G,x,y,z) {
19936  G.get_tensor_at(x,y,z).symmetric_eigen(val,vec);
19937  G(x,y,z,0) = vec(0,0);
19938  G(x,y,z,1) = vec(0,1);
19939  G(x,y,z,2) = vec(0,2);
19940  G(x,y,z,3) = 1 - (Tfloat)std::pow(1+val[0]+val[1]+val[2],-(Tfloat)nedge);
19941  }
19942  cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) {
19943  const Tfloat
19944  u = G(x,y,z,0),
19945  v = G(x,y,z,1),
19946  w = G(x,y,z,2),
19947  amp = G(x,y,z,3),
19948  ixx = (Tfloat)Incc + Ipcc - 2*Iccc,
19949  ixy = 0.25f*((Tfloat)Innc + Ippc - Inpc - Ipnc),
19950  ixz = 0.25f*((Tfloat)Incn + Ipcp - Incp - Ipcn),
19951  iyy = (Tfloat)Icnc + Icpc - 2*Iccc,
19952  iyz = 0.25f*((Tfloat)Icnn + Icpp - Icnp - Icpn),
19953  izz = (Tfloat)Iccn + Iccp - 2*Iccc,
19954  ixf = (Tfloat)Incc - Iccc,
19955  ixb = (Tfloat)Iccc - Ipcc,
19956  iyf = (Tfloat)Icnc - Iccc,
19957  iyb = (Tfloat)Iccc - Icpc,
19958  izf = (Tfloat)Iccn - Iccc,
19959  izb = (Tfloat)Iccc - Iccp,
19960  itt = u*u*ixx + v*v*iyy + w*w*izz + 2*u*v*ixy + 2*u*w*ixz + 2*v*w*iyz,
19961  it = u*cimg::minmod(ixf,ixb) + v*cimg::minmod(iyf,iyb) + w*cimg::minmod(izf,izb);
19962  veloc(x,y,z,k) = -amp*cimg::sign(itt)*cimg::abs(it);
19963  }
19964  } else cimg_forV(*this,k) cimg_for3x3x3(*this,x,y,z,k,I) veloc(x,y,z,k) = -(Tfloat)Ipcc-Incc-Icpc-Icnc-Iccp-Iccn+6*Iccc; // 3D Inverse diffusion.
19965  } else {
19966  CImg_3x3(I,T);
19967  if (sharpen_type) { // 2D Shock filter.
19968  CImg<Tfloat> G = (alpha>0?get_blur(alpha).get_structure_tensor():get_structure_tensor());
19969  if (sigma>0) G.blur(sigma);
19970  cimg_forXY(G,x,y) {
19971  G.get_tensor_at(x,y).symmetric_eigen(val,vec);
19972  G(x,y,0) = vec(0,0);
19973  G(x,y,1) = vec(0,1);
19974  G(x,y,2) = 1 - (Tfloat)std::pow(1+val[0]+val[1],-(Tfloat)nedge);
19975  }
19976  cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) {
19977  const Tfloat
19978  u = G(x,y,0),
19979  v = G(x,y,1),
19980  amp = G(x,y,2),
19981  ixx = (Tfloat)Inc + Ipc - 2*Icc,
19982  ixy = 0.25f*((Tfloat)Inn + Ipp - Inp - Ipn),
19983  iyy = (Tfloat)Icn + Icp - 2*Icc,
19984  ixf = (Tfloat)Inc - Icc,
19985  ixb = (Tfloat)Icc - Ipc,
19986  iyf = (Tfloat)Icn - Icc,
19987  iyb = (Tfloat)Icc - Icp,
19988  itt = u*u*ixx + v*v*iyy + 2*u*v*ixy,
19989  it = u*cimg::minmod(ixf,ixb) + v*cimg::minmod(iyf,iyb);
19990  veloc(x,y,k) = -amp*cimg::sign(itt)*cimg::abs(it);
19991  }
19992  } else cimg_forV(*this,k) cimg_for3x3(*this,x,y,0,k,I) veloc(x,y,k) = -(Tfloat)Ipc-Inc-Icp-Icn+4*Icc; // 3D Inverse diffusion.
19993  }
19994  float m, M = (float)veloc.maxmin(m);
19995  const float vmax = (float)cimg::max(cimg::abs(m),cimg::abs(M));
19996  if (vmax!=0) { veloc*=amplitude/vmax; (*this)+=veloc; }
19997  return cut(valm,valM);
19998  }
if(dy > dx)
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define CImg_3x3x3(I, T)
Definition: CImg.h:461
T & max()
Return a reference to the maximum pixel value of the instance image.
Definition: CImg.h:12900
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
CImg< T > & cut(const T value_min, const T value_max)
Cut values of the instance image between value_min and value_max.
Definition: CImg.h:15172
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_forXYZ(img, x, y, z)
Definition: CImg.h:603
#define cimg_for3x3(img, x, y, z, v, I)
Definition: CImg.h:1081
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
T sign(const T x)
Return the sign of a number.
Definition: CImg.h:4770
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
T & maxmin(t &min_val)
Return a reference to the maximum pixel value and return also the minimum pixel value.
Definition: CImg.h:12951
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
CImg< Tfloat > get_blur(const float sigmax, const float sigmay, const float sigmaz, const bool cond=true) const
Definition: CImg.h:19220
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
#define cimg_for3x3x3(img, x, y, z, v, I)
Definition: CImg.h:1808
T minmod(const T a, const T b)
Return the minmod of two numbers.
Definition: CImg.h:4828
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
double pow(double value, const Exponent &exp)
#define CImg_3x3(I, T)
Definition: CImg.h:421
CImg< Tfloat > get_structure_tensor(const unsigned int scheme=1) const
Definition: CImg.h:20186
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& sin ( )
inline

Compute the sinus of each pixel value.

Definition at line 12590 of file CImg.h.

Referenced by CImg< uintT >::get_sin().

12590  {
12591  cimg_for(*this,ptr,T) (*ptr) = (T)std::sin((double)(*ptr));
12592  return *this;
12593  }
NT & sin
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& sinh ( )
inline

Compute the hyperbolic sine of each pixel value.

Definition at line 12620 of file CImg.h.

Referenced by CImg< uintT >::get_sinh().

12620  {
12621  cimg_for(*this,ptr,T) (*ptr) = (T)std::sinh((double)(*ptr));
12622  return *this;
12623  }
CImg< _cimg_Tfloat > sinh(const CImg< T > &instance)
Definition: CImg.h:6071
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

unsigned int size ( ) const
inline

Return the number of image buffer elements.

example:
CImg<> img(100,100,1,3);
if (img.size()==100*100*3) std::fprintf(stderr,"This statement is true");

Definition at line 11075 of file CImg.h.

Referenced by CImg< uintT >::_at(), CImg< uintT >::_load_ascii(), CImg< uintT >::_load_pandore(), CImg< uintT >::_load_pnm(), CImg< uintT >::_load_raw(), CImg< uintT >::_load_rgb(), CImg< uintT >::_load_rgba(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_raw(), CImg< uintT >::_solve(), CImg< uintT >::assign(), CImg< uintT >::at(), CImg< uintT >::atan2(), CImg< uintT >::back(), CImg< T >::_cimg_math_parser::compile(), CImg< uintT >::contains(), CImg< uintT >::div(), CImg< uintT >::dot(), CImg< uintT >::draw_line(), CImg< uintT >::draw_point(), CImg< uintT >::draw_polygon(), CImg< uintT >::draw_spline(), CImg< uintT >::end(), CImg< uintT >::equalize(), CImg< uintT >::fill(), CImg< uintT >::get_diagonal(), CImg< uintT >::get_histogram(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_resize(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_stats(), CImg< uintT >::get_tensor(), CImg< uintT >::invert_endianness(), CImg< uintT >::is_overlapped(), CImg< uintT >::kth_smallest(), CImg< uintT >::matrix(), CImg< uintT >::max(), CImg< uintT >::mean(), CImg< uintT >::median(), CImg< uintT >::min(), CImg< uintT >::MSE(), CImg< uintT >::mul(), CImg< T >::_cimg_math_parser::opcode(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator+=(), CImg< uintT >::operator-=(), CImg< uintT >::operator==(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::pow(), CImg< uintT >::print(), CImg< uintT >::resize(), CImg< uintT >::save_analyze(), CImg< uintT >::sequence(), CImg< uintT >::solve_tridiagonal(), CImg< uintT >::sort(), CImg< uintT >::unroll(), CImg< uintT >::value_string(), and CImg< uintT >::variancemean().

11075  {
11076  return width*height*depth*dim;
11077  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& slice ( const unsigned int  z0)
inline

Get a slice.

Definition at line 18439 of file CImg.h.

18439  {
18440  return slices(z0,z0);
18441  }
CImg< T > & slices(const unsigned int z0, const unsigned int z1)
Get a set of slices.
Definition: CImg.h:18448
CImg<T>& slices ( const unsigned int  z0,
const unsigned int  z1 
)
inline

Get a set of slices.

Definition at line 18448 of file CImg.h.

Referenced by CImg< uintT >::slice().

18448  {
18449  return get_slices(z0,z1).transfer_to(*this);
18450  }
CImg< T > get_slices(const unsigned int z0, const unsigned int z1) const
Definition: CImg.h:18452

Here is the caller graph for this function:

CImg<T>& solve ( const CImg< t > &  A)
inline

Solve a linear system AX=B where B=*this.

Definition at line 13559 of file CImg.h.

Referenced by CImg< uintT >::get_solve().

13559  {
13560  if (width!=1 || depth!=1 || dim!=1 || height!=A.height || A.depth!=1 || A.dim!=1)
13561  throw CImgArgumentException("CImg<%s>::solve() : Instance matrix size is (%u,%u,%u,%u) while "
13562  "size of given matrix A is (%u,%u,%u,%u).",
13563  pixel_type(),width,height,depth,dim,A.width,A.height,A.depth,A.dim);
13564 
13565  typedef _cimg_Ttfloat Ttfloat;
13566  if (A.width==A.height) {
13567 #ifdef cimg_use_lapack
13568  char TRANS='N';
13569  int INFO, N = height, LWORK = 4*N, one = 1, *IPIV = new int[N];
13570  Ttfloat
13571  *lapA = new Ttfloat[N*N],
13572  *lapB = new Ttfloat[N],
13573  *WORK = new Ttfloat[LWORK];
13574  cimg_forXY(A,k,l) lapA[k*N+l] = (Ttfloat)(A(k,l));
13575  cimg_forY(*this,i) lapB[i] = (Ttfloat)((*this)(i));
13576  cimg::getrf(N,lapA,IPIV,INFO);
13577  if (INFO)
13578  cimg::warn("CImg<%s>::solve() : LAPACK library function dgetrf_() returned error code %d.",
13579  pixel_type(),INFO);
13580  if (!INFO) {
13581  cimg::getrs(TRANS,N,lapA,IPIV,lapB,INFO);
13582  if (INFO)
13583  cimg::warn("CImg<%s>::solve() : LAPACK library function dgetrs_() returned Error code %d",
13584  pixel_type(),INFO);
13585  }
13586  if (!INFO) cimg_forY(*this,i) (*this)(i) = (T)(lapB[i]); else fill(0);
13587  delete[] IPIV; delete[] lapA; delete[] lapB; delete[] WORK;
13588 #else
13589  CImg<Ttfloat> lu(A);
13590  CImg<Ttfloat> indx;
13591  bool d;
13592  lu._LU(indx,d);
13593  _solve(lu,indx);
13594 #endif
13595  } else assign(A.get_pseudoinvert()*(*this));
13596  return *this;
13597  }
if(dy > dx)
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
CImg< T > & solve(const CImg< t > &A)
Solve a linear system AX=B where B=*this.
Definition: CImg.h:13559
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of code(though may enhance!portability between Crays and other systems)!INTEGER MPI_TAG_UB
const NT & d
j indices k indices k
Definition: Indexing.h:6
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
#define _cimg_Ttfloat
Definition: CImg.h:2302
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
subroutine function
Definition: TEMPLATE.F90:43
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
rational * A
Definition: vinci_lass.c:67
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
blockLoc i
Definition: read.cpp:79
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
CImg< T > & _solve(const CImg< t > &A, const CImg< ti > &indx)
Definition: CImg.h:13605
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& solve_tridiagonal ( const CImg< t > &  a,
const CImg< t > &  b,
const CImg< t > &  c 
)
inline

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

Definition at line 13629 of file CImg.h.

Referenced by CImg< uintT >::get_solve_tridiagonal().

13629  {
13630  const int siz = (int)size();
13631  if ((int)a.size()!=siz || (int)b.size()!=siz || (int)c.size()!=siz)
13632  throw CImgArgumentException("CImg<%s>::solve_tridiagonal() : arrays of triagonal coefficients have different size.",pixel_type);
13633  typedef _cimg_Ttfloat Ttfloat;
13634  CImg<Ttfloat> nc(siz);
13635  const T *ptra = a.data, *ptrb = b.data, *ptrc = c.data;
13636  T *ptrnc = nc.data, *ptrd = data;
13637  const Ttfloat valb0 = (Ttfloat)*(ptrb++);
13638  *ptrnc = *(ptrc++)/valb0;
13639  Ttfloat vald = (Ttfloat)(*(ptrd++)/=valb0);
13640  for (int i = 1; i<siz; ++i) {
13641  const Ttfloat
13642  vala = (Tfloat)*(ptra++),
13643  id = 1/(*(ptrb++) - *(ptrnc++)*vala);
13644  *ptrnc = *(ptrc++)*id;
13645  vald = ((*ptrd-=vala*vald)*=id);
13646  ++ptrd;
13647  }
13648  vald = *(--ptrd);
13649  for (int i = siz-2; i>=0; --i) vald = (*(--ptrd)-=*(--ptrnc)*vald);
13650  return *this;
13651  }
#define _cimg_Ttfloat
Definition: CImg.h:2302
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
blockLoc i
Definition: read.cpp:79
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781

Here is the caller graph for this function:

CImg<T>& sort ( CImg< t > &  permutations,
const bool  increasing = true 
)
inline

Sort values of a vector and get permutations.

Definition at line 13768 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_polygon(), CImg< uintT >::get_sort(), and CImg< uintT >::sort().

13768  {
13769  if (is_empty()) permutations.assign();
13770  else {
13771  if (permutations.size()!=size()) permutations.assign(size());
13772  cimg_foroff(permutations,off) permutations[off] = (t)off;
13773  _quicksort(0,size()-1,permutations,increasing);
13774  }
13775  return *this;
13776  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< T > & _quicksort(const int min, const int max, CImg< t > &permutations, const bool increasing)
Definition: CImg.h:13794
#define cimg_foroff(img, off)
Definition: CImg.h:590

Here is the caller graph for this function:

CImg<T>& sort ( const bool  increasing = true)
inline

Sort image values.

Definition at line 13784 of file CImg.h.

13784  {
13785  CImg<T> foo;
13786  return sort(foo,increasing);
13787  }
CImg< T > & sort(CImg< t > &permutations, const bool increasing=true)
Sort values of a vector and get permutations.
Definition: CImg.h:13768
static CImg<floatT> sphere3d ( CImgList< tf > &  primitives,
const float  radius = 50,
const unsigned int  subdivisions = 3 
)
inlinestatic

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(points3d,faces3d);
ref_sphere3d.jpg

Definition at line 22007 of file CImg.h.

22007  {
22008 
22009  // Create initial icosahedron
22010  primitives.assign();
22011  const double tmp = (1+std::sqrt(5.0f))/2, a = 1.0/std::sqrt(1+tmp*tmp), b = tmp*a;
22012  CImgList<floatT> vertices(12,1,3,1,1, b,a,0.0, -b,a,0.0, -b,-a,0.0, b,-a,0.0, a,0.0,b, a,0.0,-b,
22013  -a,0.0,-b, -a,0.0,b, 0.0,b,a, 0.0,-b,a, 0.0,-b,-a, 0.0,b,-a);
22014  primitives.assign(20,1,3,1,1, 4,8,7, 4,7,9, 5,6,11, 5,10,6, 0,4,3, 0,3,5, 2,7,1, 2,1,6,
22015  8,0,11, 8,11,1, 9,10,3, 9,2,10, 8,4,0, 11,0,5, 4,9,3,
22016  5,3,10, 7,8,1, 6,1,11, 7,2,9, 6,10,2);
22017 
22018  // Recurse subdivisions
22019  for (unsigned int i = 0; i<subdivisions; ++i) {
22020  const unsigned int L = primitives.width;
22021  for (unsigned int l = 0; l<L; ++l) {
22022  const unsigned int
22023  p0 = (unsigned int)primitives(0,0), p1 = (unsigned int)primitives(0,1), p2 = (unsigned int)primitives(0,2);
22024  const float
22025  x0 = vertices(p0,0), y0 = vertices(p0,1), z0 = vertices(p0,2),
22026  x1 = vertices(p1,0), y1 = vertices(p1,1), z1 = vertices(p1,2),
22027  x2 = vertices(p2,0), y2 = vertices(p2,1), z2 = vertices(p2,2),
22028  tnx0 = (x0+x1)/2, tny0 = (y0+y1)/2, tnz0 = (z0+z1)/2, nn0 = (float)std::sqrt(tnx0*tnx0+tny0*tny0+tnz0*tnz0),
22029  tnx1 = (x0+x2)/2, tny1 = (y0+y2)/2, tnz1 = (z0+z2)/2, nn1 = (float)std::sqrt(tnx1*tnx1+tny1*tny1+tnz1*tnz1),
22030  tnx2 = (x1+x2)/2, tny2 = (y1+y2)/2, tnz2 = (z1+z2)/2, nn2 = (float)std::sqrt(tnx2*tnx2+tny2*tny2+tnz2*tnz2),
22031  nx0 = tnx0/nn0, ny0 = tny0/nn0, nz0 = tnz0/nn0,
22032  nx1 = tnx1/nn1, ny1 = tny1/nn1, nz1 = tnz1/nn1,
22033  nx2 = tnx2/nn2, ny2 = tny2/nn2, nz2 = tnz2/nn2;
22034  int i0 = -1, i1 = -1, i2 = -1;
22035  cimglist_for(vertices,p) {
22036  const float x = (float)vertices(p,0), y = (float)vertices(p,1), z = (float)vertices(p,2);
22037  if (x==nx0 && y==ny0 && z==nz0) i0 = p;
22038  if (x==nx1 && y==ny1 && z==nz1) i1 = p;
22039  if (x==nx2 && y==ny2 && z==nz2) i2 = p;
22040  }
22041  if (i0<0) { CImg<floatT>::vector(nx0,ny0,nz0).transfer_to(vertices); i0 = vertices.width - 1; }
22042  if (i1<0) { CImg<floatT>::vector(nx1,ny1,nz1).transfer_to(vertices); i1 = vertices.width - 1; }
22043  if (i2<0) { CImg<floatT>::vector(nx2,ny2,nz2).transfer_to(vertices); i2 = vertices.width - 1; }
22044  primitives.remove(0);
22045  CImg<tf>::vector(p0,i0,i1).transfer_to(primitives);
22046  CImg<tf>::vector((tf)i0,(tf)p1,(tf)i2).transfer_to(primitives);
22047  CImg<tf>::vector((tf)i1,(tf)i2,(tf)p2).transfer_to(primitives);
22048  CImg<tf>::vector((tf)i1,(tf)i0,(tf)i2).transfer_to(primitives);
22049  }
22050  }
22051  return (vertices>'x')*=radius;
22052  }
void int int REAL REAL * y
Definition: read.cpp:74
NT p1
double sqrt(double d)
Definition: double.h:73
NT p0
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
#define cimglist_for(list, l)
Definition: CImg.h:1877
CImg<T>& sqr ( )
inline

Compute the square value of each pixel.

Definition at line 12520 of file CImg.h.

Referenced by CImg< uintT >::get_sqr().

12520  {
12521  cimg_for(*this,ptr,T) { const T val = *ptr; *ptr = (T)(val*val); };
12522  return *this;
12523  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& sqrt ( )
inline

Compute the square root of each pixel value.

Definition at line 12530 of file CImg.h.

Referenced by CImg< uintT >::get_sqrt().

12530  {
12531  cimg_for(*this,ptr,T) (*ptr) = (T)std::sqrt((double)(*ptr));
12532  return *this;
12533  }
double sqrt(double d)
Definition: double.h:73
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& stats ( const unsigned int  variance_method = 1)
inline

Compute a statistics vector (min,max,mean,variance,xmin,ymin,zmin,vmin,xmax,ymax,zmax,vmax).

Definition at line 13148 of file CImg.h.

13148  {
13149  return get_stats(variance_method).transfer_to(*this);
13150  }
CImg< Tfloat > get_stats(const unsigned int variance_method=1) const
Definition: CImg.h:13152
CImg<T>& structure_tensor ( const unsigned int  scheme = 1)
inline

Compute the structure tensor field of an image.

Definition at line 20182 of file CImg.h.

20182  {
20183  return get_structure_tensor(scheme).transfer_to(*this);
20184  }
static const int scheme
CImg< Tfloat > get_structure_tensor(const unsigned int scheme=1) const
Definition: CImg.h:20186
Tfloat sum ( ) const
inline

Return the sum of all the pixel values in an image.

Definition at line 13022 of file CImg.h.

Referenced by CImg< uintT >::_LU(), CImg< uintT >::_solve(), rflu_modrepair3d::angfnd(), arruda_boyce_cauchy(), prep_modbcdistribution::bcdistributionfiles(), cauchystressprinc(), spec_rflu_modchemistry::drate_stiff(), ensemble1loop(), ensemble2loops(), ensemble3lijk(), ensemble3likj(), ensemble3ljik(), ensemble3ljki(), ensemble3lkij(), ensemble3lkji(), findprobe(), inrt_calcdrag(), inrt_calcheattransfernonburn(), inrt_setparticletemp(), jacobi(), spec_rflu_modchemistry::lusolve(), plag_binsortnozzleinlet(), plag_binsortspatialdist(), plag_calcbreakup(), plag_calcderivedvariables(), plag_modeulerian::plag_calceulerianfield(), plag_cecellsgetbuffersize(), plag_modcheckvars::plag_checkpositivity(), plag_modcheckvars::plag_checkvalidity(), plag_corncellsloaddata(), plag_edgecellsloaddata(), plag_modsurfstats::plag_gathersurfstats(), plag_getcellindices(), plag_incelltestrobust(), plag_modeulerian::plag_initeulerianfield(), plag_injcejectparticle(), plag_injctestcell(), plag_injctilecalcrhs(), plag_injctileinitialize(), plag_modinjection::plag_invokeconsrandejec(), plag_modinjection::plag_invokeejecmodel1(), plag_patchloaddatabuffers(), plag_processeulerfield(), plag_rflu_initsolutionrandom(), plag_rflu_initsolutionscratch(), plag_rflu_injctilecalcrhs(), plag_writestattecascii(), plag_writetecplotascii(), radi_extinctioncoef(), spec_rflu_modchemistry::rate_stiff(), read_patran(), rflo_checkmetrics(), rflo_modmovegridframe::rflo_mgframemovecorners(), rflu_modpetscpoisson::rflu_petsc_createpoisson(), rflu_modpetscpoisson::rflu_petsc_solvepressurepoisson(), CImg< uintT >::RGBtoHSI(), rocfracprep(), sphere_imp_contains_point_3d(), trapezoid1loop(), trapezoid2loops(), trapezoid3lijk(), trapezoid3likj(), trapezoid3ljik(), trapezoid3ljki(), trapezoid3lkij(), trapezoid3lkji(), v3d8_me(), and CImg< uintT >::XYZtoxyY().

13022  {
13023  if (is_empty())
13024  throw CImgInstanceException("CImg<%s>::sum() : Instance image (%u,%u,%u,%u,%p) is empty.",
13026  Tfloat res = 0;
13027  cimg_for(*this,ptr,T) res+=*ptr;
13028  return res;
13029  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
const CImg<T>& SVD ( CImg< t > &  U,
CImg< t > &  S,
CImg< t > &  V,
const bool  sorting = true,
const unsigned int  max_iter = 40,
const float  lambda = 0 
) const
inline

Compute the SVD of a general matrix.

Definition at line 13843 of file CImg.h.

Referenced by CImg< uintT >::get_pseudoinvert(), CImg< uintT >::get_SVD(), CImg< uintT >::invert(), and CImg< uintT >::symmetric_eigen().

13844  {
13845  if (is_empty()) { U.assign(); S.assign(); V.assign(); }
13846  else {
13847  U = *this;
13848  if (lambda!=0) {
13849  const unsigned int delta = cimg::min(U.width,U.height);
13850  for (unsigned int i = 0; i<delta; ++i) U(i,i) = (t)(U(i,i) + lambda);
13851  }
13852  if (S.size()<width) S.assign(1,width);
13853  if (V.width<width || V.height<height) V.assign(width,width);
13854  CImg<t> rv1(width);
13855  t anorm = 0, c, f, g = 0, h, s, scale = 0;
13856  int l = 0, nm = 0;
13857 
13858  cimg_forX(U,i) {
13859  l = i+1; rv1[i] = scale*g; g = s = scale = 0;
13860  if (i<dimy()) {
13861  for (int k = i; k<dimy(); ++k) scale+= cimg::abs(U(i,k));
13862  if (scale) {
13863  for (int k = i; k<dimy(); ++k) { U(i,k)/=scale; s+= U(i,k)*U(i,k); }
13864  f = U(i,i); g = (t)((f>=0?-1:1)*std::sqrt(s)); h=f*g-s; U(i,i) = f-g;
13865  for (int j = l; j<dimx(); ++j) {
13866  s = 0;
13867  for (int k=i; k<dimy(); ++k) s+= U(i,k)*U(j,k);
13868  f = s/h;
13869  for (int k = i; k<dimy(); ++k) U(j,k)+= f*U(i,k);
13870  }
13871  for (int k = i; k<dimy(); ++k) U(i,k)*= scale;
13872  }
13873  }
13874  S[i]=scale*g;
13875 
13876  g = s = scale = 0;
13877  if (i<dimy() && i!=dimx()-1) {
13878  for (int k = l; k<dimx(); ++k) scale += cimg::abs(U(k,i));
13879  if (scale) {
13880  for (int k = l; k<dimx(); ++k) { U(k,i)/= scale; s+= U(k,i)*U(k,i); }
13881  f = U(l,i); g = (t)((f>=0?-1:1)*std::sqrt(s)); h = f*g-s; U(l,i) = f-g;
13882  for (int k = l; k<dimx(); ++k) rv1[k]=U(k,i)/h;
13883  for (int j = l; j<dimy(); ++j) {
13884  s = 0;
13885  for (int k = l; k<dimx(); ++k) s+= U(k,j)*U(k,i);
13886  for (int k = l; k<dimx(); ++k) U(k,j)+= s*rv1[k];
13887  }
13888  for (int k = l; k<dimx(); ++k) U(k,i)*= scale;
13889  }
13890  }
13891  anorm = (t)cimg::max((float)anorm,(float)(cimg::abs(S[i])+cimg::abs(rv1[i])));
13892  }
13893 
13894  for (int i = dimx()-1; i>=0; --i) {
13895  if (i<dimx()-1) {
13896  if (g) {
13897  for (int j = l; j<dimx(); ++j) V(i,j) =(U(j,i)/U(l,i))/g;
13898  for (int j = l; j<dimx(); ++j) {
13899  s = 0;
13900  for (int k = l; k<dimx(); ++k) s+= U(k,i)*V(j,k);
13901  for (int k = l; k<dimx(); ++k) V(j,k)+= s*V(i,k);
13902  }
13903  }
13904  for (int j = l; j<dimx(); ++j) V(j,i) = V(i,j) = (t)0.0;
13905  }
13906  V(i,i) = (t)1.0; g = rv1[i]; l = i;
13907  }
13908 
13909 
13910  for (int i = cimg::min(dimx(),dimy())-1; i>=0; --i) {
13911  l = i+1; g = S[i];
13912  for (int j = l; j<dimx(); ++j) U(j,i) = 0;
13913  if (g) {
13914  g = 1/g;
13915  for (int j = l; j<dimx(); ++j) {
13916  s = 0; for (int k = l; k<dimy(); ++k) s+= U(i,k)*U(j,k);
13917  f = (s/U(i,i))*g;
13918  for (int k = i; k<dimy(); ++k) U(j,k)+= f*U(i,k);
13919  }
13920  for (int j = i; j<dimy(); ++j) U(i,j)*= g;
13921  } else for (int j = i; j<dimy(); ++j) U(i,j) = 0;
13922  ++U(i,i);
13923  }
13924 
13925  for (int k = dimx()-1; k>=0; --k) {
13926  for (unsigned int its = 0; its<max_iter; ++its) {
13927  bool flag = true;
13928  for (l = k; l>=1; --l) {
13929  nm = l-1;
13930  if ((cimg::abs(rv1[l])+anorm)==anorm) { flag = false; break; }
13931  if ((cimg::abs(S[nm])+anorm)==anorm) break;
13932  }
13933  if (flag) {
13934  c = 0; s = 1;
13935  for (int i = l; i<=k; ++i) {
13936  f = s*rv1[i]; rv1[i] = c*rv1[i];
13937  if ((cimg::abs(f)+anorm)==anorm) break;
13938  g = S[i]; h = (t)cimg::_pythagore(f,g); S[i] = h; h = 1/h; c = g*h; s = -f*h;
13939  cimg_forY(U,j) { const t y = U(nm,j), z = U(i,j); U(nm,j) = y*c+z*s; U(i,j) = z*c-y*s; }
13940  }
13941  }
13942  const t z = S[k];
13943  if (l==k) { if (z<0) { S[k] = -z; cimg_forX(U,j) V(k,j) = -V(k,j); } break; }
13944  nm = k-1;
13945  t x = S[l], y = S[nm];
13946  g = rv1[nm]; h = rv1[k];
13947  f = ((y-z)*(y+z)+(g-h)*(g+h))/(2*h*y);
13948  g = (t)cimg::_pythagore(f,1.0);
13949  f = ((x-z)*(x+z)+h*((y/(f+ (f>=0?g:-g)))-h))/x;
13950  c = s = 1;
13951  for (int j = l; j<=nm; ++j) {
13952  const int i = j+1;
13953  g = rv1[i]; h = s*g; g = c*g;
13954  t y = S[i];
13955  t z = (t)cimg::_pythagore(f,h);
13956  rv1[j] = z; c = f/z; s = h/z;
13957  f = x*c+g*s; g = g*c-x*s; h = y*s; y*=c;
13958  cimg_forX(U,jj) { const t x = V(j,jj), z = V(i,jj); V(j,jj) = x*c+z*s; V(i,jj) = z*c-x*s; }
13959  z = (t)cimg::_pythagore(f,h); S[j] = z;
13960  if (z) { z = 1/z; c = f*z; s = h*z; }
13961  f = c*g+s*y; x = c*y-s*g;
13962  cimg_forY(U,jj) { const t y = U(j,jj); z = U(i,jj); U(j,jj) = y*c+z*s; U(i,jj) = z*c-y*s; }
13963  }
13964  rv1[l] = 0; rv1[k]=f; S[k]=x;
13965  }
13966  }
13967 
13968  if (sorting) {
13969  CImg<intT> permutations(width);
13970  CImg<t> tmp(width);
13971  S.sort(permutations,false);
13972  cimg_forY(U,k) {
13973  cimg_forX(permutations,x) tmp(x) = U(permutations(x),k);
13974  std::memcpy(U.ptr(0,k),tmp.data,sizeof(t)*width);
13975  }
13976  cimg_forY(V,k) {
13977  cimg_forX(permutations,x) tmp(x) = V(permutations(x),k);
13978  std::memcpy(V.ptr(0,k),tmp.data,sizeof(t)*width);
13979  }
13980  }
13981  }
13982  return *this;
13983  }
cimg::superset< t1, t2 >::type min(const t1 &a, const t2 &b)
Return the minimum value between two numbers.
Definition: CImg.h:4728
#define cimg_forX(img, x)
Definition: CImg.h:593
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
blockLoc i
Definition: read.cpp:79
cimg::superset< t1, t2 >::type max(const t1 &a, const t2 &b)
Return the maximum value between two numbers.
Definition: CImg.h:4749
void int int REAL * x
Definition: read.cpp:74
double _pythagore(double a, double b)
Definition: CImg.h:4881
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
j indices j
Definition: Indexing.h:6
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
for(;;)

Here is the caller graph for this function:

CImg<T>& swap ( CImg< T > &  img)
inline

Swap all fields of two images. Use with care !

Definition at line 10357 of file CImg.h.

Referenced by CImg< uintT >::transfer_to().

10357  {
10358  cimg::swap(width,img.width);
10359  cimg::swap(height,img.height);
10360  cimg::swap(depth,img.depth);
10361  cimg::swap(dim,img.dim);
10362  cimg::swap(data,img.data);
10363  cimg::swap(is_shared,img.is_shared);
10364  return img;
10365  }
void swap(T &a, T &b)
Exchange values of variables a and b.
Definition: CImg.h:4522
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

const CImg<T>& symmetric_eigen ( CImg< t > &  val,
CImg< t > &  vec 
) const
inline

Compute the eigenvalues and eigenvectors of a symmetric matrix.

Definition at line 13703 of file CImg.h.

Referenced by CImg< uintT >::get_symmetric_eigen().

13703  {
13704  if (is_empty()) { val.assign(); vec.assign(); }
13705  else {
13706 #ifdef cimg_use_lapack
13707  char JOB = 'V', UPLO = 'U';
13708  int N = width, LWORK = 4*N, INFO;
13709  Tfloat
13710  *lapA = new Tfloat[N*N],
13711  *lapW = new Tfloat[N],
13712  *WORK = new Tfloat[LWORK];
13713  cimg_forXY(*this,k,l) lapA[k*N+l] = (Tfloat)((*this)(k,l));
13714  cimg::syev(JOB,UPLO,N,lapA,lapW,WORK,LWORK,INFO);
13715  if (INFO)
13716  cimg::warn("CImg<%s>::symmetric_eigen() : LAPACK library function dsyev_() returned error code %d.",
13717  pixel_type(),INFO);
13718  val.assign(1,N);
13719  vec.assign(N,N);
13720  if (!INFO) {
13721  cimg_forY(val,i) val(i) = (T)lapW[N-1-i];
13722  cimg_forXY(vec,k,l) vec(k,l) = (T)(lapA[(N-1-k)*N+l]);
13723  } else { val.fill(0); vec.fill(0); }
13724  delete[] lapA; delete[] lapW; delete[] WORK;
13725 #else
13726  if (width!=height || depth>1 || dim>1)
13727  throw CImgInstanceException("CImg<%s>::eigen() : Instance object (%u,%u,%u,%u,%p) is empty.",
13729  val.assign(1,width);
13730  if (vec.data) vec.assign(width,width);
13731  if (width<3) return eigen(val,vec);
13732  CImg<t> V(width,width);
13733  SVD(vec,val,V,false);
13734  bool ambiguous = false;
13735  float eig = 0;
13736  cimg_forY(val,p) { // check for ambiguous cases.
13737  if (val[p]>eig) eig = (float)val[p];
13738  t scal = 0;
13739  cimg_forY(vec,y) scal+=vec(p,y)*V(p,y);
13740  if (cimg::abs(scal)<0.9f) ambiguous = true;
13741  if (scal<0) val[p] = -val[p];
13742  }
13743  if (ambiguous) {
13744  (eig*=2)++;
13745  SVD(vec,val,V,false,40,eig);
13746  val-=eig;
13747  }
13748  CImg<intT> permutations(width); // sort eigenvalues in decreasing order
13749  CImg<t> tmp(width);
13750  val.sort(permutations,false);
13751  cimg_forY(vec,k) {
13752  cimg_forX(permutations,x) tmp(x) = vec(permutations(x),k);
13753  std::memcpy(vec.ptr(0,k),tmp.data,sizeof(t)*width);
13754  }
13755 #endif
13756  }
13757  return *this;
13758  }
if(dy > dx)
void warn(const char *format,...)
Display a warning message.
Definition: CImg.h:4470
#define cimg_forX(img, x)
Definition: CImg.h:593
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of code(though may enhance!portability between Crays and other systems)!INTEGER MPI_TAG_UB
const NT & d
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
const CImg< T > & symmetric_eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a symmetric matrix.
Definition: CImg.h:13703
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
const CImg< T > & eigen(CImg< t > &val, CImg< t > &vec) const
Compute the eigenvalues and eigenvectors of a matrix.
Definition: CImg.h:13660
subroutine function
Definition: TEMPLATE.F90:43
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
const CImg< T > & SVD(CImg< t > &U, CImg< t > &S, CImg< t > &V, const bool sorting=true, const unsigned int max_iter=40, const float lambda=0) const
Compute the SVD of a general matrix.
Definition: CImg.h:13843
CImg< T > & abs()
Compute the absolute value of each pixel value.
Definition: CImg.h:12570
#define cimg_forXY(img, x, y)
Definition: CImg.h:597
CImg()
Default constructor.
Definition: CImg.h:9857
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forY(img, y)
Definition: CImg.h:594
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& tan ( )
inline

Compute the tangent of each pixel.

Definition at line 12600 of file CImg.h.

Referenced by CImg< uintT >::get_tan().

12600  {
12601  cimg_for(*this,ptr,T) (*ptr) = (T)std::tan((double)(*ptr));
12602  return *this;
12603  }
CImg< _cimg_Tfloat > tan(const CImg< T > &instance)
Definition: CImg.h:6046
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

CImg<T>& tanh ( )
inline

Compute the hyperbolic tangent of each pixel value.

Definition at line 12630 of file CImg.h.

Referenced by CImg< uintT >::get_tanh().

12630  {
12631  cimg_for(*this,ptr,T) (*ptr) = (T)std::tanh((double)(*ptr));
12632  return *this;
12633  }
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg< _cimg_Tfloat > tanh(const CImg< T > &instance)
Definition: CImg.h:6076

Here is the caller graph for this function:

CImg<T>& tensor ( )
inline

Realign pixel values of the instance image as a symmetric tensor.

Definition at line 13372 of file CImg.h.

Referenced by CImg< uintT >::draw_gaussian(), and CImg< uintT >::get_tensor_at().

13372  {
13373  return get_tensor().transfer_to(*this);
13374  }
CImg< T > get_tensor() const
Definition: CImg.h:13376

Here is the caller graph for this function:

static CImg<T> tensor ( const T &  a1)
inlinestatic

Return a 1x1 symmetric matrix with specified coefficients.

Definition at line 14342 of file CImg.h.

14342  {
14343  return matrix(a1);
14344  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> tensor ( const T &  a1,
const T &  a2,
const T &  a3 
)
inlinestatic

Return a 2x2 symmetric matrix tensor with specified coefficients.

Definition at line 14347 of file CImg.h.

14347  {
14348  return matrix(a1,a2,a2,a3);
14349  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
static CImg<T> tensor ( const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5,
const T &  a6 
)
inlinestatic

Return a 3x3 symmetric matrix with specified coefficients.

Definition at line 14352 of file CImg.h.

14352  {
14353  return matrix(a1,a2,a3,a2,a4,a5,a3,a5,a6);
14354  }
CImg< T > & matrix()
Realign pixel values of the instance image as a square matrix.
Definition: CImg.h:13343
CImg<T>& threshold ( const T  value,
const bool  soft_threshold = false,
const bool  strict_threshold = false 
)
inline

Threshold values of the instance image.

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 instance image. Resulting pixel values are either equal to 0 or 1.
Note
Sample code :
const CImg<float> img("reference.jpg"), res = img.get_threshold(128);
(img,res.normalize(0,255)).display();
ref_threshold.jpg

Definition at line 15234 of file CImg.h.

Referenced by CImg< uintT >::get_threshold().

15234  {
15235  if (is_empty()) return *this;
15236  if (strict_threshold) {
15237  if (soft_threshold) cimg_for(*this,ptr,T) { const T v = *ptr; *ptr = v>value?(T)(v-value):v<-(float)value?(T)(v+value):(T)0; }
15238  else cimg_for(*this,ptr,T) *ptr = *ptr>value?(T)1:(T)0;
15239  } else {
15240  if (soft_threshold) cimg_for(*this,ptr,T) { const T v = *ptr; *ptr = v>=value?(T)(v-value):v<=-(float)value?(T)(v+value):(T)0; }
15241  else cimg_for(*this,ptr,T) *ptr = *ptr>=value?(T)1:(T)0;
15242  }
15243  return *this;
15244  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080

Here is the caller graph for this function:

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

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(points3d,faces3d);
ref_torus3d.jpg

Definition at line 21922 of file CImg.h.

21924  {
21925  primitives.assign();
21926  if (!subdivisions1 || !subdivisions2) return CImg<floatT>();
21927  CImgList<floatT> vertices;
21928  for (unsigned int v = 0; v<subdivisions1; ++v) {
21929  const float
21930  beta = (float)(v*2*cimg::valuePI/subdivisions1),
21931  xc = radius1*(float)std::cos(beta),
21932  yc = radius1*(float)std::sin(beta);
21933  for (unsigned int u = 0; u<subdivisions2; ++u) {
21934  const float
21935  alpha = (float)(u*2*cimg::valuePI/subdivisions2),
21936  x = xc + radius2*(float)(std::cos(alpha)*std::cos(beta)),
21937  y = yc + radius2*(float)(std::cos(alpha)*std::sin(beta)),
21938  z = radius2*(float)std::sin(alpha);
21939  CImg<floatT>::vector(x,y,z).transfer_to(vertices);
21940  }
21941  }
21942  for (unsigned int vv = 0; vv<subdivisions1; ++vv) {
21943  const unsigned int nv = (vv+1)%subdivisions1;
21944  for (unsigned int uu = 0; uu<subdivisions2; ++uu) {
21945  const unsigned int nu = (uu+1)%subdivisions2, svv = subdivisions2*vv, snv = subdivisions2*nv;
21946  CImg<tf>::vector(svv+nu,svv+uu,snv+uu).transfer_to(primitives);
21947  CImg<tf>::vector(svv+nu,snv+uu,snv+nu).transfer_to(primitives);
21948  }
21949  }
21950  return vertices>'x';
21951  }
void int int REAL REAL * y
Definition: read.cpp:74
const double valuePI
Definition of the mathematical constant PI.
Definition: CImg.h:2761
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
CImg< T > & vector()
Unroll all images values into a one-column vector.
Definition: CImg.h:13334
void int int int REAL REAL REAL * z
Definition: write.cpp:76
NT & sin
void int int REAL * x
Definition: read.cpp:74
NT & cos
Tfloat trace ( ) const
inline

Return the trace of the image, viewed as a matrix.

Definition at line 13217 of file CImg.h.

Referenced by computefluxtot(), neoinccauchystress(), turb_lesesgmodel4(), turb_vfluxhybrid(), turb_vfluxhybridpatch(), turb_visfluxeddy(), and turb_visfluxeddypatch().

13217  {
13218  if (is_empty())
13219  throw CImgInstanceException("CImg<%s>::trace() : Instance matrix (%u,%u,%u,%u,%p) is empty.",
13221  Tfloat res = 0;
13222  cimg_forX(*this,k) res+=(*this)(k,k);
13223  return res;
13224  }
#define cimg_forX(img, x)
Definition: CImg.h:593
j indices k indices k
Definition: Indexing.h:6
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<t>& transfer_to ( CImg< t > &  img)
inline

Transfer the content of the instance image into another one in a way that memory copies are avoided if possible.

The instance image is always empty after a call to this function.

Definition at line 10332 of file CImg.h.

Referenced by CImg< T >::_cimg_math_parser::compile(), cimg_library::cimg::dialog(), CImg< uintT >::get_gradient(), CImg< uintT >::get_split(), CImg< uintT >::label_regions(), CImg< uintT >::operator*=(), CImg< uintT >::operator/=(), CImg< uintT >::plane3d(), CImg< uintT >::transfer_to(), and CImg< uintT >::value_string().

10332  {
10333  img.assign(*this);
10334  assign();
10335  return img;
10336  }
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103

Here is the caller graph for this function:

CImg<T>& transfer_to ( CImg< T > &  img)
inline

Definition at line 10338 of file CImg.h.

10338  {
10339  if (is_shared || img.is_shared) { img.assign(*this); assign(); } else { img.assign(); swap(img); }
10340  return img;
10341  }
bool is_shared
Variable telling if pixel buffer of the instance image is shared with another one.
Definition: CImg.h:9747
CImg< T > & assign()
In-place version of the default constructor/destructor.
Definition: CImg.h:10103
CImg< T > & swap(CImg< T > &img)
Swap all fields of two images. Use with care !
Definition: CImg.h:10357
CImgList<t>& transfer_to ( CImgList< t > &  list,
const unsigned int  pos = ~0U 
)
inline

Definition at line 10344 of file CImg.h.

10344  {
10345  const unsigned int npos = pos>list.width?list.width:pos;
10346  transfer_to(list.insert(1,npos)[npos]);
10347  return list;
10348  }
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
CImg<T>& translate ( const int  deltax,
const int  deltay = 0,
const int  deltaz = 0,
const int  deltav = 0,
const int  border_condition = 0 
)
inline

Translate the image.

Parameters
deltaxAmount of displacement along the X-axis.
deltayAmount of displacement along the Y-axis.
deltazAmount of displacement along the Z-axis.
deltavAmount of displacement along the V-axis.
border_conditionBorder condition.
  • border_condition can be :
    • 0 : Zero border condition (Dirichlet).
    • 1 : Nearest neighbors (Neumann).
    • 2 : Repeat Pattern (Fourier style).

Definition at line 17229 of file CImg.h.

Referenced by CImg< uintT >::draw_fill(), and CImg< uintT >::get_translate().

17230  {
17231  if (is_empty()) return *this;
17232  if (deltax) // Translate along X-axis
17233  switch (border_condition) {
17234  case 0 :
17235  if (cimg::abs(deltax)>=dimx()) return fill(0);
17236  if (deltax<0) cimg_forYZV(*this,y,z,k) {
17237  std::memmove(ptr(0,y,z,k),ptr(-deltax,y,z,k),(width+deltax)*sizeof(T));
17238  std::memset(ptr(width+deltax,y,z,k),0,-deltax*sizeof(T));
17239  } else cimg_forYZV(*this,y,z,k) {
17240  std::memmove(ptr(deltax,y,z,k),ptr(0,y,z,k),(width-deltax)*sizeof(T));
17241  std::memset(ptr(0,y,z,k),0,deltax*sizeof(T));
17242  }
17243  break;
17244  case 1 :
17245  if (deltax<0) {
17246  const int ndeltax = (-deltax>=dimx())?width-1:-deltax;
17247  if (!ndeltax) return *this;
17248  cimg_forYZV(*this,y,z,k) {
17249  std::memmove(ptr(0,y,z,k),ptr(ndeltax,y,z,k),(width-ndeltax)*sizeof(T));
17250  T *ptrd = ptr(width-1,y,z,k);
17251  const T val = *ptrd;
17252  for (int l = 0; l<ndeltax-1; ++l) *(--ptrd) = val;
17253  }
17254  } else {
17255  const int ndeltax = (deltax>=dimx())?width-1:deltax;
17256  if (!ndeltax) return *this;
17257  cimg_forYZV(*this,y,z,k) {
17258  std::memmove(ptr(ndeltax,y,z,k),ptr(0,y,z,k),(width-ndeltax)*sizeof(T));
17259  T *ptrd = ptr(0,y,z,k);
17260  const T val = *ptrd;
17261  for (int l = 0; l<ndeltax-1; ++l) *(++ptrd) = val;
17262  }
17263  }
17264  break;
17265  case 2 : {
17266  const int ml = cimg::mod(-deltax,dimx()), ndeltax = (ml<=dimx()/2)?ml:(ml-dimx());
17267  if (!ndeltax) return *this;
17268  T* buf = new T[cimg::abs(ndeltax)];
17269  if (ndeltax>0) cimg_forYZV(*this,y,z,k) {
17270  std::memcpy(buf,ptr(0,y,z,k),ndeltax*sizeof(T));
17271  std::memmove(ptr(0,y,z,k),ptr(ndeltax,y,z,k),(width-ndeltax)*sizeof(T));
17272  std::memcpy(ptr(width-ndeltax,y,z,k),buf,ndeltax*sizeof(T));
17273  } else cimg_forYZV(*this,y,z,k) {
17274  std::memcpy(buf,ptr(width+ndeltax,y,z,k),-ndeltax*sizeof(T));
17275  std::memmove(ptr(-ndeltax,y,z,k),ptr(0,y,z,k),(width+ndeltax)*sizeof(T));
17276  std::memcpy(ptr(0,y,z,k),buf,-ndeltax*sizeof(T));
17277  }
17278  delete[] buf;
17279  } break;
17280  }
17281 
17282  if (deltay) // Translate along Y-axis
17283  switch (border_condition) {
17284  case 0 :
17285  if (cimg::abs(deltay)>=dimy()) return fill(0);
17286  if (deltay<0) cimg_forZV(*this,z,k) {
17287  std::memmove(ptr(0,0,z,k),ptr(0,-deltay,z,k),width*(height+deltay)*sizeof(T));
17288  std::memset(ptr(0,height+deltay,z,k),0,-deltay*width*sizeof(T));
17289  } else cimg_forZV(*this,z,k) {
17290  std::memmove(ptr(0,deltay,z,k),ptr(0,0,z,k),width*(height-deltay)*sizeof(T));
17291  std::memset(ptr(0,0,z,k),0,deltay*width*sizeof(T));
17292  }
17293  break;
17294  case 1 :
17295  if (deltay<0) {
17296  const int ndeltay = (-deltay>=dimy())?height-1:-deltay;
17297  if (!ndeltay) return *this;
17298  cimg_forZV(*this,z,k) {
17299  std::memmove(ptr(0,0,z,k),ptr(0,ndeltay,z,k),width*(height-ndeltay)*sizeof(T));
17300  T *ptrd = ptr(0,height-ndeltay,z,k), *ptrs = ptr(0,height-1,z,k);
17301  for (int l = 0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,width*sizeof(T)); ptrd+=width; }
17302  }
17303  } else {
17304  const int ndeltay = (deltay>=dimy())?height-1:deltay;
17305  if (!ndeltay) return *this;
17306  cimg_forZV(*this,z,k) {
17307  std::memmove(ptr(0,ndeltay,z,k),ptr(0,0,z,k),width*(height-ndeltay)*sizeof(T));
17308  T *ptrd = ptr(0,1,z,k), *ptrs = ptr(0,0,z,k);
17309  for (int l = 0; l<ndeltay-1; ++l) { std::memcpy(ptrd,ptrs,width*sizeof(T)); ptrd+=width; }
17310  }
17311  }
17312  break;
17313  case 2 : {
17314  const int ml = cimg::mod(-deltay,dimy()), ndeltay = (ml<=dimy()/2)?ml:(ml-dimy());
17315  if (!ndeltay) return *this;
17316  T* buf = new T[width*cimg::abs(ndeltay)];
17317  if (ndeltay>0) cimg_forZV(*this,z,k) {
17318  std::memcpy(buf,ptr(0,0,z,k),width*ndeltay*sizeof(T));
17319  std::memmove(ptr(0,0,z,k),ptr(0,ndeltay,z,k),width*(height-ndeltay)*sizeof(T));
17320  std::memcpy(ptr(0,height-ndeltay,z,k),buf,width*ndeltay*sizeof(T));
17321  } else cimg_forZV(*this,z,k) {
17322  std::memcpy(buf,ptr(0,height+ndeltay,z,k),-ndeltay*width*sizeof(T));
17323  std::memmove(ptr(0,-ndeltay,z,k),ptr(0,0,z,k),width*(height+ndeltay)*sizeof(T));
17324  std::memcpy(ptr(0,0,z,k),buf,-ndeltay*width*sizeof(T));
17325  }
17326  delete[] buf;
17327  } break;
17328  }
17329 
17330  if (deltaz) // Translate along Z-axis
17331  switch (border_condition) {
17332  case 0 :
17333  if (cimg::abs(deltaz)>=dimz()) return fill(0);
17334  if (deltaz<0) cimg_forV(*this,k) {
17335  std::memmove(ptr(0,0,0,k),ptr(0,0,-deltaz,k),width*height*(depth+deltaz)*sizeof(T));
17336  std::memset(ptr(0,0,depth+deltaz,k),0,width*height*(-deltaz)*sizeof(T));
17337  } else cimg_forV(*this,k) {
17338  std::memmove(ptr(0,0,deltaz,k),ptr(0,0,0,k),width*height*(depth-deltaz)*sizeof(T));
17339  std::memset(ptr(0,0,0,k),0,deltaz*width*height*sizeof(T));
17340  }
17341  break;
17342  case 1 :
17343  if (deltaz<0) {
17344  const int ndeltaz = (-deltaz>=dimz())?depth-1:-deltaz;
17345  if (!ndeltaz) return *this;
17346  cimg_forV(*this,k) {
17347  std::memmove(ptr(0,0,0,k),ptr(0,0,ndeltaz,k),width*height*(depth-ndeltaz)*sizeof(T));
17348  T *ptrd = ptr(0,0,depth-ndeltaz,k), *ptrs = ptr(0,0,depth-1,k);
17349  for (int l = 0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,width*height*sizeof(T)); ptrd+=width*height; }
17350  }
17351  } else {
17352  const int ndeltaz = (deltaz>=dimz())?depth-1:deltaz;
17353  if (!ndeltaz) return *this;
17354  cimg_forV(*this,k) {
17355  std::memmove(ptr(0,0,ndeltaz,k),ptr(0,0,0,k),width*height*(depth-ndeltaz)*sizeof(T));
17356  T *ptrd = ptr(0,0,1,k), *ptrs = ptr(0,0,0,k);
17357  for (int l = 0; l<ndeltaz-1; ++l) { std::memcpy(ptrd,ptrs,width*height*sizeof(T)); ptrd+=width*height; }
17358  }
17359  }
17360  break;
17361  case 2 : {
17362  const int ml = cimg::mod(-deltaz,dimz()), ndeltaz = (ml<=dimz()/2)?ml:(ml-dimz());
17363  if (!ndeltaz) return *this;
17364  T* buf = new T[width*height*cimg::abs(ndeltaz)];
17365  if (ndeltaz>0) cimg_forV(*this,k) {
17366  std::memcpy(buf,ptr(0,0,0,k),width*height*ndeltaz*sizeof(T));
17367  std::memmove(ptr(0,0,0,k),ptr(0,0,ndeltaz,k),width*height*(depth-ndeltaz)*sizeof(T));
17368  std::memcpy(ptr(0,0,depth-ndeltaz,k),buf,width*height*ndeltaz*sizeof(T));
17369  } else cimg_forV(*this,k) {
17370  std::memcpy(buf,ptr(0,0,depth+ndeltaz,k),-ndeltaz*width*height*sizeof(T));
17371  std::memmove(ptr(0,0,-ndeltaz,k),ptr(0,0,0,k),width*height*(depth+ndeltaz)*sizeof(T));
17372  std::memcpy(ptr(0,0,0,k),buf,-ndeltaz*width*height*sizeof(T));
17373  }
17374  delete[] buf;
17375  } break;
17376  }
17377 
17378  if (deltav) // Translate along V-axis
17379  switch (border_condition) {
17380  case 0 :
17381  if (cimg::abs(deltav)>=dimv()) return fill(0);
17382  if (-deltav>0) {
17383  std::memmove(data,ptr(0,0,0,-deltav),width*height*depth*(dim+deltav)*sizeof(T));
17384  std::memset(ptr(0,0,0,dim+deltav),0,width*height*depth*(-deltav)*sizeof(T));
17385  } else cimg_forV(*this,k) {
17386  std::memmove(ptr(0,0,0,deltav),data,width*height*depth*(dim-deltav)*sizeof(T));
17387  std::memset(data,0,deltav*width*height*depth*sizeof(T));
17388  }
17389  break;
17390  case 1 :
17391  if (deltav<0) {
17392  const int ndeltav = (-deltav>=dimv())?dim-1:-deltav;
17393  if (!ndeltav) return *this;
17394  std::memmove(data,ptr(0,0,0,ndeltav),width*height*depth*(dim-ndeltav)*sizeof(T));
17395  T *ptrd = ptr(0,0,0,dim-ndeltav), *ptrs = ptr(0,0,0,dim-1);
17396  for (int l = 0; l<ndeltav-1; ++l) { std::memcpy(ptrd,ptrs,width*height*depth*sizeof(T)); ptrd+=width*height*depth; }
17397  } else {
17398  const int ndeltav = (deltav>=dimv())?dim-1:deltav;
17399  if (!ndeltav) return *this;
17400  std::memmove(ptr(0,0,0,ndeltav),data,width*height*depth*(dim-ndeltav)*sizeof(T));
17401  T *ptrd = ptr(0,0,0,1);
17402  for (int l = 0; l<ndeltav-1; ++l) { std::memcpy(ptrd,data,width*height*depth*sizeof(T)); ptrd+=width*height*depth; }
17403  }
17404  break;
17405  case 2 : {
17406  const int ml = cimg::mod(-deltav,dimv()), ndeltav = (ml<=dimv()/2)?ml:(ml-dimv());
17407  if (!ndeltav) return *this;
17408  T* buf = new T[width*height*depth*cimg::abs(ndeltav)];
17409  if (ndeltav>0) {
17410  std::memcpy(buf,data,width*height*depth*ndeltav*sizeof(T));
17411  std::memmove(data,ptr(0,0,0,ndeltav),width*height*depth*(dim-ndeltav)*sizeof(T));
17412  std::memcpy(ptr(0,0,0,dim-ndeltav),buf,width*height*depth*ndeltav*sizeof(T));
17413  } else {
17414  std::memcpy(buf,ptr(0,0,0,dim+ndeltav),-ndeltav*width*height*depth*sizeof(T));
17415  std::memmove(ptr(0,0,0,-ndeltav),data,width*height*depth*(dim+ndeltav)*sizeof(T));
17416  std::memcpy(data,buf,-ndeltav*width*height*depth*sizeof(T));
17417  }
17418  delete[] buf;
17419  } break;
17420  }
17421  return *this;
17422  }
T mod(const T &x, const T &m)
Return the modulo of a number.
Definition: CImg.h:4788
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
CImg< T > & fill(const T val)
Fill an image by a value val.
Definition: CImg.h:14432
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
int dimy() const
Return the number of rows of the instance image (size along the Y-axis, i.e image height)...
Definition: CImg.h:11051
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int dimz() const
Return the number of slices of the instance image (size along the Z-axis).
Definition: CImg.h:11056
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
#define cimg_forV(img, v)
Definition: CImg.h:596
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define cimg_forZV(img, z, v)
Definition: CImg.h:602
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606
int dimv() const
Return the number of vector channels of the instance image (size along the V-axis).
Definition: CImg.h:11061

Here is the caller graph for this function:

CImg<T>& translate_object3d ( const float  tx,
const float  ty = 0,
const float  tz = 0 
)
inline

Translate a 3D object.

Definition at line 21077 of file CImg.h.

21077  {
21078  if (is_empty()) return *this;
21079  if (height!=3 || depth>1 || dim>1)
21080  throw CImgInstanceException("CImg<%s>::translate_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21082  get_shared_line(0)+=tx; get_shared_line(1)+=ty; get_shared_line(2)+=tz;
21083  return *this;
21084  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image...
Definition: CImg.h:18517
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744
CImg<T>& translate_object3d ( )
inline

Translate a 3D object so that it becomes centered.

Definition at line 21091 of file CImg.h.

Referenced by CImg< uintT >::get_translate_object3d().

21091  {
21092  if (is_empty()) return *this;
21093  if (height!=3 || depth>1 || dim>1)
21094  throw CImgInstanceException("CImg<%s>::translate_object3d() : Instance image (%u,%u,%u,%u,%p) is not a set of 3D vertices.",
21096  CImg<T> xcoords = get_shared_line(0), ycoords = get_shared_line(1), zcoords = get_shared_line(2);
21097  float xm, xM = (float)xcoords.maxmin(xm), ym, yM = (float)ycoords.maxmin(ym), zm, zM = (float)zcoords.maxmin(zm);
21098  xcoords-=(xm + xM)/2; ycoords-=(ym + yM)/2; zcoords-=(zm + zM)/2;
21099  return *this;
21100  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
T * data
Pointer to the first pixel of the pixel buffer.
Definition: CImg.h:9750
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
CImg< T > get_shared_line(const unsigned int y0, const unsigned int z0=0, const unsigned int v0=0)
Return a shared-memory image referencing one particular line (y0,z0,v0) of the instance image...
Definition: CImg.h:18517
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& transpose ( )
inline

Transpose the current matrix.

Definition at line 13441 of file CImg.h.

13441  {
13442  if (width==1) { width=height; height=1; return *this; }
13443  if (height==1) { height=width; width=1; return *this; }
13444  if (width==height) {
13445  cimg_forYZV(*this,y,z,v) for (int x=y; x<dimx(); ++x) cimg::swap((*this)(x,y,z,v),(*this)(y,x,z,v));
13446  return *this;
13447  }
13448  return get_transpose().transfer_to(*this);
13449  }
void int int REAL REAL * y
Definition: read.cpp:74
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
int dimx() const
Return the number of columns of the instance image (size along the X-axis, i.e image width)...
Definition: CImg.h:11046
void int int REAL * x
Definition: read.cpp:74
CImg< T > get_transpose() const
Definition: CImg.h:13451
for(;;)
CImg< T > & swap(CImg< T > &img)
Swap all fields of two images. Use with care !
Definition: CImg.h:10357
#define cimg_forYZV(img, y, z, v)
Definition: CImg.h:606
CImg<T>& unroll ( const char  axis)
inline

Unroll all images values into specified axis.

Definition at line 17610 of file CImg.h.

Referenced by CImg< uintT >::get_split(), CImg< uintT >::get_unroll(), and CImg< uintT >::vector().

17610  {
17611  const unsigned int siz = size();
17612  if (siz) switch (axis) {
17613  case 'x' : width = siz; height=depth=dim=1; break;
17614  case 'y' : height = siz; width=depth=dim=1; break;
17615  case 'z' : depth = siz; width=height=dim=1; break;
17616  case 'v' : dim = siz; width=height=depth=1; break;
17617  default :
17618  throw CImgArgumentException("CImg<%s>::unroll() : Given axis is '%c' which is not 'x','y','z' or 'v'",
17619  pixel_type(),axis);
17620  }
17621  return *this;
17622  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

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

Return a C-string containing the values of the instance image.

Definition at line 11838 of file CImg.h.

11838  {
11839  if (is_empty()) return CImg<charT>(1,1,1,1,0);
11840  const unsigned int siz = (unsigned int)size();
11841  CImgList<charT> items;
11842  char item[256] = { 0 };
11843  const T *ptrs = ptr();
11844  for (unsigned int off = 0; off<siz-1; ++off) {
11845  std::sprintf(item,cimg::type<T>::format(),cimg::type<T>::format(*(ptrs++)));
11846  const unsigned int l = std::strlen(item);
11847  CImg<charT>(item,l+1).transfer_to(items).back()[l] = separator;
11848  }
11849  std::sprintf(item,cimg::type<T>::format(),cimg::type<T>::format(*ptrs));
11850  CImg<charT>(item,std::strlen(item)+1).transfer_to(items);
11851  CImg<ucharT> res; (items>'x').transfer_to(res);
11852  if (max_size) { res.crop(0,max_size); res(max_size) = 0; }
11853  return res;
11854  }
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
CImg< t > & transfer_to(CImg< t > &img)
Transfer the content of the instance image into another one in a way that memory copies are avoided i...
Definition: CImg.h:10332
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
Tfloat variance ( const unsigned int  variance_method = 1) const
inline

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

Definition at line 13057 of file CImg.h.

Referenced by CImg< uintT >::get_stats(), and CImg< uintT >::variancemean().

13057  {
13058  Tfloat foo;
13059  return variancemean(variance_method,foo);
13060  }
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
Tfloat variancemean(const unsigned int variance_method, t &mean) const
Return the variance and the mean of the image.
Definition: CImg.h:13064

Here is the caller graph for this function:

Tfloat variancemean ( const unsigned int  variance_method,
t &  mean 
) const
inline

Return the variance and the mean of the image.

Definition at line 13064 of file CImg.h.

Referenced by CImg< uintT >::variance().

13064  {
13065  if (is_empty())
13066  throw CImgInstanceException("CImg<%s>::variance() : Instance image is empty.",pixel_type());
13067  Tfloat variance = 0, average = 0;
13068  const unsigned int siz = size();
13069  switch (variance_method) {
13070  case 3 : { // Least trimmed of Squares
13071  CImg<Tfloat> buf(*this);
13072  const unsigned int siz2 = siz>>1;
13073  cimg_for(buf,ptrs,Tfloat) { const Tfloat val = *ptrs; (*ptrs)*=val; average+=val; }
13074  buf.sort();
13075  Tfloat a = 0;
13076  const Tfloat *ptrs = buf.ptr();
13077  for (unsigned int j = 0; j<siz2; ++j) a+=*(ptrs++);
13078  const Tfloat sig = (Tfloat)(2.6477*std::sqrt(a/siz2));
13079  variance = sig*sig;
13080  } break;
13081  case 2 : { // Least Median of Squares (MAD)
13082  CImg<Tfloat> buf(*this);
13083  buf.sort();
13084  const unsigned int siz2 = siz>>1;
13085  const Tfloat med_i = buf[siz2];
13086  cimg_for(buf,ptrs,Tfloat) { const Tfloat val = *ptrs; *ptrs = cimg::abs(val - med_i); average+=val; }
13087  buf.sort();
13088  const Tfloat sig = (Tfloat)(1.4828*buf[siz2]);
13089  variance = sig*sig;
13090  } break;
13091  case 1 : { // Least mean square (robust definition)
13092  Tfloat S = 0, S2 = 0;
13093  cimg_for(*this,ptr,T) { const Tfloat val = (Tfloat)*ptr; S+=val; S2+=val*val; }
13094  variance = siz>1?(S2 - S*S/siz)/(siz - 1):0;
13095  average = S;
13096  } break;
13097  case 0 :{ // Least mean square (standard definition)
13098  Tfloat S = 0, S2 = 0;
13099  cimg_for(*this,ptr,T) { const Tfloat val = (Tfloat)*ptr; S+=val; S2+=val*val; }
13100  variance = (S2 - S*S/siz)/siz;
13101  average = S;
13102  } break;
13103  default :
13104  throw CImgArgumentException("CImg<%s>::variancemean() : Incorrect parameter 'variance_method = %d' (correct values are 0,1,2 or 3).",
13105  pixel_type(),variance_method);
13106  }
13107  mean = (t)(average/siz);
13108  return variance>0?variance:0;
13109  }
Tfloat mean() const
Return the mean pixel value of the instance image.
Definition: CImg.h:13032
double sqrt(double d)
Definition: double.h:73
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
unsigned int size() const
Return the number of image buffer elements.
Definition: CImg.h:11075
#define cimg_for(img, ptr, T_ptr)
Definition: CImg.h:589
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T abs(const T a)
Return the absolute value of a number.
Definition: CImg.h:4687
j indices j
Definition: Indexing.h:6
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
Tfloat variance(const unsigned int variance_method=1) const
Return the variance of the image.
Definition: CImg.h:13057

Here is the caller graph for this function:

CImg<T>& vector ( )
inline
static CImg<T> vector ( const T &  a0)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14134 of file CImg.h.

14134  {
14135  static CImg<T> r(1,1); r[0] = a0;
14136  return r;
14137  }
static CImg<T> vector ( const T &  a0,
const T &  a1 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14140 of file CImg.h.

14140  {
14141  static CImg<T> r(1,2); T *ptr = r.data;
14142  *(ptr++) = a0; *(ptr++) = a1;
14143  return r;
14144  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
static CImg<T> vector ( const T &  a0,
const T &  a1,
const T &  a2 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14147 of file CImg.h.

14147  {
14148  static CImg<T> r(1,3); T *ptr = r.data;
14149  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2;
14150  return r;
14151  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
static CImg<T> vector ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14154 of file CImg.h.

14154  {
14155  static CImg<T> r(1,4); T *ptr = r.data;
14156  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14157  return r;
14158  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
static CImg<T> vector ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14161 of file CImg.h.

14161  {
14162  static CImg<T> r(1,5); T *ptr = r.data;
14163  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4;
14164  return r;
14165  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
static CImg<T> vector ( const T &  a0,
const T &  a1,
const T &  a2,
const T &  a3,
const T &  a4,
const T &  a5 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14168 of file CImg.h.

14168  {
14169  static CImg<T> r(1,6); T *ptr = r.data;
14170  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3; *(ptr++) = a4; *(ptr++) = a5;
14171  return r;
14172  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14175 of file CImg.h.

14176  {
14177  static CImg<T> r(1,7); T *ptr = r.data;
14178  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14179  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6;
14180  return r;
14181  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14184 of file CImg.h.

14185  {
14186  static CImg<T> r(1,8); T *ptr = r.data;
14187  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14188  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14189  return r;
14190  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14193 of file CImg.h.

14195  {
14196  static CImg<T> r(1,9); T *ptr = r.data;
14197  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14198  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14199  *(ptr++) = a8;
14200  return r;
14201  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14204 of file CImg.h.

14206  {
14207  static CImg<T> r(1,10); T *ptr = r.data;
14208  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14209  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14210  *(ptr++) = a8; *(ptr++) = a9;
14211  return r;
14212  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14215 of file CImg.h.

14217  {
14218  static CImg<T> r(1,11); T *ptr = r.data;
14219  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14220  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14221  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10;
14222  return r;
14223  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14226 of file CImg.h.

14228  {
14229  static CImg<T> r(1,12); T *ptr = r.data;
14230  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14231  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14232  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14233  return r;
14234  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14237 of file CImg.h.

14240  {
14241  static CImg<T> r(1,13); T *ptr = r.data;
14242  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14243  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14244  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14245  *(ptr++) = a12;
14246  return r;
14247  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14250 of file CImg.h.

14253  {
14254  static CImg<T> r(1,14); T *ptr = r.data;
14255  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14256  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14257  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14258  *(ptr++) = a12; *(ptr++) = a13;
14259  return r;
14260  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14263 of file CImg.h.

14266  {
14267  static CImg<T> r(1,15); T *ptr = r.data;
14268  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14269  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14270  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14271  *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14;
14272  return r;
14273  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
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 
)
inlinestatic

Return a vector with specified coefficients.

Definition at line 14276 of file CImg.h.

14279  {
14280  static CImg<T> r(1,16); T *ptr = r.data;
14281  *(ptr++) = a0; *(ptr++) = a1; *(ptr++) = a2; *(ptr++) = a3;
14282  *(ptr++) = a4; *(ptr++) = a5; *(ptr++) = a6; *(ptr++) = a7;
14283  *(ptr++) = a8; *(ptr++) = a9; *(ptr++) = a10; *(ptr++) = a11;
14284  *(ptr++) = a12; *(ptr++) = a13; *(ptr++) = a14; *(ptr++) = a15;
14285  return r;
14286  }
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
CImg<T>& warp ( const CImg< t > &  warp,
const bool  relative = false,
const bool  interpolation = true,
const unsigned int  border_conditions = 0 
)
inline

Warp an image.

Definition at line 17863 of file CImg.h.

Referenced by CImg< uintT >::get_warp().

17864  {
17865  return get_warp(warp,relative,interpolation,border_conditions).transfer_to(*this);
17866  }
CImg< T > & warp(const CImg< t > &warp, const bool relative=false, const bool interpolation=true, const unsigned int border_conditions=0)
Warp an image.
Definition: CImg.h:17863
CImg< T > get_warp(const CImg< t > &warp, const bool relative=false, const bool interpolation=true, const unsigned int border_conditions=0) const
Definition: CImg.h:17869

Here is the caller graph for this function:

CImg<T>& xyYtoRGB ( )
inline

Convert a (x,y,Y) image to a (R,G,B) one.

Definition at line 16437 of file CImg.h.

Referenced by CImg< uintT >::get_xyYtoRGB().

16437  {
16438  return xyYtoXYZ().XYZtoRGB();
16439  }
CImg< T > & xyYtoXYZ()
Convert (x,y,Y) pixels of a color image into the (X,Y,Z)_709 color space.
Definition: CImg.h:16385

Here is the caller graph for this function:

CImg<T>& xyYtoXYZ ( )
inline

Convert (x,y,Y) pixels of a color image into the (X,Y,Z)_709 color space.

Definition at line 16385 of file CImg.h.

Referenced by CImg< uintT >::get_xyYtoXYZ(), and CImg< uintT >::xyYtoRGB().

16385  {
16386  if (is_empty()) return *this;
16387  if (dim!=3)
16388  throw CImgInstanceException("CImg<%s>::xyYtoXYZ() : Input image dimension is dim=%u, "
16389  "should be a (x,y,Y) image (dim=3)",
16390  pixel_type(),dim);
16391  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16392  for (unsigned int N = width*height*depth; N; --N) {
16393  const Tfloat
16394  px = (Tfloat)*p1,
16395  py = (Tfloat)*p2,
16396  Y = (Tfloat)*p3,
16397  ny = py>0?py:1;
16398  *(p1++) = (T)(px*Y/ny);
16399  *(p2++) = (T)Y;
16400  *(p3++) = (T)((1-px-py)*Y/ny);
16401  }
16402  return *this;
16403  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& XYZtoLab ( )
inline

Convert (X,Y,Z)_709 pixels of a color image into the (L*,a*,b*) color space.

Definition at line 16290 of file CImg.h.

Referenced by CImg< uintT >::get_XYZtoLab().

16290  {
16291 #define _cimg_Labf(x) ((x)>=0.008856f?(std::pow(x,(Tfloat)1/3)):(7.787f*(x)+16.0f/116))
16292  if (is_empty()) return *this;
16293  if (dim!=3)
16294  throw CImgInstanceException("CImg<%s>::XYZtoLab() : Input image dimension is dim=%u, "
16295  "should be a (X,Y,Z) image (dim=3)",
16296  pixel_type(),dim);
16297  const Tfloat
16298  Xn = (Tfloat)(0.412453f + 0.357580f + 0.180423f),
16299  Yn = (Tfloat)(0.212671f + 0.715160f + 0.072169f),
16300  Zn = (Tfloat)(0.019334f + 0.119193f + 0.950227f);
16301  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16302  for (unsigned int N = width*height*depth; N; --N) {
16303  const Tfloat
16304  X = (Tfloat)*p1,
16305  Y = (Tfloat)*p2,
16306  Z = (Tfloat)*p3,
16307  XXn = X/Xn, YYn = Y/Yn, ZZn = Z/Zn,
16308  fX = (Tfloat)_cimg_Labf(XXn),
16309  fY = (Tfloat)_cimg_Labf(YYn),
16310  fZ = (Tfloat)_cimg_Labf(ZZn);
16311  *(p1++) = (T)(116*fY - 16);
16312  *(p2++) = (T)(500*(fX - fY));
16313  *(p3++) = (T)(200*(fY - fZ));
16314  }
16315  return *this;
16316  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
#define _cimg_Labf(x)
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& XYZtoRGB ( )
inline

Convert (X,Y,Z)_709 pixels of a color image into the (R,G,B) color space.

Definition at line 16263 of file CImg.h.

Referenced by CImg< uintT >::get_XYZtoRGB().

16263  {
16264  if (is_empty()) return *this;
16265  if (dim!=3)
16266  throw CImgInstanceException("CImg<%s>::XYZtoRGB() : Input image dimension is dim=%u, "
16267  "should be a (X,Y,Z) image (dim=3)",
16268  pixel_type(),dim);
16269  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16270  for (unsigned int N = width*height*depth; N; --N) {
16271  const Tfloat
16272  X = (Tfloat)*p1*255,
16273  Y = (Tfloat)*p2*255,
16274  Z = (Tfloat)*p3*255,
16275  R = 3.240479f*X - 1.537150f*Y - 0.498535f*Z,
16276  G = -0.969256f*X + 1.875992f*Y + 0.041556f*Z,
16277  B = 0.055648f*X - 0.204043f*Y + 1.057311f*Z;
16278  *(p1++) = (T)(R<0?0:(R>255?255:R));
16279  *(p2++) = (T)(G<0?0:(G>255?255:G));
16280  *(p3++) = (T)(B<0?0:(B>255?255:B));
16281  }
16282  return *this;
16283  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& XYZtoxyY ( )
inline

Convert (X,Y,Z)_709 pixels of a color image into the (x,y,Y) color space.

Definition at line 16359 of file CImg.h.

Referenced by CImg< uintT >::get_XYZtoxyY().

16359  {
16360  if (is_empty()) return *this;
16361  if (dim!=3)
16362  throw CImgInstanceException("CImg<%s>::XYZtoxyY() : Input image dimension is dim=%u, "
16363  "should be a (X,Y,Z) image (dim=3)",
16364  pixel_type(),dim);
16365  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16366  for (unsigned int N = width*height*depth; N; --N) {
16367  const Tfloat
16368  X = (Tfloat)*p1,
16369  Y = (Tfloat)*p2,
16370  Z = (Tfloat)*p3,
16371  sum = (X+Y+Z),
16372  nsum = sum>0?sum:1;
16373  *(p1++) = (T)(X/nsum);
16374  *(p2++) = (T)(Y/nsum);
16375  *(p3++) = (T)Y;
16376  }
16377  return *this;
16378  }
Tfloat sum() const
Return the sum of all the pixel values in an image.
Definition: CImg.h:13022
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& YCbCrtoRGB ( )
inline

Convert color pixels from (R,G,B) to (Y,Cb,Cr)_8.

Definition at line 16051 of file CImg.h.

Referenced by CImg< uintT >::get_YCbCrtoRGB().

16051  {
16052  if (is_empty()) return *this;
16053  if (dim!=3)
16054  throw CImgInstanceException("CImg<%s>::YCbCrtoRGB() : Input image dimension is dim=%u, "
16055  "should be a (Y,Cb,Cr)_8 image (dim=3)",
16056  pixel_type(),dim);
16057  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16058  for (unsigned int N = width*height*depth; N; --N) {
16059  const Tfloat
16060  Y = (Tfloat)*p1 - 16,
16061  Cb = (Tfloat)*p2 - 128,
16062  Cr = (Tfloat)*p3 - 128,
16063  R = (298*Y + 409*Cr + 128)/256,
16064  G = (298*Y - 100*Cb - 208*Cr + 128)/256,
16065  B = (298*Y + 516*Cb + 128)/256;
16066  *(p1++) = (T)(R<0?0:(R>255?255:R));
16067  *(p2++) = (T)(G<0?0:(G>255?255:G));
16068  *(p3++) = (T)(B<0?0:(B>255?255:B));
16069  }
16070  return *this;
16071  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

CImg<T>& YUVtoRGB ( )
inline

Convert color pixels from (Y,U,V) to (R,G,B).

Definition at line 16103 of file CImg.h.

Referenced by CImg< uintT >::get_YUVtoRGB().

16103  {
16104  if (is_empty()) return *this;
16105  if (dim!=3)
16106  throw CImgInstanceException("CImg<%s>::YUVtoRGB() : Input image dimension is dim=%u, "
16107  "should be a (Y,U,V) image (dim=3)",
16108  pixel_type(),dim);
16109  T *p1 = ptr(0,0,0,0), *p2 = ptr(0,0,0,1), *p3 = ptr(0,0,0,2);
16110  for (unsigned int N = width*height*depth; N; --N) {
16111  const Tfloat
16112  Y = (Tfloat)*p1,
16113  U = (Tfloat)*p2,
16114  V = (Tfloat)*p3,
16115  R = (Y + 1.140f*V)*255,
16116  G = (Y - 0.395f*U - 0.581f*V)*255,
16117  B = (Y + 2.032f*U)*255;
16118  *(p1++) = (T)(R<0?0:(R>255?255:R));
16119  *(p2++) = (T)(G<0?0:(G>255?255:G));
16120  *(p3++) = (T)(B<0?0:(B>255?255:B));
16121  }
16122  return *this;
16123  }
unsigned int width
Variable representing the width of the instance image (i.e. dimensions along the X-axis).
Definition: CImg.h:9711
NT p1
bool is_empty() const
Return true if current image is empty.
Definition: CImg.h:11864
unsigned int height
Variable representing the height of the instance image (i.e. dimensions along the Y-axis)...
Definition: CImg.h:9722
static const char * pixel_type()
Return the type of the pixel values.
Definition: CImg.h:11041
cimg::superset< T, float >::type Tfloat
Definition: CImg.h:9781
T * ptr()
Return a pointer to the pixel buffer.
Definition: CImg.h:11080
unsigned int depth
Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).
Definition: CImg.h:9733
unsigned int dim
Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis)...
Definition: CImg.h:9744

Here is the caller graph for this function:

Member Data Documentation

T* data

Pointer to the first pixel of the pixel buffer.

Definition at line 9750 of file CImg.h.

Referenced by CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_load_analyze(), CImg< uintT >::_load_ascii(), CImg< uintT >::_load_jpeg(), CImg< uintT >::_load_pandore(), CImg< uintT >::_load_pnm(), CImg< uintT >::_load_raw(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_inr(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_off(), CImg< uintT >::_save_pandore(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_raw(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append_object3d(), CImg< uintT >::assign(), CImg< uintT >::atan2(), CImg< uintT >::back(), CImg< uintT >::begin(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::CImg(), CImg< uintT >::contains(), CImg< uintT >::cross(), CImg< uintT >::det(), CImg< uintT >::display_graph(), CImg< uintT >::div(), CImg< uintT >::dot(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_triangle(), CImg< uintT >::eigen(), CImg< uintT >::end(), CImg< uintT >::fill(), CImg< uintT >::front(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_dijkstra(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_map(), CImg< uintT >::get_resize(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_stats(), CImg< uintT >::get_warp(), CImg< uintT >::invert(), CImg< uintT >::invert_endianness(), CImg< uintT >::is_empty(), CImg< uintT >::is_object3d(), CImg< uintT >::is_overlapped(), CImg< uintT >::kth_smallest(), CImg< uintT >::load_magick(), CImgList< uintT >::load_parrec(), CImg< uintT >::magnitude(), CImg< uintT >::max(), CImg< uintT >::maxmin(), CImg< uintT >::min(), CImg< uintT >::minmax(), CImg< uintT >::mirror(), CImg< uintT >::mul(), CImg< uintT >::operator bool(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator()(), CImg< uintT >::operator*=(), CImg< uintT >::operator+=(), CImg< uintT >::operator-=(), CImg< uintT >::operator/=(), CImg< uintT >::operator==(), CImg< uintT >::operator[](), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::pow(), CImg< uintT >::print(), CImg< uintT >::ptr(), CImg< uintT >::resize_object3d(), CImg< uintT >::save(), CImg< uintT >::save_analyze(), CImg< uintT >::save_ffmpeg(), CImg< uintT >::save_ffmpeg_external(), CImg< uintT >::save_graphicsmagick_external(), CImg< uintT >::save_imagemagick_external(), CImg< uintT >::save_magick(), CImg< uintT >::save_medcon_external(), CImg< uintT >::save_other(), CImg< uintT >::save_tiff(), CImg< uintT >::sequence(), CImg< uintT >::solve_tridiagonal(), CImg< uintT >::sum(), CImg< uintT >::swap(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::trace(), CImg< uintT >::translate(), CImg< uintT >::translate_object3d(), and CImg< uintT >::~CImg().

unsigned int depth

Variable representing the depth of the instance image (i.e. dimensions along the Z-axis).

Remarks
  • Prefer using the function CImg<T>::dimz() to get information about the depth of an image.
  • Use function CImg<T>::resize() to set a new depth for an image. Setting directly the variable depth would probably result in a library crash.
  • Classical 2D images have depth defined to 1.
  • Empty images have depth defined to 0.

Definition at line 9733 of file CImg.h.

Referenced by CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_draw_scanline(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_linear_atXYZ(), CImg< uintT >::_linear_atXYZV(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_inr(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_off(), CImg< uintT >::_save_pandore(), CImg< uintT >::_save_pandore_header_length(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_raw(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append_object3d(), CImg< uintT >::assign(), CImg< uintT >::autocrop(), CImg< uintT >::blur(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::blur_bilateral(), CImg< uintT >::CImg(), CImg< uintT >::CMYtoRGB(), CImg< uintT >::contains(), CImg< uintT >::crop(), CImg< uintT >::cross(), CImg< uintT >::deriche(), CImg< uintT >::det(), CImg< uintT >::dimz(), CImg< uintT >::display_graph(), CImg< uintT >::distance_hamilton(), CImg< uintT >::dot(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_point(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::edge_tensors(), CImg< uintT >::eigen(), CImg< uintT >::fillV(), CImg< uintT >::fillX(), CImg< uintT >::fillY(), CImg< uintT >::fillZ(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_blur_patch(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_correlate(), CImg< uintT >::get_crop(), CImg< uintT >::get_dijkstra(), CImg< uintT >::get_dilate(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_distance(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_erode(), CImg< uintT >::get_fill(), CImg< uintT >::get_gradient(), CImg< uintT >::get_haar(), CImg< uintT >::get_hessian(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_map(), CImg< uintT >::get_norm(), CImg< uintT >::get_projections2d(), CImg< uintT >::get_resize(), CImg< uintT >::get_resize_doubleXY(), CImg< uintT >::get_resize_halfXY(), CImg< uintT >::get_resize_tripleXY(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_rotate(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_structure_tensor(), CImg< uintT >::get_vector_at(), CImg< uintT >::get_warp(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::invert(), CImg< uintT >::is_empty(), CImg< uintT >::is_object3d(), CImg< uintT >::is_sameZ(), CImg< uintT >::kth_smallest(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::magnitude(), CImg< uintT >::max(), CImg< uintT >::min(), CImg< uintT >::mirror(), CImg< uintT >::MSE(), CImg< uintT >::offset(), CImg< uintT >::operator bool(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator()(), CImg< uintT >::operator*(), CImg< uintT >::operator*=(), CImg< uintT >::operator+=(), cimg_library::operator-(), CImg< uintT >::operator-(), CImg< uintT >::operator-=(), CImg< uintT >::operator/=(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::operator~(), CImg< uintT >::pow(), CImg< uintT >::print(), CImg< uintT >::ptr(), CImg< uintT >::resize(), CImg< uintT >::resize_object3d(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::save(), CImg< uintT >::save_analyze(), CImg< uintT >::save_ffmpeg(), CImg< uintT >::save_ffmpeg_external(), CImg< uintT >::save_graphicsmagick_external(), CImg< uintT >::save_imagemagick_external(), CImg< uintT >::save_magick(), CImg< uintT >::save_medcon_external(), CImg< uintT >::save_other(), CImg< uintT >::save_tiff(), CImg< uintT >::set_vector_at(), CImg< uintT >::sharpen(), CImg< uintT >::size(), CImg< uintT >::solve(), CImg< uintT >::sum(), CImg< uintT >::swap(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::trace(), CImg< uintT >::translate(), CImg< uintT >::translate_object3d(), CImg< uintT >::unroll(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().

unsigned int dim

Variable representing the number of channels of the instance image (i.e. dimensions along the V-axis).

Remarks
  • Prefer using the function CImg<T>::dimv() to get information about the depth of an image.
  • Use function CImg<T>::resize() to set a new vector dimension for an image. Setting directly the variable dim would probably result in a library crash.
  • Scalar-valued images (one value per pixel) have dim defined to 1.
  • Empty images have depth defined to 0.

Definition at line 9744 of file CImg.h.

Referenced by CImg< uintT >::_draw_object3d(), CImg< uintT >::_save_pandore_header_length(), CImg< uintT >::assign(), CImg< uintT >::contains(), CImg< uintT >::deriche(), CImg< uintT >::dimv(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_quiver(), CImg< uintT >::get_fill(), CImg< uintT >::get_gradient(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_map(), CImg< uintT >::get_matrix_at(), CImg< uintT >::get_projections2d(), CImg< uintT >::get_resize(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared(), CImg< uintT >::get_split(), CImg< uintT >::is_empty(), CImg< uintT >::mirror(), CImg< uintT >::MSE(), CImg< uintT >::operator bool(), cimg_library::operator-(), CImg< uintT >::operator-(), CImg< uintT >::set_vector_at(), and CImg< uintT >::size().

unsigned int height

Variable representing the height of the instance image (i.e. dimensions along the Y-axis).

Remarks
  • Prefer using the function CImg<T>::dimy() to get information about the height of an image.
  • Use function CImg<T>::resize() to set a new height for an image. Setting directly the variable height would probably result in a library crash.
  • 1D signals have height defined to 1.
  • Empty images have height defined to 0.

Definition at line 9722 of file CImg.h.

Referenced by CImg< uintT >::_cubic_atXY(), CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_draw_ellipse(), CImg< uintT >::_draw_object3d(), CImg< uintT >::_draw_polygon(), CImg< uintT >::_draw_scanline(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_linear_atXY(), CImg< uintT >::_linear_atXYZ(), CImg< uintT >::_linear_atXYZV(), CImg< uintT >::_load_dlm(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_pandore_header_length(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append_object3d(), CImg< uintT >::assign(), CImg< uintT >::autocrop(), CImg< uintT >::blur(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::blur_bilateral(), CImg< uintT >::CImg(), CImg< uintT >::CMYtoRGB(), CImg< uintT >::contains(), CImg< uintT >::crop(), CImg< uintT >::cross(), CImg< uintT >::deriche(), CImg< uintT >::det(), CImg< uintT >::dimy(), CImg< uintT >::display_graph(), CImg< uintT >::dot(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_plasma(), CImg< uintT >::draw_point(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::eigen(), CImg< T >::_cimg_math_parser::eval(), CImg< uintT >::fillV(), CImg< uintT >::fillX(), CImg< uintT >::fillY(), CImg< uintT >::fillZ(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_blur_patch(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_correlate(), CImg< uintT >::get_crop(), CImg< uintT >::get_dijkstra(), CImg< uintT >::get_dilate(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_erode(), CImg< uintT >::get_fill(), CImg< uintT >::get_gradient(), CImg< uintT >::get_haar(), CImg< uintT >::get_hessian(), CImg< uintT >::get_identity_matrix(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_map(), CImg< uintT >::get_norm(), CImg< uintT >::get_projections2d(), CImg< uintT >::get_resize(), CImg< uintT >::get_resize_doubleXY(), CImg< uintT >::get_resize_halfXY(), CImg< uintT >::get_resize_tripleXY(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_rotate(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_structure_tensor(), CImg< uintT >::get_vector_at(), CImg< uintT >::get_warp(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::identity_matrix(), CImg< uintT >::invert(), CImg< uintT >::is_empty(), CImg< uintT >::is_object3d(), CImg< uintT >::is_sameY(), CImg< uintT >::kth_smallest(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::load_tiff(), CImg< uintT >::magnitude(), CImg< uintT >::matrix(), CImg< uintT >::max(), CImg< uintT >::min(), CImg< uintT >::mirror(), CImg< uintT >::MSE(), CImg< uintT >::offset(), CImg< uintT >::operator bool(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator()(), CImg< uintT >::operator*(), CImg< uintT >::operator*=(), CImg< uintT >::operator+=(), cimg_library::operator-(), CImg< uintT >::operator-(), CImg< uintT >::operator-=(), CImg< uintT >::operator/=(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::operator~(), CImg< uintT >::pow(), CImg< uintT >::print(), CImg< uintT >::ptr(), CImgDisplay::resize(), CImg< uintT >::resize(), CImg< uintT >::resize_object3d(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::save(), CImg< uintT >::save_magick(), CImg< uintT >::set_vector_at(), CImg< uintT >::sharpen(), CImg< uintT >::size(), CImg< uintT >::solve(), CImg< uintT >::sum(), CImg< uintT >::SVD(), CImg< uintT >::swap(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::trace(), CImg< uintT >::translate(), CImg< uintT >::translate_object3d(), CImg< uintT >::transpose(), CImg< uintT >::unroll(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().

bool is_shared

Variable telling if pixel buffer of the instance image is shared with another one.

Definition at line 9747 of file CImg.h.

Referenced by CImg< uintT >::assign(), CImg< uintT >::CImg(), CImg< uintT >::print(), CImg< uintT >::swap(), CImg< uintT >::transfer_to(), and CImg< uintT >::~CImg().

unsigned int width

Variable representing the width of the instance image (i.e. dimensions along the X-axis).

Remarks
  • Prefer using the function CImg<T>::dimx() to get information about the width of an image.
  • Use function CImg<T>::resize() to set a new width for an image. Setting directly the variable width would probably result in a library crash.
  • Empty images have width defined to 0.

Definition at line 9711 of file CImg.h.

Referenced by CImg< uintT >::_cubic_atX(), CImg< uintT >::_cubic_atXY(), CImg< uintT >::_display(), CImg< uintT >::_display_object3d(), CImg< uintT >::_draw_scanline(), CImg< uintT >::_get_permute_axes(), CImg< uintT >::_get_select(), CImg< uintT >::_linear_atX(), CImg< uintT >::_linear_atXY(), CImg< uintT >::_linear_atXYZ(), CImg< uintT >::_linear_atXYZV(), CImg< uintT >::_load_dlm(), CImg< uintT >::_load_png(), CImg< uintT >::_save_ascii(), CImg< uintT >::_save_bmp(), CImg< uintT >::_save_cpp(), CImg< uintT >::_save_dlm(), CImg< uintT >::_save_jpeg(), CImg< uintT >::_save_pandore_header_length(), CImg< uintT >::_save_png(), CImg< uintT >::_save_pnm(), CImg< uintT >::_save_rgb(), CImg< uintT >::_save_rgba(), CImg< uintT >::append_object3d(), CImgDisplay::assign(), CImg< uintT >::assign(), CImg< uintT >::autocrop(), CImg< uintT >::blur(), CImg< uintT >::blur_anisotropic(), CImg< uintT >::blur_bilateral(), CImg< uintT >::CImg(), CImg< uintT >::CMYtoRGB(), CImg< uintT >::contains(), CImg< uintT >::cross(), CImg< uintT >::deriche(), CImg< uintT >::det(), CImg< uintT >::dimx(), CImgDisplay::display(), CImg< uintT >::display_graph(), CImg< uintT >::dot(), CImg< uintT >::draw_axis(), CImg< uintT >::draw_fill(), CImg< uintT >::draw_gaussian(), CImg< uintT >::draw_graph(), CImg< uintT >::draw_grid(), CImg< uintT >::draw_image(), CImg< uintT >::draw_line(), CImg< uintT >::draw_mandelbrot(), CImg< uintT >::draw_plasma(), CImg< uintT >::draw_point(), CImg< uintT >::draw_quiver(), CImg< uintT >::draw_rectangle(), CImg< uintT >::draw_triangle(), CImg< uintT >::eigen(), CImg< uintT >::fillV(), CImg< uintT >::fillX(), CImg< uintT >::fillY(), CImg< uintT >::fillZ(), CImg< uintT >::get_BayertoRGB(), CImg< uintT >::get_blur_median(), CImg< uintT >::get_blur_patch(), CImg< uintT >::get_CMYKtoCMY(), CImg< uintT >::get_CMYtoCMYK(), CImg< uintT >::get_correlate(), CImg< uintT >::get_dijkstra(), CImg< uintT >::get_dilate(), CImg< uintT >::get_displacement_field(), CImg< uintT >::get_distance(), CImg< uintT >::get_elevation3d(), CImg< uintT >::get_erode(), CImg< uintT >::get_fill(), CImg< uintT >::get_gradient(), CImg< uintT >::get_haar(), CImg< uintT >::get_hessian(), CImg< uintT >::get_identity_matrix(), CImg< uintT >::get_index(), CImg< uintT >::get_isocurve3d(), CImg< uintT >::get_isosurface3d(), CImg< uintT >::get_label_regions(), CImg< uintT >::get_map(), CImg< uintT >::get_norm(), CImg< uintT >::get_projections2d(), CImg< uintT >::get_resize(), CImg< uintT >::get_resize_doubleXY(), CImg< uintT >::get_resize_halfXY(), CImg< uintT >::get_resize_tripleXY(), CImg< uintT >::get_RGBtoBayer(), CImg< uintT >::get_rotate(), CImg< uintT >::get_select_graph(), CImg< uintT >::get_shared(), CImg< uintT >::get_shared_channels(), CImg< uintT >::get_shared_lines(), CImg< uintT >::get_shared_planes(), CImg< uintT >::get_shared_points(), CImg< uintT >::get_split(), CImg< uintT >::get_structure_tensor(), CImg< uintT >::get_vector_at(), CImg< uintT >::get_warp(), CImg< uintT >::HSItoRGB(), CImg< uintT >::HSLtoRGB(), CImg< uintT >::HSVtoRGB(), CImg< uintT >::identity_matrix(), CImg< uintT >::invert(), CImg< uintT >::is_empty(), CImg< uintT >::is_object3d(), CImg< uintT >::is_sameX(), CImg< uintT >::kth_smallest(), CImg< uintT >::LabtoXYZ(), CImg< uintT >::load_tiff(), CImg< uintT >::magnitude(), CImg< uintT >::matrix(), CImg< uintT >::max(), CImg< uintT >::min(), CImg< uintT >::mirror(), CImg< uintT >::MSE(), CImg< uintT >::offset(), CImg< uintT >::operator bool(), CImg< uintT >::operator%=(), CImg< uintT >::operator&=(), CImg< uintT >::operator()(), CImg< uintT >::operator*(), CImg< uintT >::operator*=(), CImg< uintT >::operator+=(), cimg_library::operator-(), CImg< uintT >::operator-(), CImg< uintT >::operator-=(), CImg< uintT >::operator/=(), CImg< uintT >::operator^=(), CImg< uintT >::operator|=(), CImg< uintT >::operator~(), CImg< uintT >::pow(), CImg< uintT >::print(), CImg< uintT >::ptr(), CImgDisplay::render(), CImgDisplay::resize(), CImg< uintT >::resize(), CImg< uintT >::resize_object3d(), CImg< uintT >::RGBtoCMY(), CImg< uintT >::RGBtoHSI(), CImg< uintT >::RGBtoHSL(), CImg< uintT >::RGBtoHSV(), CImg< uintT >::RGBtoXYZ(), CImg< uintT >::RGBtoYCbCr(), CImg< uintT >::RGBtoYUV(), CImg< uintT >::save(), CImg< uintT >::save_magick(), CImg< uintT >::set_vector_at(), CImg< uintT >::sharpen(), CImg< uintT >::size(), CImg< uintT >::solve(), CImg< uintT >::sum(), CImg< uintT >::SVD(), CImg< uintT >::swap(), CImg< uintT >::symmetric_eigen(), CImg< uintT >::trace(), CImg< uintT >::translate(), CImg< uintT >::translate_object3d(), CImg< uintT >::transpose(), CImg< uintT >::unroll(), CImg< uintT >::xyYtoXYZ(), CImg< uintT >::XYZtoLab(), CImg< uintT >::XYZtoRGB(), CImg< uintT >::XYZtoxyY(), CImg< uintT >::YCbCrtoRGB(), and CImg< uintT >::YUVtoRGB().


The documentation for this struct was generated from the following file: