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