42 #include "private/DTypes.hpp"
59 #define MESSAGE(msg) cout << msg << endl;
64 #if defined __GNUC__ || defined __clang__
65 #define SMIL_UNUSED __attribute__((__unused__))
74 #define IMAGEFILEHANDLER_TEMP_SPEC(FORMAT, PIXELTYPE) \
76 class FORMAT##ImageFileHandler<PIXELTYPE> \
77 : public ImageFileHandler<PIXELTYPE> \
80 FORMAT##ImageFileHandler() : ImageFileHandler<PIXELTYPE>(#FORMAT) \
83 RES_T read(const char *filename, Image<PIXELTYPE> &image); \
84 RES_T write(const Image<PIXELTYPE> &image, const char *filename); \
87 #define SMART_POINTER(T) boost::shared_ptr<T>
88 #define SMART_IMAGE(T) SMART_POINTER(D_Image<T>)
90 #define D_DEFAULT_IMAGE_WIDTH 512
91 #define D_DEFAULT_IMAGE_HEIGHT 512
92 #define D_DEFAULT_IMAGE_DEPTH 1
94 #define D_DEFAULT_OUT_PIXEL_VAL 0
97 #define PI 3.141592653589793
101 #define MIN(a, b) ((a) < (b) ? (a) : (b))
104 #define MAX(a, b) ((a) > (b) ? (a) : (b))
107 #define ABS(a) ((a) >= 0 ? (a) : -(a))
112 template <
typename Lhs,
typename Rhs>
113 bool operator()(
const Lhs &lhs,
const Rhs &rhs)
const
115 return lhs.second < rhs.second;
123 template <
class T=
int>
152 Point(T _x, T _y, T _z) : x(_x), y(_y), z(_z)
160 Point(T _x, T _y) : x(_x), y(_y), z(0)
170 return (x == p2.x && y == p2.y && z == p2.z);
180 return Point(x - p2.x, y - p2.y, z - p2.z);
190 return Point(x + p2.x, y + p2.y, z + p2.z);
198 cout << indent <<
" " << x <<
"\t" << y <<
"\t" << z << endl;
271 size_t width, height, depth;
288 pt.x = pt.y = pt.z = 0;
307 ImageBox(
size_t width,
size_t height,
size_t depth = 1)
310 this->height = height;
312 pt.x = pt.y = pt.z = 0;
326 this->reference = x + y * width + z * width * height;
336 this->reference = pt.x + (pt.y + pt.z * width) * height;
344 this->reference = offset;
346 this->pt.x = offset % width;
347 offset = (offset - this->pt.x) / width;
348 this->pt.y = offset % height;
349 this->pt.z = (offset - this->pt.y) / height;
371 void shift(off_t dx, off_t dy, off_t dz = 0)
376 this->reference = pt.x + (pt.y * width + pt.z * height) * width;
387 this->reference = pt.x + (pt.y + pt.z * height) * width;
398 return inImage(pt.x, pt.y, pt.z);
408 bool inImage(off_t x, off_t y, off_t z = 0)
410 return (x >= 0 && x < width && y >= 0 && y < height && z >= 0 &&
414 bool inImage(
size_t x,
size_t y,
size_t z = 0)
416 return (x < width && y < height && z < depth);
428 return inImage(p.x, p.y, p.z);
438 return p.x + width * (p.y + p.z * height);
450 off = (off - p.x) / width;
452 p.z = (off - p.y) / height;
468 return getDistance(a, b);
479 return getDistance(reference, p);
490 return getDistance(pt, p);
501 return sqrt(
pow(a.x - b.x, 2) +
pow(a.y - b.y, 2) +
pow(a.z - b.z, 2));
506 cout <<
"ImageBox :" << endl;
507 cout <<
" Width :\t" << width << endl;
508 cout <<
" Height:\t" << height << endl;
509 cout <<
" Depth :\t" << depth << endl;
517 #define __FUNC__ __FUNCTION__
521 #define EXPAND(...) __VA_ARGS__
523 #define _GET_1ST_ARG(arg1, ...) arg1
524 #define _GET_2ND_ARG(arg1, arg2, ...) arg2
525 #define _GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
526 #define _GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
527 #define _GET_5TH_ARG(arg1, arg2, arg3, arg4, arg5, ...) arg5
528 #define _GET_6TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6
529 #define _GET_7TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ...) arg7
530 #define _GET_8TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ...) arg8
531 #define GET_1ST_ARG(...) EXPAND(_GET_1ST_ARG(__VA_ARGS__))
532 #define GET_2ND_ARG(...) EXPAND(_GET_2ND_ARG(__VA_ARGS__))
533 #define GET_3RD_ARG(...) EXPAND(_GET_3RD_ARG(__VA_ARGS__))
534 #define GET_4TH_ARG(...) EXPAND(_GET_4TH_ARG(__VA_ARGS__))
535 #define GET_5TH_ARG(...) EXPAND(_GET_5TH_ARG(__VA_ARGS__))
536 #define GET_6TH_ARG(...) EXPAND(_GET_6TH_ARG(__VA_ARGS__))
537 #define GET_7TH_ARG(...) EXPAND(_GET_7TH_ARG(__VA_ARGS__))
538 #define GET_8TH_ARG(...) EXPAND(_GET_8TH_ARG(__VA_ARGS__))
540 #define _xPP_NARGS_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
541 x13, x14, x15, N, ...) \
543 #define PP_NARGS(...) \
544 EXPAND(_xPP_NARGS_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, \
549 #define __FUNC__ __func__
551 #define GET_1ST_ARG(arg1, ...) arg1
552 #define GET_2ND_ARG(arg1, arg2, ...) arg2
553 #define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3
554 #define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
555 #define GET_5TH_ARG(arg1, arg2, arg3, arg4, arg5, ...) arg5
556 #define GET_6TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...) arg6
557 #define GET_7TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, arg7, ...) arg7
558 #define GET_8TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, ...) arg8
560 #define _xPP_NARGS_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
561 x13, x14, x15, N, ...) \
563 #define PP_NARGS(...) \
564 _xPP_NARGS_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, \
ImageBox.
Definition: DCommon.h:267
void setReference(IntPoint pt)
setReference() - set reference point
Definition: DCommon.h:333
off_t getOffset(IntPoint p)
getOffset() - given the coordinates of a pixel in a image box, get its offset.
Definition: DCommon.h:436
void setReference(off_t x, off_t y, off_t z=0)
setReference() - set reference point
Definition: DCommon.h:320
ImageBox(size_t Size[3])
ImageBox - constructor.
Definition: DCommon.h:283
bool inImage(IntPoint p)
inImage() - given the coordinates of a pixel, as a point, check if its coordinates are inside the ima...
Definition: DCommon.h:426
off_t getOffset()
getOffset() - get coordinates as an reference
Definition: DCommon.h:363
IntPoint getCoords(off_t off)
getCoords() - given the offset of a pixel inside an image, returns its coordinates as a point
Definition: DCommon.h:446
ImageBox(size_t width, size_t height, size_t depth=1)
ImageBox - constructor.
Definition: DCommon.h:307
ImageBox(const ImageBox &box)
ImageBox - constructor.
Definition: DCommon.h:298
bool inImage(size_t x, size_t y, size_t z=0)
inImage() - given the coordinates of a pixel, check if it's inside image box
Definition: DCommon.h:414
bool inImage()
inImage() - check if the reference point is inside image bounds
Definition: DCommon.h:396
void shift(off_t dx, off_t dy, off_t dz=0)
shift() - move the point by some displacements
Definition: DCommon.h:371
double getDistance(off_t pa, off_t pb)
getDistance() - given the offset of two points inside the image box returns the Euclidean between the...
Definition: DCommon.h:463
double getDistance(off_t p)
getDistance() - given a point inside an image box returns the Euclidean between this point and the re...
Definition: DCommon.h:477
double getDistance(IntPoint a, IntPoint b)
getDistance() - given two points inside the image box returns the Euclidean between them.
Definition: DCommon.h:499
double getDistance(IntPoint p)
getDistance() - given a point inside an image box returns the Euclidean between this point and the re...
Definition: DCommon.h:488
void setReference(off_t offset)
setReference() - set reference point
Definition: DCommon.h:342
void shift(IntPoint dp)
shift() - move the point by some displacements given by a point
Definition: DCommon.h:382
IntPoint getPoint()
getPoint() - get coordinates as a point
Definition: DCommon.h:355
Struct Point.
Definition: DCommon.h:125
void printSelf(string indent="")
printSelf() - Print point coordinates
Definition: DCommon.h:196
Point(T _x, T _y, T _z)
3D Point Constructor
Definition: DCommon.h:152
Point(const Point &pt)
Constructor from another point.
Definition: DCommon.h:144
Point operator-(const Point &p2)
operator- - subtract two points
Definition: DCommon.h:178
bool operator==(const Point &p2)
operator== - comparison
Definition: DCommon.h:168
Point operator+(const Point &p2)
operator+ - add two points
Definition: DCommon.h:188
Point(T _x, T _y)
2D Point Constructor
Definition: DCommon.h:160
Point()
Contructor - an empty point.
Definition: DCommon.h:135
RES_T sqrt(const Image< T1 > &imIn, Image< T2 > &imOut)
sqrt() - square root of an image
Definition: DImageArith.hpp:926
RES_T pow(const Image< T1 > &imIn, Image< T2 > &imOut, double exponent=2)
pow() - power of an image
Definition: DImageArith.hpp:905
Rectangle.
Definition: DCommon.h:253
Definition: DCommon.h:111