LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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>
47 struct variance_divides;
48 template <typename>
49 struct variance_multiplies;
50 template <typename>
51 struct variance_plus;
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>
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>
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>
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>
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 <class T, template <class...> class Template>
533 
534 template <template <class...> class Template, class... Args>
535 struct is_specialization<Template<Args...>, Template> : std::true_type {};
536 // avoid invocation with pybind11::detail::descr::operator+ for pybind11 >= 2.3.0
537 template <typename ExprT1, typename ExprT2,
538  typename = std::enable_if_t <
541  is_specialization<ExprT1,SinglePixel>{} ||
542  is_specialization<ExprT1,Pixel>{})
543  &&
545  is_specialization<ExprT2,BinaryExpr>{} ||
546  is_specialization<ExprT2,SinglePixel>{} ||
547  is_specialization<ExprT2,Pixel>{} )
548  >
549 >
550 BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
551  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
552  variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
553 operator+(ExprT1 e1, ExprT2 e2) {
557 }
558 
560 template <typename ExprT1, typename ExprT2>
561 ExprT1 operator+=(ExprT1& e1, ExprT2 e2) {
565  return e1;
566 }
567 
568 //
569 // Implementations of add that work for arithmetic or MaskedImage pixels
570 //
571 // The choice is made on the basis of std::is_arithmetic
572 namespace {
573 template <typename ExprT1, typename ExprT2>
574 ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
575  return e1 + e2;
576 }
577 
578 template <typename ExprT1, typename ExprT2>
580  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
581  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >
582 doPlus(ExprT1 e1, ExprT2 e2, double const alpha, boost::mpl::false_) {
584  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
585  variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >(e1, e2, alpha);
586 }
587 } // namespace
588 
590 template <typename ExprT1, typename ExprT2>
591 inline ExprT1 plus(
592  ExprT1& lhs,
593  ExprT2 const& rhs,
594  float covariance
595 ) {
596  return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
597 }
598 
599 //------------------------------------------
601 template <typename ExprT1, typename ExprT2>
603  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
604  variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
605 operator-(ExprT1 e1, ExprT2 e2) {
609 }
610 
612 template <typename ExprT1, typename ExprT2>
613 ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
617  return e1;
618 }
619 
620 //------------------------------------------
622 template <typename ExprT1, typename ExprT2>
624  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
625  variance_multiplies<typename exprTraits<ExprT1>::VariancePixelT> >
626 operator*(ExprT1 e1, ExprT2 e2) {
630 }
631 
633 template <typename ExprT1, typename ExprT2>
634 ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
638  return e1;
639 }
640 
641 //------------------------------------------
643 template <typename ExprT1, typename ExprT2>
645  bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
646  variance_divides<typename exprTraits<ExprT1>::VariancePixelT> >
647 operator/(ExprT1 e1, ExprT2 e2) {
651 }
652 
654 template <typename ExprT1, typename ExprT2>
655 ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
659  return e1;
660 }
661 
663 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
665  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
666 }
667 
669 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
671  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
672 }
673 
675 template <typename ExprT1, typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
677  return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
678 }
679 } // namespace pixel
680 } // namespace image
681 } // namespace afw
682 } // namespace lsst
683 
684 namespace std {
685 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
686 struct hash<lsst::afw::image::pixel::Pixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
689  size_t operator()(argument_type const& obj) const noexcept { return obj.hash_value(); }
690 };
691 
692 /*
693  * SinglePixel is an awkward case because Pixel == SinglePixel is a valid comparison
694  * but SinglePixel == SinglePixel is not.
695  * Give SinglePixel a hash consistent with Pixel's, just in case somebody tries something funny.
696  */
697 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
698 struct hash<lsst::afw::image::pixel::SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
701  size_t operator()(argument_type const& obj) const noexcept {
702  // Don't want to define SinglePixel::hash_value when SinglePixel::operator== doesn't exist
704  // Work around Pixel needing references to external data
705  ImagePixelT image = obj.image();
706  MaskPixelT mask = obj.mask();
707  VariancePixelT variance = obj.variance();
708  return EquivalentPixel(image, mask, variance).hash_value();
709  }
710 };
711 } // namespace std
712 #endif
double x
table::PointKey< int > pixel
table::Key< int > type
Definition: Detector.cc:163
afw::table::Key< afw::table::Array< MaskPixelT > > mask
afw::table::Key< afw::table::Array< VariancePixelT > > variance
std::ostream * os
Definition: Schema.cc:746
int y
Definition: SpanSet.cc:49
int m
Definition: SpanSet.cc:49
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:509
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:506
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
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:503
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
Class for representing binary operations.
Definition: Pixel.h:448
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:452
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:464
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:450
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
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
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:470
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:451
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:467
A pixel of a MaskedImage.
Definition: Pixel.h:148
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition: Pixel.h:219
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
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition: Pixel.h:278
Pixel operator=(Pixel const &rhs)
Definition: Pixel.h:175
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition: Pixel.h:260
Pixel(Pixel const &rhs)=default
ImagePixelT image() const
Return the image part of a Pixel.
Definition: Pixel.h:217
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition: Pixel.h:168
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
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition: Pixel.h:269
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition: Pixel.h:189
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition: Pixel.h:251
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Pixel.h:239
_ImagePixelT ImagePixelT
Definition: Pixel.h:150
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
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
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
Pixel(Pixel &&rhs)=default
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition: Pixel.h:221
Pixel operator=(Pixel &&rhs)
Definition: Pixel.h:197
_VariancePixelT VariancePixelT
Definition: Pixel.h:152
A single pixel of the same type as a MaskedImage.
Definition: Pixel.h:73
SinglePixel(rhsExpr const &rhs, typename std::enable_if<!std::is_fundamental< rhsExpr >::value, void * >::type dummy=nullptr)
Definition: Pixel.h:88
_VariancePixelT VariancePixelT
Definition: Pixel.h:82
VariancePixelT variance() const
Definition: Pixel.h:96
SinglePixel(ImagePixelT image, MaskPixelT mask=0, VariancePixelT variance=0)
Definition: Pixel.h:84
MaskPixelT mask() const
Definition: Pixel.h:95
ImagePixelT image() const
Definition: Pixel.h:94
Class for representing Unary operations.
Definition: Pixel.h:420
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:437
exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:422
MaskPixelT mask() const
evaluate the mask part of the expression
Definition: Pixel.h:434
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
exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:423
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:431
exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:424
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:634
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
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:647
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition: Pixel.h:655
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:561
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition: Pixel.h:141
std::ostream & operator<<(std::ostream &os, SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > const &v)
Print a SinglePixel.
Definition: Pixel.h:664
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:613
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
ExprT1 plus(ExprT1 &lhs, ExprT2 const &rhs, float covariance)
Like operator+(), but assume that covariance's 2*alpha*sqrt(vx*vy)
Definition: Pixel.h:591
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
class[[deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be " "removed after v22.")]] FilterProperty final
Describe the properties of a Filter (e.g.
Definition: Filter.h:53
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35
A base class for image defects.
STL namespace.
T quiet_NaN(T... args)
MatrixQ covariance
Definition: simpleShape.cc:152
A class used to identify classes that represent MaskedImage pixels.
Definition: MaskedImage.h:52
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:132
static const PixelT padValue()
The quantity to use when a pixel value is undefined.
Definition: Pixel.h:121
bitwise_or doesn't seem to be in std::
Definition: Pixel.h:348
T1 operator()(const T1 &x, const T1 &y) const
Definition: Pixel.h:349
T1 operator()(const T1 &x) const
Definition: Pixel.h:350
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:306
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:314
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:315
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:313
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:324
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:323
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:322
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:332
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > expr_type
Definition: Pixel.h:333
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:331
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:293
ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:296
ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:297
ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:295
A noop functor (useful for e.g. masks and variances when changing the sign of the image)
Definition: Pixel.h:338
T1 operator()(const T1 &x) const
Definition: Pixel.h:339
Calculate the variance when we divide two Pixels.
Definition: Pixel.h:359
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:367
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:360
Calculate the variance when we multiply two Pixels.
Definition: Pixel.h:376
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:377
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition: Pixel.h:383
The variance of the sum of a pair of correlated pixels.
Definition: Pixel.h:406
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:412
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:409
Calculate the variance when we add (or subtract) two Pixels.
Definition: Pixel.h:392
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition: Pixel.h:393
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition: Pixel.h:395