LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
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 { namespace afw { namespace image { namespace pixel {
32 
33 template <typename, typename, typename, typename, typename> class BinaryExpr;
34 
35 template <typename> struct exprTraits;
36 
37 template <typename> struct bitwise_or;
38 template <typename> struct variance_divides;
39 template <typename> struct variance_multiplies;
40 template <typename> struct variance_plus;
41 
42 /************************************************************************************************************/
62 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT=double>
65 public:
66  template<typename, typename, typename> friend class Pixel;
67  template<typename T> friend class PixelTypeTraits;
68 
69  typedef _ImagePixelT ImagePixelT;
70  typedef _MaskPixelT MaskPixelT;
71  typedef _VariancePixelT VariancePixelT;
72 
73  SinglePixel(double const image, int mask=0, double const variance=0) :
74  _image(image), _mask(mask), _variance(variance) {}
75  SinglePixel(int const image, int mask=0, double const variance=0) :
76  _image(image), _mask(mask), _variance(variance) {}
77 
78  template<typename rhsExpr>
79  SinglePixel(rhsExpr const& rhs) : _image(rhs.image()), _mask(rhs.mask()), _variance(rhs.variance()) {}
80 
81  ImagePixelT image() const { return _image; }
82  MaskPixelT mask() const { return _mask; }
83  VariancePixelT variance() const { return _variance; }
84 
85 private:
90  _image(std::numeric_limits<_ImagePixelT>::has_quiet_NaN ?
91  std::numeric_limits<_ImagePixelT>::quiet_NaN() : 0),
92  _mask(0),
93  _variance(std::numeric_limits<_VariancePixelT>::has_quiet_NaN ?
94  std::numeric_limits<_VariancePixelT>::quiet_NaN() : 0)
95  {}
96 
100 };
101 
103 template<typename PixelT>
105 {
107  static inline const PixelT padValue() {
108  return
109  std::numeric_limits<PixelT>::has_quiet_NaN ?
110  std::numeric_limits<PixelT>::quiet_NaN()
111  : 0;
112  }
113 };
114 
116 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT>
117 struct PixelTypeTraits<SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT> >
118 {
120 
122  static inline const PixelT padValue() {
123  return PixelT();
124  }
125 };
126 
131 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
132 SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v) {
134 }
135 
137 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT=double>
139 public:
140  typedef _ImagePixelT ImagePixelT;
141  typedef _MaskPixelT MaskPixelT;
142  typedef _VariancePixelT VariancePixelT;
143 
145 #if 0
147  _image(image), _mask(mask), _variance(variance) {}
148 #else
149  //
150  // This constructor casts away const. This should be fixed by making const Pixels.
151  //
153  _image(const_cast<ImagePixelT&>(image)),
154  _mask(const_cast<MaskPixelT&>(mask)),
155  _variance(const_cast<VariancePixelT&>(variance)) {
156  }
157 #endif
158 
160  _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {}
161 
162  Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate operator=
163  _variance = rhs.variance(); // evaluate before we update image()
164  _image = rhs.image();
165  _mask = rhs.mask();
166 
167  return *this;
168  }
173  template<typename rhsExpr>
174  Pixel operator=(rhsExpr const& rhs) {
175  _variance = rhs.variance(); // evaluate before we update image()
176  _image = rhs.image();
177  _mask = rhs.mask();
178 
179  return *this;
180  }
181 
183  Pixel operator=(double const& rhs_image) {
184  _image = rhs_image;
185  _mask = 0;
186  _variance = 0;
187 
188  return *this;
189  }
190 
192  Pixel operator=(int const& rhs_image) {
193  _image = rhs_image;
194  _mask = 0;
195  _variance = 0;
196 
197  return *this;
198  }
200  ImagePixelT image() const { return _image; }
202  MaskPixelT mask() const { return _mask; }
204  VariancePixelT variance() const { return _variance; }
205  //
206  // Logical operators. We don't need to construct BinaryExpr for them
207  // as efficiency isn't a concern.
208  //
210  template<typename T1>
211  friend bool operator==(Pixel const& lhs, T1 const& rhs) {
212  return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
213  }
214 
216  template<typename T1>
217  friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
218  return !(lhs == rhs);
219  }
220 
221  //
222  // Provide friend versions of the op= operators to permit argument promotion on their first arguments
223  //
225  template<typename ExprT>
226  friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
227  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
228  tmp = BinaryExpr<Pixel, ExprT,
229  std::plus<ImagePixelT>, bitwise_or<MaskPixelT>, variance_plus<VariancePixelT> >(tmp, e2);
230  return tmp;
231  }
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)
237  tmp = BinaryExpr<Pixel, ExprT,
238  std::minus<ImagePixelT>, bitwise_or<MaskPixelT>, variance_plus<VariancePixelT> >(tmp, e2);
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)
246  tmp = BinaryExpr<Pixel, ExprT,
247  std::multiplies<ImagePixelT>, bitwise_or<MaskPixelT>, variance_multiplies<VariancePixelT> >(tmp, e2);
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)
255  tmp = BinaryExpr<Pixel, ExprT,
256  std::divides<ImagePixelT>, bitwise_or<MaskPixelT>, variance_divides<VariancePixelT> >(tmp, e2);
257  return tmp;
258  }
259 
260 private:
264 };
265 
266 /************************************************************************************************************/
268 template <typename ExprT>
269 struct exprTraits {
270  typedef ExprT expr_type;
271  typedef typename ExprT::ImagePixelT ImagePixelT;
272  typedef typename ExprT::MaskPixelT MaskPixelT;
273  typedef typename ExprT::VariancePixelT VariancePixelT;
274 };
275 
277 template <>
278 struct exprTraits<double> {
279  typedef double ImagePixelT;
280  typedef int MaskPixelT;
281  typedef double VariancePixelT;
283 };
284 
286 template <>
287 struct exprTraits<float> {
288  typedef float ImagePixelT;
292 };
293 
295 template <>
296 struct exprTraits<int> {
297  typedef int ImagePixelT;
301 };
302 
304 template <>
305 struct exprTraits<unsigned short> {
306  typedef int ImagePixelT;
310 };
311 
312 /************************************************************************************************************/
316 template <typename T1>
317 struct noop : public std::unary_function<T1, T1> {
318  T1 operator()(const T1& x) const {
319  return x;
320  }
321 };
322 
329 template <typename T1>
330 struct bitwise_or : public std::binary_function<T1, T1, T1> {
331  T1 operator()(const T1& x, const T1& y) const {
332  return (x | y);
333  }
334  T1 operator()(const T1& x) const {
335  return x;
336  }
337 };
338 
345 template <typename T1>
346 struct variance_divides {
347  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
348  T1 const x2 = x*x;
349  T1 const y2 = y*y;
350  T1 const iy2 = 1.0/y2;
351  return x2*vy*iy2*iy2 + vx*iy2;
352  }
353 
354  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const {
355  return vx/(y*y);
356  }
357 };
364 template <typename T1>
365 struct variance_multiplies {
366  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
367  T1 const x2 = x*x;
368  T1 const y2 = y*y;
369  return x2*vy + y2*vx;
370  }
371 
372  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const {
373  return vx*y*y;
374  }
375 };
382 template <typename T1>
383 struct variance_plus {
384  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
385  return vx + vy;
386  }
387 
388  T1 operator()(T1 const&, T1 const&, T1 const& vx) const {
389  return vx;
390  }
391 };
400 template <typename T1>
403 
404  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
405  return vx + vy + 2*_alpha*sqrt(vx*vy);
406  }
407  T1 operator()(T1 const&, T1 const&, T1 const& vx) const {
408  return vx;
409  }
410 private:
411  double _alpha;
412 };
413 
414 /************************************************************************************************************/
416 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
417 class UnaryExpr {
418 public:
423  UnaryExpr(ExprT1 e1,
424  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
425  _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
426 
428  ImagePixelT image() const {
429  return _imageOp(_expr1.image());
430  }
431 
433  MaskPixelT mask() const {
434  return _maskOp(_expr1.mask());
435  }
436 
439  return _varOp(_expr1.variance());
440  }
441 private:
443  ImageBinOp _imageOp;
444  MaskBinOp _maskOp;
445  VarianceBinOp _varOp;
446 };
447 
449 template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
450 class BinaryExpr {
451 public:
456  BinaryExpr(ExprT1 e1, ExprT2 e2,
457  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
458  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
459 
461  BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha,
462  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp =VarianceBinOp()) :
463  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
465  ImagePixelT image() const {
466  return _imageOp(_expr1.image(), _expr2.image());
467  }
468 
470  MaskPixelT mask() const {
471  return _maskOp(_expr1.mask(), _expr2.mask());
472  }
473 
476  return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
477  }
478 private:
481  ImageBinOp _imageOp;
482  MaskBinOp _maskOp;
483  VarianceBinOp _varOp;
484 };
485 
489 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
490 class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> {
491 public:
496  BinaryExpr(ExprT1 e1, double e2,
497  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
498  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
499 
501  BinaryExpr(ExprT1 e1, double e2, double const alpha,
502  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp=VarianceBinOp()) :
503  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
505  ImagePixelT image() const {
506  return _imageOp(_expr1.image(), _expr2);
507  }
508 
510  MaskPixelT mask() const {
511  return _maskOp(_expr1.mask());
512  }
513 
516  return _varOp(_expr1.image(), _expr2, _expr1.variance());
517  }
518 private:
520  double _expr2;
521  ImageBinOp _imageOp;
522  MaskBinOp _maskOp;
523  VarianceBinOp _varOp;
524 };
525 
526 /************************************************************************************************************/
528 template <typename ExprT1>
529 UnaryExpr<ExprT1,
530  std::negate<typename exprTraits<ExprT1>::ImagePixelT>,
533  return UnaryExpr<ExprT1,
534  std::negate<typename exprTraits<ExprT1>::ImagePixelT>,
537 }
538 
539 //------------------------------------------
541 template <typename ExprT1,typename ExprT2>
542 BinaryExpr<ExprT1, ExprT2,
543  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
544  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
546  return BinaryExpr<ExprT1, ExprT2,
547  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
550 }
551 
553 template <typename ExprT1,typename ExprT2>
554 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
555  e1 = BinaryExpr<ExprT1, ExprT2,
556  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
559  return e1;
560 }
561 
562 //
563 // Implementations of add that work for arithmetic or MaskedImage pixels
564 //
565 // The choice is made on the basis of std::is_arithmetic
566 namespace {
567  template <typename ExprT1,typename ExprT2>
568  ExprT1 doPlus(ExprT1 e1, ExprT2 e2,
569  double const,
570  boost::mpl::true_) {
571  return e1 + e2;
572  }
573 
574  template <typename ExprT1,typename ExprT2>
575  BinaryExpr<ExprT1, ExprT2,
576  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
577  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
578  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> > doPlus(ExprT1 e1, ExprT2 e2,
579  double const alpha,
580  boost::mpl::false_) {
581  return BinaryExpr<ExprT1, ExprT2,
582  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
583  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
584  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >(e1, e2, alpha);
585  }
586 }
587 
589 template<typename ExprT1, typename ExprT2>
590 inline ExprT1 plus(ExprT1& lhs,
591  ExprT2 const& rhs,
592  float covariance
593  ) {
594  return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
595 }
596 
597 //------------------------------------------
599 template <typename ExprT1,typename ExprT2>
600 BinaryExpr<ExprT1, ExprT2,
601  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
602  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
604  return BinaryExpr<ExprT1, ExprT2,
605  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
608 }
609 
611 template <typename ExprT1,typename ExprT2>
612 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
613  e1 = BinaryExpr<ExprT1, ExprT2,
614  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
617  return e1;
618 }
619 
620 //------------------------------------------
622 template <typename ExprT1,typename ExprT2>
623 BinaryExpr<ExprT1, ExprT2,
624  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
625  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
627  return BinaryExpr<ExprT1, ExprT2,
628  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
631 }
632 
634 template <typename ExprT1,typename ExprT2>
635 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
636  e1 = BinaryExpr<ExprT1, ExprT2,
637  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
640  return e1;
641 }
642 
643 //------------------------------------------
645 template <typename ExprT1,typename ExprT2>
646 BinaryExpr<ExprT1, ExprT2,
647  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
648  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
650  return BinaryExpr<ExprT1, ExprT2,
651  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
654 }
655 
657 template <typename ExprT1,typename ExprT2>
658 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
659  e1 = BinaryExpr<ExprT1, ExprT2,
660  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
663  return e1;
664 }
665 
666 /************************************************************************************************************/
668 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
669 std::ostream& operator<<(std::ostream &os, SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
670  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
671 }
672 
674 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
675 std::ostream& operator<<(std::ostream &os, Pixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
676  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
677 }
678 
680 template <typename ExprT1,typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
681 std::ostream& operator<<(std::ostream &os, BinaryExpr<ExprT1, ExprT2, BinOp, MaskBinOp, VarBinOp> const& v) {
682  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
683 }
684 
685 }}}}
686 #endif
int y
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:204
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:183
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:289
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:253
Class for representing binary operations.
Definition: Pixel.h:33
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition: Pixel.h:132
bitwise_or doesn&#39;t seem to be in std::
Definition: Pixel.h:37
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:626
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:470
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:309
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:461
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:453
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:428
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:192
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:354
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:496
VariancePixelT variance() const
Definition: Pixel.h:83
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:217
SinglePixel(double const image, int mask=0, double const variance=0)
Definition: Pixel.h:73
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:505
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:407
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:291
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:152
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:612
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:515
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:388
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:64
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:202
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:456
exprTraits< ExprT1 >::expr_type _expr1
Definition: Pixel.h:442
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:465
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:420
MaskPixelT mask() const
Definition: Pixel.h:82
int const x0
Definition: saturated.cc:45
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:271
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:649
ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:272
Matrix alpha
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:433
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:454
exprTraits< ExprT1 >::expr_type _expr1
Definition: Pixel.h:479
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:423
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:122
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:438
exprTraits< ExprT2 >::expr_type _expr2
Definition: Pixel.h:480
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:384
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:282
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:298
Calculate the variance when we divide two Pixels.
Definition: Pixel.h:38
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:347
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:590
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:200
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:366
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:501
double x
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:235
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition: Pixel.h:174
ImagePixelT image() const
Definition: Pixel.h:81
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:510
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:635
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:658
_ImagePixelT ImagePixelT
Definition: Pixel.h:140
_VariancePixelT VariancePixelT
Definition: Pixel.h:142
A pixel of a MaskedImage.
Definition: Pixel.h:138
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:299
tuple m
Definition: lsstimport.py:48
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:401
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:421
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:372
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:244
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:331
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:452
SinglePixel(rhsExpr const &rhs)
Definition: Pixel.h:79
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:308
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:273
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:162
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:475
T1 operator()(const T1 &x) const
Definition: Pixel.h:318
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:35
table::PointKey< int > pixel
SinglePixel(int const image, int mask=0, double const variance=0)
Definition: Pixel.h:75
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:404
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:159
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:307
Class for representing Unary operations.
Definition: Pixel.h:417
Calculate the variance when we multiply two Pixels.
Definition: Pixel.h:39
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:56
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:532
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:545
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:107
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:554
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:419
Calculate the variance when we add (or subtract) two Pixels.
Definition: Pixel.h:40
VariancePixelT & _variance
Definition: Pixel.h:263
A noop functor (useful for e.g.
Definition: Pixel.h:317
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:300
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:211
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:290
_VariancePixelT VariancePixelT
Definition: Pixel.h:71
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:226
T1 operator()(const T1 &x) const
Definition: Pixel.h:334