lsst.afw  13.0-100-ge0459d59f+5
Pixel.h
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #if !defined(LSST_AFW_IMAGE_PIXEL_H)
24 #define LSST_AFW_IMAGE_PIXEL_H
25 
26 #include <cmath>
27 #include <functional>
28 #include <iostream>
29 #include <type_traits>
30 
31 namespace lsst {
32 namespace afw {
33 namespace image {
34 namespace pixel {
35 
36 template <typename, typename, typename, typename, typename>
37 class BinaryExpr;
38 
39 template <typename>
40 struct exprTraits;
41 
42 template <typename>
43 struct bitwise_or;
44 template <typename>
46 template <typename>
48 template <typename>
50 
51 /*
52  * Classes to provide utility functions for a "Pixel" to get at image/mask/variance operators
53  *
54  * These classes allow us to manipulate the tuples returned by MaskedImage iterators/locators as if they were
55  * POD. This provides convenient syntactic sugar, but it also permits us to write generic algorithms to
56  * manipulate MaskedImages as well as Images
57  *
58  * We need SinglePixel as well as Pixel as the latter is just a reference to a pixel in an image, and we need
59  * to be able to build temporary values too
60  *
61  * We use C++ template expressions to manipulate Pixel and SinglePixel; this permits us to avoid making
62  * SinglePixel inherit from Pixel (or vice versa) and allows the compiler to do a much better job of
63  * optimising mixed-mode expressions --- basically, it no longer needs to create SinglePixels as Pixels that
64  * have their own storage but use the reference members of Pixel to get work done. There may be better ways,
65  * but this way works, and g++ 4.0.1 (and maybe other compilers/versions) failed to optimise the previous
66  * solution very well.
67  */
68 
70 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
72 public:
73  template <typename, typename, typename>
74  friend class Pixel;
75  template <typename T>
76  friend class PixelTypeTraits;
77 
78  typedef _ImagePixelT ImagePixelT;
79  typedef _MaskPixelT MaskPixelT;
80  typedef _VariancePixelT VariancePixelT;
81 
82  SinglePixel(ImagePixelT image, MaskPixelT mask = 0, VariancePixelT variance = 0)
83  : _image(image), _mask(mask), _variance(variance) {}
84 
85  template <typename rhsExpr>
86  SinglePixel(rhsExpr const& rhs,
87  // ensure this ctor isn't invoked for simple numeric types, which should use
88  // the overload above.
89  typename std::enable_if<!std::is_fundamental<rhsExpr>::value, void*>::type dummy = nullptr)
90  : _image(rhs.image()), _mask(rhs.mask()), _variance(rhs.variance()) {}
91 
92  ImagePixelT image() const { return _image; }
93  MaskPixelT mask() const { return _mask; }
94  VariancePixelT variance() const { return _variance; }
95 
96 private:
101  SinglePixel()
102  : _image(std::numeric_limits<_ImagePixelT>::has_quiet_NaN
103  ? std::numeric_limits<_ImagePixelT>::quiet_NaN()
104  : 0),
105  _mask(0),
106  _variance(std::numeric_limits<_VariancePixelT>::has_quiet_NaN
107  ? std::numeric_limits<_VariancePixelT>::quiet_NaN()
108  : 0) {}
109 
110  ImagePixelT _image;
111  MaskPixelT _mask;
112  VariancePixelT _variance;
113 };
114 
116 template <typename PixelT>
119  static inline const PixelT padValue() {
120  return std::numeric_limits<PixelT>::has_quiet_NaN ? std::numeric_limits<PixelT>::quiet_NaN() : 0;
121  }
122 };
123 
125 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT>
126 struct PixelTypeTraits<SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT> > {
128 
130  static inline const PixelT padValue() { return PixelT(); }
131 };
132 
138 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
140  VariancePixelT v) {
142 }
143 
145 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
147 public:
148  typedef _ImagePixelT ImagePixelT;
149  typedef _MaskPixelT MaskPixelT;
150  typedef _VariancePixelT VariancePixelT;
151 
153 #if 0
154  Pixel(ImagePixelT& image, MaskPixelT& mask, VariancePixelT& variance) :
155  _image(image), _mask(mask), _variance(variance) {}
156 #else
157  //
158  // This constructor casts away const. This should be fixed by making const Pixels.
159  //
160  Pixel(ImagePixelT const& image, MaskPixelT const& mask = 0x0, VariancePixelT const& variance = 0)
161  : _image(const_cast<ImagePixelT&>(image)),
162  _mask(const_cast<MaskPixelT&>(mask)),
163  _variance(const_cast<VariancePixelT&>(variance)) {}
164 #endif
165 
167  : _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {}
168 
169  Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate
170  // operator=
171  _variance = rhs.variance(); // evaluate before we update image()
172  _image = rhs.image();
173  _mask = rhs.mask();
174 
175  return *this;
176  }
182  template <typename rhsExpr>
183  Pixel operator=(rhsExpr const& rhs) {
184  _variance = rhs.variance(); // evaluate before we update image()
185  _image = rhs.image();
186  _mask = rhs.mask();
187 
188  return *this;
189  }
190 
192  Pixel operator=(double const& rhs_image) {
193  _image = rhs_image;
194  _mask = 0;
195  _variance = 0;
196 
197  return *this;
198  }
199 
201  Pixel operator=(int const& rhs_image) {
202  _image = rhs_image;
203  _mask = 0;
204  _variance = 0;
205 
206  return *this;
207  }
209  ImagePixelT image() const { return _image; }
211  MaskPixelT mask() const { return _mask; }
213  VariancePixelT variance() const { return _variance; }
214  //
215  // Logical operators. We don't need to construct BinaryExpr for them
216  // as efficiency isn't a concern.
217  //
219  template <typename T1>
220  friend bool operator==(Pixel const& lhs, T1 const& rhs) {
221  return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
222  }
223 
225  template <typename T1>
226  friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
227  return !(lhs == rhs);
228  }
229 
230  //
231  // Provide friend versions of the op= operators to permit argument promotion on their first arguments
232  //
234  template <typename ExprT>
235  friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
236  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
239  return tmp;
240  }
241 
243  template <typename ExprT>
244  friend Pixel operator-=(Pixel const& e1, ExprT const& e2) {
245  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
248  return tmp;
249  }
250 
252  template <typename ExprT>
253  friend Pixel operator*=(Pixel const& e1, ExprT const& e2) {
254  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
257  return tmp;
258  }
259 
261  template <typename ExprT>
262  friend Pixel operator/=(Pixel const& e1, ExprT const& e2) {
263  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
266  return tmp;
267  }
268 
269 private:
270  ImagePixelT& _image;
271  MaskPixelT& _mask;
272  VariancePixelT& _variance;
273 };
274 
276 template <typename ExprT>
277 struct exprTraits {
278  typedef ExprT expr_type;
279  typedef typename ExprT::ImagePixelT ImagePixelT;
280  typedef typename ExprT::MaskPixelT MaskPixelT;
281  typedef typename ExprT::VariancePixelT VariancePixelT;
282 };
283 
285 template <>
286 struct exprTraits<double> {
287  typedef double ImagePixelT;
288  typedef int MaskPixelT;
289  typedef double VariancePixelT;
291 };
292 
294 template <>
295 struct exprTraits<float> {
296  typedef float ImagePixelT;
300 };
301 
303 template <>
304 struct exprTraits<int> {
305  typedef int ImagePixelT;
309 };
310 
312 template <>
313 struct exprTraits<unsigned short> {
314  typedef int ImagePixelT;
318 };
319 
321 template <typename T1>
322 struct noop : public std::unary_function<T1, T1> {
323  T1 operator()(const T1& x) const { return x; }
324 };
325 
331 template <typename T1>
332 struct bitwise_or : public std::binary_function<T1, T1, T1> {
333  T1 operator()(const T1& x, const T1& y) const { return (x | y); }
334  T1 operator()(const T1& x) const { return x; }
335 };
336 
342 template <typename T1>
343 struct variance_divides {
344  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
345  T1 const x2 = x * x;
346  T1 const y2 = y * y;
347  T1 const iy2 = 1.0 / y2;
348  return x2 * vy * iy2 * iy2 + vx * iy2;
349  }
350 
351  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx / (y * y); }
352 };
353 
359 template <typename T1>
360 struct variance_multiplies {
361  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
362  T1 const x2 = x * x;
363  T1 const y2 = y * y;
364  return x2 * vy + y2 * vx;
365  }
366 
367  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx * y * y; }
368 };
369 
375 template <typename T1>
376 struct variance_plus {
377  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const { return vx + vy; }
378 
379  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
380 };
381 
389 template <typename T1>
391  variance_plus_covar(double alpha = 0) : _alpha(alpha) {}
392 
393  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
394  return vx + vy + 2 * _alpha * sqrt(vx * vy);
395  }
396  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
397 
398 private:
399  double _alpha;
400 };
401 
403 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
404 class UnaryExpr {
405 public:
410  UnaryExpr(ExprT1 e1, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
411  VarianceBinOp varOp = VarianceBinOp())
412  : _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
413 
415  ImagePixelT image() const { return _imageOp(_expr1.image()); }
416 
418  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
419 
421  VariancePixelT variance() const { return _varOp(_expr1.variance()); }
422 
423 private:
424  typename exprTraits<ExprT1>::expr_type _expr1;
425  ImageBinOp _imageOp;
426  MaskBinOp _maskOp;
427  VarianceBinOp _varOp;
428 };
429 
431 template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
432 class BinaryExpr {
433 public:
438  BinaryExpr(ExprT1 e1, ExprT2 e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
439  VarianceBinOp varOp = VarianceBinOp())
440  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
441 
444  BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
445  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
446  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
448  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2.image()); }
449 
451  MaskPixelT mask() const { return _maskOp(_expr1.mask(), _expr2.mask()); }
452 
454  VariancePixelT variance() const {
455  return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
456  }
457 
458 private:
459  typename exprTraits<ExprT1>::expr_type _expr1;
460  typename exprTraits<ExprT2>::expr_type _expr2;
461  ImageBinOp _imageOp;
462  MaskBinOp _maskOp;
463  VarianceBinOp _varOp;
464 };
465 
470 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
471 class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> {
472 public:
477  BinaryExpr(ExprT1 e1, double e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
478  VarianceBinOp varOp = VarianceBinOp())
479  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
480 
483  BinaryExpr(ExprT1 e1, double e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
484  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
485  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
487  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2); }
488 
490  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
491 
493  VariancePixelT variance() const { return _varOp(_expr1.image(), _expr2, _expr1.variance()); }
494 
495 private:
496  typename exprTraits<ExprT1>::expr_type _expr1;
497  double _expr2;
498  ImageBinOp _imageOp;
499  MaskBinOp _maskOp;
500  VarianceBinOp _varOp;
501 };
502 
504 template <typename ExprT1>
507 operator-(ExprT1 e1) {
509  noop<typename exprTraits<ExprT1>::MaskPixelT>,
511 }
512 
513 //------------------------------------------
515 template <typename ExprT1, typename ExprT2>
519 operator+(ExprT1 e1, ExprT2 e2) {
520  return BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
521  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
523 }
524 
526 template <typename ExprT1, typename ExprT2>
527 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
528  e1 = BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
529  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
531  return e1;
532 }
533 
534 //
535 // Implementations of add that work for arithmetic or MaskedImage pixels
536 //
537 // The choice is made on the basis of std::is_arithmetic
538 namespace {
539 template <typename ExprT1, typename ExprT2>
540 ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
541  return e1 + e2;
542 }
543 
544 template <typename ExprT1, typename ExprT2>
545 BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
546  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
548 doPlus(ExprT1 e1, ExprT2 e2, double const alpha, boost::mpl::false_) {
549  return BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
550  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
552 }
553 }
554 
556 template <typename ExprT1, typename ExprT2>
557 inline ExprT1 plus(
558  ExprT1& lhs,
559  ExprT2 const& rhs,
560  float covariance
561  ) {
562  return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
563 }
564 
565 //------------------------------------------
567 template <typename ExprT1, typename ExprT2>
569  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
571 operator-(ExprT1 e1, ExprT2 e2) {
573  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
575 }
576 
578 template <typename ExprT1, typename ExprT2>
579 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
581  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
583  return e1;
584 }
585 
586 //------------------------------------------
588 template <typename ExprT1, typename ExprT2>
590  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
592 operator*(ExprT1 e1, ExprT2 e2) {
594  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
596 }
597 
599 template <typename ExprT1, typename ExprT2>
600 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
602  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
604  return e1;
605 }
606 
607 //------------------------------------------
609 template <typename ExprT1, typename ExprT2>
611  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
613 operator/(ExprT1 e1, ExprT2 e2) {
615  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
617 }
618 
620 template <typename ExprT1, typename ExprT2>
621 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
623  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
625  return e1;
626 }
627 
629 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
630 std::ostream& operator<<(std::ostream& os, SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
631  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
632 }
633 
635 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
636 std::ostream& operator<<(std::ostream& os, Pixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
637  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
638 }
639 
641 template <typename ExprT1, typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
642 std::ostream& operator<<(std::ostream& os, BinaryExpr<ExprT1, ExprT2, BinOp, MaskBinOp, VarBinOp> const& v) {
643  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
644 }
645 }
646 }
647 }
648 }
649 #endif
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:451
Pixel operator=(double const &rhs_image)
set the image part of a Pixel to rhs_image (the mask and variance are set to 0)
Definition: Pixel.h:192
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:297
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:262
Class for representing binary operations.
Definition: Pixel.h:37
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition: Pixel.h:139
bitwise_or doesn&#39;t seem to be in std::
Definition: Pixel.h:43
BinaryExpr< ExprT1, ExprT2, std::multiplies< typename exprTraits< ExprT1 >::ImagePixelT >, bitwise_or< typename exprTraits< ExprT1 >::MaskPixelT >, variance_multiplies< typename exprTraits< ExprT1 >::VariancePixelT > > operator*(ExprT1 e1, ExprT2 e2)
Template to evaluate (e1 * e2)
Definition: Pixel.h:592
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:213
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:317
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:415
BinaryExpr(ExprT1 e1, ExprT2 e2, ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp())
A binary operation, with three functors to represent the image/mask/variance operations.
Definition: Pixel.h:438
Pixel operator=(int const &rhs_image)
set the image part of a Pixel to rhs_image (the mask and variance are set to 0)
Definition: Pixel.h:201
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:396
BinaryExpr(ExprT1 e1, double e2, ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp())
A binary operation, with three functors to represent the image/mask/variance operations.
Definition: Pixel.h:477
friend bool operator!=(Pixel const &lhs, T1 const &rhs)
Return true iff two pixels are unequal (in at least one of image, mask, and variance) ...
Definition: Pixel.h:226
VariancePixelT variance() const
Definition: Pixel.h:94
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:299
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:418
Pixel(ImagePixelT const &image, MaskPixelT const &mask=0x0, VariancePixelT const &variance=0)
Construct a Pixel from references to its image/mask/variance components.
Definition: Pixel.h:160
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:579
T1 operator()(const T1 &x) const
Definition: Pixel.h:323
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:361
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:279
MaskPixelT mask() const
Definition: Pixel.h:93
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:71
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:379
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:344
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:407
BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha, ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp=VarianceBinOp())
A binary operation, with three functors to represent the image/mask/variance operations and an extra ...
Definition: Pixel.h:444
BinaryExpr< ExprT1, ExprT2, std::divides< typename exprTraits< ExprT1 >::ImagePixelT >, bitwise_or< typename exprTraits< ExprT1 >::MaskPixelT >, variance_divides< typename exprTraits< ExprT1 >::VariancePixelT > > operator/(ExprT1 e1, ExprT2 e2)
Template to evaluate (e1 / e2)
Definition: Pixel.h:613
UnaryExpr(ExprT1 e1, ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp())
a unary expression, with three functors to represent the image/mask/variance operations ...
Definition: Pixel.h:410
ImagePixelT image() const
Definition: Pixel.h:92
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:130
ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:280
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:290
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:306
A base class for image defects.
Definition: cameraGeom.dox:3
Calculate the variance when we divide two Pixels.
Definition: Pixel.h:45
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:367
SinglePixel(rhsExpr const &rhs, typename std::enable_if<!std::is_fundamental< rhsExpr >::value, void *>::type dummy=nullptr)
Definition: Pixel.h:86
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:377
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:211
ExprT1 plus(ExprT1 &lhs, ExprT2 const &rhs, float covariance)
Like operator+(), but assume that covariance&#39;s 2*alpha*sqrt(vx*vy)
Definition: Pixel.h:557
T1 operator()(const T1 &x) const
Definition: Pixel.h:334
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:209
BinaryExpr(ExprT1 e1, double e2, double const alpha, ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp=VarianceBinOp())
A binary operation, with three functors to represent the image/mask/variance operations and an extra ...
Definition: Pixel.h:483
double x
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:244
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition: Pixel.h:183
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:435
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:600
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:621
_ImagePixelT ImagePixelT
Definition: Pixel.h:148
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:351
_VariancePixelT VariancePixelT
Definition: Pixel.h:150
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:454
A pixel of a MaskedImage.
Definition: Pixel.h:146
SinglePixel(ImagePixelT image, MaskPixelT mask=0, VariancePixelT variance=0)
Definition: Pixel.h:82
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:307
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:390
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:408
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:253
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:421
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:493
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:316
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:169
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:333
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:40
table::PointKey< int > pixel
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:434
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:448
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:393
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:166
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:487
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:490
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:315
Class for representing Unary operations.
Definition: Pixel.h:404
Calculate the variance when we multiply two Pixels.
Definition: Pixel.h:47
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:55
UnaryExpr< ExprT1, std::negate< typename exprTraits< ExprT1 >::ImagePixelT >, noop< typename exprTraits< ExprT1 >::MaskPixelT >, noop< typename exprTraits< ExprT1 >::VariancePixelT > > operator-(ExprT1 e1)
Template for -e1.
Definition: Pixel.h:507
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:281
BinaryExpr< ExprT1, ExprT2, std::plus< typename exprTraits< ExprT1 >::ImagePixelT >, bitwise_or< typename exprTraits< ExprT1 >::MaskPixelT >, variance_plus< typename exprTraits< ExprT1 >::VariancePixelT > > operator+(ExprT1 e1, ExprT2 e2)
Template for (e1 + e2)
Definition: Pixel.h:519
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:119
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:527
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:406
Calculate the variance when we add (or subtract) two Pixels.
Definition: Pixel.h:49
A noop functor (useful for e.g. masks and variances when changing the sign of the image) ...
Definition: Pixel.h:322
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:308
friend bool operator==(Pixel const &lhs, T1 const &rhs)
Return true iff two pixels are equal (in all three of image, mask, and variance)
Definition: Pixel.h:220
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:436
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:298
_VariancePixelT VariancePixelT
Definition: Pixel.h:80
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:235