[an error occurred while processing this directive]
Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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

Generated on Mon Sep 20 01:01:27 2010 for Hugintrunk by doxygen 1.3.9.1