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         }
00047 
00048 CREATE_COPY_CONSTRUCTOR(uChar, 1);
00049 CREATE_COPY_CONSTRUCTOR(uChar, 3);
00050 CREATE_COPY_CONSTRUCTOR(uShort, 1);
00051 CREATE_COPY_CONSTRUCTOR(uShort, 3);
00052 CREATE_COPY_CONSTRUCTOR(sShort, 1);
00053 CREATE_COPY_CONSTRUCTOR(sShort, 3);
00054 CREATE_COPY_CONSTRUCTOR(sInt, 1);
00055 CREATE_COPY_CONSTRUCTOR(sInt, 3);
00056 CREATE_COPY_CONSTRUCTOR(sFloat, 1);
00057 CREATE_COPY_CONSTRUCTOR(sFloat, 3);
00058 
00059 // Copy operator
00060 #define CREATE_COPY_OPERATOR(TYPE, C)                                                   \
00061 template <> QVImage<TYPE,C> & QVImage<TYPE, C>::operator=(const QVImage<TYPE, C> &img)  \
00062         {                                                                               \
00063         imageBuffer = img.imageBuffer;                                                  \
00064         setROI(img.getROI()); setAnchor(img.getAnchor());                               \
00065         return *this;                                                                   \
00066         }
00067 
00068 CREATE_COPY_OPERATOR(uChar, 1);
00069 CREATE_COPY_OPERATOR(uChar, 3);
00070 CREATE_COPY_OPERATOR(uShort, 1);
00071 CREATE_COPY_OPERATOR(uShort, 3);
00072 CREATE_COPY_OPERATOR(sShort, 1);
00073 CREATE_COPY_OPERATOR(sShort, 3);
00074 CREATE_COPY_OPERATOR(sInt, 1);
00075 CREATE_COPY_OPERATOR(sInt, 3);
00076 CREATE_COPY_OPERATOR(sFloat, 1);
00077 CREATE_COPY_OPERATOR(sFloat, 3);
00078 
00080 // QVIPP FUNCTIONS
00081 #include <qvip/qvipp/qvipp.h>
00082 
00083 // Compose copy constructors
00084 #define CREATE_COMPOSE_COPY_CONSTRUCTOR(TYPE)                                                                                                                   \
00085 template <> QVImage<TYPE, 3>::QVImage(QVImage<TYPE,1> const &red, QVImage<TYPE,1> const &green, QVImage<TYPE,1> const &blue):QVGenericImage(red)                \
00086         {                                                                                                                                                       \
00087         imageBuffer = new QVImageBuffer<TYPE, 3>(red.getCols(), red.getRows());                                                                                 \
00088         Copy(red, green, blue, *this);                                                                                                                          \
00089         setROI(red.getROI()); setAnchor(red.getAnchor());                                                                                                       \
00090         }
00091 
00092 CREATE_COMPOSE_COPY_CONSTRUCTOR(uChar);
00093 CREATE_COMPOSE_COPY_CONSTRUCTOR(uShort);
00094 CREATE_COMPOSE_COPY_CONSTRUCTOR(sShort);
00095 CREATE_COMPOSE_COPY_CONSTRUCTOR(sInt);
00096 CREATE_COMPOSE_COPY_CONSTRUCTOR(sFloat);
00097 
00098 // Conversion constructors
00099 #define CREATE_CONVERT_CONSTRUCTOR(TYPE1, TYPE2, C)                                             \
00100 template <> QVImage<TYPE2, C>::QVImage(QVImage<TYPE1, C> const &img):QVGenericImage(img)        \
00101         {                                                                                       \
00102         imageBuffer = new QVImageBuffer<TYPE2, C>(img.getCols(), img.getRows());                \
00103         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00104         Convert(img, *this);                                                                    \
00105         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00106         }
00107 
00108 // (ORIG, DEST, CHAN)
00109 CREATE_CONVERT_CONSTRUCTOR(uChar,       uShort, 1);
00110 CREATE_CONVERT_CONSTRUCTOR(uChar,       sShort, 1);
00111 CREATE_CONVERT_CONSTRUCTOR(uChar,       sInt, 1);
00112 CREATE_CONVERT_CONSTRUCTOR(uChar,       sFloat, 1);
00113 CREATE_CONVERT_CONSTRUCTOR(uChar,       uShort, 3);
00114 CREATE_CONVERT_CONSTRUCTOR(uChar,       sShort, 3);
00115 CREATE_CONVERT_CONSTRUCTOR(uChar,       sInt, 3);
00116 CREATE_CONVERT_CONSTRUCTOR(uChar,       sFloat, 3);
00117 CREATE_CONVERT_CONSTRUCTOR(uShort,      uChar, 1);
00118 CREATE_CONVERT_CONSTRUCTOR(uShort,      sInt, 1);
00119 CREATE_CONVERT_CONSTRUCTOR(uShort,      sFloat, 1);
00120 CREATE_CONVERT_CONSTRUCTOR(uShort,      uChar, 3);
00121 CREATE_CONVERT_CONSTRUCTOR(uShort,      sInt, 3);
00122 CREATE_CONVERT_CONSTRUCTOR(uShort,      sFloat, 3);
00123 CREATE_CONVERT_CONSTRUCTOR(sShort,      uChar, 1);
00124 CREATE_CONVERT_CONSTRUCTOR(sShort,      sInt, 1);
00125 CREATE_CONVERT_CONSTRUCTOR(sShort,      sFloat, 1);
00126 CREATE_CONVERT_CONSTRUCTOR(sShort,      uChar, 3);
00127 CREATE_CONVERT_CONSTRUCTOR(sShort,      sInt, 3);
00128 CREATE_CONVERT_CONSTRUCTOR(sShort,      sFloat, 3);
00129 CREATE_CONVERT_CONSTRUCTOR(sInt,        uChar, 1);
00130 CREATE_CONVERT_CONSTRUCTOR(sInt,        uChar, 3);
00131 CREATE_CONVERT_CONSTRUCTOR(sFloat,      uChar, 1);
00132 CREATE_CONVERT_CONSTRUCTOR(sFloat,      uShort, 1);
00133 CREATE_CONVERT_CONSTRUCTOR(sFloat,      sShort, 1);
00134 CREATE_CONVERT_CONSTRUCTOR(sFloat,      uChar, 3);
00135 CREATE_CONVERT_CONSTRUCTOR(sFloat,      uShort, 3);
00136 CREATE_CONVERT_CONSTRUCTOR(sFloat,      sShort, 3);
00137 
00138 // Nota: las siguientes funciones dan error al compilar, ya que no existen versiones de la función wrapper Convert,
00139 // para convertir de una imagen entera, a una imagen de tipo uShort, sShort, o sFloat.
00140 //      CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 1);
00141 //      CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 1);
00142 //      CREATE_CONVERT_CONSTRUCTOR(uShort, sInt, 3);
00143 //      CREATE_CONVERT_CONSTRUCTOR(sShort, sInt, 3);
00144 //      CREATE_CONVERT_CONSTRUCTOR(sFloat, sInt, 3);
00145 //      CREATE_CONVERT_CONSTRUCTOR(sFloat, sInt, 3);
00146 //
00147 // Por ello, estas funciones deben ser definidas con funciones de conversión Ad-hoc, así como las funciones de conversión
00148 // de valores uShort a valores sShort, y viceversa, que tampoco están implementadas por las IPP, ni las funciones para convertir
00149 // imagenes de distinto tipo y canal.
00150 //
00151 // Ojo: Para implementar las funciones de conversión entre imagenes de tipo sShort y uShort, hay que tener en cuenta la saturación
00152 // (que hacen las IPP para todas las funciones de conversión que implementa):
00153 // - Si se quiere convertir un valor sShort menor que cero a un valor uShort, se deja como el valor cero (0).
00154 // - Si se quiere convertir un valor uShort mayor que IPP_MAX_16S a sShort, se debe dejar como el valor IPP_MAX_16S.
00155 
00156 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(TYPE1, TYPE2)                                               \
00157 template <> QVImage<TYPE2, 1>::QVImage(QVImage<TYPE1, 1> const &img):QVGenericImage(img)                \
00158         {                                                                                               \
00159         imageBuffer = new QVImageBuffer<TYPE2, 1>(img.getCols(), img.getRows());                        \
00160         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00161         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00162         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00163                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00164                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00165         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00166         }
00167 
00168 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(uShort, sShort);
00169 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sShort, uShort);
00170 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, uShort);
00171 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, sShort);
00172 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sInt, sFloat);
00173 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_1(sFloat, sInt);
00174 
00175 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(TYPE1, TYPE2)                                               \
00176 template <> QVImage<TYPE2, 3>::QVImage(QVImage<TYPE1, 3> const &img):QVGenericImage(img)                \
00177         {                                                                                               \
00178         imageBuffer = new QVImageBuffer<TYPE2, 3>(img.getCols(), img.getRows());                        \
00179         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00180         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00181         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00182                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00183                         {                                                                               \
00184                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00185                         QVIMAGE_PIXEL(this, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1);             \
00186                         QVIMAGE_PIXEL(this, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2);             \
00187                         }                                                                               \
00188         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00189         }
00190 
00191 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(uShort, sShort);
00192 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sShort, uShort);
00193 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, uShort);
00194 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, sShort);
00195 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sInt, sFloat);
00196 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_3(sFloat, sInt);
00197 
00198 #define CREATE_CONVERT_CONSTRUCTOR_C3_C1(TYPE)                                                  \
00199 template <> QVImage<TYPE, 1>::QVImage(QVImage<TYPE, 3> const &img):QVGenericImage(img)          \
00200         {                                                                                       \
00201         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                 \
00202         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00203         RGBToGray(img, *this);                                                                  \
00204         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00205         }
00206 
00207 CREATE_CONVERT_CONSTRUCTOR_C3_C1(uChar);
00208 CREATE_CONVERT_CONSTRUCTOR_C3_C1(uShort);
00209 CREATE_CONVERT_CONSTRUCTOR_C3_C1(sShort);
00210 CREATE_CONVERT_CONSTRUCTOR_C3_C1(sFloat);
00211 
00212 #define CREATE_CONVERT_CONSTRUCTOR_NO_IPP_C3_C1(TYPE)                                                   \
00213 template <> QVImage<TYPE, 1>::QVImage(QVImage<TYPE, 3> const &img):QVGenericImage(img)                  \
00214         {                                                                                               \
00215         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                         \
00216         QVIMAGE_PTR_INIT_WRITE(TYPE, this);                                                             \
00217         QVIMAGE_INIT_READ(TYPE, img);                                                                   \
00218         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00219                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00220                         {                                                                               \
00221                         QVIMAGE_PIXEL(this, col, row, 0) = 0.299 * QVIMAGE_PIXEL(img, col, row, 0);     \
00222                         QVIMAGE_PIXEL(this, col, row, 0) += 0.587 * QVIMAGE_PIXEL(img, col, row, 1);    \
00223                         QVIMAGE_PIXEL(this, col, row, 0) += 0.114 * QVIMAGE_PIXEL(img, col, row, 2);    \
00224                         }                                                                               \
00225         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00226         }
00227 
00228 CREATE_CONVERT_CONSTRUCTOR_NO_IPP_C3_C1(sInt);
00229 
00230 #define CREATE_CONVERT_CONSTRUCTOR_C1_C3(TYPE)                                                  \
00231 template <> QVImage<TYPE, 3>::QVImage(QVImage<TYPE, 1> const &img):QVGenericImage(img)          \
00232         {                                                                                       \
00233         imageBuffer = new QVImageBuffer<TYPE, 3>(img.getCols(), img.getRows());                 \
00234         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00235         Copy(img, img, img, *this);                                                             \
00236         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00237         }
00238 
00239 CREATE_CONVERT_CONSTRUCTOR_C1_C3(uChar);
00240 CREATE_CONVERT_CONSTRUCTOR_C1_C3(uShort);
00241 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sShort);
00242 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sInt);
00243 CREATE_CONVERT_CONSTRUCTOR_C1_C3(sFloat);
00244 
00245 
00246 // Operators
00247 #define CREATE_OPERATOR(NAME, OPERATOR, TYPE, C)                                                \
00248 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const       \
00249         {                                                                                       \
00250         QVImage<TYPE, C> result = *this;                                                        \
00251         NAME(*this, img, result);                                                               \
00252         return result;                                                                          \
00253         }
00254 
00255 CREATE_OPERATOR(Add, operator+, uChar, 1);
00256 CREATE_OPERATOR(Mul, operator*, uChar, 1);
00257 CREATE_OPERATOR(Sub, operator-, uChar, 1);
00258 CREATE_OPERATOR(Div, operator/, uChar, 1);
00259 CREATE_OPERATOR(Add, operator+, uChar, 3);
00260 CREATE_OPERATOR(Mul, operator*, uChar, 3);
00261 CREATE_OPERATOR(Sub, operator-, uChar, 3);
00262 CREATE_OPERATOR(Div, operator/, uChar, 3);
00263 
00264 CREATE_OPERATOR(Add, operator+, uShort, 1);
00265 CREATE_OPERATOR(Mul, operator*, uShort, 1);
00266 CREATE_OPERATOR(Sub, operator-, uShort, 1);
00267 CREATE_OPERATOR(Div, operator/, uShort, 1);
00268 CREATE_OPERATOR(Add, operator+, uShort, 3);
00269 CREATE_OPERATOR(Mul, operator*, uShort, 3);
00270 CREATE_OPERATOR(Sub, operator-, uShort, 3);
00271 CREATE_OPERATOR(Div, operator/, uShort, 3);
00272 
00273 CREATE_OPERATOR(Add, operator+, sShort, 1);
00274 CREATE_OPERATOR(Mul, operator*, sShort, 1);
00275 CREATE_OPERATOR(Sub, operator-, sShort, 1);
00276 CREATE_OPERATOR(Div, operator/, sShort, 1);
00277 CREATE_OPERATOR(Add, operator+, sShort, 3);
00278 CREATE_OPERATOR(Mul, operator*, sShort, 3);
00279 CREATE_OPERATOR(Sub, operator-, sShort, 3);
00280 CREATE_OPERATOR(Div, operator/, sShort, 3);
00281 
00282 #define CREATE_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE)                                                                                       \
00283 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const QVImage<TYPE, 1> &img) const                                                      \
00284         {                                                                                                                                       \
00285         QVImage<TYPE, 1> result = *this;                                                                                                        \
00286         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                                                      \
00287         QVIMAGE_INIT_READ(TYPE, img);                                                                                                           \
00288         QVIMAGE_INIT_WRITE(TYPE, result);                                                                                                       \
00289         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                                                            \
00290                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                                                    \
00291                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0);        \
00292         return result;                                                                                                                          \
00293         }
00294 
00295 CREATE_OPERATOR_INT_C1(operator+, +, sInt);
00296 CREATE_OPERATOR_INT_C1(operator*, *, sInt);
00297 CREATE_OPERATOR_INT_C1(operator-, -, sInt);
00298 CREATE_OPERATOR_INT_C1(operator/, /, sInt);
00299 
00300 #define CREATE_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE)                                                                                       \
00301 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const QVImage<TYPE, 3> &img) const                                                      \
00302         {                                                                                                                                       \
00303         QVImage<TYPE, 3> result = *this;                                                                                                        \
00304         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                                                      \
00305         QVIMAGE_INIT_READ(TYPE, img);                                                                                                           \
00306         QVIMAGE_INIT_WRITE(TYPE, result);                                                                                                       \
00307         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                                                            \
00308                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                                                    \
00309                         {                                                                                                                       \
00310                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0) OPERATION QVIMAGE_PIXEL(this, col, row, 0);        \
00311                         QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1) OPERATION QVIMAGE_PIXEL(this, col, row, 1);        \
00312                         QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2) OPERATION QVIMAGE_PIXEL(this, col, row, 2);        \
00313                         }                                                                                                                       \
00314         return result;                                                                                                                          \
00315         }
00316 
00317 CREATE_OPERATOR_INT_C3(operator+, +, sInt);
00318 CREATE_OPERATOR_INT_C3(operator*, *, sInt);
00319 CREATE_OPERATOR_INT_C3(operator-, -, sInt);
00320 CREATE_OPERATOR_INT_C3(operator/, /, sInt);
00321 
00322 
00323 #define CREATE_CONST_OPERATOR(NAME, OPERATOR, TYPE, C)                          \
00324 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00325         {                                                                       \
00326         QVImage<TYPE, C> result = *this;                                        \
00327         NAME(*this, value, result);                                             \
00328         return result;                                                          \
00329         }
00330 
00331 CREATE_CONST_OPERATOR(AddC, operator+, uChar, 1);
00332 CREATE_CONST_OPERATOR(MulC, operator*, uChar, 1);
00333 CREATE_CONST_OPERATOR(SubC, operator-, uChar, 1);
00334 CREATE_CONST_OPERATOR(DivC, operator/, uChar, 1);
00335 CREATE_CONST_OPERATOR(AddC, operator+, uShort, 1);
00336 CREATE_CONST_OPERATOR(MulC, operator*, uShort, 1);
00337 CREATE_CONST_OPERATOR(SubC, operator-, uShort, 1);
00338 CREATE_CONST_OPERATOR(DivC, operator/, uShort, 1);
00339 CREATE_CONST_OPERATOR(AddC, operator+, sShort, 1);
00340 CREATE_CONST_OPERATOR(MulC, operator*, sShort, 1);
00341 CREATE_CONST_OPERATOR(SubC, operator-, sShort, 1);
00342 CREATE_CONST_OPERATOR(DivC, operator/, sShort, 1);
00343 CREATE_CONST_OPERATOR(AddC, operator+, sFloat, 1);
00344 CREATE_CONST_OPERATOR(MulC, operator*, sFloat, 1);
00345 CREATE_CONST_OPERATOR(SubC, operator-, sFloat, 1);
00346 CREATE_CONST_OPERATOR(DivC, operator/, sFloat, 1);
00347 CREATE_CONST_OPERATOR(LShiftC, operator<<, uChar, 1);
00348 CREATE_CONST_OPERATOR(RShiftC, operator>>, uChar, 1);
00349 CREATE_CONST_OPERATOR(LShiftC, operator<<, uShort, 1);
00350 CREATE_CONST_OPERATOR(RShiftC, operator>>, uShort, 1);
00351 CREATE_CONST_OPERATOR(LShiftC, operator<<, sInt, 1);
00352 CREATE_CONST_OPERATOR(RShiftC, operator>>, sInt, 1);
00353 CREATE_CONST_OPERATOR(AndC, operator&, uChar, 1);
00354 CREATE_CONST_OPERATOR(OrC, operator|, uChar, 1);
00355 CREATE_CONST_OPERATOR(XorC, operator^, uChar, 1);
00356 CREATE_CONST_OPERATOR(AndC, operator&, uShort, 1);
00357 CREATE_CONST_OPERATOR(OrC, operator|, uShort, 1);
00358 CREATE_CONST_OPERATOR(XorC, operator^, uShort, 1);
00359 CREATE_CONST_OPERATOR(AndC, operator&, sInt, 1);
00360 CREATE_CONST_OPERATOR(OrC, operator|, sInt, 1);
00361 CREATE_CONST_OPERATOR(XorC, operator^, sInt, 1);
00362 
00364 
00365 #define CREATE_CONST_OPERATOR_C3(NAME, OPERATOR, TYPE, C)                       \
00366 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00367         {                                                                       \
00368         const TYPE values[3] = { value, value, value };                         \
00369         QVImage<TYPE, C> result = *this;                                        \
00370         NAME(*this, values, result);                                            \
00371         return result;                                                          \
00372         }
00373 
00374 CREATE_CONST_OPERATOR_C3(AddC, operator+, uChar, 3);
00375 CREATE_CONST_OPERATOR_C3(MulC, operator*, uChar, 3);
00376 CREATE_CONST_OPERATOR_C3(SubC, operator-, uChar, 3);
00377 CREATE_CONST_OPERATOR_C3(DivC, operator/, uChar, 3);
00378 CREATE_CONST_OPERATOR_C3(AddC, operator+, sShort, 3);
00379 CREATE_CONST_OPERATOR_C3(MulC, operator*, sShort, 3);
00380 CREATE_CONST_OPERATOR_C3(SubC, operator-, sShort, 3);
00381 CREATE_CONST_OPERATOR_C3(DivC, operator/, sShort, 3);
00382 CREATE_CONST_OPERATOR_C3(AddC, operator+, uShort, 3);
00383 CREATE_CONST_OPERATOR_C3(MulC, operator*, uShort, 3);
00384 CREATE_CONST_OPERATOR_C3(SubC, operator-, uShort, 3);
00385 CREATE_CONST_OPERATOR_C3(DivC, operator/, uShort, 3);
00386 CREATE_CONST_OPERATOR_C3(AddC, operator+, sFloat, 3);
00387 CREATE_CONST_OPERATOR_C3(MulC, operator*, sFloat, 3);
00388 CREATE_CONST_OPERATOR_C3(SubC, operator-, sFloat, 3);
00389 CREATE_CONST_OPERATOR_C3(DivC, operator/, sFloat, 3);
00390 CREATE_CONST_OPERATOR_C3(AndC, operator&, uChar, 3);
00391 CREATE_CONST_OPERATOR_C3(OrC, operator|, uChar, 3);
00392 CREATE_CONST_OPERATOR_C3(XorC, operator^, uChar, 3);
00393 CREATE_CONST_OPERATOR_C3(AndC, operator&, uShort, 3);
00394 CREATE_CONST_OPERATOR_C3(OrC, operator|, uShort, 3);
00395 CREATE_CONST_OPERATOR_C3(XorC, operator^, uShort, 3);
00396 CREATE_CONST_OPERATOR_C3(AndC, operator&, sInt, 3);
00397 CREATE_CONST_OPERATOR_C3(OrC, operator|, sInt, 3);
00398 CREATE_CONST_OPERATOR_C3(XorC, operator^, sInt, 3);
00399 
00400 #define CREATE_CONST_OPERATOR_C4(NAME, OPERATOR, TYPE, C)                       \
00401 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR(const TYPE value) const  \
00402         {                                                                       \
00403         const uInt values[3] = { value, value, value };                         \
00404         QVImage<TYPE, C> result = *this;                                        \
00405         NAME(*this, values, result);                                            \
00406         return result;                                                          \
00407         }
00408 
00409 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uChar, 3);
00410 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uChar, 3);
00411 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, uShort, 3);
00412 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, uShort, 3);
00413 CREATE_CONST_OPERATOR_C4(LShiftC, operator<<, sInt, 3);
00414 CREATE_CONST_OPERATOR_C4(RShiftC, operator>>, sInt, 3);
00415 
00416 #define CREATE_CONST_OPERATOR_INT_C1(OPERATOR, OPERATION, TYPE)                                                 \
00417 template <> QVImage<TYPE, 1> QVImage<TYPE, 1>::OPERATOR(const TYPE value) const                                 \
00418         {                                                                                                       \
00419         QVImage<TYPE, 1> result = *this;                                                                        \
00420         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                      \
00421         QVIMAGE_INIT_WRITE(TYPE, result);                                                                       \
00422         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00423                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00424                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value;  \
00425         return result;                                                                                          \
00426         }
00427 
00428 CREATE_CONST_OPERATOR_INT_C1(operator+, +, sInt);
00429 CREATE_CONST_OPERATOR_INT_C1(operator*, *, sInt);
00430 CREATE_CONST_OPERATOR_INT_C1(operator-, -, sInt);
00431 CREATE_CONST_OPERATOR_INT_C1(operator/, /, sInt);
00432 
00433 #define CREATE_CONST_OPERATOR_INT_C3(OPERATOR, OPERATION, TYPE)                                                 \
00434 template <> QVImage<TYPE, 3> QVImage<TYPE, 3>::OPERATOR(const TYPE value) const                                 \
00435         {                                                                                                       \
00436         QVImage<TYPE, 3> result = *this;                                                                        \
00437         QVIMAGE_PTR_INIT_READ(TYPE, this);                                                                      \
00438         QVIMAGE_INIT_WRITE(TYPE, result);                                                                       \
00439         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00440                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00441                         {                                                                                       \
00442                         QVIMAGE_PIXEL(result, col, row, 0) = QVIMAGE_PIXEL(this, col, row, 0) OPERATION value;  \
00443                         QVIMAGE_PIXEL(result, col, row, 1) = QVIMAGE_PIXEL(this, col, row, 1) OPERATION value;  \
00444                         QVIMAGE_PIXEL(result, col, row, 2) = QVIMAGE_PIXEL(this, col, row, 2) OPERATION value;  \
00445                         }                                                                                       \
00446         return result;                                                                                          \
00447         }
00448 
00449 CREATE_CONST_OPERATOR_INT_C3(operator+, +, sInt);
00450 CREATE_CONST_OPERATOR_INT_C3(operator*, *, sInt);
00451 CREATE_CONST_OPERATOR_INT_C3(operator-, -, sInt);
00452 CREATE_CONST_OPERATOR_INT_C3(operator/, /, sInt);
00453 
00454 #define CREATE_NOT_OPERATOR(NAME, OPERATOR, TYPE, C)            \
00455 template <> QVImage<TYPE, C> QVImage<TYPE,C>::OPERATOR() const  \
00456         {                                                       \
00457         QVImage<TYPE, C> result = *this;                        \
00458         NAME(*this, result);                                    \
00459         return result;                                          \
00460         }
00461 
00462 CREATE_NOT_OPERATOR(Not, operator!, uChar, 1);
00463 CREATE_NOT_OPERATOR(Not, operator!, uChar, 3);
00464 
00465 #define CREATE_COMPARE_OPERATOR(NAME, OPERATOR, CMP, TYPE, C)                           \
00466 template <> QVImage<uChar> QVImage<TYPE,C>::OPERATOR(const QVImage<TYPE, C> &img) const \
00467         {                                                                               \
00468         QVImage<uChar> result(getCols(), getRows());                                    \
00469         NAME(*this, img, result, CMP);                                                  \
00470         return result;                                                                  \
00471         }
00472 
00473 // ippcmpLess
00474 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 1);
00475 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 1);
00476 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 1);
00477 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 1);
00478 
00479 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uChar, 3);
00480 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, uShort, 3);
00481 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sShort, 3);
00482 CREATE_COMPARE_OPERATOR(Compare, operator<, ippCmpLess, sFloat, 3);
00483 
00484 // ippCmpGreater
00485 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 1);
00486 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 1);
00487 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 1);
00488 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 1);
00489 
00490 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uChar, 3);
00491 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, uShort, 3);
00492 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sShort, 3);
00493 CREATE_COMPARE_OPERATOR(Compare, operator>, ippCmpGreater, sFloat, 3);
00494 
00495 // ippcmpLessEq
00496 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 1);
00497 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 1);
00498 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 1);
00499 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 1);
00500 
00501 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uChar, 3);
00502 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, uShort, 3);
00503 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sShort, 3);
00504 CREATE_COMPARE_OPERATOR(Compare, operator<=, ippCmpLessEq, sFloat, 3);
00505 
00506 // ippCmpGreaterEq
00507 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 1);
00508 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 1);
00509 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 1);
00510 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 1);
00511 
00512 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uChar, 3);
00513 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, uShort, 3);
00514 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sShort, 3);
00515 CREATE_COMPARE_OPERATOR(Compare, operator>=, ippCmpGreaterEq, sFloat, 3);
00516 
00517 #define CREATE_GENERIC_COMPARE_OPERATOR_C1(OPERATOR, OPERATION, TYPE1, TYPE2)                           \
00518 template <> QVImage<uChar> QVImage<TYPE1, 1>::OPERATOR(const QVImage<TYPE2, 1> &img) const              \
00519         {                                                                                               \
00520         QVImage<uChar> result(getCols(), getRows());                                                    \
00521         result.setROI(getROI()); result.setAnchor(getAnchor());                                         \
00522         QVIMAGE_PTR_INIT_READ(TYPE1, this);                                                             \
00523         QVIMAGE_INIT_READ(TYPE2, img);                                                                  \
00524         QVIMAGE_INIT_WRITE(uChar, result);                                                              \
00525         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                    \
00526                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)            \
00527                         if (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) \
00528                                 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U;                        \
00529                         else    QVIMAGE_PIXEL(result, col, row, 0) = 0;                                 \
00530         return result;                                                                                  \
00531         }
00532 
00533 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, uShort);
00534 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, uShort);
00535 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, uShort);
00536 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, uShort);
00537 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sShort);
00538 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sShort);
00539 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sShort);
00540 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sShort);
00541 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sInt);
00542 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sInt);
00543 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sInt);
00544 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sInt);
00545 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uChar, sFloat);
00546 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uChar, sFloat);
00547 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uChar, sFloat);
00548 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uChar, sFloat);
00549 
00550 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, uChar);
00551 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, uChar);
00552 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, uChar);
00553 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, uChar);
00554 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sShort);
00555 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sShort);
00556 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sShort);
00557 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sShort);
00558 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sInt);
00559 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sInt);
00560 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sInt);
00561 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sInt);
00562 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, uShort, sFloat);
00563 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, uShort, sFloat);
00564 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, uShort, sFloat);
00565 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, uShort, sFloat);
00566 
00567 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uChar);
00568 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uChar);
00569 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uChar);
00570 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uChar);
00571 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, uShort);
00572 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, uShort);
00573 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, uShort);
00574 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, uShort);
00575 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sInt);
00576 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sInt);
00577 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sInt);
00578 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sInt);
00579 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sShort, sFloat);
00580 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sShort, sFloat);
00581 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sShort, sFloat);
00582 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sShort, sFloat);
00583 
00584 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uChar);
00585 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uChar);
00586 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uChar);
00587 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uChar);
00588 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, uShort);
00589 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, uShort);
00590 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, uShort);
00591 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, uShort);
00592 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sShort);
00593 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sShort);
00594 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sShort);
00595 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sShort);
00596 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sInt);
00597 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sInt);
00598 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sInt);
00599 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sInt);
00600 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sInt, sFloat);
00601 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sInt, sFloat);
00602 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sInt, sFloat);
00603 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sInt, sFloat);
00604 
00605 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uChar);
00606 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uChar);
00607 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uChar);
00608 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uChar);
00609 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, uShort);
00610 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, uShort);
00611 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, uShort);
00612 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, uShort);
00613 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sShort);
00614 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sShort);
00615 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sShort);
00616 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sShort);
00617 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<, <, sFloat, sInt);
00618 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>, >, sFloat, sInt);
00619 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator<=, <=, sFloat, sInt);
00620 CREATE_GENERIC_COMPARE_OPERATOR_C1(operator>=, >=, sFloat, sInt);
00621 
00622 
00623 #define CREATE_GENERIC_COMPARE_OPERATOR_C3(OPERATOR, OPERATION, TYPE1, TYPE2)                                   \
00624 template <> QVImage<uChar> QVImage<TYPE1, 3>::OPERATOR(const QVImage<TYPE2, 3> &img) const                      \
00625         {                                                                                                       \
00626         QVImage<uChar> result(getCols(), getRows());                                                            \
00627         result.setROI(getROI()); result.setAnchor(getAnchor());                                                 \
00628         QVIMAGE_PTR_INIT_READ(TYPE1, this);                                                                     \
00629         QVIMAGE_INIT_READ(TYPE2, img);                                                                          \
00630         QVIMAGE_INIT_WRITE(uChar, result);                                                                      \
00631         for (int col = result.getROI().left(); col < result.getROI().right(); col++)                            \
00632                 for (int row = result.getROI().top(); row < result.getROI().bottom(); row++)                    \
00633                         {                                                                                       \
00634                         if( (QVIMAGE_PIXEL(this, col, row, 0) OPERATION QVIMAGE_PIXEL(img, col, row, 0)) &&     \
00635                             (QVIMAGE_PIXEL(this, col, row, 1) OPERATION QVIMAGE_PIXEL(img, col, row, 1)) &&     \
00636                             (QVIMAGE_PIXEL(this, col, row, 2) OPERATION QVIMAGE_PIXEL(img, col, row, 2))    )   \
00637                                 QVIMAGE_PIXEL(result, col, row, 0) = IPP_MAX_8U;                                \
00638                         else    QVIMAGE_PIXEL(result, col, row, 0) = 0;                                         \
00639                         }                                                                                       \
00640         return result;                                                                                          \
00641         }
00642 
00643 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, uShort);
00644 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, uShort);
00645 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, uShort);
00646 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, uShort);
00647 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sShort);
00648 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sShort);
00649 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sShort);
00650 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sShort);
00651 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sInt);
00652 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sInt);
00653 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sInt);
00654 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sInt);
00655 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uChar, sFloat);
00656 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uChar, sFloat);
00657 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uChar, sFloat);
00658 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uChar, sFloat);
00659 
00660 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, uChar);
00661 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, uChar);
00662 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, uChar);
00663 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, uChar);
00664 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sShort);
00665 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sShort);
00666 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sShort);
00667 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sShort);
00668 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sInt);
00669 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sInt);
00670 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sInt);
00671 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sInt);
00672 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, uShort, sFloat);
00673 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, uShort, sFloat);
00674 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, uShort, sFloat);
00675 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, uShort, sFloat);
00676 
00677 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uChar);
00678 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uChar);
00679 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uChar);
00680 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uChar);
00681 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, uShort);
00682 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, uShort);
00683 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, uShort);
00684 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, uShort);
00685 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sInt);
00686 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sInt);
00687 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sInt);
00688 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sInt);
00689 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sShort, sFloat);
00690 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sShort, sFloat);
00691 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sShort, sFloat);
00692 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sShort, sFloat);
00693 
00694 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uChar);
00695 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uChar);
00696 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uChar);
00697 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uChar);
00698 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, uShort);
00699 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, uShort);
00700 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, uShort);
00701 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, uShort);
00702 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sShort);
00703 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sShort);
00704 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sShort);
00705 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sShort);
00706 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sInt);
00707 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sInt);
00708 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sInt);
00709 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sInt);
00710 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sInt, sFloat);
00711 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sInt, sFloat);
00712 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sInt, sFloat);
00713 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sInt, sFloat);
00714 
00715 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uChar);
00716 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uChar);
00717 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uChar);
00718 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uChar);
00719 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, uShort);
00720 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, uShort);
00721 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, uShort);
00722 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, uShort);
00723 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sShort);
00724 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sShort);
00725 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sShort);
00726 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sShort);
00727 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<, <, sFloat, sInt);
00728 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>, >, sFloat, sInt);
00729 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator<=, <=, sFloat, sInt);
00730 CREATE_GENERIC_COMPARE_OPERATOR_C3(operator>=, >=, sFloat, sInt);
00731 
00732 
00733 // Set FUNCTION
00734 #define CREATE_SET_FUNCTION_C1(TYPE)                            \
00735 template <> void QVImage<TYPE>::set(TYPE c1, TYPE, TYPE)        \
00736         { Set(c1, *this); }
00737 
00738 CREATE_SET_FUNCTION_C1(uChar);
00739 CREATE_SET_FUNCTION_C1(uShort);
00740 CREATE_SET_FUNCTION_C1(sShort);
00741 CREATE_SET_FUNCTION_C1(sInt);
00742 CREATE_SET_FUNCTION_C1(sFloat);
00743 
00744 #define CREATE_SET_FUNCTION_C3(TYPE)                                    \
00745 template <> void QVImage<TYPE,3>::set(TYPE c1, TYPE c2, TYPE c3)        \
00746         {                                                               \
00747         const TYPE values[3] = { c1, c2, c3 };                          \
00748         Set(values, *this);                                             \
00749         }
00750 
00751 CREATE_SET_FUNCTION_C3(uChar);
00752 CREATE_SET_FUNCTION_C3(uShort);
00753 CREATE_SET_FUNCTION_C3(sShort);
00754 CREATE_SET_FUNCTION_C3(sInt);
00755 CREATE_SET_FUNCTION_C3(sFloat);
00756 
00758 // operator =
00759 #define CREATE_CONVERT_OPERATOR(TYPE1, TYPE2, C)                                                \
00760 template <> QVImage<TYPE2, C> & QVImage<TYPE2, C>::operator=(const QVImage<TYPE1, C> &img)      \
00761         {                                                                                       \
00762         imageBuffer = new QVImageBuffer<TYPE2, C>(img.getCols(), img.getRows());                \
00763         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00764         Convert(img, *this);                                                                    \
00765         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00766         return *this;                                                                           \
00767         }
00768 
00769 CREATE_CONVERT_OPERATOR(uChar, uShort, 1);
00770 CREATE_CONVERT_OPERATOR(uChar, sShort, 1);
00771 CREATE_CONVERT_OPERATOR(uChar, sInt, 1);
00772 CREATE_CONVERT_OPERATOR(uChar, sFloat, 1);
00773 CREATE_CONVERT_OPERATOR(uChar, uShort, 3);
00774 CREATE_CONVERT_OPERATOR(uChar, sShort, 3);
00775 CREATE_CONVERT_OPERATOR(uChar, sInt, 3);
00776 CREATE_CONVERT_OPERATOR(uChar, sFloat, 3);
00777 CREATE_CONVERT_OPERATOR(uShort, uChar, 1);
00778 CREATE_CONVERT_OPERATOR(uShort, sInt, 1);
00779 CREATE_CONVERT_OPERATOR(uShort, sFloat, 1);
00780 CREATE_CONVERT_OPERATOR(uShort, uChar, 3);
00781 CREATE_CONVERT_OPERATOR(uShort, sInt, 3);
00782 CREATE_CONVERT_OPERATOR(uShort, sFloat, 3);
00783 CREATE_CONVERT_OPERATOR(sShort, uChar, 1);
00784 CREATE_CONVERT_OPERATOR(sShort, sInt, 1);
00785 CREATE_CONVERT_OPERATOR(sShort, sFloat, 1);
00786 CREATE_CONVERT_OPERATOR(sShort, uChar, 3);
00787 CREATE_CONVERT_OPERATOR(sShort, sInt, 3);
00788 CREATE_CONVERT_OPERATOR(sShort, sFloat, 3);
00789 CREATE_CONVERT_OPERATOR(sInt, uChar, 1);
00790 CREATE_CONVERT_OPERATOR(sInt, uChar, 3);
00791 CREATE_CONVERT_OPERATOR(sFloat, uChar, 1);
00792 CREATE_CONVERT_OPERATOR(sFloat, uShort, 1);
00793 CREATE_CONVERT_OPERATOR(sFloat, sShort, 1);
00794 CREATE_CONVERT_OPERATOR(sFloat, uChar, 3);
00795 CREATE_CONVERT_OPERATOR(sFloat, uShort, 3);
00796 CREATE_CONVERT_OPERATOR(sFloat, sShort, 3);
00797 
00798 // Nota: las siguientes funciones dan error al compilar, ya que no existen versiones de la función wrapper Convert,
00799 // para convertir de una imagen entera, a una imagen de tipo uShort, sShort, o sFloat.
00800 //      CREATE_CONVERT_OPERATOR(uShort, sInt, 1);
00801 //      CREATE_CONVERT_OPERATOR(sShort, sInt, 1);
00802 //      CREATE_CONVERT_OPERATOR(uShort, sInt, 3);
00803 //      CREATE_CONVERT_OPERATOR(sShort, sInt, 3);
00804 //      CREATE_CONVERT_OPERATOR(sFloat, sInt, 3);
00805 //      CREATE_CONVERT_OPERATOR(sFloat, sInt, 3);
00806 //
00807 // Por ello, estas funciones deben ser definidas con funciones de conversión Ad-hoc, así como las funciones de conversión
00808 // de valores uShort a valores sShort, y viceversa, que tampoco están implementadas por las IPP, ni las funciones para convertir
00809 // imagenes de distinto tipo y canal.
00810 //
00811 // Ojo: Para implementar las funciones de conversión entre imagenes de tipo sShort y uShort, hay que tener en cuenta la saturación
00812 // (que hacen las IPP para todas las funciones de conversión que implementa):
00813 // - Si se quiere convertir un valor sShort menor que cero a un valor uShort, se deja como el valor cero (0).
00814 // - Si se quiere convertir un valor uShort mayor que IPP_MAX_16S a sShort, se debe dejar como el valor IPP_MAX_16S.
00815 
00816 
00817 #define CREATE_CONVERT_OPERATOR_NO_IPP_1(TYPE1, TYPE2)                                                  \
00818 template <> QVImage<TYPE2, 1> & QVImage<TYPE2, 1>::operator=(const QVImage<TYPE1, 1> &img)              \
00819         {                                                                                               \
00820         imageBuffer = new QVImageBuffer<TYPE2, 1>(img.getCols(), img.getRows());                        \
00821         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00822         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00823         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00824                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00825                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00826         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00827         return *this;                                                                                   \
00828         }
00829 
00830 CREATE_CONVERT_OPERATOR_NO_IPP_1(uShort, sShort);
00831 CREATE_CONVERT_OPERATOR_NO_IPP_1(sShort, uShort);
00832 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, uShort);
00833 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sShort);
00834 CREATE_CONVERT_OPERATOR_NO_IPP_1(sInt, sFloat);
00835 CREATE_CONVERT_OPERATOR_NO_IPP_1(sFloat, sInt);
00836 
00837 #define CREATE_CONVERT_OPERATOR_NO_IPP_3(TYPE1, TYPE2)                                                  \
00838 template <> QVImage<TYPE2, 3> & QVImage<TYPE2, 3>::operator=(const QVImage<TYPE1, 3> &img)              \
00839         {                                                                                               \
00840         imageBuffer = new QVImageBuffer<TYPE2, 3>(img.getCols(), img.getRows());                        \
00841         QVIMAGE_PTR_INIT_WRITE(TYPE2, this);                                                            \
00842         QVIMAGE_INIT_READ(TYPE1, img);                                                                  \
00843         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00844                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00845                         {                                                                               \
00846                         QVIMAGE_PIXEL(this, col, row, 0) = QVIMAGE_PIXEL(img, col, row, 0);             \
00847                         QVIMAGE_PIXEL(this, col, row, 1) = QVIMAGE_PIXEL(img, col, row, 1);             \
00848                         QVIMAGE_PIXEL(this, col, row, 2) = QVIMAGE_PIXEL(img, col, row, 2);             \
00849                         }                                                                               \
00850         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00851         return *this;                                                                                   \
00852         }
00853 
00854 CREATE_CONVERT_OPERATOR_NO_IPP_3(uShort, sShort);
00855 CREATE_CONVERT_OPERATOR_NO_IPP_3(sShort, uShort);
00856 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, uShort);
00857 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sShort);
00858 CREATE_CONVERT_OPERATOR_NO_IPP_3(sInt, sFloat);
00859 CREATE_CONVERT_OPERATOR_NO_IPP_3(sFloat, sInt);
00860 
00861 #define CREATE_CONVERT_OPERATOR_C3_C1(TYPE)                                                     \
00862 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img)         \
00863         {                                                                                       \
00864         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                 \
00865         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00866         RGBToGray(img, *this);                                                                  \
00867         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00868         return *this;                                                                           \
00869         }
00870 
00871 CREATE_CONVERT_OPERATOR_C3_C1(uChar);
00872 CREATE_CONVERT_OPERATOR_C3_C1(uShort);
00873 CREATE_CONVERT_OPERATOR_C3_C1(sShort);
00874 CREATE_CONVERT_OPERATOR_C3_C1(sFloat);
00875 
00876 #define CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(TYPE)                                                      \
00877 template <> QVImage<TYPE, 1> & QVImage<TYPE, 1>::operator=(const QVImage<TYPE, 3> &img)                 \
00878         {                                                                                               \
00879         imageBuffer = new QVImageBuffer<TYPE, 1>(img.getCols(), img.getRows());                         \
00880         QVIMAGE_PTR_INIT_WRITE(TYPE, this);                                                             \
00881         QVIMAGE_INIT_READ(TYPE, img);                                                                   \
00882         for (int col = img.getROI().left(); col < img.getROI().right(); col++)                          \
00883                 for (int row = img.getROI().top(); row < img.getROI().bottom(); row++)                  \
00884                         {                                                                               \
00885                         QVIMAGE_PIXEL(this, col, row, 0) = 0.299 * QVIMAGE_PIXEL(img, col, row, 0);     \
00886                         QVIMAGE_PIXEL(this, col, row, 0) += 0.587 * QVIMAGE_PIXEL(img, col, row, 1);    \
00887                         QVIMAGE_PIXEL(this, col, row, 0) += 0.114 * QVIMAGE_PIXEL(img, col, row, 2);    \
00888                         }                                                                               \
00889         setROI(img.getROI()); setAnchor(img.getAnchor());                                               \
00890         return *this;                                                                                   \
00891         }
00892 
00893 CREATE_CONVERT_OPERATOR_NO_IPP_C3_C1(sInt);
00894 
00895 #define CREATE_CONVERT_OPERATOR_C1_C3(TYPE)                                                     \
00896 template <> QVImage<TYPE, 3> & QVImage<TYPE, 3>::operator=(const QVImage<TYPE, 1> &img)         \
00897         {                                                                                       \
00898         imageBuffer = new QVImageBuffer<TYPE, 3>(img.getCols(), img.getRows());                 \
00899         setAnchor(img.getROI().x(),img.getROI().y());                                           \
00900         Copy(img, img, img, *this);                                                             \
00901         setROI(img.getROI()); setAnchor(img.getAnchor());                                       \
00902         return *this;                                                                           \
00903         }
00904 
00905 CREATE_CONVERT_OPERATOR_C1_C3(uChar);
00906 CREATE_CONVERT_OPERATOR_C1_C3(uShort);
00907 CREATE_CONVERT_OPERATOR_C1_C3(sShort);
00908 CREATE_CONVERT_OPERATOR_C1_C3(sInt);
00909 CREATE_CONVERT_OPERATOR_C1_C3(sFloat);
00910 
00911 
00912 //Convert constructors with double conversion (after operator= declaration)
00913 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(TYPE1, TYPE2)                                   \
00914 template <> QVImage<TYPE2, 1>::QVImage(QVImage<TYPE1, 3> const &img):QVGenericImage(img)        \
00915         {                                                                                       \
00916         *this = QVImage<TYPE2, 3>(img);                                                         \
00917         }
00918 
00919 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, uShort);
00920 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sShort);
00921 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sInt);
00922 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uChar, sFloat);
00923 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, uChar);
00924 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sShort);
00925 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sInt);
00926 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(uShort, sFloat);
00927 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uChar);
00928 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, uShort);
00929 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sInt);
00930 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sShort, sFloat);
00931 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uChar);
00932 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, uShort);
00933 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sShort);
00934 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sInt, sFloat);
00935 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uChar);
00936 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, uShort);
00937 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sShort);
00938 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C3_C1(sFloat, sInt);
00939 
00940 #define CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(TYPE1, TYPE2)                                   \
00941 template <> QVImage<TYPE2, 3>::QVImage(QVImage<TYPE1, 1> const &img):QVGenericImage(img)        \
00942         {                                                                                       \
00943         *this = QVImage<TYPE2, 1>(img);                                                         \
00944         }
00945 
00946 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, uShort);
00947 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sShort);
00948 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sInt);
00949 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uChar, sFloat);
00950 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, uChar);
00951 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sShort);
00952 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sInt);
00953 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(uShort, sFloat);
00954 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uChar);
00955 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, uShort);
00956 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sInt);
00957 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sShort, sFloat);
00958 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uChar);
00959 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, uShort);
00960 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sShort);
00961 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sInt, sFloat);
00962 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uChar);
00963 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, uShort);
00964 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sShort);
00965 CREATE_CONVERT_CONSTRUCTOR_DOUBLE_C1_C3(sFloat, sInt);
00966 
00967 
00968 #define CREATE_ACCESS_CONSTRUCTOR(OPERATOR, TYPE, C)                                            \
00969 template <> QVImage<TYPE, 1> QVImage<TYPE, C>::OPERATOR(const uInt channel) const               \
00970         {                                                                                       \
00971         QVImage<TYPE, 1> result(getCols(), getRows());                                          \
00972         Copy(*this, channel, result);                                                           \
00973         result.setROI(getROI()); result.setAnchor(getAnchor());                                 \
00974         return result;                                                                          \
00975         }
00976 
00977 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 1);
00978 CREATE_ACCESS_CONSTRUCTOR(operator(), uChar, 3);
00979 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 1);
00980 CREATE_ACCESS_CONSTRUCTOR(operator(), uShort, 3);
00981 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 1);
00982 CREATE_ACCESS_CONSTRUCTOR(operator(), sShort, 3);
00983 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 1);
00984 CREATE_ACCESS_CONSTRUCTOR(operator(), sInt, 3);
00985 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 1);
00986 CREATE_ACCESS_CONSTRUCTOR(operator(), sFloat, 3);
00987 
00988 
00989 
00990