27#ifndef _VIGRA_EXT_IMAGETRANSFORMSGPU_H
28#define _VIGRA_EXT_IMAGETRANSFORMSGPU_H
36#include <vigra/basicimage.hxx>
39#include <vigra/accessor.hxx>
46using vigra::NumericTraits;
57 const std::vector<double>&
invLut,
58 const std::vector<double>&
destLut,
64 const vigra::Diff2D
destUL,
95#define DEFINE_GPUNUMERICTRAITS(IMAGECOMPONENT, GLFORMAT, GLFORMATRGB, GLTRANSFER, GLTRANSFERRGB, GLTYPE) \
97struct GpuNumericTraits<IMAGECOMPONENT> { \
98 typedef IMAGECOMPONENT ImagePixelComponentType; \
99 enum {NumBands = 1}; \
100 enum {ImageGLInternalFormat = GLFORMAT}; \
101 enum {ImageGLTransferFormat = GLTRANSFER}; \
102 enum {ImageGLFormat = XGL_LUMINANCE}; \
103 enum {ImagePixelComponentGLType = GLTYPE}; \
106struct GpuNumericTraits<vigra::RGBValue<IMAGECOMPONENT, 0, 1, 2> > { \
107 typedef IMAGECOMPONENT ImagePixelComponentType; \
108 enum {NumBands = 3}; \
109 enum {ImageGLInternalFormat = GLFORMATRGB}; \
110 enum {ImageGLTransferFormat = GLTRANSFERRGB}; \
111 enum {ImageGLFormat = XGL_RGB}; \
112 enum {ImagePixelComponentGLType = GLTYPE}; \
115struct GpuNumericTraits<vigra::TinyVector<IMAGECOMPONENT, 2> > { \
116 typedef IMAGECOMPONENT ImagePixelComponentType; \
117 enum {NumBands = 2}; \
118 enum {ImageGLInternalFormat = GLFORMAT}; \
119 enum {ImageGLTransferFormat = GLFORMAT}; \
120 enum {ImageGLFormat = XGL_LUMINANCE_ALPHA}; \
121 enum {ImagePixelComponentGLType = GLTYPE}; \
124struct GpuNumericTraits<vigra::TinyVector<IMAGECOMPONENT, 4> > { \
125 typedef IMAGECOMPONENT ImagePixelComponentType; \
126 enum {NumBands = 4}; \
127 enum {ImageGLInternalFormat = GLFORMATRGB}; \
128 enum {ImageGLTransferFormat = GLFORMATRGB}; \
129 enum {ImageGLFormat = XGL_RGBA}; \
130 enum {ImagePixelComponentGLType = GLTYPE}; \
178 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor>
dest,
179 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
208 std::vector<double>
invLut;
254 std::pair<SrcAlphaIterator, SrcAlphaAccessor>
srcAlpha,
255 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor>
dest,
256 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
265 typedef typename SrcAlphaAccessor::value_type
SrcAlphaType;
282 std::cerr <<
"nona: Found unsupported transformation in stack." << std::endl
283 <<
" This geometric transformation is not supported by GPU." << std::endl
284 <<
" Remove -g switch and try with CPU transformation." << std::endl;
293 std::vector<double>
invLut;
392 vigra::FVector4Image::traverser
yd =
phonyDest.upperLeft();
403 vigra::FVector4Image::traverser
xd(
yd);
404 vigra::FImage::traverser
xdm(
ydm);
411 bool result = transform.transformImgCoordPartial(
sx,
sy,x,y);
412 float errorX = (*xd)[2] -
static_cast<float>(
sx);
413 float errorY = (*xd)[1] -
static_cast<float>(
sy);
417 std::cout << std::setprecision(20) <<
"pos=[" << x <<
", " << y <<
"] shouldBe=[" <<
sx <<
", " <<
sy <<
" is=[" << (*xd)[2] <<
", " << (*xd)[1] <<
"] error=" << error << std::endl;
426 dest.third.set(NumericTraits<DestValueType>::fromRealPromote(std::min(255.0, std::max(0.0, 255.0 * 10.0 * error))),
xdest);
427 alpha.second.set(255,
xdesta);
433 std::cout <<
"numSamples=" <<
samples << std::endl
434 <<
"average error=" <<
avgError << std::endl
473 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor>
dest,
474 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
532 throw std::logic_error(
"Anti-aliased interpolation not supported on GPU");
543 std::pair<SrcAlphaIterator, SrcAlphaAccessor>
srcAlpha,
544 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor>
dest,
545 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
603 throw std::logic_error(
"Anti-aliased interpolation not supported on GPU");
The pano tools interpolators ported to vigra.
"wrapper" for efficient interpolation access to an image
misc math function & classes used by other parts of the program
void transformImageAlphaGPUIntern(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, std::pair< SrcAlphaIterator, SrcAlphaAccessor > srcAlpha, vigra::triple< DestImageIterator, DestImageIterator, DestAccessor > dest, std::pair< AlphaImageIterator, AlphaAccessor > alpha, TRANSFORM &transform, PixelTransform &pixelTransform, vigra::Diff2D destUL, Interpolator interp, bool warparound, AppBase::ProgressDisplay *progress)
transform input images with alpha channel
bool transformImageGPUIntern(const std::string &coordXformGLSL, const std::string &interpolatorGLSL, const int interpolatorSize, const std::string &photometricGLSL, const vector< double > &invLut, const vector< double > &destLut, const vigra::Diff2D srcSize, const void *const srcBuffer, const int srcGLInternalFormat, const int srcGLTransferFormat, const int srcGLFormat, const int srcGLType, const void *const srcAlphaBuffer, const int srcAlphaGLType, const vigra::Diff2D destUL, const vigra::Diff2D destSize, void *const destBuffer, const int destGLInternalFormat, const int destGLTransferFormat, const int destGLFormat, const int destGLType, void *const destAlphaBuffer, const int destAlphaGLType, const bool warparound)
void SetGPUDebugMessages(const bool doPrint)
@ XGL_LUMINANCE16_ALPHA16
Interpolator
enum with all interpolation methods
@ INTERP_NEAREST_NEIGHBOUR
void transformImageAlphaGPU(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, std::pair< SrcAlphaIterator, SrcAlphaAccessor > srcAlpha, vigra::triple< DestImageIterator, DestImageIterator, DestAccessor > dest, std::pair< AlphaImageIterator, AlphaAccessor > alpha, vigra::Diff2D destUL, TRANSFORM &transform, PixelTransform &pixelTransform, bool warparound, Interpolator interpol, AppBase::ProgressDisplay *progress)
Transform image, and respect a possible alpha channel.
void transformImageGPU(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, vigra::triple< DestImageIterator, DestImageIterator, DestAccessor > dest, std::pair< AlphaImageIterator, AlphaAccessor > alpha, vigra::Diff2D destUL, TRANSFORM &transform, PixelTransform &pixelTransform, bool warparound, Interpolator interpol, AppBase::ProgressDisplay *progress)
Transform an image into the panorama.
Error_GpuNumericTraits_not_specialized_for_this_case ImagePixelComponentType
@ ImagePixelComponentGLType
simple bilinear interpolation
several classes to calculate interpolator weights,
sinc interpolation, with variable width
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.