Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
26 #ifndef VIGRA_EXT_UTILS_H
27 #define VIGRA_EXT_UTILS_H
28 
29 #include <hugin_math/hugin_math.h>
30 #include <vigra/rgbvalue.hxx>
31 #include <vigra/transformimage.hxx>
32 #include <vigra/codec.hxx>
33 #include <cmath>
34 
35 namespace vigra {
36 
37 template <class T1, unsigned int R, unsigned int G, unsigned int B, class T2>
38 struct PromoteTraits<RGBValue<T1, R, G, B>, T2 >
39 {
40  typedef RGBValue<typename PromoteTraits<T1, T2>::Promote> Promote;
41 };
42 
43 }
44 
45 namespace vigra_ext {
46 
49 #define LUT_TRAITS(T1, Smin, Smax) \
50 template<> \
51 struct LUTTraits<T1> \
52 { \
53  static T1 max() \
54 { \
55  return Smax; \
56 } \
57  static T1 min() \
58 { \
59  return Smin; \
60 } \
61 }; \
62 template<> \
63 struct LUTTraits<vigra::RGBValue<T1> > \
64 { \
65  static T1 max() \
66 { \
67  return Smax; \
68 } \
69  static T1 min() \
70 { \
71  return Smin; \
72 } \
73 };
74 
75  template <class T1>
76  struct LUTTraits;
77 
78  LUT_TRAITS(unsigned char, 0, UCHAR_MAX);
79  LUT_TRAITS(signed char, SCHAR_MIN, SCHAR_MAX);
80  LUT_TRAITS(unsigned short, 0, USHRT_MAX);
81  LUT_TRAITS(signed short, SHRT_MIN, SHRT_MAX);
82  LUT_TRAITS(unsigned int, 0, UINT_MAX);
83  LUT_TRAITS(signed int, INT_MIN, INT_MAX);
84  LUT_TRAITS(float, 0.0f, 1.0f);
85  LUT_TRAITS(double, 0.0, 1.0);
86 
87 #undef LUT_TRAITS
88 
89 inline double getMaxValForPixelType(const std::string & v)
90 {
91  if (v == "UINT8") {
92  return 255;
93  } else if (v == "INT8") {
94  return 127;
95  } else if (v == "UINT16") {
96  return 65535;
97  } else if (v == "INT16") {
98  return 32767;
99  } else if (v == "UINT32") {
100  return 4294967295u;
101  } else if (v == "INT32") {
102  return 2147483647;
103  }
104  return 1.0;
105 }
106 
107 template <class VALUE>
109 {
111  {
112  }
113 
114  PointPairT(short img1, VALUE val1, const hugin_utils::FDiff2D & p1, float r1,
115  short img2, VALUE val2, const hugin_utils::FDiff2D & p2, float r2)
116  : imgNr1(img1), i1(val1), p1(p1), r1(r1), imgNr2(img2), i2(val2), p2(p2), r2(r2)
117  {
118  }
119 
120  short imgNr1;
121  VALUE i1;
123  float r1;
124  short imgNr2;
125  VALUE i2;
127  float r2;
128 };
129 
132 
133 
134 
135 // get the value_type of vector pixels and also single channel pixels.
136 #define VT_TRAITS_VEC(T1) \
137 template<> \
138 struct ValueTypeTraits<vigra::RGBValue<T1, 0u, 1u, 2u> > \
139 { \
140  typedef vigra::RGBValue<T1, 0u, 1u, 2u>::value_type value_type; \
141 };
142 
143 #define VT_TRAITS(T1) \
144 template<> \
145 struct ValueTypeTraits<T1> \
146 { \
147  typedef T1 value_type; \
148 };
149 
150 template <class T1>
152 {
153  typedef typename T1::value_type value_type;
154 };
155 
156 #if 0
157 VT_TRAITS_VEC(vigra::UInt8);
158 VT_TRAITS_VEC(vigra::Int16);
159 VT_TRAITS_VEC(vigra::UInt16);
160 VT_TRAITS_VEC(vigra::Int32);
161 VT_TRAITS_VEC(vigra::UInt32);
162 VT_TRAITS_VEC(float);
163 VT_TRAITS_VEC(double);
164 #endif
165 
166 VT_TRAITS(vigra::UInt8);
167 VT_TRAITS(vigra::Int16);
168 VT_TRAITS(vigra::UInt16);
169 VT_TRAITS(vigra::Int32);
170 VT_TRAITS(vigra::UInt32);
171 VT_TRAITS(float);
172 VT_TRAITS(double);
173 
174 #undef VT_TRAITS
175 #undef VT_TRAITS_VEC
176 
177 
178 using VIGRA_CSTD::pow;
179 using VIGRA_CSTD::log;
180 
181 inline float pow(float a, double b)
182 {
183  return std::pow(a,(float) b);
184 }
185 
187 template <class T, unsigned int R, unsigned int G, unsigned int B>
188 inline
189 vigra::RGBValue<T, R, G, B> pow(vigra::RGBValue<T, R, G, B> const & v, double e) {
190  return vigra::RGBValue<T, R, G, B>(pow(v.red(),e), pow(v.green(),e), pow(v.blue(),e));
191 }
192 
194 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
195 inline
196 vigra::RGBValue<V1, R, G, B> &
197 operator+=(vigra::RGBValue<V1, R, G, B> & l, V2 const & r)
198 {
199  l.red() += r;
200  l.green() += r;
201  l.blue() += r;
202  return l;
203 }
204 
206 template <class T, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
207 inline
208 vigra::RGBValue<T, RIDX, GIDX, BIDX>
209 log(vigra::RGBValue<T, RIDX, GIDX, BIDX> const & v)
210 {
211  return vigra::RGBValue<T, RIDX, GIDX, BIDX>(std::log(v.red()), std::log(v.green()), std::log(v.blue()));
212 }
213 
215 template <class T, unsigned int RIDX, unsigned int GIDX, unsigned int BIDX>
216 inline
217 vigra::RGBValue<T, RIDX, GIDX, BIDX>
218 log10(vigra::RGBValue<T, RIDX, GIDX, BIDX> const & v)
219 {
220  return vigra::RGBValue<T, RIDX, GIDX, BIDX>(std::log10(v.red()), std::log10(v.green()), std::log10(v.blue()));
221 }
222 
224 template <class V1, unsigned int R, unsigned int G, unsigned int B, class V2>
225 inline
226 // WARNING: This is a hack..
227 //vigra::RGBValue<V1>
228 typename vigra::PromoteTraits<vigra::RGBValue<V1, R, G, B>, V2 >::Promote
229 operator+(vigra::RGBValue<V1, R, G, B> const & r1, V2 const & r2)
230 {
231  typename vigra::PromoteTraits<vigra::RGBValue<V1, R, G, B>, V2 >::Promote res(r1);
232 
233  res += r2;
234 
235  return res;
236 }
237 
240 template <class V, int SIZE, class D1, class D2>
241 inline
242 vigra::TinyVector<V, SIZE>
243 pow(vigra::TinyVector<V, SIZE> const & v, double e)
244 {
245  vigra::TinyVector<V, SIZE> res;
246  for (int i=0; i<SIZE; i++)
247  res[i] = std::pow(v[i], e);
248  return res;
249 }
250 
253 template <class V, int SIZE, class D1, class D2>
254 inline
255 vigra::TinyVector<V, SIZE>
256 log(vigra::TinyVector<V, SIZE> const & v, double e)
257 {
258  vigra::TinyVector<V, SIZE> res;
259  for (int i=0; i<SIZE; i++)
260  res[i] = std::log(v[i], e);
261  return res;
262 }
263 
265 template <class V>
266 inline
267 V
268 getMaxComponent(vigra::RGBValue<V> const & v)
269 {
270  return std::max(std::max(v.red(), v.green()), v.blue());
271 }
272 
274 template <class V>
275 inline
276 V
278 {
279  return v;
280 }
281 
283 template <class V>
284 inline
285 V
286 getMinComponent(vigra::RGBValue<V> const & v)
287 {
288  return std::min(std::min(v.red(), v.green()), v.blue());
289 }
290 
292 template <class V>
293 inline
294 V
296 {
297  return v;
298 }
299 
300 template <class VALUETYPE>
302 {
303 public:
305  typedef VALUETYPE argument_type;
307  typedef VALUETYPE result_type;
309  typedef VALUETYPE value_type;
310 
312  FindComponentsMinMax() : min(vigra::NumericTraits<value_type>::max()), max(vigra::NumericTraits<value_type>::min()), count(0)
313  {}
314 
316  void reset()
317  {
318  count = 0;
319  }
320 
322  void operator()(argument_type const & v)
323  {
324  if (count)
325  {
326  if (v < min) min = v;
327  if (max < v) max = v;
328  }
329  else
330  {
331  min = v;
332  max = v;
333  }
334  ++count;
335  }
336 
338  void operator()(vigra::RGBValue<VALUETYPE> const & v)
339  {
340  const VALUETYPE vMax = vigra_ext::getMaxComponent(v);
341  const VALUETYPE vMin = vigra_ext::getMinComponent(v);
342  if (count)
343  {
344  if (vMin < min)
345  {
346  min = vMin;
347  };
348  if (vMax > max)
349  {
350  max = vMax;
351  };
352  }
353  else
354  {
355  min = vMin;
356  max = vMax;
357  }
358  ++count;
359  }
360 
362  VALUETYPE min;
364  VALUETYPE max;
366  unsigned int count;
367 };
368 
369 template<class ImgIter, class ImgAccessor, class AlphaIter, class AlphaAccessor>
370 void applyExposureClipMask(vigra::triple<ImgIter, ImgIter, ImgAccessor> image, vigra::triple<AlphaIter, AlphaIter, AlphaAccessor> mask, double lowerLimit, double upperLimit)
371 {
372  typedef typename ImgAccessor::value_type ImageValueType;
373  vigra_precondition((image.second - image.first) == (mask.second - mask.first), "applyExposureMask: image and mask have different sizes");
374  const vigra::Diff2D imgSize = image.second - image.first;
375  const double LowerLimit = lowerLimit * LUTTraits<ImageValueType>::max();
376  const double UpperLimit = upperLimit * LUTTraits<ImageValueType>::max();
377 
378  // create dest y iterator
379  ImgIter yd(image.first);
380  AlphaIter ymd(mask.first);
381  // loop over the image and transform
382  for (int y = 0; y < imgSize.y; ++y, ++yd.y, ++ymd.y)
383  {
384  // create x iterators
385  ImgIter xd(yd);
386  AlphaIter xmd(ymd);
387  for (int x = 0; x < imgSize.x; ++x, ++xd.x, ++xmd.x)
388  {
389  const double minVal = vigra_ext::getMinComponent(*xd);
390  const double maxVal = vigra_ext::getMaxComponent(*xd);
391  if (minVal < LowerLimit || maxVal > UpperLimit)
392  {
393  *xmd = 0;
394  };
395  }
396  }
397 }
398 
401 {
403  : size(0)
404  { }
405 
406  template<typename PIXEL>
407  void operator()(PIXEL const & img1, PIXEL const & img2)
408  {
409  if (img1 > 0 && img2 > 0) {
410  size++;
411  }
412  }
413 
414  unsigned int getSize()
415  {
416  return size;
417  }
418 
419  unsigned int size;
420 };
421 
422 
430 template <class F1, class F2>
432 {
433  F1 f1;
434  F2 f2;
435  NestFunctor(const F1 & fu1, const F2 & fu2)
436  : f1(fu1), f2(fu2)
437  { }
438 
441  typedef typename F1::result_type result_type;
442 
443  template <class T1>
444  result_type operator()(T1 const & v) const
445  {
446  return f1(f2(v));
447  }
448 
450  template <class T1, class T2>
451  result_type operator()(T1 const & v1, T2 const & v2) const
452  {
453  return f1(f2(v1,v2));
454  }
455 
457  template <class T1, class T2, class T3>
458  result_type operator()(T1 const & v1, T2 const & v2, T3 const & v3) const
459  {
460  return f1(f2(v1,v2,v3));
461  }
462 };
463 
464 
467 {
469  : count(0)
470  { }
471 
472  template<typename PIXEL>
473  void operator()(PIXEL const & img1)
474  {
475  if (img1 > 0) {
476  count++;
477  }
478  }
479 
480  int getCount()
481  {
482  return count;
483  }
484 
485  int count;
486 };
487 
494 template <class SrcImageIterator, class SrcAccessor>
495 void circularCrop(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> img,
496  hugin_utils::FDiff2D middle, double radius)
497 {
498  vigra::Diff2D imgSize = img.second - img.first;
499  double r2 = radius*radius;
500 
501  // create dest y iterator
502  SrcImageIterator yd(img.first);
503  // loop over the image and transform
504  for(int y=0; y < imgSize.y; ++y, ++yd.y)
505  {
506  // create x iterators
507  SrcImageIterator xd(yd);
508  for(int x=0; x < imgSize.x; ++x, ++xd.x)
509  {
510  double dx = x-middle.x;
511  double dy = y-middle.y;
512  if (dx*dx+dy*dy > r2) {
513  *xd = 0;
514  }
515  }
516  }
517 }
518 
520 template <class T>
522 {
523  typedef T result_type;
524 
525  T operator()(const T & a) const
526  {
527  return a;
528  }
529 
530  template <class T2>
531  T2 operator()(const T2 & a, const hugin_utils::FDiff2D & p) const
532  {
533  return a;
534  }
535 
536  template <class T2, class A>
537  A
538  hdrWeight(T2 v, A a) const
539  {
540  return a;
541  }
542 
543 };
544 
545 
549 template <class T>
550 typename vigra::NumericTraits<T>::RealPromote
551 normalizeValue(T v, vigra::VigraTrueType)
552 {
553  return vigra::NumericTraits<T>::toRealPromote(v) / vigra::NumericTraits<T>::max();
554 }
555 
556 template <class T>
557 typename vigra::NumericTraits<T>::RealPromote
558 normalizeValue(T v, vigra::VigraFalseType)
559 {
560  return v;
561 }
562 
563 
564 
565 template <class DestValueType>
567 {
568  public:
569  /* the functors argument type (actually, since
570  <tt>operator()</tt> is a template, much more types are possible)
571  */
572  typedef DestValueType argument_type;
573 
574  /* the functors result type
575  */
576  typedef DestValueType result_type;
577 
578  /* init scale and offset
579  */
580  LinearTransform(float scale, float offset)
581  : scale_(scale), offset_(offset)
582  {}
583  template <class SrcValueType>
584  result_type operator()(SrcValueType const & s) const
585  {
586  return vigra::NumericTraits<result_type>::fromRealPromote(scale_ * (vigra::NumericTraits<SrcValueType>::toRealPromote(s) + offset_));
587  }
588  private:
589 
590  float scale_;
591  float offset_;
592 };
593 
594 
596 {
597  float minv;
598  float maxv;
599  float scale;
600 
601  ApplyLogFunctor(float min_, float max_)
602  {
603  // protect against zeros in image data
604  if (min_ <= 0.0f) {
605  min_ = 1e-5f;
606  }
607  minv = std::log10(min_);
608  maxv = std::log10(max_);
609  scale = (maxv - minv)/255;
610  }
611 
612  template <class T>
613  unsigned char operator()(T v) const
614  {
615  typedef vigra::NumericTraits<vigra::UInt8> DestTraits;
616  return DestTraits::fromRealPromote((std::log10(float(v))-minv)/scale);
617  }
618 
619  template <class T, unsigned int R, unsigned int G, unsigned int B>
620  vigra::RGBValue<vigra::UInt8,0,1,2> operator()(const vigra::RGBValue<T,R,G,B> & v) const
621  {
622  typedef vigra::NumericTraits< vigra::RGBValue<vigra::UInt8,0,1,2> > DestTraits;
623  typedef vigra::NumericTraits< vigra::RGBValue<T,R,G,B> > SrcTraits;
624  return DestTraits::fromRealPromote((log10(SrcTraits::toRealPromote(v)) + (-minv))/scale);
625  }
626 };
627 
628 
629 template <class TIn, class TOut=vigra::UInt8>
631 {
632  float minv;
633  float maxv;
634  float gamma;
635  float scale;
636 
637  ApplyGammaFunctor(TIn min_, TIn max_, float gamma_)
638  {
639  minv = min_;
640  maxv = max_;
641  gamma = gamma_;
642  scale = float(maxv) - minv;
643  }
644 
645  TOut operator()(TIn v) const
646  {
647  typedef vigra::NumericTraits<TOut> DestTraits;
648  return DestTraits::fromRealPromote(pow((float(v)-minv)/scale, gamma)*255);
649  }
650 
651  vigra::RGBValue<TOut> operator()(const vigra::RGBValue<TIn> & v) const
652  {
653  typedef vigra::NumericTraits< vigra::RGBValue<TOut> > DestTraits;
654  typedef vigra::NumericTraits< vigra::RGBValue<TIn> > SrcTraits;
655  return DestTraits::fromRealPromote(vigra_ext::pow((SrcTraits::toRealPromote(v)+(-minv))/scale, gamma)*255);
656  }
657 };
658 
659 // gamma correction with lookup table
660 template <>
661 struct ApplyGammaFunctor<vigra::UInt16, vigra::UInt8>
662 {
663  vigra::UInt8 lut[65536];
664 
665  ApplyGammaFunctor(vigra::UInt16 min, vigra::UInt16 max, float gamma)
666  {
667  float scale = float(max) - min;
668  for (int i=0; i<65536; i++) {
669  lut[i] = hugin_utils::roundi(pow((float(i)-min)/scale, gamma)*255);
670  }
671  }
672 
673  vigra::UInt8 operator()(vigra::UInt16 v) const
674  {
675  return lut[v];
676  }
677 
678  vigra::RGBValue<vigra::UInt8> operator()(const vigra::RGBValue<vigra::UInt16> & v) const
679  {
680  return vigra::RGBValue<vigra::UInt8>(lut[v[0]], lut[v[1]], lut[v[2]]);
681  }
682 };
683 
684 template <class SrcIterator, class SrcAccessor, class DestIterator, class DestAccessor, class T>
685  void applyMapping(vigra::triple<SrcIterator, SrcIterator, SrcAccessor> img,
686  vigra::pair<DestIterator, DestAccessor> dest, T min, T max, int mapping )
687 {
688 
689  switch (mapping)
690  {
691  case 0:
692  {
693  // linear
694  float offset_ = -float(min);
695  float scale_ = 255/float(max)-float(min);
696  vigra::transformImage(img, dest,
698  );
699  break;
700  }
701  case 1:
702  {
703  // log
704  ApplyLogFunctor logfunc(min, max);
705  transformImage(img, dest,
706  logfunc);
707  break;
708  }
709  case 2:
710  {
711  // gamma
712  ApplyGammaFunctor<T> logfunc(min, max, 1/2.2f);
713  transformImage(img, dest,
714  logfunc);
715  break;
716  }
717  default:
718  vigra_fail("Unknown image mapping mode");
719  }
720 }
721 
722 template <class SrcImageIterator, class SrcAccessor,
723 class DestImageIterator, class DestAccessor, class Functor>
724 void
725 transformImageSpatial(SrcImageIterator src_upperleft,
726  SrcImageIterator src_lowerright, SrcAccessor sa,
727  DestImageIterator dest_upperleft, DestAccessor da,
728  Functor const & f, vigra::Diff2D ul)
729 {
730  vigra::Diff2D destSize = src_lowerright - src_upperleft;
731 
732  int offsetX=ul.x;
733  for(; src_upperleft.y < src_lowerright.y; ++src_upperleft.y, ++dest_upperleft.y, ++ul.y)
734  {
735  typename SrcImageIterator::row_iterator s(src_upperleft.rowIterator());
736  typename SrcImageIterator::row_iterator send(s+ destSize.x);
737  typename DestImageIterator::row_iterator d(dest_upperleft.rowIterator());
738  ul.x=offsetX;
739  for(; s != send; ++s, ++d, ++ul.x) {
740  da.set(f(sa(s), ul), d);
741  }
742  }
743 }
744 
745 template <class SrcImageIterator, class SrcAccessor,
746 class DestImageIterator, class DestAccessor, class Functor>
747 void
748 transformImageSpatial(vigra::triple<SrcImageIterator, SrcImageIterator, SrcAccessor> src,
749  vigra::pair<DestImageIterator, DestAccessor> dest,
750  Functor const & f, vigra::Diff2D ul)
751 {
752  transformImageSpatial(src.first, src.second, src.third, dest.first, dest.second, f, ul);
753 }
754 
756 template <class ImageType>
758 {
759  typedef vigra::NumericTraits<typename ImageType::PixelType> DestTraits;
762  const std::string pixelType = vigra::TypeAsString<typename DestTraits::ValueType>::result();
763  int mapping = 0;
764  if (pixelType == "FLOAT" || pixelType == "DOUBLE")
765  {
766  vigra::FindMinMax<typename ImageType::PixelType> minmax;
767  vigra::inspectImage(srcImageRange(image), minmax);
768  minVal = vigra_ext::getMaxComponent(minmax.min);
769  maxVal = vigra_ext::getMaxComponent(minmax.max);
770  mapping = 1;
771  }
772  if (minVal != 0 || maxVal != 255)
773  {
774  vigra_ext::applyMapping(srcImageRange(image), destImage(image), minVal, maxVal, mapping);
775  };
776 };
777 
778 } // namespace
779 
780 #endif // VIGRA_EXT_UTILS_H
void transformImageSpatial(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor sa, DestImageIterator dest_upperleft, DestAccessor da, Functor const &f, vigra::Diff2D ul)
Definition: utils.h:725
vigra::RGBValue< vigra::UInt8 > operator()(const vigra::RGBValue< vigra::UInt16 > &v) const
Definition: utils.h:678
vigra::RGBValue< V1, R, G, B > & operator+=(vigra::RGBValue< V1, R, G, B > &l, V2 const &r)
add a scalar to all components
Definition: utils.h:197
double getMaxValForPixelType(const std::string &v)
Definition: utils.h:89
result_type operator()(SrcValueType const &s) const
Definition: utils.h:584
V getMaxComponent(vigra::RGBValue< V > const &v)
get the maximum component of a vector (also works for single pixel types...)
Definition: utils.h:268
PointPairT(short img1, VALUE val1, const hugin_utils::FDiff2D &p1, float r1, short img2, VALUE val2, const hugin_utils::FDiff2D &p2, float r2)
Definition: utils.h:114
int roundi(T x)
Definition: hugin_math.h:73
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.
unsigned char operator()(T v) const
Definition: utils.h:613
T operator()(const T &a) const
Definition: utils.h:525
VALUETYPE argument_type
the functor&#39;s argument type
Definition: utils.h:305
LUT_TRAITS(unsigned char, 0, UCHAR_MAX)
misc math function &amp; classes used by other parts of the program
static const double A(-0.75)
unsigned int getSize()
Definition: utils.h:414
hugin_utils::FDiff2D p1
Definition: utils.h:122
result_type operator()(T1 const &v) const
Definition: utils.h:444
ApplyLogFunctor(float min_, float max_)
Definition: utils.h:601
vigra::UInt8 operator()(vigra::UInt16 v) const
Definition: utils.h:673
count pixels that are &gt; 0 in a single image
Definition: utils.h:466
vigra::PromoteTraits< vigra::RGBValue< V1, R, G, B >, V2 >::Promote operator+(vigra::RGBValue< V1, R, G, B > const &r1, V2 const &r2)
add a scalar to all components
Definition: utils.h:229
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Definition: utils.h:685
NestFunctor(const F1 &fu1, const F2 &fu2)
Definition: utils.h:435
LinearTransform(float scale, float offset)
Definition: utils.h:580
VALUETYPE result_type
the functor&#39;s result type
Definition: utils.h:307
A hdrWeight(T2 v, A a) const
Definition: utils.h:538
vigra::RGBValue< T, RIDX, GIDX, BIDX > log10(vigra::RGBValue< T, RIDX, GIDX, BIDX > const &v)
component-wise logarithm
Definition: utils.h:218
vigra::NumericTraits< T >::RealPromote normalizeValue(T v, vigra::VigraTrueType)
normalize a pixel to 0..1 Only has an effect on integer pixel types
Definition: utils.h:551
void operator()(argument_type const &v)
update min and max
Definition: utils.h:322
result_type operator()(T1 const &v1, T2 const &v2, T3 const &v3) const
if F2 takes 3 arguments
Definition: utils.h:458
unsigned int count
the number of values processed so far
Definition: utils.h:366
#define VT_TRAITS_VEC(T1)
Definition: utils.h:136
vigra::FRGBImage ImageType
float pow(float a, double b)
Definition: utils.h:181
DestValueType argument_type
Definition: utils.h:572
DestValueType result_type
Definition: utils.h:576
void applyExposureClipMask(vigra::triple< ImgIter, ImgIter, ImgAccessor > image, vigra::triple< AlphaIter, AlphaIter, AlphaAccessor > mask, double lowerLimit, double upperLimit)
Definition: utils.h:370
hugin_utils::FDiff2D p2
Definition: utils.h:126
void operator()(vigra::RGBValue< VALUETYPE > const &v)
update min and max with components of RGBValue&lt;VALUETYPE&gt;
Definition: utils.h:338
void operator()(PIXEL const &img1)
Definition: utils.h:473
PointPairT< float > PointPair
Definition: utils.h:130
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
Definition: ROIImage.h:324
functor to combine two functors: result = f1( f2(v) )
Definition: utils.h:431
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
Definition: ROIImage.h:287
VALUETYPE min
the current min
Definition: utils.h:362
ApplyGammaFunctor(TIn min_, TIn max_, float gamma_)
Definition: utils.h:637
vigra::RGBValue< T, RIDX, GIDX, BIDX > log(vigra::RGBValue< T, RIDX, GIDX, BIDX > const &v)
component-wise logarithm
Definition: utils.h:209
RGBValue< typename PromoteTraits< T1, T2 >::Promote > Promote
Definition: utils.h:40
TOut operator()(TIn v) const
Definition: utils.h:645
vigra::RGBValue< TOut > operator()(const vigra::RGBValue< TIn > &v) const
Definition: utils.h:651
static T max(T x, T y)
Definition: svm.cpp:65
VALUETYPE max
the current max
Definition: utils.h:364
void reset()
(re-)init functor (clear min, max)
Definition: utils.h:316
ApplyGammaFunctor(vigra::UInt16 min, vigra::UInt16 max, float gamma)
Definition: utils.h:665
FindComponentsMinMax()
init min and max
Definition: utils.h:312
T1::value_type value_type
Definition: utils.h:153
F1::result_type result_type
the functor&#39;s second argument type
Definition: utils.h:441
vigra::RGBValue< vigra::UInt8, 0, 1, 2 > operator()(const vigra::RGBValue< T, R, G, B > &v) const
Definition: utils.h:620
V getMinComponent(vigra::RGBValue< V > const &v)
get the maximum component of a vector (also works for single pixel types...)
Definition: utils.h:286
T2 operator()(const T2 &a, const hugin_utils::FDiff2D &p) const
Definition: utils.h:531
void ConvertTo8Bit(ImageType &image)
converts to given image to fit into 0..255
Definition: utils.h:757
count pixels that are &gt; 0 in both images
Definition: utils.h:400
static T min(T x, T y)
Definition: svm.cpp:62
void operator()(PIXEL const &img1, PIXEL const &img2)
Definition: utils.h:407
result_type operator()(T1 const &v1, T2 const &v2) const
if F2 takes 2 arguments
Definition: utils.h:451
PointPairT< vigra::RGBValue< float > > PointPairRGB
Definition: utils.h:131
void circularCrop(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > img, hugin_utils::FDiff2D middle, double radius)
Apply a circular crop to img.
Definition: utils.h:495
VT_TRAITS(vigra::UInt8)