LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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 #include "lsst/utils/hashCombine.h"
32 
33 namespace lsst {
34 namespace afw {
35 namespace image {
36 namespace pixel {
37 
38 template <typename, typename, typename, typename, typename>
39 class BinaryExpr;
40 
41 template <typename>
42 struct exprTraits;
43 
44 template <typename>
45 struct bitwise_or;
46 template <typename>
48 template <typename>
50 template <typename>
52 
53 /*
54  * Classes to provide utility functions for a "Pixel" to get at image/mask/variance operators
55  *
56  * These classes allow us to manipulate the tuples returned by MaskedImage iterators/locators as if they were
57  * POD. This provides convenient syntactic sugar, but it also permits us to write generic algorithms to
58  * manipulate MaskedImages as well as Images
59  *
60  * We need SinglePixel as well as Pixel as the latter is just a reference to a pixel in an image, and we need
61  * to be able to build temporary values too
62  *
63  * We use C++ template expressions to manipulate Pixel and SinglePixel; this permits us to avoid making
64  * SinglePixel inherit from Pixel (or vice versa) and allows the compiler to do a much better job of
65  * optimising mixed-mode expressions --- basically, it no longer needs to create SinglePixels as Pixels that
66  * have their own storage but use the reference members of Pixel to get work done. There may be better ways,
67  * but this way works, and g++ 4.0.1 (and maybe other compilers/versions) failed to optimise the previous
68  * solution very well.
69  */
70 
72 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
74 public:
75  template <typename, typename, typename>
76  friend class Pixel;
77  template <typename T>
78  friend class PixelTypeTraits;
79 
80  typedef _ImagePixelT ImagePixelT;
81  typedef _MaskPixelT MaskPixelT;
82  typedef _VariancePixelT VariancePixelT;
83 
85  : _image(image), _mask(mask), _variance(variance) {}
86 
87  template <typename rhsExpr>
88  SinglePixel(rhsExpr const& rhs,
89  // ensure this ctor isn't invoked for simple numeric types, which should use
90  // the overload above.
91  typename std::enable_if<!std::is_fundamental<rhsExpr>::value, void*>::type dummy = nullptr)
92  : _image(rhs.image()), _mask(rhs.mask()), _variance(rhs.variance()) {}
93 
94  ImagePixelT image() const { return _image; }
95  MaskPixelT mask() const { return _mask; }
96  VariancePixelT variance() const { return _variance; }
97 
98 private:
103  SinglePixel()
104  : _image(std::numeric_limits<_ImagePixelT>::has_quiet_NaN
105  ? std::numeric_limits<_ImagePixelT>::quiet_NaN()
106  : 0),
107  _mask(0),
108  _variance(std::numeric_limits<_VariancePixelT>::has_quiet_NaN
109  ? std::numeric_limits<_VariancePixelT>::quiet_NaN()
110  : 0) {}
111 
112  ImagePixelT _image;
113  MaskPixelT _mask;
114  VariancePixelT _variance;
115 };
116 
118 template <typename PixelT>
121  static inline const PixelT padValue() {
123  }
124 };
125 
127 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT>
128 struct PixelTypeTraits<SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT> > {
130 
132  static inline const PixelT padValue() { return PixelT(); }
133 };
134 
140 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
142  VariancePixelT v) {
144 }
145 
147 template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
149 public:
150  typedef _ImagePixelT ImagePixelT;
151  typedef _MaskPixelT MaskPixelT;
152  typedef _VariancePixelT VariancePixelT;
153 
155 #if 0
157  _image(image), _mask(mask), _variance(variance) {}
158 #else
159  //
160  // This constructor casts away const. This should be fixed by making const Pixels.
161  //
162  Pixel(ImagePixelT const& image, MaskPixelT const& mask = 0x0, VariancePixelT const& variance = 0)
163  : _image(const_cast<ImagePixelT&>(image)),
164  _mask(const_cast<MaskPixelT&>(mask)),
165  _variance(const_cast<VariancePixelT&>(variance)) {}
166 #endif
167 
169  : _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {}
170 
171  Pixel(Pixel const& rhs) = default;
172  Pixel(Pixel&& rhs) = default;
173  ~Pixel() = default;
174 
175  Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate
176  // operator=
177  _variance = rhs.variance(); // evaluate before we update image()
178  _image = rhs.image();
179  _mask = rhs.mask();
180 
181  return *this;
182  }
188  template <typename rhsExpr>
189  Pixel operator=(rhsExpr const& rhs) {
190  _variance = rhs.variance(); // evaluate before we update image()
191  _image = rhs.image();
192  _mask = rhs.mask();
193 
194  return *this;
195  }
196  // Delegate to copy-assignment for backwards compatibility
197  Pixel operator=(Pixel&& rhs) { return *this = rhs; }
198 
200  Pixel operator=(double const& rhs_image) {
201  _image = rhs_image;
202  _mask = 0;
203  _variance = 0;
204 
205  return *this;
206  }
207 
209  Pixel operator=(int const& rhs_image) {
210  _image = rhs_image;
211  _mask = 0;
212  _variance = 0;
213 
214  return *this;
215  }
217  ImagePixelT image() const { return _image; }
219  MaskPixelT mask() const { return _mask; }
221  VariancePixelT variance() const { return _variance; }
222  //
223  // Logical operators. We don't need to construct BinaryExpr for them
224  // as efficiency isn't a concern.
225  //
227  template <typename T1>
228  friend bool operator==(Pixel const& lhs, T1 const& rhs) {
229  return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
230  }
231 
233  template <typename T1>
234  friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
235  return !(lhs == rhs);
236  }
237 
239  std::size_t hash_value() const noexcept {
240  // Completely arbitrary seed
241  // Convert to double to avoid inconsistently hashing equal numbers of different types
242  return utils::hashCombine(17, static_cast<double>(image()), static_cast<double>(mask()),
243  static_cast<double>(variance()));
244  }
245 
246  //
247  // Provide friend versions of the op= operators to permit argument promotion on their first arguments
248  //
250  template <typename ExprT>
251  friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
252  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
255  return tmp;
256  }
257 
259  template <typename ExprT>
260  friend Pixel operator-=(Pixel const& e1, ExprT const& e2) {
261  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
264  return tmp;
265  }
266 
268  template <typename ExprT>
269  friend Pixel operator*=(Pixel const& e1, ExprT const& e2) {
270  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
273  return tmp;
274  }
275 
277  template <typename ExprT>
278  friend Pixel operator/=(Pixel const& e1, ExprT const& e2) {
279  Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
282  return tmp;
283  }
284 
285 private:
286  ImagePixelT& _image;
287  MaskPixelT& _mask;
288  VariancePixelT& _variance;
289 };
290 
292 template <typename ExprT>
293 struct exprTraits {
294  typedef ExprT expr_type;
295  typedef typename ExprT::ImagePixelT ImagePixelT;
296  typedef typename ExprT::MaskPixelT MaskPixelT;
297  typedef typename ExprT::VariancePixelT VariancePixelT;
298 };
299 
301 template <>
302 struct exprTraits<double> {
303  typedef double ImagePixelT;
304  typedef int MaskPixelT;
305  typedef double VariancePixelT;
307 };
308 
310 template <>
311 struct exprTraits<float> {
312  typedef float ImagePixelT;
316 };
317 
319 template <>
320 struct exprTraits<int> {
321  typedef int ImagePixelT;
325 };
326 
328 template <>
329 struct exprTraits<unsigned short> {
330  typedef int ImagePixelT;
334 };
335 
337 template <typename T1>
338 struct noop : public std::unary_function<T1, T1> {
339  T1 operator()(const T1& x) const { return x; }
340 };
341 
347 template <typename T1>
348 struct bitwise_or : public std::binary_function<T1, T1, T1> {
349  T1 operator()(const T1& x, const T1& y) const { return (x | y); }
350  T1 operator()(const T1& x) const { return x; }
351 };
352 
358 template <typename T1>
359 struct variance_divides {
360  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
361  T1 const x2 = x * x;
362  T1 const y2 = y * y;
363  T1 const iy2 = 1.0 / y2;
364  return x2 * vy * iy2 * iy2 + vx * iy2;
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_multiplies {
377  T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
378  T1 const x2 = x * x;
379  T1 const y2 = y * y;
380  return x2 * vy + y2 * vx;
381  }
382 
383  T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx * y * y; }
384 };
385 
391 template <typename T1>
392 struct variance_plus {
393  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const { return vx + vy; }
394 
395  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
396 };
397 
405 template <typename T1>
407  variance_plus_covar(double alpha = 0) : _alpha(alpha) {}
408 
409  T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const {
410  return vx + vy + 2 * _alpha * sqrt(vx * vy);
411  }
412  T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
413 
414 private:
415  double _alpha;
416 };
417 
419 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
420 class UnaryExpr {
421 public:
426  UnaryExpr(ExprT1 e1, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
427  VarianceBinOp varOp = VarianceBinOp())
428  : _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
429 
431  ImagePixelT image() const { return _imageOp(_expr1.image()); }
432 
434  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
435 
437  VariancePixelT variance() const { return _varOp(_expr1.variance()); }
438 
439 private:
440  typename exprTraits<ExprT1>::expr_type _expr1;
441  ImageBinOp _imageOp;
442  MaskBinOp _maskOp;
443  VarianceBinOp _varOp;
444 };
445 
447 template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
448 class BinaryExpr final {
449 public:
454  BinaryExpr(ExprT1 e1, ExprT2 e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
455  VarianceBinOp varOp = VarianceBinOp())
456  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
457 
460  BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
461  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
462  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
464  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2.image()); }
465 
467  MaskPixelT mask() const { return _maskOp(_expr1.mask(), _expr2.mask()); }
468 
471  return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
472  }
473 
474 private:
475  typename exprTraits<ExprT1>::expr_type _expr1;
476  typename exprTraits<ExprT2>::expr_type _expr2;
477  ImageBinOp _imageOp;
478  MaskBinOp _maskOp;
479  VarianceBinOp _varOp;
480 };
481 
486 template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
487 class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> final {
488 public:
493  BinaryExpr(ExprT1 e1, double e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
494  VarianceBinOp varOp = VarianceBinOp())
495  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
496 
499  BinaryExpr(ExprT1 e1, double e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
500  MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
501  : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
503  ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2); }
504 
506  MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
507 
509  VariancePixelT variance() const { return _varOp(_expr1.image(), _expr2, _expr1.variance()); }
510 
511 private:
512  typename exprTraits<ExprT1>::expr_type _expr1;
513  double _expr2;
514  ImageBinOp _imageOp;
515  MaskBinOp _maskOp;
516  VarianceBinOp _varOp;
517 };
518 
520 template <typename ExprT1>
522  noop<typename exprTraits<ExprT1>::MaskPixelT>, noop<typename exprTraits<ExprT1>::VariancePixelT> >
523 operator-(ExprT1 e1) {
527 }
528 
529 //------------------------------------------
531 template <typename ExprT1, typename ExprT2>
533  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
534  variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
535 operator+(ExprT1 e1, ExprT2 e2) {
539 }
540 
542 template <typename ExprT1, typename ExprT2>
543 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
547  return e1;
548 }
549 
550 //
551 // Implementations of add that work for arithmetic or MaskedImage pixels
552 //
553 // The choice is made on the basis of std::is_arithmetic
554 namespace {
555 template <typename ExprT1, typename ExprT2>
556 ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
557  return e1 + e2;
558 }
559 
560 template <typename ExprT1, typename ExprT2>
562  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
563  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >
564 doPlus(ExprT1 e1, ExprT2 e2, double const alpha, boost::mpl::false_) {
566  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
567  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >(e1, e2, alpha);
568 }
569 } // namespace
570 
572 template <typename ExprT1, typename ExprT2>
573 inline ExprT1 plus(
574  ExprT1& lhs,
575  ExprT2 const& rhs,
576  float covariance
577 ) {
578  return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
579 }
580 
581 //------------------------------------------
583 template <typename ExprT1, typename ExprT2>
585  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
586  variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
587 operator-(ExprT1 e1, ExprT2 e2) {
591 }
592 
594 template <typename ExprT1, typename ExprT2>
595 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
599  return e1;
600 }
601 
602 //------------------------------------------
604 template <typename ExprT1, typename ExprT2>
606  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
607  variance_multiplies<typename exprTraits<ExprT1>::VariancePixelT> >
608 operator*(ExprT1 e1, ExprT2 e2) {
612 }
613 
615 template <typename ExprT1, typename ExprT2>
616 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
620  return e1;
621 }
622 
623 //------------------------------------------
625 template <typename ExprT1, typename ExprT2>
627  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
628  variance_divides<typename exprTraits<ExprT1>::VariancePixelT> >
629 operator/(ExprT1 e1, ExprT2 e2) {
633 }
634 
636 template <typename ExprT1, typename ExprT2>
637 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
641  return e1;
642 }
643 
645 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
647  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
648 }
649 
651 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
653  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
654 }
655 
657 template <typename ExprT1, typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
659  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
660 }
661 } // namespace pixel
662 } // namespace image
663 } // namespace afw
664 } // namespace lsst
665 
666 namespace std {
667 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
668 struct hash<lsst::afw::image::pixel::Pixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
671  size_t operator()(argument_type const& obj) const noexcept { return obj.hash_value(); }
672 };
673 
674 /*
675  * SinglePixel is an awkward case because Pixel == SinglePixel is a valid comparison
676  * but SinglePixel == SinglePixel is not.
677  * Give SinglePixel a hash consistent with Pixel's, just in case somebody tries something funny.
678  */
679 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
680 struct hash<lsst::afw::image::pixel::SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
683  size_t operator()(argument_type const& obj) const noexcept {
684  // Don't want to define SinglePixel::hash_value when SinglePixel::operator== doesn't exist
686  // Work around Pixel needing references to external data
687  ImagePixelT image = obj.image();
688  MaskPixelT mask = obj.mask();
689  VariancePixelT variance = obj.variance();
690  return EquivalentPixel(image, mask, variance).hash_value();
691  }
692 };
693 } // namespace std
694 #endif
lsst::afw::image::pixel::Pixel::operator==
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:228
lsst::afw::image::pixel::Pixel::operator=
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:209
lsst::afw::image::pixel::Pixel::mask
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:219
y
int y
Definition: SpanSet.cc:49
lsst::afw::image::pixel::UnaryExpr
Class for representing Unary operations.
Definition: Pixel.h:420
lsst::afw::image::pixel::exprTraits< float >::MaskPixelT
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:313
lsst::afw::image::pixel::Pixel::operator!=
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:234
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::pixel::exprTraits< int >::expr_type
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:324
std::binary_function
lsst::afw::image::pixel::SinglePixel::SinglePixel
SinglePixel(ImagePixelT image, MaskPixelT mask=0, VariancePixelT variance=0)
Definition: Pixel.h:84
std::hash< lsst::afw::image::pixel::SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > >::operator()
size_t operator()(argument_type const &obj) const noexcept
Definition: Pixel.h:683
lsst::afw::image::pixel::BinaryExpr::ImagePixelT
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:450
lsst::afw::image::pixel::bitwise_or::operator()
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:349
lsst::afw::image::pixel::Pixel::Pixel
Pixel(Pixel const &rhs)=default
lsst::afw::image::pixel::BinaryExpr::variance
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:470
lsst::afw::image::pixel::noop::operator()
T1 operator()(const T1 &x) const
Definition: Pixel.h:339
lsst::afw::image::pixel::operator*
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:608
lsst::afw::image::pixel::Pixel
A pixel of a MaskedImage.
Definition: Pixel.h:148
lsst::afw::image::pixel::bitwise_or
bitwise_or doesn't seem to be in std::
Definition: Pixel.h:45
lsst::afw::image::pixel::exprTraits< unsigned short >::expr_type
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:333
lsst::afw::image::pixel::bitwise_or::operator()
T1 operator()(const T1 &x) const
Definition: Pixel.h:350
lsst::afw::image::pixel::operator*=
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:616
lsst::afw::image::pixel::SinglePixel
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
lsst::afw::image::pixel::Pixel::ImagePixelT
_ImagePixelT ImagePixelT
Definition: Pixel.h:150
lsst::afw::image::pixel::UnaryExpr::variance
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:437
lsst::meas::modelfit::Pixel
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
lsst::afw::image::pixel::noop
A noop functor (useful for e.g. masks and variances when changing the sign of the image)
Definition: Pixel.h:338
lsst::afw::image::pixel::exprTraits< int >::ImagePixelT
int ImagePixelT
Definition: Pixel.h:321
lsst::afw::image::pixel::variance_plus::operator()
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:395
lsst::afw::image::pixel::Pixel::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Pixel.h:239
lsst::afw::image::pixel::exprTraits< double >::expr_type
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:306
lsst::afw::image::pixel::Pixel::Pixel
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:162
lsst::afw::image::pixel::exprTraits::VariancePixelT
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:297
lsst::ip::diffim::detail::PixelT
float PixelT
Definition: AssessSpatialKernelVisitor.cc:208
lsst::afw::image::pixel::Pixel::VariancePixelT
_VariancePixelT VariancePixelT
Definition: Pixel.h:152
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::image::pixel::exprTraits< unsigned short >::ImagePixelT
int ImagePixelT
Definition: Pixel.h:330
lsst::afw::image::pixel::Pixel::operator+=
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:251
lsst::afw::image::pixel::Pixel::operator*=
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:269
lsst::afw::image::pixel::Pixel::operator=
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:200
lsst::afw::image::pixel::PixelTypeTraits< SinglePixel< _ImagePixelT, _MaskPixelT, _VariancePixelT > >::padValue
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:132
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::BinaryExpr
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:499
mask
afw::table::Key< afw::table::Array< MaskPixelT > > mask
Definition: HeavyFootprint.cc:217
lsst::afw::image::pixel::exprTraits< int >::MaskPixelT
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:322
lsst::afw::image.image
Definition: __init__.py:1
lsst::afw::image::pixel::Pixel::operator=
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition: Pixel.h:189
lsst::afw::image::pixel::variance_divides::operator()
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:360
lsst::afw::image::pixel::exprTraits< double >::VariancePixelT
double VariancePixelT
Definition: Pixel.h:305
lsst::afw::image::pixel::BinaryExpr::BinaryExpr
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
lsst::afw::image::pixel::Pixel::variance
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:221
lsst::afw::image::pixel::exprTraits::MaskPixelT
ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:296
lsst::afw::image::pixel::BinaryExpr::mask
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:467
lsst::afw::image::pixel::Pixel::operator=
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:175
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::VariancePixelT
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:491
lsst::afw::image::pixel::UnaryExpr::MaskPixelT
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:423
std::is_arithmetic
hashCombine.h
lsst::afw::image::pixel::Pixel::Pixel
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:168
std::is_fundamental
lsst::afw::image::pixel::operator+=
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:543
lsst::afw::image::pixel::operator-
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:523
lsst::afw::image::pixel::UnaryExpr::ImagePixelT
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:422
lsst::afw::image::pixel::variance_plus_covar::operator()
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:412
lsst::afw::image::pixel::operator-=
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:595
lsst::afw::image::pixel::Pixel::operator-=
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:260
lsst::afw::image::pixel::operator<<
std::ostream & operator<<(std::ostream &os, SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > const &v)
Print a SinglePixel.
Definition: Pixel.h:646
std::enable_if
lsst::afw::image::pixel::UnaryExpr::mask
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:434
lsst::afw::image::pixel::SinglePixel::MaskPixelT
_MaskPixelT MaskPixelT
Definition: Pixel.h:81
std::ostream
STL class.
lsst::afw::image::pixel::Pixel::~Pixel
~Pixel()=default
lsst::afw::image::pixel::variance_plus
Calculate the variance when we add (or subtract) two Pixels.
Definition: Pixel.h:51
std::hash< lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > >::operator()
size_t operator()(argument_type const &obj) const noexcept
Definition: Pixel.h:671
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::image::pixel::exprTraits::expr_type
ExprT expr_type
Definition: Pixel.h:294
lsst::afw::image::pixel::makeSinglePixel
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition: Pixel.h:141
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::variance
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:509
lsst::afw::image::pixel::BinaryExpr
Class for representing binary operations.
Definition: Pixel.h:39
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::MaskPixelT
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:490
lsst::afw::image::pixel::BinaryExpr::BinaryExpr
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:454
lsst::afw::image::pixel::Pixel::Pixel
Pixel(Pixel &&rhs)=default
lsst::afw::image::pixel::SinglePixel::ImagePixelT
_ImagePixelT ImagePixelT
Definition: Pixel.h:80
lsst::afw::image::detail::MaskedImagePixel_tag
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52
lsst::afw::image::pixel::Pixel::MaskPixelT
_MaskPixelT MaskPixelT
Definition: Pixel.h:151
lsst::afw::image::pixel::exprTraits< int >::VariancePixelT
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:323
lsst::afw::image::pixel::variance_divides
Calculate the variance when we divide two Pixels.
Definition: Pixel.h:47
lsst::afw::image::pixel::PixelTypeTraits
Pixel type traits.
Definition: Pixel.h:119
lsst::afw::image::pixel::Pixel::operator=
Pixel operator=(Pixel &&rhs)
Definition: Pixel.h:197
lsst::afw::image::pixel::exprTraits< float >::ImagePixelT
float ImagePixelT
Definition: Pixel.h:312
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::BinaryExpr
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:493
lsst::afw::image::pixel::BinaryExpr::MaskPixelT
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:451
lsst::afw::image::pixel::exprTraits< float >::expr_type
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:315
lsst::afw::image::pixel::BinaryExpr::VariancePixelT
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:452
lsst::afw::image::pixel::variance_plus::operator()
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:393
pixel
table::PointKey< int > pixel
Definition: DeltaFunctionKernel.cc:101
lsst::afw::image::pixel::SinglePixel::mask
MaskPixelT mask() const
Definition: Pixel.h:95
lsst::afw::image::pixel::exprTraits< float >::VariancePixelT
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:314
std::unary_function
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::pixel::BinaryExpr::image
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:464
lsst::afw::image::pixel::variance_multiplies::operator()
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:377
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::image
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:503
os
std::ostream * os
Definition: Schema.cc:746
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::mask
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:506
lsst::utils::hashCombine
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35
lsst::afw::image::pixel::SinglePixel::image
ImagePixelT image() const
Definition: Pixel.h:94
lsst::afw::image::pixel::operator/
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:629
variance
afw::table::Key< afw::table::Array< VariancePixelT > > variance
Definition: HeavyFootprint.cc:218
lsst::afw::image::pixel::variance_plus_covar::operator()
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:409
lsst::afw::image::pixel::variance_multiplies
Calculate the variance when we multiply two Pixels.
Definition: Pixel.h:49
lsst::afw::image::pixel::variance_plus_covar::variance_plus_covar
variance_plus_covar(double alpha=0)
Definition: Pixel.h:407
lsst::afw::image::pixel::SinglePixel::VariancePixelT
_VariancePixelT VariancePixelT
Definition: Pixel.h:82
std
STL namespace.
type
table::Key< int > type
Definition: Detector.cc:163
lsst::afw::image::pixel::exprTraits< unsigned short >::VariancePixelT
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:332
lsst::afw::image::pixel::variance_divides::operator()
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:367
lsst::afw::image::pixel::plus
ExprT1 plus(ExprT1 &lhs, ExprT2 const &rhs, float covariance)
Like operator+(), but assume that covariance's 2*alpha*sqrt(vx*vy)
Definition: Pixel.h:573
covariance
MatrixQ covariance
Definition: simpleShape.cc:152
lsst::afw::image::pixel::UnaryExpr::image
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:431
lsst::afw::image::pixel::exprTraits< double >::ImagePixelT
double ImagePixelT
Definition: Pixel.h:303
lsst::afw::image::pixel::exprTraits< double >::MaskPixelT
int MaskPixelT
Definition: Pixel.h:304
std::size_t
lsst::afw::image::pixel::SinglePixel::variance
VariancePixelT variance() const
Definition: Pixel.h:96
lsst::afw::image::pixel::exprTraits::ImagePixelT
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:295
lsst::afw::image::pixel::exprTraits< unsigned short >::MaskPixelT
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:331
lsst::afw::image::pixel::operator/=
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:637
lsst::afw::image::pixel::exprTraits
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:42
lsst::afw::image::pixel::variance_multiplies::operator()
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:383
lsst::afw::image::pixel::BinaryExpr< ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp >::ImagePixelT
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:489
lsst::afw::image::pixel::Pixel::operator/=
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:278
lsst::afw::image::pixel::PixelTypeTraits< SinglePixel< _ImagePixelT, _MaskPixelT, _VariancePixelT > >::PixelT
SinglePixel< _ImagePixelT, _MaskPixelT, _VariancePixelT > PixelT
Definition: Pixel.h:129
lsst::afw::image::pixel::variance_plus_covar
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:406
std::numeric_limits
lsst::afw::image::pixel::UnaryExpr::UnaryExpr
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:426
lsst::afw::image::pixel::SinglePixel::SinglePixel
SinglePixel(rhsExpr const &rhs, typename std::enable_if<!std::is_fundamental< rhsExpr >::value, void * >::type dummy=nullptr)
Definition: Pixel.h:88
lsst::afw::image::pixel::UnaryExpr::VariancePixelT
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:424
lsst::afw::image::pixel::Pixel::image
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:217
lsst::afw::image::pixel::operator+
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:535
std::hash
m
int m
Definition: SpanSet.cc:49
lsst::afw::image::pixel::PixelTypeTraits::padValue
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:121