PARP Research Group University of Murcia, Spain


src/qvcore/qvimage.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
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 // Copy constructors
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 // Copy operator
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 // QVIPP FUNCTIONS
00083 #include <qvip/qvipp/qvipp.h>
00084 
00085 // Compose copy constructors
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 // Conversion constructors
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 // (ORIG, DEST, CHAN)
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 // Nota: las siguientes funciones dan error al compilar, ya que no existen versiones de la función wrapper Convert,
00143 // para convertir de una imagen entera, a una imagen de tipo uShort, sShort, o sFloat.
00144 //      CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 1);
00145 //      CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 1);
00146 //      CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 3);
00147 //      CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 3);
00148 //      CREATE_CONVERT_CONSTRUCTOR(sFloat, sInt, 3);
00149 //      CREATE_CONVERT_CONSTRUCTOR(sFloat, sInt, 3);
00150 //
00151 // Por ello, estas funciones deben ser definidas con funciones de conversión Ad-hoc, así como las funciones de conversión
00152 // de valores uShort a valores sShort, y viceversa, que tampoco están implementadas por las IPP, ni las funciones para convertir
00153 // imagenes de distinto tipo y canal.
00154 //
00155 // Ojo: Para implementar las funciones de conversión entre imagenes de tipo sShort y uShort, hay que tener en cuenta la saturación
00156 // (que hacen las IPP para todas las funciones de conversión que implementa):
00157 // - Si se quiere convertir un valor sShort menor que cero a un valor uShort, se deja como el valor cero (0).
00158 // - Si se quiere convertir un valor uShort mayor que IPP_MAX_16S a sShort, se debe dejar como el valor IPP_MAX_16S.
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) = 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) = QVIMAGE_PIXEL(img, col, row, 0);             \
00190                         QVIMAGE_PIXEL(this, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1);             \
00191                         QVIMAGE_PIXEL(this, col, row, 2) = 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) = 0.299 * QVIMAGE_PIXEL(img, col, row, 0);     \
00228                         QVIMAGE_PIXEL(this, col, row, 0) += 0.587 * QVIMAGE_PIXEL(img, col, row, 1);    \
00229                         QVIMAGE_PIXEL(this, col, row, 0) += 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 // Convert to and from QImage
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(int row=0; row != getRows(); row++)
00266                for(int 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         QImage qImage(getCols(), getRows(), QImage::Format_RGB32);
00277 
00278         const int step = getStep();
00279         const uChar *imagerawdata = getReadData();
00280         for(int row = 0; row != getRows(); row++)
00281                for(int col = 0; col != getCols(); col++)
00282                         {
00283                         uChar r = imagerawdata[row*step + 3*col],
00284                               g = imagerawdata[row*step + 3*col + 1],
00285                               b = imagerawdata[row*step + 3*col + 2];
00286                         qImage.setPixel(col,row,qRgb(r,g,b));
00287                         }
00288 
00289         return qImage;
00290         }
00291 
00292 // Operators
00293 #define CREATE_OPERATOR(NAME, OPERATOR, TYPE, C)                                                \
00294 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const       \
00295         {                                                                                       \
00296         QVImage<TYPE, C> result = *this;                                                        \
00297         NAME(*this, img, result);                                                               \
00298         return result;                                                                          \
00299         }
00300 
00301 CREATE_OPERATOR(Add, operator+, uChar, 1);
00302 CREATE_OPERATOR(Mul, operator*, uChar, 1);
00303 CREATE_OPERATOR(Sub, operator-, uChar, 1);
00304 CREATE_OPERATOR(Div, operator/, uChar, 1);
00305 CREATE_OPERATOR(Add, operator+, uChar, 3);
00306 CREATE_OPERATOR(Mul, operator*, uChar, 3);
00307 CREATE_OPERATOR(Sub, operator-, uChar, 3);
00308 CREATE_OPERATOR(Div, operator/, uChar, 3);
00309 
00310 CREATE_OPERATOR(Add, operator+, uShort, 1);
00311 CREATE_OPERATOR(Mul, operator*, uShort, 1);
00312 CREATE_OPERATOR(Sub, operator-, uShort, 1);
00313 CREATE_OPERATOR(Div, operator/, uShort, 1);
00314 CREATE_OPERATOR(Add, operator+, uShort, 3);
00315 CREATE_OPERATOR(Mul, operator*, uShort, 3);
00316 CREATE_OPERATOR(Sub, operator-, uShort, 3);
00317 CREATE_OPERATOR(Div, operator/, uShort, 3);
00318 
00319 CREATE_OPERATOR(Add, operator+, sShort, 1);
00320 CREATE_OPERATOR(Mul, operator*, sShort, 1);
00321 CREATE_OPERATOR(Sub, operator-, sShort, 1);
00322 CREATE_OPERATOR(Div, operator/, sShort, 1);
00323 CREATE_OPERATOR(Add, operator+, sShort, 3);
00324 CREATE_OPERATOR(Mul, operator*, sShort, 3);
00325 CREATE_OPERATOR(Sub, operator-, sShort, 3);
00326 CREATE_OPERATOR(Div, operator/, sShort, 3);
00327 
00328 #define CREATE_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE)                                                                                       \
00329 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const QVImage<TYPE, 1> &img) const                                                      \
00330         {                                                                                                                                       \
00331         QVImage<TYPE, 1> result = *this;                                                                                                        \
00332         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                                                      \
00333         QVIMAGE_INIT_READ(TYPE, img);                                                                                                           \
00334         QVIMAGE_INIT_WRITE(TYPE, result);                                                                                                       \
00335         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                                                            \
00336                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                                                    \
00337                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0);        \
00338         return result;                                                                                                                          \
00339         }
00340 
00341 CREATE_OPERATOR_INT_C1(operator+, +, sInt);
00342 CREATE_OPERATOR_INT_C1(operator*, *, sInt);
00343 CREATE_OPERATOR_INT_C1(operator-, -, sInt);
00344 CREATE_OPERATOR_INT_C1(operator/, /, sInt);
00345 
00346 #define CREATE_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE)                                                                                       \
00347 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const QVImage<TYPE, 3> &img) const                                                      \
00348         {                                                                                                                                       \
00349         QVImage<TYPE, 3> result = *this;                                                                                                        \
00350         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                                                      \
00351         QVIMAGE_INIT_READ(TYPE, img);                                                                                                           \
00352         QVIMAGE_INIT_WRITE(TYPE, result);                                                                                                       \
00353         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                                                            \
00354                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                                                    \
00355                         {                                                                                                                       \
00356                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0);        \
00357                         QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1) OPERATION QVIMAGE_PIXEL(this, col, row, 1);        \
00358                         QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2) OPERATION QVIMAGE_PIXEL(this, col, row, 2);        \
00359                         }                                                                                                                       \
00360         return result;                                                                                                                          \
00361         }
00362 
00363 CREATE_OPERATOR_INT_C3(operator+, +, sInt);
00364 CREATE_OPERATOR_INT_C3(operator*, *, sInt);
00365 CREATE_OPERATOR_INT_C3(operator-, -, sInt);
00366 CREATE_OPERATOR_INT_C3(operator/, /, sInt);
00367 
00368 
00369 #define CREATE_CONST_OPERATOR(NAME, OPERATOR, TYPE, C)                          \
00370 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00371         {                                                                       \
00372         QVImage<TYPE, C> result = *this;                                        \
00373         NAME(*this, value, result);                                             \
00374         return result;                                                          \
00375         }
00376 
00377 CREATE_CONST_OPERATOR(AddC, operator+, uChar, 1);
00378 CREATE_CONST_OPERATOR(MulC, operator*, uChar, 1);
00379 CREATE_CONST_OPERATOR(SubC, operator-, uChar, 1);
00380 CREATE_CONST_OPERATOR(DivC, operator/, uChar, 1);
00381 CREATE_CONST_OPERATOR(AddC, operator+, uShort, 1);
00382 CREATE_CONST_OPERATOR(MulC, operator*, uShort, 1);
00383 CREATE_CONST_OPERATOR(SubC, operator-, uShort, 1);
00384 CREATE_CONST_OPERATOR(DivC, operator/, uShort, 1);
00385 CREATE_CONST_OPERATOR(AddC, operator+, sShort, 1);
00386 CREATE_CONST_OPERATOR(MulC, operator*, sShort, 1);
00387 CREATE_CONST_OPERATOR(SubC, operator-, sShort, 1);
00388 CREATE_CONST_OPERATOR(DivC, operator/, sShort, 1);
00389 CREATE_CONST_OPERATOR(AddC, operator+, sFloat, 1);
00390 CREATE_CONST_OPERATOR(MulC, operator*, sFloat, 1);
00391 CREATE_CONST_OPERATOR(SubC, operator-, sFloat, 1);
00392 CREATE_CONST_OPERATOR(DivC, operator/, sFloat, 1);
00393 CREATE_CONST_OPERATOR(LShiftC, operator<<, uChar, 1);
00394 CREATE_CONST_OPERATOR(RShiftC, operator>>, uChar, 1);
00395 CREATE_CONST_OPERATOR(LShiftC, operator<<, uShort, 1);
00396 CREATE_CONST_OPERATOR(RShiftC, operator>>, uShort, 1);
00397 CREATE_CONST_OPERATOR(LShiftC, operator<<, sInt, 1);
00398 CREATE_CONST_OPERATOR(RShiftC, operator>>, sInt, 1);
00399 CREATE_CONST_OPERATOR(AndC, operator&, uChar, 1);
00400 CREATE_CONST_OPERATOR(OrC, operator|, uChar, 1);
00401 CREATE_CONST_OPERATOR(XorC, operator^, uChar, 1);
00402 CREATE_CONST_OPERATOR(AndC, operator&, uShort, 1);
00403 CREATE_CONST_OPERATOR(OrC, operator|, uShort, 1);
00404 CREATE_CONST_OPERATOR(XorC, operator^, uShort, 1);
00405 CREATE_CONST_OPERATOR(AndC, operator&, sInt, 1);
00406 CREATE_CONST_OPERATOR(OrC, operator|, sInt, 1);
00407 CREATE_CONST_OPERATOR(XorC, operator^, sInt, 1);
00408 
00410 
00411 #define CREATE_CONST_OPERATOR_C3(NAME, OPERATOR, TYPE, C)                       \
00412 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00413         {                                                                       \
00414         const TYPE values[3] = { value, value, value };                         \
00415         QVImage<TYPE, C> result = *this;                                        \
00416         NAME(*this, values, result);                                            \
00417         return result;                                                          \
00418         }
00419 
00420 CREATE_CONST_OPERATOR_C3(AddC, operator+, uChar, 3);
00421 CREATE_CONST_OPERATOR_C3(MulC, operator*, uChar, 3);
00422 CREATE_CONST_OPERATOR_C3(SubC, operator-, uChar, 3);
00423 CREATE_CONST_OPERATOR_C3(DivC, operator/, uChar, 3);
00424 CREATE_CONST_OPERATOR_C3(AddC, operator+, sShort, 3);
00425 CREATE_CONST_OPERATOR_C3(MulC, operator*, sShort, 3);
00426 CREATE_CONST_OPERATOR_C3(SubC, operator-, sShort, 3);
00427 CREATE_CONST_OPERATOR_C3(DivC, operator/, sShort, 3);
00428 CREATE_CONST_OPERATOR_C3(AddC, operator+, uShort, 3);
00429 CREATE_CONST_OPERATOR_C3(MulC, operator*, uShort, 3);
00430 CREATE_CONST_OPERATOR_C3(SubC, operator-, uShort, 3);
00431 CREATE_CONST_OPERATOR_C3(DivC, operator/, uShort, 3);
00432 CREATE_CONST_OPERATOR_C3(AddC, operator+, sFloat, 3);
00433 CREATE_CONST_OPERATOR_C3(MulC, operator*, sFloat, 3);
00434 CREATE_CONST_OPERATOR_C3(SubC, operator-, sFloat, 3);
00435 CREATE_CONST_OPERATOR_C3(DivC, operator/, sFloat, 3);
00436 CREATE_CONST_OPERATOR_C3(AndC, operator&, uChar, 3);
00437 CREATE_CONST_OPERATOR_C3(OrC, operator|, uChar, 3);
00438 CREATE_CONST_OPERATOR_C3(XorC, operator^, uChar, 3);
00439 CREATE_CONST_OPERATOR_C3(AndC, operator&, uShort, 3);
00440 CREATE_CONST_OPERATOR_C3(OrC, operator|, uShort, 3);
00441 CREATE_CONST_OPERATOR_C3(XorC, operator^, uShort, 3);
00442 CREATE_CONST_OPERATOR_C3(AndC, operator&, sInt, 3);
00443 CREATE_CONST_OPERATOR_C3(OrC, operator|, sInt, 3);
00444 CREATE_CONST_OPERATOR_C3(XorC, operator^, sInt, 3);
00445 
00446 #define CREATE_CONST_OPERATOR_C4(NAME, OPERATOR, TYPE, C)                       \
00447 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00448         {                                                                       \
00449         const uInt values[3] = { value, value, value };                         \
00450         QVImage<TYPE, C> result = *this;                                        \
00451         NAME(*this, values, result);                                            \
00452         return result;                                                          \
00453         }
00454 
00455 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uChar, 3);
00456 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uChar, 3);
00457 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uShort, 3);
00458 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uShort, 3);
00459 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, sInt, 3);
00460 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, sInt, 3);
00461 
00462 #define CREATE_CONST_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE)                                                 \
00463 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const TYPE value) const                                 \
00464         {                                                                                                       \
00465         QVImage<TYPE, 1> result = *this;                                                                        \
00466         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                      \
00467         QVIMAGE_INIT_WRITE(TYPE, result);                                                                       \
00468         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00469                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00470                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value;  \
00471         return result;                                                                                          \
00472         }
00473 
00474 CREATE_CONST_OPERATOR_INT_C1(operator+, +, sInt);
00475 CREATE_CONST_OPERATOR_INT_C1(operator*, *, sInt);
00476 CREATE_CONST_OPERATOR_INT_C1(operator-, -, sInt);
00477 CREATE_CONST_OPERATOR_INT_C1(operator/, /, sInt);
00478 
00479 #define CREATE_CONST_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE)                                                 \
00480 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const TYPE value) const                                 \
00481         {                                                                                                       \
00482         QVImage<TYPE, 3> result = *this;                                                                        \
00483         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                      \
00484         QVIMAGE_INIT_WRITE(TYPE, result);                                                                       \
00485         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00486                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00487                         {                                                                                       \
00488                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value;  \
00489                         QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(this, col, row, 1) OPERATION value;  \
00490                         QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(this, col, row, 2) OPERATION value;  \
00491                         }                                                                                       \
00492         return result;                                                                                          \
00493         }
00494 
00495 CREATE_CONST_OPERATOR_INT_C3(operator+, +, sInt);
00496 CREATE_CONST_OPERATOR_INT_C3(operator*, *, sInt);
00497 CREATE_CONST_OPERATOR_INT_C3(operator-, -, sInt);
00498 CREATE_CONST_OPERATOR_INT_C3(operator/, /, sInt);
00499 
00500 #define CREATE_NOT_OPERATOR(NAME, OPERATOR, TYPE, C)            \
00501 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR() const  \
00502         {                                                       \
00503         QVImage<TYPE, C> result = *this;                        \
00504         NAME(*this, result);                                    \
00505         return result;                                          \
00506         }
00507 
00508 CREATE_NOT_OPERATOR(Not, operator!, uChar, 1);
00509 CREATE_NOT_OPERATOR(Not, operator!, uChar, 3);
00510 
00511 #define CREATE_COMPARE_OPERATOR(NAME, OPERATOR, CMP, TYPE, C)                           \
00512 template <> QVImage<uChar> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const \
00513         {                                                                               \
00514         QVImage<uChar> result(getCols(), getRows());                                    \
00515         NAME(*this, img, result, CMP);                                                  \
00516         return result;                                                                  \
00517         }
00518 
00519 // ippcmpLess
00520 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 1);
00521 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 1);
00522 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 1);
00523 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 1);
00524 
00525 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 3);
00526 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 3);
00527 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 3);
00528 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 3);
00529 
00530 // ippCmpGreater
00531 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 1);
00532 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 1);
00533 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 1);
00534 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 1);
00535 
00536 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 3);
00537 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 3);
00538 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 3);
00539 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 3);
00540 
00541 // ippcmpLessEq
00542 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 1);
00543 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 1);
00544 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 1);
00545 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 1);
00546 
00547 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 3);
00548 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 3);
00549 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 3);
00550 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 3);
00551 
00552 // ippCmpGreaterEq
00553 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 1);
00554 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 1);
00555 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 1);
00556 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 1);
00557 
00558 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 3);
00559 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 3);
00560 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 3);
00561 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 3);
00562 
00563 #define CREATE_GENERIC_COMPARE_OPERATOR_C1(OPERATOR, OPERATION, TYPE1, TYPE2)                           \
00564 template <> QVImage<uChar> QVImage<TYPE1, 1>::OPERATOR(const QVImage<TYPE2, 1> &img) const              \
00565         {                                                                                               \
00566         QVImage<uChar> result(getCols(), getRows());                                                    \
00567         result.setROI(getROI()); result.setAnchor(getAnchor());                                         \
00568         QVIMAGE_PTR_INIT_READ(TYPE1, this);                                                             \
00569         QVIMAGE_INIT_READ(TYPE2, img);                                                                  \
00570         QVIMAGE_INIT_WRITE(uChar, result);                                                              \
00571         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                    \
00572                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)            \
00573                         if (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) \
00574                                 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U;                        \
00575                         else    QVIMAGE_PIXEL(result, col, row, 0) = 0;                                 \
00576         return result;                                                                                  \
00577         }
00578 
00579 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, uShort);
00580 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, uShort);
00581 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, uShort);
00582 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, uShort);
00583 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sShort);
00584 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sShort);
00585 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sShort);
00586 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sShort);
00587 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sInt);
00588 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sInt);
00589 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sInt);
00590 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sInt);
00591 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sFloat);
00592 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sFloat);
00593 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sFloat);
00594 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sFloat);
00595 
00596 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, uChar);
00597 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, uChar);
00598 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, uChar);
00599 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, uChar);
00600 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sShort);
00601 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sShort);
00602 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sShort);
00603 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sShort);
00604 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sInt);
00605 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sInt);
00606 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sInt);
00607 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sInt);
00608 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sFloat);
00609 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sFloat);
00610 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sFloat);
00611 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sFloat);
00612 
00613 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uChar);
00614 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uChar);
00615 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uChar);
00616 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uChar);
00617 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uShort);
00618 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uShort);
00619 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uShort);
00620 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uShort);
00621 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sInt);
00622 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sInt);
00623 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sInt);
00624 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sInt);
00625 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sFloat);
00626 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sFloat);
00627 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sFloat);
00628 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sFloat);
00629 
00630 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uChar);
00631 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uChar);
00632 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uChar);
00633 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uChar);
00634 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uShort);
00635 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uShort);
00636 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uShort);
00637 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uShort);
00638 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sShort);
00639 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sShort);
00640 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sShort);
00641 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sShort);
00642 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sInt);
00643 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sInt);
00644 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sInt);
00645 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sInt);
00646 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sFloat);
00647 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sFloat);
00648 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sFloat);
00649 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sFloat);
00650 
00651 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uChar);
00652 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uChar);
00653 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uChar);
00654 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uChar);
00655 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uShort);
00656 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uShort);
00657 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uShort);
00658 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uShort);
00659 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sShort);
00660 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sShort);
00661 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sShort);
00662 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sShort);
00663 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sInt);
00664 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sInt);
00665 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sInt);
00666 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sInt);
00667 
00668 
00669 #define CREATE_GENERIC_COMPARE_OPERATOR_C3(OPERATOR, OPERATION, TYPE1, TYPE2)                                   \
00670 template <> QVImage<uChar> QVImage<TYPE1, 3>::OPERATOR(const QVImage<TYPE2, 3> &img) const                      \
00671         {                                                                                                       \
00672         QVImage<uChar> result(getCols(), getRows());                                                            \
00673         result.setROI(getROI()); result.setAnchor(getAnchor());                                                 \
00674         QVIMAGE_PTR_INIT_READ(TYPE1, this);                                                                     \
00675         QVIMAGE_INIT_READ(TYPE2, img);                                                                          \
00676         QVIMAGE_INIT_WRITE(uChar, result);                                                                      \
00677         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00678                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00679                         {                                                                                       \
00680                         if( (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) &&     \
00681                             (QVIMAGE_PIXEL(this, col, row, 1) OPERATION QVIMAGE_PIXEL(img, col, row, 1)) &&     \
00682                             (QVIMAGE_PIXEL(this, col, row, 2) OPERATION QVIMAGE_PIXEL(img, col, row, 2))    )   \
00683                                 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U;                                \
00684                         else    QVIMAGE_PIXEL(result, col, row, 0) = 0;                                         \
00685                         }                                                                                       \
00686         return result;                                                                                          \
00687         }
00688 
00689 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, uShort);
00690 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, uShort);
00691 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, uShort);
00692 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, uShort);
00693 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sShort);
00694 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sShort);
00695 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sShort);
00696 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sShort);
00697 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sInt);
00698 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sInt);
00699 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sInt);
00700 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sInt);
00701 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sFloat);
00702 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sFloat);
00703 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sFloat);
00704 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sFloat);
00705 
00706 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, uChar);
00707 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, uChar);
00708 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, uChar);
00709 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, uChar);
00710 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sShort);
00711 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sShort);
00712 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sShort);
00713 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sShort);
00714 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sInt);
00715 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sInt);
00716 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sInt);
00717 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sInt);
00718 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sFloat);
00719 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sFloat);
00720 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sFloat);
00721 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sFloat);
00722 
00723 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uChar);
00724 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uChar);
00725 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uChar);
00726 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uChar);
00727 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uShort);
00728 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uShort);
00729 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uShort);
00730 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uShort);
00731 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sInt);
00732 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sInt);
00733 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sInt);
00734 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sInt);
00735 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sFloat);
00736 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sFloat);
00737 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sFloat);
00738 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sFloat);
00739 
00740 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uChar);
00741 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uChar);
00742 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uChar);
00743 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uChar);
00744 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uShort);
00745 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uShort);
00746 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uShort);
00747 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uShort);
00748 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sShort);
00749 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sShort);
00750 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sShort);
00751 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sShort);
00752 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sInt);
00753 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sInt);
00754 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sInt);
00755 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sInt);
00756 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sFloat);
00757 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sFloat);
00758 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sFloat);
00759 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sFloat);
00760 
00761 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uChar);
00762 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uChar);
00763 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uChar);
00764 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uChar);
00765 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uShort);
00766 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uShort);
00767 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uShort);
00768 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uShort);
00769 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sShort);
00770 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sShort);
00771 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sShort);
00772 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sShort);
00773 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sInt);
00774 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sInt);
00775 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sInt);
00776 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sInt);
00777 
00778 
00779 // Set FUNCTION
00780 #define CREATE_SET_FUNCTION_C1(TYPE)                            \
00781 template <> void QVImage<TYPE>::set(TYPE c1, TYPE, TYPE)        \
00782         { Set(c1, *this); }
00783 
00784 CREATE_SET_FUNCTION_C1(uChar);
00785 CREATE_SET_FUNCTION_C1(uShort);
00786 CREATE_SET_FUNCTION_C1(sShort);
00787 CREATE_SET_FUNCTION_C1(sInt);
00788 CREATE_SET_FUNCTION_C1(sFloat);
00789 
00790 #define CREATE_SET_FUNCTION_C3(TYPE)                                    \
00791 template <> void QVImage<TYPE,3>::set(TYPE c1, TYPE c2, TYPE c3)        \
00792         {                                                               \
00793         const TYPE values[3] = { c1, c2, c3 };                          \
00794         Set(values, *this);                                             \
00795         }
00796 
00797 CREATE_SET_FUNCTION_C3(uChar);
00798 CREATE_SET_FUNCTION_C3(uShort);
00799 CREATE_SET_FUNCTION_C3(sShort);
00800 CREATE_SET_FUNCTION_C3(sInt);
00801 CREATE_SET_FUNCTION_C3(sFloat);
00802 
00804 // operator =
00805 #define CREATE_CONVERT_OPERATOR(TYPE1, TYPE2, C)                                                \
00806 template <> QVImage<TYPE2, C> & QVImage<TYPE2, C>::operator=(const QVImage<TYPE1, C> &img)      \
00807         {                                                                                       \
00808         imageBuffer = new QVImageBuffer<TYPE2, C>(img.getCols(), img.getRows());                \
00809         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00810         Convert(img, *this);                                                                    \
00811         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00812         return *this;                                                                           \
00813         }
00814 
00815 CREATE_CONVERT_OPERATOR(uChar, uShort, 1);
00816 CREATE_CONVERT_OPERATOR(uChar, sShort, 1);
00817 CREATE_CONVERT_OPERATOR(uChar, sInt, 1);
00818 CREATE_CONVERT_OPERATOR(uChar, sFloat, 1);
00819 CREATE_CONVERT_OPERATOR(uChar, uShort, 3);
00820 CREATE_CONVERT_OPERATOR(uChar, sShort, 3);
00821 CREATE_CONVERT_OPERATOR(uChar, sInt, 3);
00822 CREATE_CONVERT_OPERATOR(uChar, sFloat, 3);
00823 CREATE_CONVERT_OPERATOR(uShort, uChar, 1);
00824 CREATE_CONVERT_OPERATOR(uShort, sInt, 1);
00825 CREATE_CONVERT_OPERATOR(uShort, sFloat, 1);
00826 CREATE_CONVERT_OPERATOR(uShort, uChar, 3);
00827 CREATE_CONVERT_OPERATOR(uShort, sInt, 3);
00828 CREATE_CONVERT_OPERATOR(uShort, sFloat, 3);
00829 CREATE_CONVERT_OPERATOR(sShort, uChar, 1);
00830 CREATE_CONVERT_OPERATOR(sShort, sInt, 1);
00831 CREATE_CONVERT_OPERATOR(sShort, sFloat, 1);
00832 CREATE_CONVERT_OPERATOR(sShort, uChar, 3);
00833 CREATE_CONVERT_OPERATOR(sShort, sInt, 3);
00834 CREATE_CONVERT_OPERATOR(sShort, sFloat, 3);
00835 CREATE_CONVERT_OPERATOR(sInt, uChar, 1);
00836 CREATE_CONVERT_OPERATOR(sInt, uChar, 3);
00837 CREATE_CONVERT_OPERATOR(sFloat, uChar, 1);
00838 CREATE_CONVERT_OPERATOR(sFloat, uShort, 1);
00839 CREATE_CONVERT_OPERATOR(sFloat, sShort, 1);
00840 CREATE_CONVERT_OPERATOR(sFloat, uChar, 3);
00841 CREATE_CONVERT_OPERATOR(sFloat, uShort, 3);
00842 CREATE_CONVERT_OPERATOR(sFloat, sShort, 3);
00843 
00844 // Nota: las siguientes funciones dan error al compilar, ya que no existen versiones de la función wrapper Convert,
00845 // para convertir de una imagen entera, a una imagen de tipo uShort, sShort, o sFloat.
00846 //      CREATE_CONVERT_OPERATOR(uShort, sInt, 1);
00847 //      CREATE_CONVERT_OPERATOR(sShort, sInt, 1);
00848 //      CREATE_CONVERT_OPERATOR(uShort, sInt, 3);
00849 //      CREATE_CONVERT_OPERATOR(sShort, sInt, 3);
00850 //      CREATE_CONVERT_OPERATOR(sFloat, sInt, 3);
00851 //      CREATE_CONVERT_OPERATOR(sFloat, sInt, 3);
00852 //
00853 // Por ello, estas funciones deben ser definidas con funciones de conversión Ad-hoc, así como las funciones de conversión
00854 // de valores uShort a valores sShort, y viceversa, que tampoco están implementadas por las IPP, ni las funciones para convertir
00855 // imagenes de distinto tipo y canal.
00856 //
00857 // Ojo: Para implementar las funciones de conversión entre imagenes de tipo sShort y uShort, hay que tener en cuenta la saturación
00858 // (que hacen las IPP para todas las funciones de conversión que implementa):
00859 // - Si se quiere convertir un valor sShort menor que cero a un valor uShort, se deja como el valor cero (0).
00860 // - Si se quiere convertir un valor uShort mayor que IPP_MAX_16S a sShort, se debe dejar como el valor IPP_MAX_16S.
00861 
00862 
00863 #define CREATE_CONVERT_OPERATOR_NO_IPP_1(TYPE1, TYPE2)                                                  \
00864 template <> QVImage<TYPE2, 1> & QVImage<TYPE2, 1>::operator=(const QVImage<TYPE1, 1> &img)              \
00865         {                                                                                               \
00866         imageBuffer = new QVImageBuffer<TYPE2, 1>(img.getCols(), img.getRows());                        \
00867         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00868         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00869         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00870                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00871                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00872         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00873         return *this;                                                                                   \
00874         }
00875 
00876 CREATE_CONVERT_OPERATOR_NO_IPP_1(uShort, sShort);
00877 CREATE_CONVERT_OPERATOR_NO_IPP_1(sShort, uShort);
00878 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, uShort);
00879 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sShort);
00880 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sFloat);
00881 CREATE_CONVERT_OPERATOR_NO_IPP_1(sFloat, sInt);
00882 
00883 #define CREATE_CONVERT_OPERATOR_NO_IPP_3(TYPE1, TYPE2)                                                  \
00884 template <> QVImage<TYPE2, 3> & QVImage<TYPE2, 3>::operator=(const QVImage<TYPE1, 3> &img)              \
00885         {                                                                                               \
00886         imageBuffer = new QVImageBuffer<TYPE2, 3>(img.getCols(), img.getRows());                        \
00887         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00888         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00889         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00890                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00891                         {                                                                               \
00892                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00893                         QVIMAGE_PIXEL(this, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1);             \
00894                         QVIMAGE_PIXEL(this, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2);             \
00895                         }                                                                               \
00896         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00897         return *this;                                                                                   \
00898         }
00899 
00900 CREATE_CONVERT_OPERATOR_NO_IPP_3(uShort, sShort);
00901 CREATE_CONVERT_OPERATOR_NO_IPP_3(sShort, uShort);
00902 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, uShort);
00903 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sShort);
00904 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sFloat);
00905 CREATE_CONVERT_OPERATOR_NO_IPP_3(sFloat, sInt);
00906 
00907 #define CREATE_CONVERT_OPERATOR_C3_C1(TYPE)                                                     \
00908 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img)         \
00909         {                                                                                       \
00910         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                 \
00911         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00912         RGBToGray(img, *this);                                                                  \
00913         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00914         return *this;                                                                           \
00915         }
00916 
00917 CREATE_CONVERT_OPERATOR_C3_C1(uChar);
00918 CREATE_CONVERT_OPERATOR_C3_C1(uShort);
00919 CREATE_CONVERT_OPERATOR_C3_C1(sShort);
00920 CREATE_CONVERT_OPERATOR_C3_C1(sFloat);
00921 
00922 #define CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(TYPE)                                                      \
00923 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img)                 \
00924         {                                                                                               \
00925         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                         \
00926         QVIMAGE_PTR_INIT_WRITE(TYPE, this);                                                             \
00927         QVIMAGE_INIT_READ(TYPE, img);                                                                   \
00928         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00929                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00930                         {                                                                               \
00931                         QVIMAGE_PIXEL(this, col, row, 0) = 0.299 * QVIMAGE_PIXEL(img, col, row, 0);     \
00932                         QVIMAGE_PIXEL(this, col, row, 0) += 0.587 * QVIMAGE_PIXEL(img, col, row, 1);    \
00933                         QVIMAGE_PIXEL(this, col, row, 0) += 0.114 * QVIMAGE_PIXEL(img, col, row, 2);    \
00934                         }                                                                               \
00935         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00936         return *this;                                                                                   \
00937         }
00938 
00939 CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(sInt);
00940 
00941 #define CREATE_CONVERT_OPERATOR_C1_C3(TYPE)                                                     \
00942 template <> QVImage<TYPE, 3> & QVImage<TYPE, 3>::operator=(const QVImage<TYPE, 1> &img)         \
00943         {                                                                                       \
00944         imageBuffer = new QVImageBuffer<TYPE, 3>(img.getCols(), img.getRows());                 \
00945         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00946         Copy(img, img, img, *this);                                                             \
00947         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00948         return *this;                                                                           \
00949         }
00950 
00951 CREATE_CONVERT_OPERATOR_C1_C3(uChar);
00952 CREATE_CONVERT_OPERATOR_C1_C3(uShort);
00953 CREATE_CONVERT_OPERATOR_C1_C3(sShort);
00954 CREATE_CONVERT_OPERATOR_C1_C3(sInt);
00955 CREATE_CONVERT_OPERATOR_C1_C3(sFloat);
00956 
00957 
00958 //Convert constructors with double conversion (after operator= declaration)
00959 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(TYPE1, TYPE2)                                   \
00960 template <> QVImage<TYPE2, 1>::QVImage(QVImage<TYPE1, 3> const &img):QVGenericImage(img)        \
00961         {                                                                                       \
00962         *this = QVImage<TYPE2, 3>(img);                                                         \
00963         }
00964 
00965 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, uShort);
00966 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sShort);
00967 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sInt);
00968 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sFloat);
00969 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, uChar);
00970 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sShort);
00971 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sInt);
00972 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sFloat);
00973 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uChar);
00974 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uShort);
00975 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sInt);
00976 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sFloat);
00977 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uChar);
00978 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uShort);
00979 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sShort);
00980 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sFloat);
00981 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uChar);
00982 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uShort);
00983 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sShort);
00984 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sInt);
00985 
00986 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(TYPE1, TYPE2)                                   \
00987 template <> QVImage<TYPE2, 3>::QVImage(QVImage<TYPE1, 1> const &img):QVGenericImage(img)        \
00988         {                                                                                       \
00989         *this = QVImage<TYPE2, 1>(img);                                                         \
00990         }
00991 
00992 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, uShort);
00993 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sShort);
00994 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sInt);
00995 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sFloat);
00996 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, uChar);
00997 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sShort);
00998 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sInt);
00999 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sFloat);
01000 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uChar);
01001 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uShort);
01002 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sInt);
01003 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sFloat);
01004 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uChar);
01005 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uShort);
01006 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sShort);
01007 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sFloat);
01008 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uChar);
01009 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uShort);
01010 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sShort);
01011 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sInt);
01012 
01013 
01014 #define CREATE_ACCESS_CONSTRUCTOR(OPERATOR, TYPE, C)                                            \
01015 template <> QVImage<TYPE, 1> QVImage<TYPE, C>::OPERATOR(const uInt channel) const               \
01016         {                                                                                       \
01017         QVImage<TYPE, 1> result(getCols(), getRows());                                          \
01018         Copy(*this, channel, result);                                                           \
01019         result.setROI(getROI()); result.setAnchor(getAnchor());                                 \
01020         return result;                                                                          \
01021         }
01022 
01023 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 1);
01024 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 3);
01025 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 1);
01026 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 3);
01027 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 1);
01028 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 3);
01029 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 1);
01030 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 3);
01031 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 1);
01032 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 3);
01033 
01034 
01035 
01036 



QVision framework. PARP research group, copyright 2007, 2008.