LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
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
32
33namespace lsst {
34namespace afw {
35namespace image {
36namespace pixel {
37
38template <typename, typename, typename, typename, typename>
39class BinaryExpr;
40
41template <typename>
42struct exprTraits;
43
44template <typename>
45struct bitwise_or;
46template <typename>
47struct variance_divides;
48template <typename>
50template <typename>
51struct 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
72template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
74public:
75 template <typename, typename, typename>
76 friend class Pixel;
77 template <typename T>
78 friend class PixelTypeTraits;
79
80 using ImagePixelT = _ImagePixelT;
81 using MaskPixelT = _MaskPixelT;
82 using 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
98private:
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
118template <typename PixelT>
121 static inline const PixelT padValue() {
123 }
124};
125
127template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT>
128struct PixelTypeTraits<SinglePixel<_ImagePixelT, _MaskPixelT, _VariancePixelT> > {
130
132 static inline const PixelT padValue() { return PixelT(); }
133};
134
140template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
142 VariancePixelT v) {
144}
145
147template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
149public:
150 using ImagePixelT = _ImagePixelT;
151 using MaskPixelT = _MaskPixelT;
152 using 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
285private:
286 ImagePixelT& _image;
287 MaskPixelT& _mask;
288 VariancePixelT& _variance;
289};
290
292template <typename ExprT>
294 using expr_type = ExprT;
295 using ImagePixelT = typename ExprT::ImagePixelT;
296 using MaskPixelT = typename ExprT::MaskPixelT;
297 using VariancePixelT = typename ExprT::VariancePixelT;
298};
299
301template <>
307};
308
310template <>
316};
317
319template <>
325};
326
328template <>
329struct exprTraits<unsigned short> {
334};
335
337template <typename T1>
338struct noop : public std::unary_function<T1, T1> {
339 T1 operator()(const T1& x) const { return x; }
340};
341
347template <typename T1>
348struct 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
358template <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
375template <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
391template <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
405template <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
414private:
415 double _alpha;
416};
417
419template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
421public:
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
439private:
440 typename exprTraits<ExprT1>::expr_type _expr1;
441 ImageBinOp _imageOp;
442 MaskBinOp _maskOp;
443 VarianceBinOp _varOp;
444};
445
447template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
448class BinaryExpr final {
449public:
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
474private:
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
486template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
487class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> final {
488public:
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
511private:
512 typename exprTraits<ExprT1>::expr_type _expr1;
513 double _expr2;
514 ImageBinOp _imageOp;
515 MaskBinOp _maskOp;
516 VarianceBinOp _varOp;
517};
518
520template <typename ExprT1>
522 noop<typename exprTraits<ExprT1>::MaskPixelT>, noop<typename exprTraits<ExprT1>::VariancePixelT> >
523operator-(ExprT1 e1) {
527}
528
529//------------------------------------------
531template <class T, template <class...> class Template>
533
534template <template <class...> class Template, class... Args>
535struct is_specialization<Template<Args...>, Template> : std::true_type {};
536// avoid invocation with pybind11::detail::descr::operator+ for pybind11 >= 2.3.0
537template <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>
550BinaryExpr<ExprT1, ExprT2, std::plus<typename exprTraits<ExprT1>::ImagePixelT>,
551 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
552 variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
553operator+(ExprT1 e1, ExprT2 e2) {
557}
558
560template <typename ExprT1, typename ExprT2>
561ExprT1 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
572namespace {
573template <typename ExprT1, typename ExprT2>
574ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
575 return e1 + e2;
576}
577
578template <typename ExprT1, typename ExprT2>
580 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
581 variance_plus_covar<typename exprTraits<ExprT1>::VariancePixelT> >
582doPlus(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
590template <typename ExprT1, typename ExprT2>
591inline 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//------------------------------------------
601template <typename ExprT1, typename ExprT2>
603 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
604 variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
605operator-(ExprT1 e1, ExprT2 e2) {
609}
610
612template <typename ExprT1, typename ExprT2>
613ExprT1 operator-=(ExprT1& e1, ExprT2 e2) {
617 return e1;
618}
619
620//------------------------------------------
622template <typename ExprT1, typename ExprT2>
624 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
625 variance_multiplies<typename exprTraits<ExprT1>::VariancePixelT> >
626operator*(ExprT1 e1, ExprT2 e2) {
630}
631
633template <typename ExprT1, typename ExprT2>
634ExprT1 operator*=(ExprT1& e1, ExprT2 e2) {
638 return e1;
639}
640
641//------------------------------------------
643template <typename ExprT1, typename ExprT2>
645 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
646 variance_divides<typename exprTraits<ExprT1>::VariancePixelT> >
647operator/(ExprT1 e1, ExprT2 e2) {
651}
652
654template <typename ExprT1, typename ExprT2>
655ExprT1 operator/=(ExprT1& e1, ExprT2 e2) {
659 return e1;
660}
661
663template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
665 return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
666}
667
669template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
671 return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
672}
673
675template <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
684namespace std {
685template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
686struct 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 */
697template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
698struct 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:557
int y
Definition: SpanSet.cc:48
int m
Definition: SpanSet.cc:48
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
typename exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:452
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:464
typename 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
typename exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:451
VariancePixelT variance() const
evaluate the variance part of the expression
Definition: Pixel.h:470
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
_VariancePixelT VariancePixelT
Definition: Pixel.h:152
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
_ImagePixelT ImagePixelT
Definition: Pixel.h:150
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Pixel.h:239
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
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 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
_VariancePixelT VariancePixelT
Definition: Pixel.h:82
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
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
typename exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition: Pixel.h:422
typename exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition: Pixel.h:424
ImagePixelT image() const
evaluate the image part of the expression
Definition: Pixel.h:431
typename exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition: Pixel.h:423
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition: Pixel.h:634
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:655
ExprT1 operator+=(ExprT1 &e1, ExprT2 e2)
template for e1 += e2
Definition: Pixel.h:561
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
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition: Pixel.h:141
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition: Pixel.h:613
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
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.
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
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
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:314
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:313
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:323
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:322
exprTraits< double >::VariancePixelT VariancePixelT
Definition: Pixel.h:332
exprTraits< double >::MaskPixelT MaskPixelT
Definition: Pixel.h:331
A traits class to return the types of the image/mask/variance.
Definition: Pixel.h:293
typename ExprT::ImagePixelT ImagePixelT
Definition: Pixel.h:295
typename ExprT::MaskPixelT MaskPixelT
Definition: Pixel.h:296
typename ExprT::VariancePixelT VariancePixelT
Definition: Pixel.h:297
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