LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Pixel.h
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010 LSST Corporation.
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 <iostream>
28 #include <functional>
29 
30 namespace lsst { namespace afw { namespace image { namespace pixel {
31 
32 template <typename, typename, typename, typename, typename> class BinaryExpr;
33 
34 template <typename> struct exprTraits;
35 
36 template <typename> struct bitwise_or;
37 template <typename> struct variance_divides;
38 template <typename> struct variance_multiplies;
39 template <typename> struct variance_plus;
40 
41 /************************************************************************************************************/
61 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT=double>
64 public:
65  template<typename, typename, typename> friend class Pixel;
66  template<typename T> friend class PixelTypeTraits;
67 
68  typedef _ImagePixelT ImagePixelT;
69  typedef _MaskPixelT MaskPixelT;
70  typedef _VariancePixelT VariancePixelT;
71 
72  SinglePixel(double const image, int mask=0, double const variance=0) :
73  _image(image), _mask(mask), _variance(variance) {}
74  SinglePixel(int const image, int mask=0, double const variance=0) :
75  _image(image), _mask(mask), _variance(variance) {}
76 
77  template<typename rhsExpr>
78  SinglePixel(rhsExpr const& rhs) : _image(rhs.image()), _mask(rhs.mask()), _variance(rhs.variance()) {}
79 
80  ImagePixelT image() const { return _image; }
81  MaskPixelT mask() const { return _mask; }
82  VariancePixelT variance() const { return _variance; }
83 
84 private:
89  _image(std::numeric_limits<_ImagePixelT>::has_quiet_NaN ?
90  std::numeric_limits<_ImagePixelT>::quiet_NaN() : 0),
91  _mask(0),
92  _variance(std::numeric_limits<_VariancePixelT>::has_quiet_NaN ?
93  std::numeric_limits<_VariancePixelT>::quiet_NaN() : 0)
94  {}
95 
99 };
100 
102 template<typename PixelT>
104 {
106  static inline const PixelT padValue() {
107  return
108  std::numeric_limits<PixelT>::has_quiet_NaN ?
109  std::numeric_limits<PixelT>::quiet_NaN()
110  : 0;
111  }
112 };
113 
115 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT>
116 struct PixelTypeTraits<SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT> >
117 {
119 
121  static inline const PixelT padValue() {
122  return PixelT();
123  }
124 };
125 
130 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
131 SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v) {
133 }
134 
136 template<typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT=double>
138 public:
139  typedef _ImagePixelT ImagePixelT;
140  typedef _MaskPixelT MaskPixelT;
141  typedef _VariancePixelT VariancePixelT;
142 
144 #if 0
146  _image(image), _mask(mask), _variance(variance) {}
147 #else
148  //
149  // This constructor casts away const. This should be fixed by making const Pixels.
150  //
152  _image(const_cast<ImagePixelT&>(image)),
153  _mask(const_cast<MaskPixelT&>(mask)),
154  _variance(const_cast<VariancePixelT&>(variance)) {
155  }
156 #endif
157 
159  _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {}
160 
161  Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate operator=
162  _variance = rhs.variance(); // evaluate before we update image()
163  _image = rhs.image();
164  _mask = rhs.mask();
165 
166  return *this;
167  }
172  template<typename rhsExpr>
173  Pixel operator=(rhsExpr const& rhs) {
174  _variance = rhs.variance(); // evaluate before we update image()
175  _image = rhs.image();
176  _mask = rhs.mask();
177 
178  return *this;
179  }
180 
182  Pixel operator=(double const& rhs_image) {
183  _image = rhs_image;
184  _mask = 0;
185  _variance = 0;
186 
187  return *this;
188  }
189 
191  Pixel operator=(int const& rhs_image) {
192  _image = rhs_image;
193  _mask = 0;
194  _variance = 0;
195 
196  return *this;
197  }
199  ImagePixelT image() const { return _image; }
201  MaskPixelT mask() const { return _mask; }
203  VariancePixelT variance() const { return _variance; }
204  //
205  // Logical operators. We don't need to construct BinaryExpr for them
206  // as efficiency isn't a concern.
207  //
209  template<typename T1>
210  friend bool operator==(Pixel const& lhs, T1 const& rhs) {
211  return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
212  }
213 
215  template<typename T1>
216  friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
217  return !(lhs == rhs);
218  }
219 
220  //
221  // Provide friend versions of the op= operators to permit argument promotion on their first arguments
222  //
224  template<typename ExprT>
225  friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
226  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
227  tmp = BinaryExpr<Pixel, ExprT,
228  std::plus<ImagePixelT>, bitwise_or<MaskPixelT>, variance_plus<VariancePixelT> >(tmp, e2);
229  return tmp;
230  }
231 
233  template<typename ExprT>
234  friend Pixel operator-=(Pixel const& e1, ExprT const& e2) {
235  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
236  tmp = BinaryExpr<Pixel, ExprT,
237  std::minus<ImagePixelT>, bitwise_or<MaskPixelT>, variance_plus<VariancePixelT> >(tmp, e2);
238  return tmp;
239  }
240 
242  template<typename ExprT>
243  friend Pixel operator*=(Pixel const& e1, ExprT const& e2) {
244  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
245  tmp = BinaryExpr<Pixel, ExprT,
246  std::multiplies<ImagePixelT>, bitwise_or<MaskPixelT>, variance_multiplies<VariancePixelT> >(tmp, e2);
247  return tmp;
248  }
249 
251  template<typename ExprT>
252  friend Pixel operator/=(Pixel const& e1, ExprT const& e2) {
253  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
254  tmp = BinaryExpr<Pixel, ExprT,
255  std::divides<ImagePixelT>, bitwise_or<MaskPixelT>, variance_divides<VariancePixelT> >(tmp, e2);
256  return tmp;
257  }
258 
259 private:
263 };
264 
265 /************************************************************************************************************/
267 template <typename ExprT>
268 struct exprTraits {
269  typedef ExprT expr_type;
270  typedef typename ExprT::ImagePixelT ImagePixelT;
271  typedef typename ExprT::MaskPixelT MaskPixelT;
272  typedef typename ExprT::VariancePixelT VariancePixelT;
273 };
274 
276 template <>
277 struct exprTraits<double> {
278  typedef double ImagePixelT;
279  typedef int MaskPixelT;
280  typedef double VariancePixelT;
282 };
283 
285 template <>
286 struct exprTraits<float> {
287  typedef float ImagePixelT;
291 };
292 
294 template <>
295 struct exprTraits<int> {
296  typedef int ImagePixelT;
300 };
301 
303 template <>
304 struct exprTraits<unsigned short> {
305  typedef int ImagePixelT;
309 };
310 
311 /************************************************************************************************************/
315 template <typename T1>
316 struct noop : public std::unary_function<T1, T1> {
317  T1 operator()(const T1& x) const {
318  return x;
319  }
320 };
321 
328 template <typename T1>
329 struct bitwise_or : public std::binary_function<T1, T1, T1> {
330  T1 operator()(const T1& x, const T1& y) const {
331  return (x | y);
332  }
333  T1 operator()(const T1& x) const {
334  return x;
335  }
336 };
337 
344 template <typename T1>
345 struct variance_divides {
346  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
347  T1 const x2 = x*x;
348  T1 const y2 = y*y;
349  T1 const iy2 = 1.0/y2;
350  return x2*vy*iy2*iy2 + vx*iy2;
351  }
352 
353  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const {
354  return vx/(y*y);
355  }
356 };
363 template <typename T1>
364 struct variance_multiplies {
365  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
366  T1 const x2 = x*x;
367  T1 const y2 = y*y;
368  return x2*vy + y2*vx;
369  }
370 
371  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const {
372  return vx*y*y;
373  }
374 };
381 template <typename T1>
382 struct variance_plus {
383  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
384  return vx + vy;
385  }
386 
387  T1 operator()(T1 const&, T1 const&, T1 const& vx) const {
388  return vx;
389  }
390 };
399 template <typename T1>
402 
403  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
404  return vx + vy + 2*_alpha*sqrt(vx*vy);
405  }
406  T1 operator()(T1 const&, T1 const&, T1 const& vx) const {
407  return vx;
408  }
409 private:
410  double _alpha;
411 };
412 
413 /************************************************************************************************************/
415 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
416 class UnaryExpr {
417 public:
422  UnaryExpr(ExprT1 e1,
423  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
424  _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
425 
427  ImagePixelT image() const {
428  return _imageOp(_expr1.image());
429  }
430 
432  MaskPixelT mask() const {
433  return _maskOp(_expr1.mask());
434  }
435 
438  return _varOp(_expr1.variance());
439  }
440 private:
442  ImageBinOp _imageOp;
443  MaskBinOp _maskOp;
444  VarianceBinOp _varOp;
445 };
446 
448 template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
449 class BinaryExpr {
450 public:
455  BinaryExpr(ExprT1 e1, ExprT2 e2,
456  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
457  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
458 
460  BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha,
461  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp =VarianceBinOp()) :
462  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
464  ImagePixelT image() const {
465  return _imageOp(_expr1.image(), _expr2.image());
466  }
467 
469  MaskPixelT mask() const {
470  return _maskOp(_expr1.mask(), _expr2.mask());
471  }
472 
475  return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
476  }
477 private:
480  ImageBinOp _imageOp;
481  MaskBinOp _maskOp;
482  VarianceBinOp _varOp;
483 };
484 
488 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
489 class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> {
490 public:
495  BinaryExpr(ExprT1 e1, double e2,
496  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp varOp=VarianceBinOp()) :
497  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
498 
500  BinaryExpr(ExprT1 e1, double e2, double const alpha,
501  ImageBinOp imageOp=ImageBinOp(), MaskBinOp maskOp=MaskBinOp(), VarianceBinOp=VarianceBinOp()) :
502  _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
504  ImagePixelT image() const {
505  return _imageOp(_expr1.image(), _expr2);
506  }
507 
509  MaskPixelT mask() const {
510  return _maskOp(_expr1.mask());
511  }
512 
515  return _varOp(_expr1.image(), _expr2, _expr1.variance());
516  }
517 private:
519  double _expr2;
520  ImageBinOp _imageOp;
521  MaskBinOp _maskOp;
522  VarianceBinOp _varOp;
523 };
524 
525 /************************************************************************************************************/
527 template <typename ExprT1>
528 UnaryExpr<ExprT1,
529  std::negate<typename exprTraits<ExprT1>::ImagePixelT>,
532  return UnaryExpr<ExprT1,
533  std::negate<typename exprTraits<ExprT1>::ImagePixelT>,
536 }
537 
538 //------------------------------------------
540 template <typename ExprT1,typename ExprT2>
541 BinaryExpr<ExprT1, ExprT2,
542  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
543  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
545  return BinaryExpr<ExprT1, ExprT2,
546  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
549 }
550 
552 template <typename ExprT1,typename ExprT2>
553 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
554  e1 = BinaryExpr<ExprT1, ExprT2,
555  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
558  return e1;
559 }
560 
561 //
562 // Implementations of add that work for arithmetic or MaskedImage pixels
563 //
564 // The choice is made on the basis of boost::is_arithmetic
565 namespace {
566  template <typename ExprT1,typename ExprT2>
567  ExprT1 doPlus(ExprT1 e1, ExprT2 e2,
568  double const,
569  boost::mpl::true_) {
570  return e1 + e2;
571  }
572 
573  template <typename ExprT1,typename ExprT2>
574  BinaryExpr<ExprT1, ExprT2,
575  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
576  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
577  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> > doPlus(ExprT1 e1, ExprT2 e2,
578  double const alpha,
579  boost::mpl::false_) {
580  return BinaryExpr<ExprT1, ExprT2,
581  std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
582  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
583  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >(e1, e2, alpha);
584  }
585 }
586 
588 template<typename ExprT1, typename ExprT2>
589 inline ExprT1 plus(ExprT1& lhs,
590  ExprT2 const& rhs,
591  float covariance
592  ) {
593  return doPlus(lhs, rhs, covariance, typename boost::is_arithmetic<ExprT1>::type());
594 }
595 
596 //------------------------------------------
598 template <typename ExprT1,typename ExprT2>
599 BinaryExpr<ExprT1, ExprT2,
600  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
601  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
603  return BinaryExpr<ExprT1, ExprT2,
604  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
607 }
608 
610 template <typename ExprT1,typename ExprT2>
611 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
612  e1 = BinaryExpr<ExprT1, ExprT2,
613  std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
616  return e1;
617 }
618 
619 //------------------------------------------
621 template <typename ExprT1,typename ExprT2>
622 BinaryExpr<ExprT1, ExprT2,
623  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
624  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
626  return BinaryExpr<ExprT1, ExprT2,
627  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
630 }
631 
633 template <typename ExprT1,typename ExprT2>
634 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
635  e1 = BinaryExpr<ExprT1, ExprT2,
636  std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
639  return e1;
640 }
641 
642 //------------------------------------------
644 template <typename ExprT1,typename ExprT2>
645 BinaryExpr<ExprT1, ExprT2,
646  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
647  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
649  return BinaryExpr<ExprT1, ExprT2,
650  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
653 }
654 
656 template <typename ExprT1,typename ExprT2>
657 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
658  e1 = BinaryExpr<ExprT1, ExprT2,
659  std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
662  return e1;
663 }
664 
665 /************************************************************************************************************/
667 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
668 std::ostream& operator<<(std::ostream &os, SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
669  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
670 }
671 
673 template<typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
674 std::ostream& operator<<(std::ostream &os, Pixel<ImagePixelT, MaskPixelT, VariancePixelT> const& v) {
675  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
676 }
677 
679 template <typename ExprT1,typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
680 std::ostream& operator<<(std::ostream &os, BinaryExpr<ExprT1, ExprT2, BinOp, MaskBinOp, VarBinOp> const& v) {
681  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
682 }
683 
684 }}}}
685 #endif
int y
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:203
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:182
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:288
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:252
Class for representing binary operations.
Definition: Pixel.h:32
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Definition: Pixel.h:131
bitwise_or doesn&#39;t seem to be in std::
Definition: Pixel.h:36
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:625
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:469
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:308
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:460
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:452
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:427
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:191
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:353
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:495
VariancePixelT variance() const
Definition: Pixel.h:82
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:216
SinglePixel(double const image, int mask=0, double const variance=0)
Definition: Pixel.h:72
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:504
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:406
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:290
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:151
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:611
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:514
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:387
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:63
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:201
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:455
exprTraits< ExprT1 >::expr_type _expr1
Definition: Pixel.h:441
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:464
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:419
MaskPixelT mask() const
Definition: Pixel.h:81
int const x0
Definition: saturated.cc:45
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:270
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:648
ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:271
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:432
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:453
exprTraits< ExprT1 >::expr_type _expr1
Definition: Pixel.h:478
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:422
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:121
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:437
exprTraits< ExprT2 >::expr_type _expr2
Definition: Pixel.h:479
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:383
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:281
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:297
Calculate the variance when we divide two Pixels.
Definition: Pixel.h:37
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:346
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:589
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:199
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:365
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:500
double x
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:234
Pixel operator=(rhsExpr const &rhs)
Definition: Pixel.h:173
ImagePixelT image() const
Definition: Pixel.h:80
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:509
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:634
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:657
_ImagePixelT ImagePixelT
Definition: Pixel.h:139
_VariancePixelT VariancePixelT
Definition: Pixel.h:141
A pixel of a MaskedImage.
Definition: Pixel.h:137
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:298
tuple m
Definition: lsstimport.py:48
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:400
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:420
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:371
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:243
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:330
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:451
SinglePixel(rhsExpr const &rhs)
Definition: Pixel.h:78
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:307
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:272
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:161
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:474
T1 operator()(const T1 &x) const
Definition: Pixel.h:317
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:34
table::PointKey< int > pixel
SinglePixel(int const image, int mask=0, double const variance=0)
Definition: Pixel.h:74
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:403
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:158
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:306
Class for representing Unary operations.
Definition: Pixel.h:416
Calculate the variance when we multiply two Pixels.
Definition: Pixel.h:38
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:531
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:544
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:106
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:553
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:418
Calculate the variance when we add (or subtract) two Pixels.
Definition: Pixel.h:39
VariancePixelT & _variance
Definition: Pixel.h:262
A noop functor (useful for e.g. masks and variances when changing the sign of the image) ...
Definition: Pixel.h:316
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:299
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:210
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:289
_VariancePixelT VariancePixelT
Definition: Pixel.h:70
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:225
T1 operator()(const T1 &x) const
Definition: Pixel.h:333