ImageTransformsGPU.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00027 #ifndef _VIGRA_EXT_IMAGETRANSFORMSGPU_H
00028 #define _VIGRA_EXT_IMAGETRANSFORMSGPU_H
00029 
00030 #include <fstream>
00031 #include <iostream>
00032 #include <iomanip>
00033 
00034 #include <hugin_shared.h>
00035 #include <vigra/basicimage.hxx>
00036 #include <vigra_ext/ROIImage.h>
00037 #include <vigra_ext/Interpolators.h>
00038 #include <vigra/accessor.hxx>
00039 #include <vigra_ext/FunctorAccessor.h>
00040 
00041 #include <hugin_math/hugin_math.h>
00042 #include <hugin_utils/utils.h>
00043 #include <appbase/ProgressDisplay.h>
00044 
00045 using vigra::NumericTraits;
00046 
00047 namespace vigra_ext
00048 {
00049 
00050 IMPEX void SetGPUDebugMessages(const bool doPrint);
00051 
00052 bool IMPEX transformImageGPUIntern(const std::string& coordXformGLSL,
00053                              const std::string& interpolatorGLSL,
00054                              const int interpolatorSize,
00055                              const std::string& photometricGLSL,
00056                              const std::vector<double>& invLut,
00057                              const std::vector<double>& destLut,
00058                              const vigra::Diff2D srcSize,
00059                              const void* const srcBuffer,
00060                              const int srcGLInternalFormat, const int srcGLTransferFormat, const int srcGLFormat, const int srcGLType,
00061                              const void* const srcAlphaBuffer,
00062                              const int srcAlphaGLType,
00063                              const vigra::Diff2D destUL,
00064                              const vigra::Diff2D destSize,
00065                              void* const destBuffer,
00066                              const int destGLInternalFormat, const int destGLTransferFormat, const int destGLFormat, const int destGLType,
00067                              void* const destAlphaBuffer,
00068                              const int destAlphaGLType,
00069                              const bool warparound);
00070 
00071 // This is to avoid including GL headers in this file.
00072 enum {
00073     // gltypes
00074     XGL_BYTE=0, XGL_UNSIGNED_BYTE, XGL_SHORT, XGL_UNSIGNED_SHORT, XGL_INT, XGL_UNSIGNED_INT, XGL_FLOAT,
00075     // Internalformats
00076     XGL_RGBA8, XGL_RGBA16, XGL_RGBA32F, XGL_LUMINANCE8_ALPHA8, XGL_LUMINANCE16_ALPHA16, XGL_LUMINANCE_ALPHA32F,
00077     XGL_RGB8,  XGL_RGB16,  XGL_RGB32F,  XGL_LUMINANCE8,        XGL_LUMINANCE16,         XGL_LUMINANCE32F,
00078     // formats
00079     XGL_LUMINANCE, XGL_RGB, XGL_LUMINANCE_ALPHA, XGL_RGBA
00080 };
00081 
00082 struct Error_GpuNumericTraits_not_specialized_for_this_case { };
00083 
00084 template <class A>
00085 struct GpuNumericTraits {
00086     typedef Error_GpuNumericTraits_not_specialized_for_this_case ImagePixelComponentType;
00087     enum {NumBands = 0};
00088     enum {ImageGLInternalFormat = 0};
00089     enum {ImageGLTransferFormat = 0};
00090     enum {ImageGLFormat = 0};
00091     enum {ImagePixelComponentGLType = 0};
00092 };
00093 
00094 #define DEFINE_GPUNUMERICTRAITS(IMAGECOMPONENT, GLFORMAT, GLFORMATRGB, GLTRANSFER, GLTRANSFERRGB, GLTYPE) \
00095 template<> \
00096 struct GpuNumericTraits<IMAGECOMPONENT> { \
00097     typedef IMAGECOMPONENT ImagePixelComponentType; \
00098     enum {NumBands = 1}; \
00099     enum {ImageGLInternalFormat = GLFORMAT}; \
00100     enum {ImageGLTransferFormat = GLTRANSFER}; \
00101     enum {ImageGLFormat = XGL_LUMINANCE}; \
00102     enum {ImagePixelComponentGLType = GLTYPE}; \
00103 }; \
00104 template<> \
00105 struct GpuNumericTraits<vigra::RGBValue<IMAGECOMPONENT, 0, 1, 2> > { \
00106     typedef IMAGECOMPONENT ImagePixelComponentType; \
00107     enum {NumBands = 3}; \
00108     enum {ImageGLInternalFormat = GLFORMATRGB}; \
00109     enum {ImageGLTransferFormat = GLTRANSFERRGB}; \
00110     enum {ImageGLFormat = XGL_RGB}; \
00111     enum {ImagePixelComponentGLType = GLTYPE}; \
00112 }; \
00113 template<> \
00114 struct GpuNumericTraits<vigra::TinyVector<IMAGECOMPONENT, 2> > { \
00115     typedef IMAGECOMPONENT ImagePixelComponentType; \
00116     enum {NumBands = 2}; \
00117     enum {ImageGLInternalFormat = GLFORMAT}; \
00118     enum {ImageGLTransferFormat = GLFORMAT}; \
00119     enum {ImageGLFormat = XGL_LUMINANCE_ALPHA}; \
00120     enum {ImagePixelComponentGLType = GLTYPE}; \
00121 }; \
00122 template<> \
00123 struct GpuNumericTraits<vigra::TinyVector<IMAGECOMPONENT, 4> > { \
00124     typedef IMAGECOMPONENT ImagePixelComponentType; \
00125     enum {NumBands = 4}; \
00126     enum {ImageGLInternalFormat = GLFORMATRGB}; \
00127     enum {ImageGLTransferFormat = GLFORMATRGB}; \
00128     enum {ImageGLFormat = XGL_RGBA}; \
00129     enum {ImagePixelComponentGLType = GLTYPE}; \
00130 };
00131 
00132 DEFINE_GPUNUMERICTRAITS(vigra::Int8,   XGL_LUMINANCE8_ALPHA8,   XGL_RGBA8,   XGL_LUMINANCE8,   XGL_RGB8,   XGL_BYTE);
00133 DEFINE_GPUNUMERICTRAITS(vigra::UInt8,  XGL_LUMINANCE8_ALPHA8,   XGL_RGBA8,   XGL_LUMINANCE8,   XGL_RGB8,   XGL_UNSIGNED_BYTE);
00134 DEFINE_GPUNUMERICTRAITS(vigra::Int16,  XGL_LUMINANCE16_ALPHA16, XGL_RGBA16,  XGL_LUMINANCE16,  XGL_RGB16,  XGL_SHORT);
00135 DEFINE_GPUNUMERICTRAITS(vigra::UInt16, XGL_LUMINANCE16_ALPHA16, XGL_RGBA16,  XGL_LUMINANCE16,  XGL_RGB16,  XGL_UNSIGNED_SHORT);
00136 DEFINE_GPUNUMERICTRAITS(vigra::Int32,  XGL_LUMINANCE_ALPHA32F,  XGL_RGBA32F, XGL_LUMINANCE32F, XGL_RGB32F, XGL_INT);
00137 DEFINE_GPUNUMERICTRAITS(vigra::UInt32, XGL_LUMINANCE_ALPHA32F,  XGL_RGBA32F, XGL_LUMINANCE32F, XGL_RGB32F, XGL_UNSIGNED_INT);
00138 DEFINE_GPUNUMERICTRAITS(float,         XGL_LUMINANCE_ALPHA32F,  XGL_RGBA32F, XGL_LUMINANCE32F, XGL_RGB32F, XGL_FLOAT);
00139 
00140 // FIXME ACM this is wrong, there is no GL_DOUBLE for transfering doubles.
00141 DEFINE_GPUNUMERICTRAITS(double,        XGL_LUMINANCE_ALPHA32F,  XGL_RGBA32F, XGL_LUMINANCE32F, XGL_RGB32F, XGL_FLOAT);
00142 
00143 
00170 template <class SrcImageIterator, class SrcAccessor,
00171           class DestImageIterator, class DestAccessor,
00172           class TRANSFORM,
00173           class PixelTransform,
00174           class AlphaImageIterator, class AlphaAccessor,
00175           class Interpolator>
00176 void transformImageGPUIntern(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
00177                              vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
00178                              std::pair<AlphaImageIterator, AlphaAccessor> alpha,
00179                              TRANSFORM & transform,
00180                              PixelTransform & pixelTransform,
00181                              vigra::Diff2D destUL,
00182                              Interpolator interp,
00183                              bool warparound,
00184                              AppBase::ProgressDisplay* progress)
00185 {
00186     typedef typename SrcAccessor::value_type SrcValueType;
00187     typedef typename DestAccessor::value_type DestValueType;
00188     typedef typename AlphaAccessor::value_type AlphaValueType;
00189 
00190     vigra::Diff2D srcSize = src.second - src.first;
00191     vigra::Diff2D destSize = dest.second - dest.first;
00192 
00193     vigra_ext::ImageInterpolator<SrcImageIterator, SrcAccessor, Interpolator>
00194                                  interpol (src, interp, warparound);
00195 
00196     // Emit coordinate transform and interpolator as GLSL shader program.
00197 
00198     std::ostringstream coordXformOss;
00199     coordXformOss << std::setprecision(20) << std::showpoint;
00200     transform.emitGLSL(coordXformOss);
00201 
00202     std::ostringstream interpolatorOss;
00203     interpolatorOss << std::setprecision(20) << std::showpoint;
00204     interpol.emitGLSL(interpolatorOss);
00205 
00206     std::ostringstream photometricOss;
00207     std::vector<double> invLut;
00208     std::vector<double> destLut;
00209     photometricOss << std::setprecision(20) << std::showpoint;
00210     pixelTransform.emitGLSL(photometricOss, invLut, destLut);
00211 
00212     // Do remapping.
00213     // Give the GPU pointers directly to the image data, bypassing the vigra iterators and accessors.
00214     // This is cheating. It will not work if the iterators describe subsets of the images or if
00215     // the accessors perform computation.
00216     transformImageGPUIntern(coordXformOss.str(),
00217                             interpolatorOss.str(),
00218                             interp.size,
00219                             photometricOss.str(),
00220                             invLut,
00221                             destLut,
00222                             srcSize,
00223                             src.first[0],
00224                             GpuNumericTraits<SrcValueType>::ImageGLInternalFormat,
00225                             GpuNumericTraits<SrcValueType>::ImageGLTransferFormat,
00226                             GpuNumericTraits<SrcValueType>::ImageGLFormat,
00227                             GpuNumericTraits<SrcValueType>::ImagePixelComponentGLType,
00228                             NULL, /* no alpha buffer */
00229                             XGL_BYTE,
00230                             destUL,
00231                             destSize,
00232                             dest.first[0],
00233                             GpuNumericTraits<DestValueType>::ImageGLInternalFormat,
00234                             GpuNumericTraits<DestValueType>::ImageGLTransferFormat,
00235                             GpuNumericTraits<DestValueType>::ImageGLFormat,
00236                             GpuNumericTraits<DestValueType>::ImagePixelComponentGLType,
00237                             alpha.first[0],
00238                             GpuNumericTraits<AlphaValueType>::ImagePixelComponentGLType,
00239                             warparound);
00240 
00241 }
00242 
00243 
00245 template <class SrcImageIterator, class SrcAccessor,
00246           class SrcAlphaIterator, class SrcAlphaAccessor,
00247           class DestImageIterator, class DestAccessor,
00248           class TRANSFORM,
00249           class PixelTransform,
00250           class AlphaImageIterator, class AlphaAccessor,
00251           class Interpolator>
00252 void transformImageAlphaGPUIntern(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
00253                                   std::pair<SrcAlphaIterator, SrcAlphaAccessor> srcAlpha,
00254                                   vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
00255                                   std::pair<AlphaImageIterator, AlphaAccessor> alpha,
00256                                   TRANSFORM & transform,
00257                                   PixelTransform & pixelTransform,
00258                                   vigra::Diff2D destUL,
00259                                   Interpolator interp,
00260                                   bool warparound,
00261                                   AppBase::ProgressDisplay* progress)
00262 {
00263     typedef typename SrcAccessor::value_type SrcValueType;
00264     typedef typename SrcAlphaAccessor::value_type SrcAlphaType;
00265     typedef typename DestAccessor::value_type DestValueType;
00266     typedef typename AlphaAccessor::value_type DestAlphaType;
00267 
00268     vigra::Diff2D srcSize = src.second - src.first;
00269     vigra::Diff2D destSize = dest.second - dest.first;
00270 
00271     // Note that GPU interpolators are the same for source images with and without alpha channels.
00272     vigra_ext::ImageInterpolator<SrcImageIterator, SrcAccessor, Interpolator>
00273                                  interpol (src, interp, warparound);
00274 
00275     // Emit coordinate transform and interpolator as GLSL shader program.
00276 
00277     std::ostringstream coordXformOss;
00278     coordXformOss << std::setprecision(20) << std::showpoint;
00279     if(!transform.emitGLSL(coordXformOss))
00280     {
00281         std::cerr << "nona: Found unsupported transformation in stack." << std::endl
00282              << "      This geometric transformation is not supported by GPU." << std::endl
00283              << "      Remove -g switch and try with CPU transformation." << std::endl;
00284         exit(1);
00285     };
00286 
00287     std::ostringstream interpolatorOss;
00288     interpolatorOss << std::setprecision(20) << std::showpoint;
00289     interpol.emitGLSL(interpolatorOss);
00290 
00291     std::ostringstream photometricOss;
00292     std::vector<double> invLut;
00293     std::vector<double> destLut;
00294     photometricOss << std::setprecision(20) << std::showpoint;
00295     pixelTransform.emitGLSL(photometricOss, invLut, destLut);
00296 
00297 /*
00298     // Experiment: measure speedup with TinyVector4 source images.
00299     typedef typename GpuNumericTraits<SrcValueType>::ImagePixelComponentType SrcImagePixelComponentType;
00300     typedef vigra::TinyVector<SrcImagePixelComponentType, 4> SrcVectorValueType;
00301     //class SrcVectorPixelType : public SrcVectorValueType {
00302     //public:
00303     //    SrcVectorPixelType() : SrcVectorValueType() { }
00304     //    SrcVectorPixelType(const SrcImagePixelComponentType & s) : SrcVectorValueType(s) { }
00305     //    SrcVectorPixelType(const vigra::RGBValue<SrcImagePixelComponentType> & s) : SrcVectorValueType(s.red(), s.green(), s.blue(), 0) { }
00306     //};
00307     //std::allocator<SrcVectorPixelType> al;
00308     //vigra::BasicImage<SrcVectorPixelType, std::allocator<SrcVectorPixelType> > srcVectorImage(srcSize, al);
00309     vigra::BasicImage<SrcVectorValueType> srcVectorImage(srcSize);
00310     //vigra::copyImage(src, destImage(srcVectorImage));
00311     vigra::copyImage(srcAlpha.first, srcAlpha.first + (src.second - src.first), srcAlpha.second, srcVectorImage.upperLeft(), vigra::VectorComponentAccessor<SrcVectorValueType>(3));
00312 
00313     transformImageGPUIntern(coordXformOss.str(),
00314                             interpolatorOss.str(),
00315                             interp.size,
00316                             srcSize,
00317                             srcVectorImage[0],
00318                             GpuNumericTraits<SrcVectorValueType>::ImageGLInternalFormat,
00319                             GpuNumericTraits<SrcVectorValueType>::ImageGLTransferFormat,
00320                             GpuNumericTraits<SrcVectorValueType>::ImageGLFormat,
00321                             GpuNumericTraits<SrcVectorValueType>::ImagePixelComponentGLType,
00322                             NULL,
00323                             XGL_BYTE,
00324                             destUL,
00325                             destSize,
00326                             dest.first[0],
00327                             GpuNumericTraits<DestValueType>::ImageGLInternalFormat,
00328                             GpuNumericTraits<DestValueType>::ImageGLTransferFormat,
00329                             GpuNumericTraits<DestValueType>::ImageGLFormat,
00330                             GpuNumericTraits<DestValueType>::ImagePixelComponentGLType,
00331                             alpha.first[0],
00332                             GpuNumericTraits<DestAlphaType>::ImagePixelComponentGLType,
00333                             warparound);
00334 */
00335     // Do remapping.
00336     // Give the GPU pointers directly to the image data, bypassing the vigra iterators and accessors.
00337     // This is cheating. It will not work if the iterators describe subsets of the images or if
00338     // the accessors perform computation.
00339 #if 1
00340     transformImageGPUIntern(coordXformOss.str(),
00341                             interpolatorOss.str(),
00342                             interp.size,
00343                             photometricOss.str(),
00344                             invLut,
00345                             destLut,
00346                             srcSize,
00347                             src.first[0],
00348                             GpuNumericTraits<SrcValueType>::ImageGLInternalFormat,
00349                             GpuNumericTraits<SrcValueType>::ImageGLTransferFormat,
00350                             GpuNumericTraits<SrcValueType>::ImageGLFormat,
00351                             GpuNumericTraits<SrcValueType>::ImagePixelComponentGLType,
00352                             srcAlpha.first[0],
00353                             GpuNumericTraits<SrcAlphaType>::ImagePixelComponentGLType,
00354                             destUL,
00355                             destSize,
00356                             dest.first[0],
00357                             GpuNumericTraits<DestValueType>::ImageGLInternalFormat,
00358                             GpuNumericTraits<DestValueType>::ImageGLTransferFormat,
00359                             GpuNumericTraits<DestValueType>::ImageGLFormat,
00360                             GpuNumericTraits<DestValueType>::ImagePixelComponentGLType,
00361                             alpha.first[0],
00362                             GpuNumericTraits<DestAlphaType>::ImagePixelComponentGLType,
00363                             warparound);
00364 #endif
00365 
00366 #if 0
00367     //vigra::FRGBImage phonyDest(destSize);
00368     vigra::FVector4Image phonyDest(destSize);
00369     vigra::FImage phonyDestAlpha(destSize);
00370     vigra::FRGBImage phonySrc(srcSize);
00371     vigra::FImage phonySrcAlpha(srcSize);
00372 
00373     transformImageGPUIntern(oss.str(), srcSize, phonySrc[0], XGL_FLOAT, XGL_RGB,
00374                             phonySrcAlpha[0], XGL_FLOAT, XGL_RED,
00375                             destUL, destSize, phonyDest[0], XGL_FLOAT, XGL_RGBA,
00376                             phonyDestAlpha[0], XGL_FLOAT, XGL_RED,
00377                             warparound);
00378 
00379     // Test accuracy
00380     int xstart = destUL.x;
00381     int xend   = destUL.x + destSize.x;
00382     int ystart = destUL.y;
00383     int yend   = destUL.y + destSize.y;
00384 
00385     double samples = 0.0;
00386     double sumError = 0.0;
00387     double sumErrorSq = 0.0;
00388 
00389     // create dest y iterator
00390     //vigra::FRGBImage::traverser yd = phonyDest.upperLeft();
00391     vigra::FVector4Image::traverser yd = phonyDest.upperLeft();
00392     vigra::FImage::traverser ydm = phonyDestAlpha.upperLeft();
00393     DestImageIterator ydest(dest.first);
00394     AlphaImageIterator ydesta(alpha.first);
00395 
00396     int numMessages = 0;
00397 
00398     for(int y=ystart; y < yend; ++y, ++yd.y, ++ydm.y, ++ydest.y, ++ydesta.y)
00399     {
00400         // create x iterators
00401         //vigra::FRGBImage::traverser xd(yd);
00402         vigra::FVector4Image::traverser xd(yd);
00403         vigra::FImage::traverser xdm(ydm);
00404         DestImageIterator xdest(ydest);
00405         AlphaImageIterator xdesta(ydesta);
00406 
00407         for(int x=xstart; x < xend; ++x, ++xd.x, ++xdm.x, ++xdest.x, ++xdesta.x)
00408         {
00409             double sx,sy;
00410             bool result = transform.transformImgCoordPartial(sx,sy,x,y);
00411             float errorX = (*xd)[2] - static_cast<float>(sx);
00412             float errorY = (*xd)[1] - static_cast<float>(sy);
00413             double error = sqrt(errorX * errorX + errorY * errorY);
00414 
00415             if (error != 0.0 && numMessages < 150) {
00416                 std::cout << std::setprecision(20) << "pos=[" << x << ", " << y << "] shouldBe=[" << sx << ", " << sy << " is=[" << (*xd)[2] << ", " << (*xd)[1] << "] error=" << error << std::endl;
00417                 ++numMessages;
00418             }
00419 
00420             sumError += error;
00421             sumErrorSq += (error * error);
00422 
00423             samples += 1.0;
00424 
00425             dest.third.set(NumericTraits<DestValueType>::fromRealPromote(std::min(255.0, std::max(0.0, 255.0 * 10.0 * error))), xdest);
00426             alpha.second.set(255, xdesta);
00427         }
00428     }
00429 
00430     double avgError = sumError/samples;
00431 
00432     std::cout << "numSamples=" << samples << std::endl
00433               << "average error=" << avgError << std::endl
00434               << "stddev=" << (sumErrorSq/samples - avgError*avgError) << std::endl;
00435 #endif
00436 
00437 };
00438 
00439 
00466 template <class SrcImageIterator, class SrcAccessor,
00467           class DestImageIterator, class DestAccessor,
00468           class AlphaImageIterator, class AlphaAccessor,
00469           class TRANSFORM,
00470           class PixelTransform>
00471 void transformImageGPU(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
00472                        vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
00473                        std::pair<AlphaImageIterator, AlphaAccessor> alpha,
00474                        vigra::Diff2D destUL,
00475                        TRANSFORM & transform,
00476                        PixelTransform & pixelTransform,
00477                        bool warparound,
00478                        Interpolator interpol,
00479                        AppBase::ProgressDisplay* progress)
00480 {
00481     switch (interpol) {
00482     case INTERP_CUBIC:
00483         DEBUG_DEBUG("using cubic interpolator");
00484     transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00485                                  vigra_ext::interp_cubic(), warparound,
00486                                  progress);
00487         break;
00488     case INTERP_SPLINE_16:
00489         DEBUG_DEBUG("interpolator: spline16");
00490     transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00491                                  vigra_ext::interp_spline16(), warparound,
00492                                  progress);
00493         break;
00494     case INTERP_SPLINE_36:
00495         DEBUG_DEBUG("interpolator: spline36");
00496     transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00497                                  vigra_ext::interp_spline36(), warparound,
00498                                  progress);
00499         break;
00500     case INTERP_SPLINE_64:
00501         DEBUG_DEBUG("interpolator: spline64");
00502     transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00503                                  vigra_ext::interp_spline64(), warparound,
00504                                  progress);
00505         break;
00506     case INTERP_SINC_256:
00507         DEBUG_DEBUG("interpolator: sinc 256");
00508     transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00509                                  vigra_ext::interp_sinc<8>(), warparound,
00510                                  progress);
00511         break;
00512     case INTERP_BILINEAR:
00513         transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00514                                  vigra_ext::interp_bilin(), warparound,
00515                                  progress);
00516         break;
00517     case INTERP_NEAREST_NEIGHBOUR:
00518         transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00519                                  vigra_ext::interp_nearest(), warparound,
00520                                  progress);
00521         break;
00522     case INTERP_SINC_1024:
00523         transformImageGPUIntern(src, dest, alpha, transform, pixelTransform, destUL,
00524                                  vigra_ext::interp_sinc<32>(), warparound,
00525                                  progress);
00526         break;
00527     }
00528 }
00529 
00531 template <class SrcImageIterator, class SrcAccessor,
00532           class SrcAlphaIterator, class SrcAlphaAccessor,
00533           class DestImageIterator, class DestAccessor,
00534           class AlphaImageIterator, class AlphaAccessor,
00535           class TRANSFORM, class PixelTransform>
00536 void transformImageAlphaGPU(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
00537                             std::pair<SrcAlphaIterator, SrcAlphaAccessor> srcAlpha,
00538                             vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
00539                             std::pair<AlphaImageIterator, AlphaAccessor> alpha,
00540                             vigra::Diff2D destUL,
00541                             TRANSFORM & transform,
00542                             PixelTransform & pixelTransform,
00543                             bool warparound,
00544                             Interpolator interpol,
00545                             AppBase::ProgressDisplay* progress)
00546 {
00547     switch (interpol) {
00548     case INTERP_CUBIC:
00549         DEBUG_DEBUG("using cubic interpolator");
00550         transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00551                                               vigra_ext::interp_cubic(), warparound,
00552                               progress);
00553         break;
00554     case INTERP_SPLINE_16:
00555         DEBUG_DEBUG("interpolator: spline16");
00556     transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00557                               vigra_ext::interp_spline16(), warparound,
00558                                       progress);
00559         break;
00560     case INTERP_SPLINE_36:
00561         DEBUG_DEBUG("interpolator: spline36");
00562     transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00563                               vigra_ext::interp_spline36(),  warparound,
00564                                       progress);
00565         break;
00566     case INTERP_SPLINE_64:
00567         DEBUG_DEBUG("interpolator: spline64");
00568     transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00569                               vigra_ext::interp_spline64(),  warparound,
00570                                       progress);
00571         break;
00572     case INTERP_SINC_256:
00573         DEBUG_DEBUG("interpolator: sinc 256");
00574     transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00575                               vigra_ext::interp_sinc<8>(), warparound,
00576                                       progress);
00577         break;
00578     case INTERP_BILINEAR:
00579         transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00580                               vigra_ext::interp_bilin(), warparound,
00581                                       progress);
00582         break;
00583     case INTERP_NEAREST_NEIGHBOUR:
00584         transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00585                               vigra_ext::interp_nearest(), warparound,
00586                                       progress);
00587         break;
00588     case INTERP_SINC_1024:
00589         transformImageAlphaGPUIntern(src,srcAlpha, dest, alpha, transform, pixelTransform, destUL,
00590                               vigra_ext::interp_sinc<32>(), warparound,
00591                                       progress);
00592         break;
00593     }
00594 }
00595 
00596 }; // namespace
00597 
00598 #endif // _VIGRA_EXT_IMAGETRANSFORMSGPU_H

Generated on 1 Aug 2015 for Hugintrunk by  doxygen 1.4.7