lsst.afw  14.0-56-gfbf220870
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()
104  : 0),
105  _mask(0),
108  : 0) {}
109 
110  ImagePixelT _image;
111  MaskPixelT _mask;
112  VariancePixelT _variance;
113 };
114 
116 template <typename PixelT>
119  static inline const PixelT padValue() {
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(Pixel const& rhs) = default;
170  Pixel(Pixel&& rhs) = default;
171  ~Pixel() = default;
172 
173  Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate
174  // operator=
175  _variance = rhs.variance(); // evaluate before we update image()
176  _image = rhs.image();
177  _mask = rhs.mask();
178 
179  return *this;
180  }
186  template <typename rhsExpr>
187  Pixel operator=(rhsExpr const& rhs) {
188  _variance = rhs.variance(); // evaluate before we update image()
189  _image = rhs.image();
190  _mask = rhs.mask();
191 
192  return *this;
193  }
194  // Delegate to copy-assignment for backwards compatibility
195  Pixel operator=(Pixel&& rhs) { return *this = rhs; }
196 
198  Pixel operator=(double const& rhs_image) {
199  _image = rhs_image;
200  _mask = 0;
201  _variance = 0;
202 
203  return *this;
204  }
205 
207  Pixel operator=(int const& rhs_image) {
208  _image = rhs_image;
209  _mask = 0;
210  _variance = 0;
211 
212  return *this;
213  }
215  ImagePixelT image() const { return _image; }
217  MaskPixelT mask() const { return _mask; }
219  VariancePixelT variance() const { return _variance; }
220  //
221  // Logical operators. We don't need to construct BinaryExpr for them
222  // as efficiency isn't a concern.
223  //
225  template <typename T1>
226  friend bool operator==(Pixel const& lhs, T1 const& rhs) {
227  return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
228  }
229 
231  template <typename T1>
232  friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
233  return !(lhs == rhs);
234  }
235 
236  //
237  // Provide friend versions of the op= operators to permit argument promotion on their first arguments
238  //
240  template <typename ExprT>
241  friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
242  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
245  return tmp;
246  }
247 
249  template <typename ExprT>
250  friend Pixel operator-=(Pixel const& e1, ExprT const& e2) {
251  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
254  return tmp;
255  }
256 
258  template <typename ExprT>
259  friend Pixel operator*=(Pixel const& e1, ExprT const& e2) {
260  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
263  return tmp;
264  }
265 
267  template <typename ExprT>
268  friend Pixel operator/=(Pixel const& e1, ExprT const& e2) {
269  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
272  return tmp;
273  }
274 
275 private:
276  ImagePixelT& _image;
277  MaskPixelT& _mask;
278  VariancePixelT& _variance;
279 };
280 
282 template <typename ExprT>
283 struct exprTraits {
284  typedef ExprT expr_type;
285  typedef typename ExprT::ImagePixelT ImagePixelT;
286  typedef typename ExprT::MaskPixelT MaskPixelT;
287  typedef typename ExprT::VariancePixelT VariancePixelT;
288 };
289 
291 template <>
292 struct exprTraits<double> {
293  typedef double ImagePixelT;
294  typedef int MaskPixelT;
295  typedef double VariancePixelT;
297 };
298 
300 template <>
301 struct exprTraits<float> {
302  typedef float ImagePixelT;
306 };
307 
309 template <>
310 struct exprTraits<int> {
311  typedef int ImagePixelT;
315 };
316 
318 template <>
319 struct exprTraits<unsigned short> {
320  typedef int ImagePixelT;
324 };
325 
327 template <typename T1>
328 struct noop : public std::unary_function<T1, T1> {
329  T1 operator()(const T1& x) const { return x; }
330 };
331 
337 template <typename T1>
338 struct bitwise_or : public std::binary_function<T1, T1, T1> {
339  T1 operator()(const T1& x, const T1& y) const { return (x | y); }
340  T1 operator()(const T1& x) const { return x; }
341 };
342 
348 template <typename T1>
349 struct variance_divides {
350  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
351  T1 const x2 = x * x;
352  T1 const y2 = y * y;
353  T1 const iy2 = 1.0 / y2;
354  return x2 * vy * iy2 * iy2 + vx * iy2;
355  }
356 
357  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx / (y * y); }
358 };
359 
365 template <typename T1>
366 struct variance_multiplies {
367  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
368  T1 const x2 = x * x;
369  T1 const y2 = y * y;
370  return x2 * vy + y2 * vx;
371  }
372 
373  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx * y * y; }
374 };
375 
381 template <typename T1>
382 struct variance_plus {
383  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const { return vx + vy; }
384 
385  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
386 };
387 
395 template <typename T1>
397  variance_plus_covar(double alpha = 0) : _alpha(alpha) {}
398 
399  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
400  return vx + vy + 2 * _alpha * sqrt(vx * vy);
401  }
402  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
403 
404 private:
405  double _alpha;
406 };
407 
409 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
410 class UnaryExpr {
411 public:
416  UnaryExpr(ExprT1 e1, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
417  VarianceBinOp varOp = VarianceBinOp())
418  : _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
419 
421  ImagePixelT image() const { return _imageOp(_expr1.image()); }
422 
424  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
425 
427  VariancePixelT variance() const { return _varOp(_expr1.variance()); }
428 
429 private:
430  typename exprTraits<ExprT1>::expr_type _expr1;
431  ImageBinOp _imageOp;
432  MaskBinOp _maskOp;
433  VarianceBinOp _varOp;
434 };
435 
437 template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
438 class BinaryExpr {
439 public:
444  BinaryExpr(ExprT1 e1, ExprT2 e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
445  VarianceBinOp varOp = VarianceBinOp())
446  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
447 
450  BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
451  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
452  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
454  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2.image()); }
455 
457  MaskPixelT mask() const { return _maskOp(_expr1.mask(), _expr2.mask()); }
458 
460  VariancePixelT variance() const {
461  return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
462  }
463 
464 private:
465  typename exprTraits<ExprT1>::expr_type _expr1;
466  typename exprTraits<ExprT2>::expr_type _expr2;
467  ImageBinOp _imageOp;
468  MaskBinOp _maskOp;
469  VarianceBinOp _varOp;
470 };
471 
476 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
477 class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> {
478 public:
483  BinaryExpr(ExprT1 e1, double e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
484  VarianceBinOp varOp = VarianceBinOp())
485  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
486 
489  BinaryExpr(ExprT1 e1, double e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
490  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
491  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
493  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2); }
494 
496  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
497 
499  VariancePixelT variance() const { return _varOp(_expr1.image(), _expr2, _expr1.variance()); }
500 
501 private:
502  typename exprTraits<ExprT1>::expr_type _expr1;
503  double _expr2;
504  ImageBinOp _imageOp;
505  MaskBinOp _maskOp;
506  VarianceBinOp _varOp;
507 };
508 
510 template <typename ExprT1>
513 operator-(ExprT1 e1) {
515  noop<typename exprTraits<ExprT1>::MaskPixelT>,
517 }
518 
519 //------------------------------------------
521 template <typename ExprT1, typename ExprT2>
525 operator+(ExprT1 e1, ExprT2 e2) {
526  return BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
527  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
529 }
530 
532 template <typename ExprT1, typename ExprT2>
533 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
534  e1 = BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
535  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
537  return e1;
538 }
539 
540 //
541 // Implementations of add that work for arithmetic or MaskedImage pixels
542 //
543 // The choice is made on the basis of std::is_arithmetic
544 namespace {
545 template <typename ExprT1, typename ExprT2>
546 ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
547  return e1 + e2;
548 }
549 
550 template <typename ExprT1, typename ExprT2>
551 BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
552  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
554 doPlus(ExprT1 e1, ExprT2 e2, double const alpha, boost::mpl::false_) {
555  return BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
556  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
558 }
559 }
560 
562 template <typename ExprT1, typename ExprT2>
563 inline ExprT1 plus(
564  ExprT1& lhs,
565  ExprT2 const& rhs,
566  float covariance
567  ) {
568  return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
569 }
570 
571 //------------------------------------------
573 template <typename ExprT1, typename ExprT2>
575  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
577 operator-(ExprT1 e1, ExprT2 e2) {
579  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
581 }
582 
584 template <typename ExprT1, typename ExprT2>
585 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
587  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
589  return e1;
590 }
591 
592 //------------------------------------------
594 template <typename ExprT1, typename ExprT2>
596  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
598 operator*(ExprT1 e1, ExprT2 e2) {
600  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
602 }
603 
605 template <typename ExprT1, typename ExprT2>
606 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
608  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
610  return e1;
611 }
612 
613 //------------------------------------------
615 template <typename ExprT1, typename ExprT2>
617  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
619 operator/(ExprT1 e1, ExprT2 e2) {
621  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
623 }
624 
626 template <typename ExprT1, typename ExprT2>
627 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
629  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
631  return e1;
632 }
633 
635 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
636 std::ostream& operator<<(std::ostream& os, SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
637  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
638 }
639 
641 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
642 std::ostream& operator<<(std::ostream& os, Pixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
643  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
644 }
645 
647 template <typename ExprT1, typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
648 std::ostream& operator<<(std::ostream& os, BinaryExpr<ExprT1, ExprT2, BinOp, MaskBinOp, VarBinOp> const& v) {
649  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
650 }
651 }
652 }
653 }
654 }
655 #endif
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:457
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:198
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:303
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:268
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:598
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:219
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:323
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:421
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:444
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:207
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:402
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:483
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:232
VariancePixelT variance() const
Definition: Pixel.h:94
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:305
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:424
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:585
T1 operator()(const T1 &x) const
Definition: Pixel.h:329
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:367
Pixel operator=(Pixel &&rhs)
Definition: Pixel.h:195
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:285
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:385
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:350
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:413
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:450
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:619
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:416
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:286
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:296
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:312
A base class for image defects.
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:373
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:383
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:217
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:563
T1 operator()(const T1 &x) const
Definition: Pixel.h:340
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:215
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:489
double x
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:250
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition: Pixel.h:187
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:441
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:606
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:627
_ImagePixelT ImagePixelT
Definition: Pixel.h:148
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:357
_VariancePixelT VariancePixelT
Definition: Pixel.h:150
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:460
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:313
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:396
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:414
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:259
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:427
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:499
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:322
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:173
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:339
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:440
T quiet_NaN(T... args)
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:454
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:399
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:166
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:493
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:496
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:321
Class for representing Unary operations.
Definition: Pixel.h:410
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:513
STL class.
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:287
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:525
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:533
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:412
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:328
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:314
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:226
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:442
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:304
_VariancePixelT VariancePixelT
Definition: Pixel.h:80
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:241