27 #ifndef _VIGRA_EXT_IMAGETRANSFORMS_H
28 #define _VIGRA_EXT_IMAGETRANSFORMS_H
32 #include <vigra/basicimage.hxx>
48 return vigra::NumericTraits<T>::zero();
58 if (p.red() < 0) p.setRed(vigra::NumericTraits<T>::zero());
59 if (p.green() < 0) p.setGreen(vigra::NumericTraits<T>::zero());
60 if (p.blue() < 0) p.setBlue(vigra::NumericTraits<T>::zero());
90 template <
class SrcImageIterator,
class SrcAccessor,
91 class DestImageIterator,
class DestAccessor,
94 class AlphaImageIterator,
class AlphaAccessor,
97 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
98 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
99 TRANSFORM & transform,
100 PixelTransform & pixelTransform,
101 vigra::Diff2D destUL,
107 const vigra::Diff2D destSize = dest.second - dest.first;
109 const int xstart = destUL.x;
110 const int xend = destUL.x + destSize.x;
111 const int ystart = destUL.y;
112 const int yend = destUL.y + destSize.y;
115 interpol(src, interp, warparound);
118 #pragma omp parallel for if(!singleThreaded) schedule(dynamic)
119 for (
int y = ystart; y < yend; ++y)
122 DestImageIterator xd(dest.first);
124 AlphaImageIterator xdm(alpha.first);
126 typename SrcAccessor::value_type tempval;
127 for (
int x = xstart; x < xend; ++x, ++xd.x, ++xdm.x)
130 if (transform.transformImgCoord(sx, sy, x, y)) {
131 if (interpol.operator()(sx, sy, tempval)){
134 alpha.second.set(pixelTransform.hdrWeight(tempval, vigra::UInt8(255)), xdm);
137 alpha.second.set(0, xdm);
141 alpha.second.set(0, xdm);
148 template <
class SrcImageIterator,
class SrcAccessor,
149 class SrcAlphaIterator,
class SrcAlphaAccessor,
150 class DestImageIterator,
class DestAccessor,
152 class PixelTransform,
153 class AlphaImageIterator,
class AlphaAccessor,
156 std::pair<SrcAlphaIterator, SrcAlphaAccessor> srcAlpha,
157 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
158 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
159 TRANSFORM & transform,
160 PixelTransform & pixelTransform,
161 vigra::Diff2D destUL,
167 const vigra::Diff2D destSize = dest.second - dest.first;
169 const int xstart = destUL.x;
170 const int xend = destUL.x + destSize.x;
171 const int ystart = destUL.y;
172 const int yend = destUL.y + destSize.y;
176 interpol (src, srcAlpha, interp, warparound);
179 #pragma omp parallel for if(!singleThreaded) schedule(dynamic)
180 for(
int y=ystart; y < yend; ++y)
183 DestImageIterator xd(dest.first);
185 AlphaImageIterator xdist(alpha.first);
186 xdist.y += y - ystart;
187 typename SrcAccessor::value_type tempval;
188 typename SrcAlphaAccessor::value_type alphaval;
189 for (
int x = xstart; x < xend; ++x, ++xd.x, ++xdist.x)
192 if (transform.transformImgCoord(sx,sy,x,y)) {
194 if (interpol(sx, sy, tempval, alphaval)) {
196 alpha.second.set(pixelTransform.hdrWeight(tempval, alphaval), xdist);
199 alpha.second.set(0, xdist);
202 alpha.second.set(0, xdist);
232 template <
class SrcImageIterator,
class SrcAccessor,
233 class DestImageIterator,
class DestAccessor,
234 class AlphaImageIterator,
class AlphaAccessor,
236 class PixelTransform>
237 void transformImage(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
238 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
239 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
240 vigra::Diff2D destUL,
241 TRANSFORM & transform,
242 PixelTransform & pixelTransform,
252 progress, singleThreaded);
258 progress, singleThreaded);
264 progress, singleThreaded);
270 progress, singleThreaded);
276 progress, singleThreaded);
281 progress, singleThreaded);
286 progress, singleThreaded);
291 progress, singleThreaded);
297 template <
class SrcImageIterator,
class SrcAccessor,
298 class SrcAlphaIterator,
class SrcAlphaAccessor,
299 class DestImageIterator,
class DestAccessor,
300 class AlphaImageIterator,
class AlphaAccessor,
301 class TRANSFORM,
class PixelTransform>
303 std::pair<SrcAlphaIterator, SrcAlphaAccessor> srcAlpha,
304 vigra::triple<DestImageIterator, DestImageIterator, DestAccessor> dest,
305 std::pair<AlphaImageIterator, AlphaAccessor> alpha,
306 vigra::Diff2D destUL,
307 TRANSFORM & transform,
308 PixelTransform & pixelTransform,
318 progress, singleThreaded);
324 progress, singleThreaded);
330 progress, singleThreaded);
336 progress, singleThreaded);
342 progress, singleThreaded);
347 progress, singleThreaded);
352 progress, singleThreaded);
357 progress, singleThreaded);
364 #endif // _VIGRA_EXT_IMAGETRANSFORMS_H
void transformImage(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, bool singleThreaded=false)
Transform an image into the panorama.
simple bilinear interpolation
misc math function & classes used by other parts of the program
"wrapper" for efficient interpolation access to an image
void transformImageAlphaIntern(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, bool singleThreaded)
transform input images with alpha channel
sinc interpolation, with variable width
void transformImageIntern(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, 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, bool singleThreaded)
Transform an image into the panorama.
several classes to calculate interpolator weights,
The pano tools interpolators ported to vigra.
void transformImageAlpha(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, bool singleThreaded=false)
Transform image, and respect a possible alpha channel.
"wrapper" for efficient interpolation access to an image
Interpolator
enum with all interpolation methods
T zeroNegative(T p)
Set negative elements of a pixel to zero.