00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <QDebug>
00026 #include <QVImage>
00027
00028 #include <iostream>
00029 template <> const char * QVImage<uChar,1>::getTypeQString() const { return "QVImage<uChar,1>"; }
00030 template <> const char * QVImage<uChar,3>::getTypeQString() const { return "QVImage<uChar,3>"; }
00031 template <> const char * QVImage<uShort,1>::getTypeQString() const { return "QVImage<uShort,1>"; }
00032 template <> const char * QVImage<uShort,3>::getTypeQString() const { return "QVImage<uShort,3>"; }
00033 template <> const char * QVImage<sShort,1>::getTypeQString() const { return "QVImage<sShort,1>"; }
00034 template <> const char * QVImage<sShort,3>::getTypeQString() const { return "QVImage<sShort,3>"; }
00035 template <> const char * QVImage<sInt,1>::getTypeQString() const { return "QVImage<sInt,1>"; }
00036 template <> const char * QVImage<sInt,3>::getTypeQString() const { return "QVImage<sInt,3>"; }
00037 template <> const char * QVImage<sFloat,1>::getTypeQString() const { return "QVImage<sFloat,1>"; }
00038 template <> const char * QVImage<sFloat,3>::getTypeQString() const { return "QVImage<sFloat,3>"; }
00039
00040
00041 #define CREATE_COPY_CONSTRUCTOR(TYPE, C) \
00042 template <> QVImage<TYPE, C>::QVImage(QVImage<TYPE, C> const &img):QVGenericImage(img) \
00043 { \
00044 imageBuffer = img.imageBuffer; \
00045 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00046 step_div_type_size = getStep()/sizeof(TYPE); \
00047 }
00048
00049 CREATE_COPY_CONSTRUCTOR(uChar, 1);
00050 CREATE_COPY_CONSTRUCTOR(uChar, 3);
00051 CREATE_COPY_CONSTRUCTOR(uShort, 1);
00052 CREATE_COPY_CONSTRUCTOR(uShort, 3);
00053 CREATE_COPY_CONSTRUCTOR(sShort, 1);
00054 CREATE_COPY_CONSTRUCTOR(sShort, 3);
00055 CREATE_COPY_CONSTRUCTOR(sInt, 1);
00056 CREATE_COPY_CONSTRUCTOR(sInt, 3);
00057 CREATE_COPY_CONSTRUCTOR(sFloat, 1);
00058 CREATE_COPY_CONSTRUCTOR(sFloat, 3);
00059
00060
00061 #define CREATE_COPY_OPERATOR(TYPE, C) \
00062 template <> QVImage<TYPE,C> & QVImage<TYPE, C>::operator=(const QVImage<TYPE, C> &img) \
00063 { \
00064 imageBuffer = img.imageBuffer; \
00065 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00066 step_div_type_size = getStep()/sizeof(TYPE); \
00067 return *this; \
00068 }
00069
00070 CREATE_COPY_OPERATOR(uChar, 1);
00071 CREATE_COPY_OPERATOR(uChar, 3);
00072 CREATE_COPY_OPERATOR(uShort, 1);
00073 CREATE_COPY_OPERATOR(uShort, 3);
00074 CREATE_COPY_OPERATOR(sShort, 1);
00075 CREATE_COPY_OPERATOR(sShort, 3);
00076 CREATE_COPY_OPERATOR(sInt, 1);
00077 CREATE_COPY_OPERATOR(sInt, 3);
00078 CREATE_COPY_OPERATOR(sFloat, 1);
00079 CREATE_COPY_OPERATOR(sFloat, 3);
00080
00082
00083 #include <qvip/qvipp/qvipp.h>
00084
00085
00086 #define CREATE_COMPOSE_COPY_CONSTRUCTOR(TYPE) \
00087 template <> QVImage<TYPE, 3>::QVImage(QVImage<TYPE,1> const &red, QVImage<TYPE,1> const &green, QVImage<TYPE,1> const &blue):QVGenericImage(red) \
00088 { \
00089 imageBuffer = new QVImageBuffer<TYPE, 3>(red.getCols(), red.getRows()); \
00090 Copy(red, green, blue, *this); \
00091 setROI(red.getROI()); setAnchor(red.getAnchor()); \
00092 step_div_type_size = getStep()/sizeof(TYPE); \
00093 }
00094
00095 CREATE_COMPOSE_COPY_CONSTRUCTOR(uChar);
00096 CREATE_COMPOSE_COPY_CONSTRUCTOR(uShort);
00097 CREATE_COMPOSE_COPY_CONSTRUCTOR(sShort);
00098 CREATE_COMPOSE_COPY_CONSTRUCTOR(sInt);
00099 CREATE_COMPOSE_COPY_CONSTRUCTOR(sFloat);
00100
00101
00102 #define CREATE_CONVERT_CONSTRUCTOR(TYPE1, TYPE2, C) \
00103 template <> QVImage<TYPE2, C>::QVImage(QVImage<TYPE1, C> const &img):QVGenericImage(img) \
00104 { \
00105 imageBuffer = new QVImageBuffer<TYPE2, C>(img.getCols(), img.getRows()); \
00106 setAnchor(img.getROI().x(),img.getROI().y()); \
00107 Convert(img, *this); \
00108 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00109 step_div_type_size = getStep()/sizeof(TYPE2); \
00110 }
00111
00112
00113 CREATE_CONVERT_CONSTRUCTOR(uChar, uShort, 1);
00114 CREATE_CONVERT_CONSTRUCTOR(uChar, sShort, 1);
00115 CREATE_CONVERT_CONSTRUCTOR(uChar, sInt, 1);
00116 CREATE_CONVERT_CONSTRUCTOR(uChar, sFloat, 1);
00117 CREATE_CONVERT_CONSTRUCTOR(uChar, uShort, 3);
00118 CREATE_CONVERT_CONSTRUCTOR(uChar, sShort, 3);
00119 CREATE_CONVERT_CONSTRUCTOR(uChar, sInt, 3);
00120 CREATE_CONVERT_CONSTRUCTOR(uChar, sFloat, 3);
00121 CREATE_CONVERT_CONSTRUCTOR(uShort, uChar, 1);
00122 CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 1);
00123 CREATE_CONVERT_CONSTRUCTOR(uShort, sFloat, 1);
00124 CREATE_CONVERT_CONSTRUCTOR(uShort, uChar, 3);
00125 CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 3);
00126 CREATE_CONVERT_CONSTRUCTOR(uShort, sFloat, 3);
00127 CREATE_CONVERT_CONSTRUCTOR(sShort, uChar, 1);
00128 CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 1);
00129 CREATE_CONVERT_CONSTRUCTOR(sShort, sFloat, 1);
00130 CREATE_CONVERT_CONSTRUCTOR(sShort, uChar, 3);
00131 CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 3);
00132 CREATE_CONVERT_CONSTRUCTOR(sShort, sFloat, 3);
00133 CREATE_CONVERT_CONSTRUCTOR(sInt, uChar, 1);
00134 CREATE_CONVERT_CONSTRUCTOR(sInt, uChar, 3);
00135 CREATE_CONVERT_CONSTRUCTOR(sFloat, uChar, 1);
00136 CREATE_CONVERT_CONSTRUCTOR(sFloat, uShort, 1);
00137 CREATE_CONVERT_CONSTRUCTOR(sFloat, sShort, 1);
00138 CREATE_CONVERT_CONSTRUCTOR(sFloat, uChar, 3);
00139 CREATE_CONVERT_CONSTRUCTOR(sFloat, uShort, 3);
00140 CREATE_CONVERT_CONSTRUCTOR(sFloat, sShort, 3);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(TYPE1, TYPE2) \
00161 template <> QVImage<TYPE2, 1>::QVImage(QVImage<TYPE1, 1> const &img):QVGenericImage(img) \
00162 { \
00163 imageBuffer = new QVImageBuffer<TYPE2, 1>(img.getCols(), img.getRows()); \
00164 QVIMAGE_PTR_INIT_WRITE(TYPE2, this); \
00165 QVIMAGE_INIT_READ(TYPE1, img); \
00166 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
00167 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
00168 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 0); \
00169 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00170 step_div_type_size = getStep()/sizeof(TYPE2); \
00171 }
00172
00173 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(uShort, sShort);
00174 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sShort, uShort);
00175 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, uShort);
00176 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, sShort);
00177 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, sFloat);
00178 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sFloat, sInt);
00179
00180 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(TYPE1, TYPE2) \
00181 template <> QVImage<TYPE2, 3>::QVImage(QVImage<TYPE1, 3> const &img):QVGenericImage(img) \
00182 { \
00183 imageBuffer = new QVImageBuffer<TYPE2, 3>(img.getCols(), img.getRows()); \
00184 QVIMAGE_PTR_INIT_WRITE(TYPE2, this); \
00185 QVIMAGE_INIT_READ(TYPE1, img); \
00186 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
00187 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
00188 { \
00189 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 0); \
00190 QVIMAGE_PIXEL(this, col, row, 1) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 1); \
00191 QVIMAGE_PIXEL(this, col, row, 2) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 2); \
00192 } \
00193 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00194 step_div_type_size = getStep()/sizeof(TYPE2); \
00195 }
00196
00197 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(uShort, sShort);
00198 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sShort, uShort);
00199 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, uShort);
00200 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, sShort);
00201 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, sFloat);
00202 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sFloat, sInt);
00203
00204 #define CREATE_CONVERT_CONSTRUCTOR_C3_C1(TYPE) \
00205 template <> QVImage<TYPE, 1>::QVImage(QVImage<TYPE, 3> const &img):QVGenericImage(img) \
00206 { \
00207 imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows()); \
00208 setAnchor(img.getROI().x(),img.getROI().y()); \
00209 RGBToGray(img, *this); \
00210 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00211 }
00212
00213 CREATE_CONVERT_CONSTRUCTOR_C3_C1(uChar);
00214 CREATE_CONVERT_CONSTRUCTOR_C3_C1(uShort);
00215 CREATE_CONVERT_CONSTRUCTOR_C3_C1(sShort);
00216 CREATE_CONVERT_CONSTRUCTOR_C3_C1(sFloat);
00217
00218 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_C3_C1(TYPE) \
00219 template <> QVImage<TYPE, 1>::QVImage(QVImage<TYPE, 3> const &img):QVGenericImage(img) \
00220 { \
00221 imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows()); \
00222 QVIMAGE_PTR_INIT_WRITE(TYPE, this); \
00223 QVIMAGE_INIT_READ(TYPE, img); \
00224 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
00225 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
00226 { \
00227 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE)(0.299 * QVIMAGE_PIXEL(img, col, row, 0)); \
00228 QVIMAGE_PIXEL(this, col, row, 0) += (TYPE)(0.587 * QVIMAGE_PIXEL(img, col, row, 1)); \
00229 QVIMAGE_PIXEL(this, col, row, 0) += (TYPE)(0.114 * QVIMAGE_PIXEL(img, col, row, 2)); \
00230 } \
00231 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00232 step_div_type_size = getStep()/sizeof(TYPE); \
00233 }
00234
00235 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_C3_C1(sInt);
00236
00237 #define CREATE_CONVERT_CONSTRUCTOR_C1_C3(TYPE) \
00238 template <> QVImage<TYPE, 3>::QVImage(QVImage<TYPE, 1> const &img):QVGenericImage(img) \
00239 { \
00240 imageBuffer = new QVImageBuffer<TYPE, 3>(img.getCols(), img.getRows()); \
00241 setAnchor(img.getROI().x(),img.getROI().y()); \
00242 Copy(img, img, img, *this); \
00243 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00244 step_div_type_size = getStep()/sizeof(TYPE); \
00245 }
00246
00247 CREATE_CONVERT_CONSTRUCTOR_C1_C3(uChar);
00248 CREATE_CONVERT_CONSTRUCTOR_C1_C3(uShort);
00249 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sShort);
00250 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sInt);
00251 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sFloat);
00252
00253
00254 inline int align(int v, int m)
00255 { return (v%m==0) ? v:(v-v%m+m); }
00256
00257 template <> QVImage<uChar, 3>::QVImage(const QImage &qimg):QVGenericImage()
00258 {
00259 imageBuffer = new QVImageBuffer<uChar, 3>(qimg.size().width(), qimg.size().height(), align(3*qimg.size().width(),4));
00260 setROI(0, 0, qimg.size().width(), qimg.size().height());
00261 setAnchor(getROI().x(), getROI().y());
00262
00263 const int step = getStep();
00264 uChar *imagerawdata = getWriteData();
00265 for(uint row=0; row != getRows(); row++)
00266 for(uint col=0; col != getCols(); col++)
00267 {
00268 imagerawdata[row*step + 3*col] = qRed(qimg.pixel(col,row));
00269 imagerawdata[row*step + 3*col + 1] = qGreen(qimg.pixel(col,row));
00270 imagerawdata[row*step + 3*col + 2] = qBlue(qimg.pixel(col,row));
00271 }
00272 }
00273
00274 template <> QVImage<uChar, 3>::operator QImage() const
00275 {
00276 QRect roi = getROI();
00277 const int x=roi.x(), y=roi.y(), w=roi.width(), h=roi.height(), step = getStep();
00278 QImage qImage(w, h, QImage::Format_RGB32);
00279 const uChar *imagerawdata = getReadData();
00280 for(int row = y; row != y+h; row++)
00281 for(int col = x; col != x+w; col++)
00282 {
00283 uChar r = imagerawdata[(row-y)*step + 3*(col-x)],
00284 g = imagerawdata[(row-y)*step + 3*(col-x) + 1],
00285 b = imagerawdata[(row-y)*step + 3*(col-x) + 2];
00286 qImage.setPixel(col-x, row-y, qRgb(r,g,b));
00287 }
00288
00289 return qImage;
00290 }
00291
00292
00293 #ifdef OPENCV
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00328 #define CREATE_IPLIMAGE_CONSTRUCTOR(TYPE, C, DEPTH) \
00329 template <> QVImage<TYPE, C>::QVImage(const IplImage *iplImage):QVGenericImage() \
00330 { \
00331 if (iplImage->nChannels != C) \
00332 qWarning("Conversion from incompatible OpenCV image: incompatible channel number"); \
00333 if (iplImage->depth != DEPTH) \
00334 qWarning("Conversion from incompatible OpenCV image: incompatible depth"); \
00335 \
00336 imageBuffer = new QVImageBuffer<TYPE, C>(iplImage->width, iplImage->height, align(C*iplImage->width,4)); \
00337 setROI(0, 0, iplImage->width, iplImage->height); \
00338 setAnchor(0, 0); \
00339 \
00340 const int lineSize = getCols() * C; \
00341 \
00342 for (uInt y=0 ;y<getRows(); y++) \
00343 memcpy(getWriteData() + getStep() * y, iplImage->imageData + iplImage->widthStep*y, lineSize); \
00344 }
00345
00346 CREATE_IPLIMAGE_CONSTRUCTOR(uChar, 1, IPL_DEPTH_8U);
00347 CREATE_IPLIMAGE_CONSTRUCTOR(uChar, 3, IPL_DEPTH_8U);
00348 CREATE_IPLIMAGE_CONSTRUCTOR(sFloat, 1, IPL_DEPTH_32F);
00349 CREATE_IPLIMAGE_CONSTRUCTOR(sFloat, 3, IPL_DEPTH_32F);
00350
00351 #define CREATE_IPLIMAGE_CONVERSION(TYPE, C, DEPTH) \
00352 template <> QVImage<TYPE, C>::operator IplImage *() const \
00353 { \
00354 IplImage *imageDest = cvCreateImageHeader(cvSize(getCols(), getRows()), DEPTH, C); \
00355 cvCreateImageData(imageDest); \
00356 \
00357 const int lineSize = getCols() * C; \
00358 \
00359 for (uInt y=0 ;y<getRows(); y++) \
00360 memcpy(imageDest->imageData + imageDest->widthStep*y, getReadData() + getStep() * y, lineSize); \
00361 \
00362 return imageDest; \
00363 }
00364
00365 CREATE_IPLIMAGE_CONVERSION(uChar, 1, IPL_DEPTH_8U);
00366 CREATE_IPLIMAGE_CONVERSION(uChar, 3, IPL_DEPTH_8U);
00367 CREATE_IPLIMAGE_CONVERSION(sFloat, 1, IPL_DEPTH_32F);
00368 CREATE_IPLIMAGE_CONVERSION(sFloat, 3, IPL_DEPTH_32F);
00369
00370 #endif
00371
00372
00373 #define CREATE_OPERATOR(NAME, OPERATOR, TYPE, C) \
00374 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const \
00375 { \
00376 QVImage<TYPE, C> result = *this; \
00377 NAME(*this, img, result); \
00378 return result; \
00379 }
00380
00381 CREATE_OPERATOR(Add, operator+, uChar, 1);
00382 CREATE_OPERATOR(Mul, operator*, uChar, 1);
00383 CREATE_OPERATOR(Sub, operator-, uChar, 1);
00384 CREATE_OPERATOR(Div, operator/, uChar, 1);
00385 CREATE_OPERATOR(Add, operator+, uChar, 3);
00386 CREATE_OPERATOR(Mul, operator*, uChar, 3);
00387 CREATE_OPERATOR(Sub, operator-, uChar, 3);
00388 CREATE_OPERATOR(Div, operator/, uChar, 3);
00389
00390 CREATE_OPERATOR(Add, operator+, uShort, 1);
00391 CREATE_OPERATOR(Mul, operator*, uShort, 1);
00392 CREATE_OPERATOR(Sub, operator-, uShort, 1);
00393 CREATE_OPERATOR(Div, operator/, uShort, 1);
00394 CREATE_OPERATOR(Add, operator+, uShort, 3);
00395 CREATE_OPERATOR(Mul, operator*, uShort, 3);
00396 CREATE_OPERATOR(Sub, operator-, uShort, 3);
00397 CREATE_OPERATOR(Div, operator/, uShort, 3);
00398
00399 CREATE_OPERATOR(Add, operator+, sShort, 1);
00400 CREATE_OPERATOR(Mul, operator*, sShort, 1);
00401 CREATE_OPERATOR(Sub, operator-, sShort, 1);
00402 CREATE_OPERATOR(Div, operator/, sShort, 1);
00403 CREATE_OPERATOR(Add, operator+, sShort, 3);
00404 CREATE_OPERATOR(Mul, operator*, sShort, 3);
00405 CREATE_OPERATOR(Sub, operator-, sShort, 3);
00406 CREATE_OPERATOR(Div, operator/, sShort, 3);
00407
00408 #define CREATE_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE) \
00409 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const QVImage<TYPE, 1> &img) const \
00410 { \
00411 QVImage<TYPE, 1> result = *this; \
00412 QVIMAGE_PTR_INIT_READ(TYPE, this); \
00413 QVIMAGE_INIT_READ(TYPE, img); \
00414 QVIMAGE_INIT_WRITE(TYPE, result); \
00415 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00416 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00417 QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0); \
00418 return result; \
00419 }
00420
00421 CREATE_OPERATOR_INT_C1(operator+, +, sInt);
00422 CREATE_OPERATOR_INT_C1(operator*, *, sInt);
00423 CREATE_OPERATOR_INT_C1(operator-, -, sInt);
00424 CREATE_OPERATOR_INT_C1(operator/, /, sInt);
00425
00426 #define CREATE_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE) \
00427 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const QVImage<TYPE, 3> &img) const \
00428 { \
00429 QVImage<TYPE, 3> result = *this; \
00430 QVIMAGE_PTR_INIT_READ(TYPE, this); \
00431 QVIMAGE_INIT_READ(TYPE, img); \
00432 QVIMAGE_INIT_WRITE(TYPE, result); \
00433 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00434 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00435 { \
00436 QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0); \
00437 QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1) OPERATION QVIMAGE_PIXEL(this, col, row, 1); \
00438 QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2) OPERATION QVIMAGE_PIXEL(this, col, row, 2); \
00439 } \
00440 return result; \
00441 }
00442
00443 CREATE_OPERATOR_INT_C3(operator+, +, sInt);
00444 CREATE_OPERATOR_INT_C3(operator*, *, sInt);
00445 CREATE_OPERATOR_INT_C3(operator-, -, sInt);
00446 CREATE_OPERATOR_INT_C3(operator/, /, sInt);
00447
00448
00449 #define CREATE_CONST_OPERATOR(NAME, OPERATOR, TYPE, C) \
00450 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const \
00451 { \
00452 QVImage<TYPE, C> result = *this; \
00453 NAME(*this, value, result); \
00454 return result; \
00455 }
00456
00457 CREATE_CONST_OPERATOR(AddC, operator+, uChar, 1);
00458 CREATE_CONST_OPERATOR(MulC, operator*, uChar, 1);
00459 CREATE_CONST_OPERATOR(SubC, operator-, uChar, 1);
00460 CREATE_CONST_OPERATOR(DivC, operator/, uChar, 1);
00461 CREATE_CONST_OPERATOR(AddC, operator+, uShort, 1);
00462 CREATE_CONST_OPERATOR(MulC, operator*, uShort, 1);
00463 CREATE_CONST_OPERATOR(SubC, operator-, uShort, 1);
00464 CREATE_CONST_OPERATOR(DivC, operator/, uShort, 1);
00465 CREATE_CONST_OPERATOR(AddC, operator+, sShort, 1);
00466 CREATE_CONST_OPERATOR(MulC, operator*, sShort, 1);
00467 CREATE_CONST_OPERATOR(SubC, operator-, sShort, 1);
00468 CREATE_CONST_OPERATOR(DivC, operator/, sShort, 1);
00469 CREATE_CONST_OPERATOR(AddC, operator+, sFloat, 1);
00470 CREATE_CONST_OPERATOR(MulC, operator*, sFloat, 1);
00471 CREATE_CONST_OPERATOR(SubC, operator-, sFloat, 1);
00472 CREATE_CONST_OPERATOR(DivC, operator/, sFloat, 1);
00473 CREATE_CONST_OPERATOR(LShiftC, operator<<, uChar, 1);
00474 CREATE_CONST_OPERATOR(RShiftC, operator>>, uChar, 1);
00475 CREATE_CONST_OPERATOR(LShiftC, operator<<, uShort, 1);
00476 CREATE_CONST_OPERATOR(RShiftC, operator>>, uShort, 1);
00477 CREATE_CONST_OPERATOR(LShiftC, operator<<, sInt, 1);
00478 CREATE_CONST_OPERATOR(RShiftC, operator>>, sInt, 1);
00479 CREATE_CONST_OPERATOR(AndC, operator&, uChar, 1);
00480 CREATE_CONST_OPERATOR(OrC, operator|, uChar, 1);
00481 CREATE_CONST_OPERATOR(XorC, operator^, uChar, 1);
00482 CREATE_CONST_OPERATOR(AndC, operator&, uShort, 1);
00483 CREATE_CONST_OPERATOR(OrC, operator|, uShort, 1);
00484 CREATE_CONST_OPERATOR(XorC, operator^, uShort, 1);
00485 CREATE_CONST_OPERATOR(AndC, operator&, sInt, 1);
00486 CREATE_CONST_OPERATOR(OrC, operator|, sInt, 1);
00487 CREATE_CONST_OPERATOR(XorC, operator^, sInt, 1);
00488
00490
00491 #define CREATE_CONST_OPERATOR_C3(NAME, OPERATOR, TYPE, C) \
00492 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const \
00493 { \
00494 const TYPE values[3] = { value, value, value }; \
00495 QVImage<TYPE, C> result = *this; \
00496 NAME(*this, values, result); \
00497 return result; \
00498 }
00499
00500 CREATE_CONST_OPERATOR_C3(AddC, operator+, uChar, 3);
00501 CREATE_CONST_OPERATOR_C3(MulC, operator*, uChar, 3);
00502 CREATE_CONST_OPERATOR_C3(SubC, operator-, uChar, 3);
00503 CREATE_CONST_OPERATOR_C3(DivC, operator/, uChar, 3);
00504 CREATE_CONST_OPERATOR_C3(AddC, operator+, sShort, 3);
00505 CREATE_CONST_OPERATOR_C3(MulC, operator*, sShort, 3);
00506 CREATE_CONST_OPERATOR_C3(SubC, operator-, sShort, 3);
00507 CREATE_CONST_OPERATOR_C3(DivC, operator/, sShort, 3);
00508 CREATE_CONST_OPERATOR_C3(AddC, operator+, uShort, 3);
00509 CREATE_CONST_OPERATOR_C3(MulC, operator*, uShort, 3);
00510 CREATE_CONST_OPERATOR_C3(SubC, operator-, uShort, 3);
00511 CREATE_CONST_OPERATOR_C3(DivC, operator/, uShort, 3);
00512 CREATE_CONST_OPERATOR_C3(AddC, operator+, sFloat, 3);
00513 CREATE_CONST_OPERATOR_C3(MulC, operator*, sFloat, 3);
00514 CREATE_CONST_OPERATOR_C3(SubC, operator-, sFloat, 3);
00515 CREATE_CONST_OPERATOR_C3(DivC, operator/, sFloat, 3);
00516 CREATE_CONST_OPERATOR_C3(AndC, operator&, uChar, 3);
00517 CREATE_CONST_OPERATOR_C3(OrC, operator|, uChar, 3);
00518 CREATE_CONST_OPERATOR_C3(XorC, operator^, uChar, 3);
00519 CREATE_CONST_OPERATOR_C3(AndC, operator&, uShort, 3);
00520 CREATE_CONST_OPERATOR_C3(OrC, operator|, uShort, 3);
00521 CREATE_CONST_OPERATOR_C3(XorC, operator^, uShort, 3);
00522 CREATE_CONST_OPERATOR_C3(AndC, operator&, sInt, 3);
00523 CREATE_CONST_OPERATOR_C3(OrC, operator|, sInt, 3);
00524 CREATE_CONST_OPERATOR_C3(XorC, operator^, sInt, 3);
00525
00526 #define CREATE_CONST_OPERATOR_C4(NAME, OPERATOR, TYPE, C) \
00527 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const \
00528 { \
00529 const uInt values[3] = { value, value, value }; \
00530 QVImage<TYPE, C> result = *this; \
00531 NAME(*this, values, result); \
00532 return result; \
00533 }
00534
00535 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uChar, 3);
00536 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uChar, 3);
00537 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uShort, 3);
00538 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uShort, 3);
00539 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, sInt, 3);
00540 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, sInt, 3);
00541
00542 #define CREATE_CONST_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE) \
00543 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const TYPE value) const \
00544 { \
00545 QVImage<TYPE, 1> result = *this; \
00546 QVIMAGE_PTR_INIT_READ(TYPE, this); \
00547 QVIMAGE_INIT_WRITE(TYPE, result); \
00548 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00549 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00550 QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value; \
00551 return result; \
00552 }
00553
00554 CREATE_CONST_OPERATOR_INT_C1(operator+, +, sInt);
00555 CREATE_CONST_OPERATOR_INT_C1(operator*, *, sInt);
00556 CREATE_CONST_OPERATOR_INT_C1(operator-, -, sInt);
00557 CREATE_CONST_OPERATOR_INT_C1(operator/, /, sInt);
00558
00559 #define CREATE_CONST_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE) \
00560 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const TYPE value) const \
00561 { \
00562 QVImage<TYPE, 3> result = *this; \
00563 QVIMAGE_PTR_INIT_READ(TYPE, this); \
00564 QVIMAGE_INIT_WRITE(TYPE, result); \
00565 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00566 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00567 { \
00568 QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value; \
00569 QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(this, col, row, 1) OPERATION value; \
00570 QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(this, col, row, 2) OPERATION value; \
00571 } \
00572 return result; \
00573 }
00574
00575 CREATE_CONST_OPERATOR_INT_C3(operator+, +, sInt);
00576 CREATE_CONST_OPERATOR_INT_C3(operator*, *, sInt);
00577 CREATE_CONST_OPERATOR_INT_C3(operator-, -, sInt);
00578 CREATE_CONST_OPERATOR_INT_C3(operator/, /, sInt);
00579
00580 #define CREATE_NOT_OPERATOR(NAME, OPERATOR, TYPE, C) \
00581 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR() const \
00582 { \
00583 QVImage<TYPE, C> result = *this; \
00584 NAME(*this, result); \
00585 return result; \
00586 }
00587
00588 CREATE_NOT_OPERATOR(Not, operator!, uChar, 1);
00589 CREATE_NOT_OPERATOR(Not, operator!, uChar, 3);
00590
00591 #define CREATE_COMPARE_OPERATOR(NAME, OPERATOR, CMP, TYPE, C) \
00592 template <> QVImage<uChar> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const \
00593 { \
00594 QVImage<uChar> result(getCols(), getRows()); \
00595 NAME(*this, img, result, CMP); \
00596 return result; \
00597 }
00598
00599
00600 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 1);
00601 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 1);
00602 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 1);
00603 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 1);
00604
00605 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 3);
00606 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 3);
00607 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 3);
00608 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 3);
00609
00610
00611 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 1);
00612 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 1);
00613 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 1);
00614 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 1);
00615
00616 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 3);
00617 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 3);
00618 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 3);
00619 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 3);
00620
00621
00622 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 1);
00623 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 1);
00624 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 1);
00625 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 1);
00626
00627 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 3);
00628 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 3);
00629 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 3);
00630 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 3);
00631
00632
00633 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 1);
00634 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 1);
00635 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 1);
00636 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 1);
00637
00638 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 3);
00639 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 3);
00640 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 3);
00641 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 3);
00642
00643 #define CREATE_GENERIC_COMPARE_OPERATOR_C1(OPERATOR, OPERATION, TYPE1, TYPE2) \
00644 template <> QVImage<uChar> QVImage<TYPE1, 1>::OPERATOR(const QVImage<TYPE2, 1> &img) const \
00645 { \
00646 QVImage<uChar> result(getCols(), getRows()); \
00647 result.setROI(getROI()); result.setAnchor(getAnchor()); \
00648 QVIMAGE_PTR_INIT_READ(TYPE1, this); \
00649 QVIMAGE_INIT_READ(TYPE2, img); \
00650 QVIMAGE_INIT_WRITE(uChar, result); \
00651 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00652 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00653 if (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) \
00654 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U; \
00655 else QVIMAGE_PIXEL(result, col, row, 0) = 0; \
00656 return result; \
00657 }
00658
00659 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, uShort);
00660 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, uShort);
00661 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, uShort);
00662 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, uShort);
00663 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sShort);
00664 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sShort);
00665 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sShort);
00666 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sShort);
00667 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sInt);
00668 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sInt);
00669 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sInt);
00670 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sInt);
00671 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sFloat);
00672 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sFloat);
00673 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sFloat);
00674 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sFloat);
00675
00676 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, uChar);
00677 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, uChar);
00678 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, uChar);
00679 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, uChar);
00680 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sShort);
00681 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sShort);
00682 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sShort);
00683 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sShort);
00684 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sInt);
00685 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sInt);
00686 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sInt);
00687 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sInt);
00688 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sFloat);
00689 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sFloat);
00690 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sFloat);
00691 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sFloat);
00692
00693 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uChar);
00694 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uChar);
00695 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uChar);
00696 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uChar);
00697 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uShort);
00698 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uShort);
00699 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uShort);
00700 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uShort);
00701 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sInt);
00702 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sInt);
00703 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sInt);
00704 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sInt);
00705 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sFloat);
00706 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sFloat);
00707 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sFloat);
00708 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sFloat);
00709
00710 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uChar);
00711 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uChar);
00712 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uChar);
00713 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uChar);
00714 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uShort);
00715 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uShort);
00716 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uShort);
00717 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uShort);
00718 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sShort);
00719 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sShort);
00720 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sShort);
00721 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sShort);
00722 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sInt);
00723 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sInt);
00724 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sInt);
00725 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sInt);
00726 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sFloat);
00727 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sFloat);
00728 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sFloat);
00729 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sFloat);
00730
00731 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uChar);
00732 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uChar);
00733 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uChar);
00734 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uChar);
00735 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uShort);
00736 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uShort);
00737 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uShort);
00738 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uShort);
00739 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sShort);
00740 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sShort);
00741 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sShort);
00742 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sShort);
00743 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sInt);
00744 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sInt);
00745 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sInt);
00746 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sInt);
00747
00748
00749 #define CREATE_GENERIC_COMPARE_OPERATOR_C3(OPERATOR, OPERATION, TYPE1, TYPE2) \
00750 template <> QVImage<uChar> QVImage<TYPE1, 3>::OPERATOR(const QVImage<TYPE2, 3> &img) const \
00751 { \
00752 QVImage<uChar> result(getCols(), getRows()); \
00753 result.setROI(getROI()); result.setAnchor(getAnchor()); \
00754 QVIMAGE_PTR_INIT_READ(TYPE1, this); \
00755 QVIMAGE_INIT_READ(TYPE2, img); \
00756 QVIMAGE_INIT_WRITE(uChar, result); \
00757 for (int col = result.getROI().left(); col < result.getROI().right(); col++) \
00758 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++) \
00759 { \
00760 if( (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) && \
00761 (QVIMAGE_PIXEL(this, col, row, 1) OPERATION QVIMAGE_PIXEL(img, col, row, 1)) && \
00762 (QVIMAGE_PIXEL(this, col, row, 2) OPERATION QVIMAGE_PIXEL(img, col, row, 2)) ) \
00763 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U; \
00764 else QVIMAGE_PIXEL(result, col, row, 0) = 0; \
00765 } \
00766 return result; \
00767 }
00768
00769 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, uShort);
00770 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, uShort);
00771 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, uShort);
00772 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, uShort);
00773 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sShort);
00774 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sShort);
00775 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sShort);
00776 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sShort);
00777 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sInt);
00778 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sInt);
00779 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sInt);
00780 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sInt);
00781 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sFloat);
00782 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sFloat);
00783 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sFloat);
00784 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sFloat);
00785
00786 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, uChar);
00787 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, uChar);
00788 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, uChar);
00789 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, uChar);
00790 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sShort);
00791 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sShort);
00792 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sShort);
00793 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sShort);
00794 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sInt);
00795 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sInt);
00796 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sInt);
00797 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sInt);
00798 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sFloat);
00799 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sFloat);
00800 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sFloat);
00801 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sFloat);
00802
00803 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uChar);
00804 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uChar);
00805 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uChar);
00806 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uChar);
00807 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uShort);
00808 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uShort);
00809 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uShort);
00810 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uShort);
00811 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sInt);
00812 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sInt);
00813 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sInt);
00814 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sInt);
00815 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sFloat);
00816 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sFloat);
00817 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sFloat);
00818 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sFloat);
00819
00820 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uChar);
00821 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uChar);
00822 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uChar);
00823 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uChar);
00824 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uShort);
00825 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uShort);
00826 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uShort);
00827 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uShort);
00828 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sShort);
00829 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sShort);
00830 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sShort);
00831 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sShort);
00832 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sInt);
00833 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sInt);
00834 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sInt);
00835 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sInt);
00836 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sFloat);
00837 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sFloat);
00838 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sFloat);
00839 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sFloat);
00840
00841 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uChar);
00842 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uChar);
00843 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uChar);
00844 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uChar);
00845 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uShort);
00846 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uShort);
00847 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uShort);
00848 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uShort);
00849 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sShort);
00850 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sShort);
00851 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sShort);
00852 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sShort);
00853 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sInt);
00854 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sInt);
00855 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sInt);
00856 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sInt);
00857
00858
00859
00860 #define CREATE_SET_FUNCTION_C1(TYPE) \
00861 template <> void QVImage<TYPE>::set(TYPE c1, TYPE, TYPE) \
00862 { Set(c1, *this); }
00863
00864 CREATE_SET_FUNCTION_C1(uChar);
00865 CREATE_SET_FUNCTION_C1(uShort);
00866 CREATE_SET_FUNCTION_C1(sShort);
00867 CREATE_SET_FUNCTION_C1(sInt);
00868 CREATE_SET_FUNCTION_C1(sFloat);
00869
00870 #define CREATE_SET_FUNCTION_C3(TYPE) \
00871 template <> void QVImage<TYPE,3>::set(TYPE c1, TYPE c2, TYPE c3) \
00872 { \
00873 const TYPE values[3] = { c1, c2, c3 }; \
00874 Set(values, *this); \
00875 }
00876
00877 CREATE_SET_FUNCTION_C3(uChar);
00878 CREATE_SET_FUNCTION_C3(uShort);
00879 CREATE_SET_FUNCTION_C3(sShort);
00880 CREATE_SET_FUNCTION_C3(sInt);
00881 CREATE_SET_FUNCTION_C3(sFloat);
00882
00884
00885 #define CREATE_CONVERT_OPERATOR(TYPE1, TYPE2, C) \
00886 template <> QVImage<TYPE2, C> & QVImage<TYPE2, C>::operator=(const QVImage<TYPE1, C> &img) \
00887 { \
00888 imageBuffer = new QVImageBuffer<TYPE2, C>(img.getCols(), img.getRows()); \
00889 setAnchor(img.getROI().x(),img.getROI().y()); \
00890 Convert(img, *this); \
00891 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00892 return *this; \
00893 }
00894
00895 CREATE_CONVERT_OPERATOR(uChar, uShort, 1);
00896 CREATE_CONVERT_OPERATOR(uChar, sShort, 1);
00897 CREATE_CONVERT_OPERATOR(uChar, sInt, 1);
00898 CREATE_CONVERT_OPERATOR(uChar, sFloat, 1);
00899 CREATE_CONVERT_OPERATOR(uChar, uShort, 3);
00900 CREATE_CONVERT_OPERATOR(uChar, sShort, 3);
00901 CREATE_CONVERT_OPERATOR(uChar, sInt, 3);
00902 CREATE_CONVERT_OPERATOR(uChar, sFloat, 3);
00903 CREATE_CONVERT_OPERATOR(uShort, uChar, 1);
00904 CREATE_CONVERT_OPERATOR(uShort, sInt, 1);
00905 CREATE_CONVERT_OPERATOR(uShort, sFloat, 1);
00906 CREATE_CONVERT_OPERATOR(uShort, uChar, 3);
00907 CREATE_CONVERT_OPERATOR(uShort, sInt, 3);
00908 CREATE_CONVERT_OPERATOR(uShort, sFloat, 3);
00909 CREATE_CONVERT_OPERATOR(sShort, uChar, 1);
00910 CREATE_CONVERT_OPERATOR(sShort, sInt, 1);
00911 CREATE_CONVERT_OPERATOR(sShort, sFloat, 1);
00912 CREATE_CONVERT_OPERATOR(sShort, uChar, 3);
00913 CREATE_CONVERT_OPERATOR(sShort, sInt, 3);
00914 CREATE_CONVERT_OPERATOR(sShort, sFloat, 3);
00915 CREATE_CONVERT_OPERATOR(sInt, uChar, 1);
00916 CREATE_CONVERT_OPERATOR(sInt, uChar, 3);
00917 CREATE_CONVERT_OPERATOR(sFloat, uChar, 1);
00918 CREATE_CONVERT_OPERATOR(sFloat, uShort, 1);
00919 CREATE_CONVERT_OPERATOR(sFloat, sShort, 1);
00920 CREATE_CONVERT_OPERATOR(sFloat, uChar, 3);
00921 CREATE_CONVERT_OPERATOR(sFloat, uShort, 3);
00922 CREATE_CONVERT_OPERATOR(sFloat, sShort, 3);
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943 #define CREATE_CONVERT_OPERATOR_NO_IPP_1(TYPE1, TYPE2) \
00944 template <> QVImage<TYPE2, 1> & QVImage<TYPE2, 1>::operator=(const QVImage<TYPE1, 1> &img) \
00945 { \
00946 imageBuffer = new QVImageBuffer<TYPE2, 1>(img.getCols(), img.getRows()); \
00947 QVIMAGE_PTR_INIT_WRITE(TYPE2, this); \
00948 QVIMAGE_INIT_READ(TYPE1, img); \
00949 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
00950 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
00951 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 0); \
00952 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00953 return *this; \
00954 }
00955
00956 CREATE_CONVERT_OPERATOR_NO_IPP_1(uShort, sShort);
00957 CREATE_CONVERT_OPERATOR_NO_IPP_1(sShort, uShort);
00958 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, uShort);
00959 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sShort);
00960 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sFloat);
00961 CREATE_CONVERT_OPERATOR_NO_IPP_1(sFloat, sInt);
00962
00963 #define CREATE_CONVERT_OPERATOR_NO_IPP_3(TYPE1, TYPE2) \
00964 template <> QVImage<TYPE2, 3> & QVImage<TYPE2, 3>::operator=(const QVImage<TYPE1, 3> &img) \
00965 { \
00966 imageBuffer = new QVImageBuffer<TYPE2, 3>(img.getCols(), img.getRows()); \
00967 QVIMAGE_PTR_INIT_WRITE(TYPE2, this); \
00968 QVIMAGE_INIT_READ(TYPE1, img); \
00969 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
00970 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
00971 { \
00972 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 0); \
00973 QVIMAGE_PIXEL(this, col, row, 1) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 1); \
00974 QVIMAGE_PIXEL(this, col, row, 2) = (TYPE2)QVIMAGE_PIXEL(img, col, row, 2); \
00975 } \
00976 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00977 return *this; \
00978 }
00979
00980 CREATE_CONVERT_OPERATOR_NO_IPP_3(uShort, sShort);
00981 CREATE_CONVERT_OPERATOR_NO_IPP_3(sShort, uShort);
00982 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, uShort);
00983 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sShort);
00984 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sFloat);
00985 CREATE_CONVERT_OPERATOR_NO_IPP_3(sFloat, sInt);
00986
00987 #define CREATE_CONVERT_OPERATOR_C3_C1(TYPE) \
00988 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img) \
00989 { \
00990 imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows()); \
00991 setAnchor(img.getROI().x(),img.getROI().y()); \
00992 RGBToGray(img, *this); \
00993 setROI(img.getROI()); setAnchor(img.getAnchor()); \
00994 return *this; \
00995 }
00996
00997 CREATE_CONVERT_OPERATOR_C3_C1(uChar);
00998 CREATE_CONVERT_OPERATOR_C3_C1(uShort);
00999 CREATE_CONVERT_OPERATOR_C3_C1(sShort);
01000 CREATE_CONVERT_OPERATOR_C3_C1(sFloat);
01001
01002 #define CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(TYPE) \
01003 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img) \
01004 { \
01005 imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows()); \
01006 QVIMAGE_PTR_INIT_WRITE(TYPE, this); \
01007 QVIMAGE_INIT_READ(TYPE, img); \
01008 for (int col = img.getROI().left(); col < img.getROI().right(); col++) \
01009 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++) \
01010 { \
01011 QVIMAGE_PIXEL(this, col, row, 0) = (TYPE)(0.299 * QVIMAGE_PIXEL(img, col, row, 0)); \
01012 QVIMAGE_PIXEL(this, col, row, 0) += (TYPE)(0.587 * QVIMAGE_PIXEL(img, col, row, 1)); \
01013 QVIMAGE_PIXEL(this, col, row, 0) += (TYPE)(0.114 * QVIMAGE_PIXEL(img, col, row, 2)); \
01014 } \
01015 setROI(img.getROI()); setAnchor(img.getAnchor()); \
01016 return *this; \
01017 }
01018
01019 CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(sInt);
01020
01021 #define CREATE_CONVERT_OPERATOR_C1_C3(TYPE) \
01022 template <> QVImage<TYPE, 3> & QVImage<TYPE, 3>::operator=(const QVImage<TYPE, 1> &img) \
01023 { \
01024 imageBuffer = new QVImageBuffer<TYPE, 3>(img.getCols(), img.getRows()); \
01025 setAnchor(img.getROI().x(),img.getROI().y()); \
01026 Copy(img, img, img, *this); \
01027 setROI(img.getROI()); setAnchor(img.getAnchor()); \
01028 return *this; \
01029 }
01030
01031 CREATE_CONVERT_OPERATOR_C1_C3(uChar);
01032 CREATE_CONVERT_OPERATOR_C1_C3(uShort);
01033 CREATE_CONVERT_OPERATOR_C1_C3(sShort);
01034 CREATE_CONVERT_OPERATOR_C1_C3(sInt);
01035 CREATE_CONVERT_OPERATOR_C1_C3(sFloat);
01036
01037
01038
01039 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(TYPE1, TYPE2) \
01040 template <> QVImage<TYPE2, 1>::QVImage(QVImage<TYPE1, 3> const &img):QVGenericImage(img) \
01041 { \
01042 *this = QVImage<TYPE2, 3>(img); \
01043 }
01044
01045 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, uShort);
01046 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sShort);
01047 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sInt);
01048 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sFloat);
01049 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, uChar);
01050 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sShort);
01051 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sInt);
01052 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sFloat);
01053 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uChar);
01054 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uShort);
01055 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sInt);
01056 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sFloat);
01057 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uChar);
01058 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uShort);
01059 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sShort);
01060 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sFloat);
01061 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uChar);
01062 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uShort);
01063 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sShort);
01064 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sInt);
01065
01066 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(TYPE1, TYPE2) \
01067 template <> QVImage<TYPE2, 3>::QVImage(QVImage<TYPE1, 1> const &img):QVGenericImage(img) \
01068 { \
01069 *this = QVImage<TYPE2, 1>(img); \
01070 }
01071
01072 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, uShort);
01073 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sShort);
01074 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sInt);
01075 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sFloat);
01076 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, uChar);
01077 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sShort);
01078 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sInt);
01079 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sFloat);
01080 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uChar);
01081 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uShort);
01082 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sInt);
01083 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sFloat);
01084 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uChar);
01085 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uShort);
01086 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sShort);
01087 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sFloat);
01088 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uChar);
01089 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uShort);
01090 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sShort);
01091 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sInt);
01092
01093
01094 #define CREATE_ACCESS_CONSTRUCTOR(OPERATOR, TYPE, C) \
01095 template <> QVImage<TYPE, 1> QVImage<TYPE, C>::OPERATOR(const uInt channel) const \
01096 { \
01097 QVImage<TYPE, 1> result(getCols(), getRows()); \
01098 Copy(*this, channel, result); \
01099 result.setROI(getROI()); result.setAnchor(getAnchor()); \
01100 return result; \
01101 }
01102
01103 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 1);
01104 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 3);
01105 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 1);
01106 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 3);
01107 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 1);
01108 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 3);
01109 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 1);
01110 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 3);
01111 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 1);
01112 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 3);
01113
01114
01115
01116