LSST Applications g063fba187b+eddd1b24d7,g0f08755f38+4a855ab515,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+062a45aee3,g1dcb35cd9c+45d3fa5522,g20f6ffc8e0+4a855ab515,g217e2c1bcf+f55e51b560,g28da252d5a+7d8e536cc7,g2bbee38e9b+2d92fc7d83,g2bc492864f+2d92fc7d83,g3156d2b45e+6e55a43351,g32e5bea42b+625186cc6b,g347aa1857d+2d92fc7d83,g35bb328faa+a8ce1bb630,g3a166c0a6a+2d92fc7d83,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+1af189bab1,g7af13505b9+7b6a50a2f8,g80478fca09+6174b7f182,g82479be7b0+5b71efbaf0,g858d7b2824+4a855ab515,g9125e01d80+a8ce1bb630,ga5288a1d22+61618a97c4,gb58c049af0+d64f4d3760,gc28159a63d+2d92fc7d83,gc5452a3dca+f4add4ffd5,gcab2d0539d+d9f5af7f69,gcf0d15dbbd+6c7e0a19ec,gda6a2b7d83+6c7e0a19ec,gdaeeff99f8+1711a396fd,ge79ae78c31+2d92fc7d83,gef2f8181fd+55fff6f525,gf0baf85859+c1f95f4921,gfa517265be+4a855ab515,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
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_t<!std::is_fundamental_v<rhsExpr>, void*> = 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>
124};
125
126
127
133template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
138
140template <typename _ImagePixelT, typename _MaskPixelT, typename _VariancePixelT = double>
142public:
143 using ImagePixelT = _ImagePixelT;
144 using MaskPixelT = _MaskPixelT;
145 using VariancePixelT = _VariancePixelT;
146
148 //
149 // This constructor casts away const. This should be fixed by making const Pixels.
150 //
151 Pixel(ImagePixelT const& image, MaskPixelT const& mask = 0x0, VariancePixelT const& variance = 0)
152 : _image(const_cast<ImagePixelT&>(image)),
153 _mask(const_cast<MaskPixelT&>(mask)),
154 _variance(const_cast<VariancePixelT&>(variance)) {}
155
157 : _image(rhs._image), _mask(rhs._mask), _variance(rhs._variance) {}
158
159 Pixel(Pixel const& rhs) = default;
160 Pixel(Pixel&& rhs) = default;
161 ~Pixel() = default;
162
163 Pixel operator=(Pixel const& rhs) { // the following template won't stop the compiler trying to generate
164 // operator=
165 _variance = rhs.variance(); // evaluate before we update image()
166 _image = rhs.image();
167 _mask = rhs.mask();
168
169 return *this;
170 }
176 template <typename rhsExpr>
177 Pixel operator=(rhsExpr const& rhs) {
178 _variance = rhs.variance(); // evaluate before we update image()
179 _image = rhs.image();
180 _mask = rhs.mask();
181
182 return *this;
183 }
184 // Delegate to copy-assignment for backwards compatibility
185 Pixel operator=(Pixel&& rhs) { return *this = rhs; }
186
188 Pixel operator=(double const& rhs_image) {
189 _image = rhs_image;
190 _mask = 0;
191 _variance = 0;
192
193 return *this;
194 }
195
197 Pixel operator=(int const& rhs_image) {
198 _image = rhs_image;
199 _mask = 0;
200 _variance = 0;
201
202 return *this;
203 }
205 ImagePixelT image() const { return _image; }
207 MaskPixelT mask() const { return _mask; }
209 VariancePixelT variance() const { return _variance; }
210 //
211 // Logical operators. We don't need to construct BinaryExpr for them
212 // as efficiency isn't a concern.
213 //
216 template <typename T1,typename T2, typename T3>
217 friend bool operator==(Pixel const& lhs, Pixel<T1,T2,T3> const& rhs) {
218 return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
219 }
220 template <typename T1,typename T2, typename T3>
221 friend bool operator==(Pixel const& lhs, SinglePixel<T1, T2, T3> const& rhs) {
222 return lhs.image() == rhs.image() && lhs.mask() == rhs.mask() && lhs.variance() == rhs.variance();
223 }
224
226 template <typename T1>
227 friend bool operator!=(Pixel const& lhs, T1 const& rhs) {
228 return !(lhs == rhs);
229 }
230
232 std::size_t hash_value() const noexcept {
233 // Completely arbitrary seed
234 // Convert to double to avoid inconsistently hashing equal numbers of different types
235 return cpputils::hashCombine(17, static_cast<double>(image()), static_cast<double>(mask()),
236 static_cast<double>(variance()));
237 }
238
239 //
240 // Provide friend versions of the op= operators to permit argument promotion on their first arguments
241 //
243 template <typename ExprT>
244 friend Pixel operator+=(Pixel const& e1, ExprT const& e2) {
245 Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
248 return tmp;
249 }
250
252 template <typename ExprT>
253 friend Pixel operator-=(Pixel const& e1, ExprT const& e2) {
254 Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
257 return tmp;
258 }
259
261 template <typename ExprT>
262 friend Pixel operator*=(Pixel const& e1, ExprT const& e2) {
263 Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
266 return tmp;
267 }
268
270 template <typename ExprT>
271 friend Pixel operator/=(Pixel const& e1, ExprT const& e2) {
272 Pixel tmp(e1); // n.b. shares storage with e1 but gets around "const" (which is required)
275 return tmp;
276 }
277
278private:
279 ImagePixelT& _image;
280 MaskPixelT& _mask;
281 VariancePixelT& _variance;
282};
283
285template <typename ExprT>
287 using expr_type = ExprT;
288 using ImagePixelT = typename ExprT::ImagePixelT;
289 using MaskPixelT = typename ExprT::MaskPixelT;
290 using VariancePixelT = typename ExprT::VariancePixelT;
291};
292
294template <>
295struct exprTraits<double> {
296 using ImagePixelT = double;
297 using MaskPixelT = int;
298 using VariancePixelT = double;
300};
301
303template <>
310
312template <>
319
321template <>
328
330template <typename T1>
331struct noop {
332 T1 operator()(const T1& x) const { return x; }
333};
334
340template <typename T1>
342 T1 operator()(const T1& x, const T1& y) const { return (x | y); }
343 T1 operator()(const T1& x) const { return x; }
344};
345
351template <typename T1>
353 T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
354 T1 const x2 = x * x;
355 T1 const y2 = y * y;
356 T1 const iy2 = 1.0 / y2;
357 return x2 * vy * iy2 * iy2 + vx * iy2;
358 }
359
360 T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx / (y * y); }
361};
362
368template <typename T1>
370 T1 operator()(T1 const& x, T1 const& y, T1 const& vx, T1 const& vy) const {
371 T1 const x2 = x * x;
372 T1 const y2 = y * y;
373 return x2 * vy + y2 * vx;
374 }
375
376 T1 operator()(T1 const&, T1 const& y, T1 const& vx) const { return vx * y * y; }
377};
378
384template <typename T1>
386 T1 operator()(T1 const&, T1 const&, T1 const& vx, T1 const& vy) const { return vx + vy; }
387
388 T1 operator()(T1 const&, T1 const&, T1 const& vx) const { return vx; }
389};
390
392template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
394public:
399 UnaryExpr(ExprT1 e1, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
400 VarianceBinOp varOp = VarianceBinOp())
401 : _expr1(e1), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
402
404 ImagePixelT image() const { return _imageOp(_expr1.image()); }
405
407 MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
408
410 VariancePixelT variance() const { return _varOp(_expr1.variance()); }
411
412private:
413 typename exprTraits<ExprT1>::expr_type _expr1;
414 ImageBinOp _imageOp;
415 MaskBinOp _maskOp;
416 VarianceBinOp _varOp;
417};
418
420template <typename ExprT1, typename ExprT2, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
421class BinaryExpr final {
422public:
427 BinaryExpr(ExprT1 e1, ExprT2 e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
428 VarianceBinOp varOp = VarianceBinOp())
429 : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
430
433 BinaryExpr(ExprT1 e1, ExprT2 e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
434 MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
435 : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
437 ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2.image()); }
438
440 MaskPixelT mask() const { return _maskOp(_expr1.mask(), _expr2.mask()); }
441
444 return _varOp(_expr1.image(), _expr2.image(), _expr1.variance(), _expr2.variance());
445 }
446
447private:
448 typename exprTraits<ExprT1>::expr_type _expr1;
449 typename exprTraits<ExprT2>::expr_type _expr2;
450 ImageBinOp _imageOp;
451 MaskBinOp _maskOp;
452 VarianceBinOp _varOp;
453};
454
459template <typename ExprT1, typename ImageBinOp, typename MaskBinOp, typename VarianceBinOp>
460class BinaryExpr<ExprT1, double, ImageBinOp, MaskBinOp, VarianceBinOp> final {
461public:
466 BinaryExpr(ExprT1 e1, double e2, ImageBinOp imageOp = ImageBinOp(), MaskBinOp maskOp = MaskBinOp(),
467 VarianceBinOp varOp = VarianceBinOp())
468 : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(varOp) {}
469
472 BinaryExpr(ExprT1 e1, double e2, double const alpha, ImageBinOp imageOp = ImageBinOp(),
473 MaskBinOp maskOp = MaskBinOp(), VarianceBinOp = VarianceBinOp())
474 : _expr1(e1), _expr2(e2), _imageOp(imageOp), _maskOp(maskOp), _varOp(VarianceBinOp(alpha)) {}
476 ImagePixelT image() const { return _imageOp(_expr1.image(), _expr2); }
477
479 MaskPixelT mask() const { return _maskOp(_expr1.mask()); }
480
482 VariancePixelT variance() const { return _varOp(_expr1.image(), _expr2, _expr1.variance()); }
483
484private:
485 typename exprTraits<ExprT1>::expr_type _expr1;
486 double _expr2;
487 ImageBinOp _imageOp;
488 MaskBinOp _maskOp;
489 VarianceBinOp _varOp;
490};
491
493template <typename ExprT1>
499
500//------------------------------------------
502template <class T, template <class...> class Template>
504
505template <template <class...> class Template, class... Args>
506struct is_specialization<Template<Args...>, Template> : std::true_type {};
507// avoid invocation with pybind11::detail::descr::operator+ for pybind11 >= 2.3.0
508template <typename T>
510 std::is_floating_point_v<T> ||
512 is_specialization<T, SinglePixel>{} ||
513 is_specialization<T, Pixel>{};
514template <typename T1, typename T2>
515constexpr bool valid_binary_operands = is_valid_operand<T1> && is_valid_operand<T2>;
516
517template <typename T1, typename T2>
518using valid_operands = std::enable_if_t<valid_binary_operands<T1, T2>>;
519
520template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
526
528template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
535
536//
537// Implementations of add that work for arithmetic or MaskedImage pixels
538//
539namespace {
540template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
541ExprT1 doPlus(ExprT1 e1, ExprT2 e2, double const, boost::mpl::true_) {
542 return e1 + e2;
543}
544
545} // namespace
546
548template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
549inline ExprT1 plus(
550 ExprT1& lhs,
551 ExprT2 const& rhs,
552 float covariance
553) {
554 return doPlus(lhs, rhs, covariance, typename std::is_arithmetic<ExprT1>::type());
555}
556
557//------------------------------------------
559template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
560BinaryExpr<ExprT1, ExprT2, std::minus<typename exprTraits<ExprT1>::ImagePixelT>,
561 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
562 variance_plus<typename exprTraits<ExprT1>::VariancePixelT> >
568
570template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
577
578//------------------------------------------
580template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
581BinaryExpr<ExprT1, ExprT2, std::multiplies<typename exprTraits<ExprT1>::ImagePixelT>,
582 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
583 variance_multiplies<typename exprTraits<ExprT1>::VariancePixelT> >
589
591template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
598
599//------------------------------------------
601template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
602BinaryExpr<ExprT1, ExprT2, std::divides<typename exprTraits<ExprT1>::ImagePixelT>,
603 bitwise_or<typename exprTraits<ExprT1>::MaskPixelT>,
604 variance_divides<typename exprTraits<ExprT1>::VariancePixelT> >
610
612template <typename ExprT1, typename ExprT2, typename = valid_operands<ExprT1, ExprT2>>
619
621template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
623 return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
624}
625
627template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
629 return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
630}
631
633template <typename ExprT1, typename ExprT2, typename BinOp, typename MaskBinOp, typename VarBinOp>
635 return os << "(" << v.image() << ", " << v.mask() << ", " << v.variance() << ")";
636}
637} // namespace pixel
638} // namespace image
639} // namespace afw
640} // namespace lsst
641
642namespace std {
643template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
644struct hash<lsst::afw::image::pixel::Pixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
647 size_t operator()(argument_type const& obj) const noexcept { return obj.hash_value(); }
648};
649
650/*
651 * SinglePixel is an awkward case because Pixel == SinglePixel is a valid comparison
652 * but SinglePixel == SinglePixel is not.
653 * Give SinglePixel a hash consistent with Pixel's, just in case somebody tries something funny.
654 */
655template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
656struct hash<lsst::afw::image::pixel::SinglePixel<ImagePixelT, MaskPixelT, VariancePixelT>> {
659 size_t operator()(argument_type const& obj) const noexcept {
660 // Don't want to define SinglePixel::hash_value when SinglePixel::operator== doesn't exist
662 // Work around Pixel needing references to external data
663 ImagePixelT image = obj.image();
664 MaskPixelT mask = obj.mask();
665 VariancePixelT variance = obj.variance();
666 return EquivalentPixel(image, mask, variance).hash_value();
667 }
668};
669} // namespace std
670#endif
afw::table::Key< afw::table::Array< MaskPixelT > > mask
afw::table::Key< afw::table::Array< VariancePixelT > > variance
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:482
MaskPixelT mask() const
evaluate the mask part of the expression
Definition Pixel.h:479
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:472
ImagePixelT image() const
evaluate the image part of the expression
Definition Pixel.h:476
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:466
Class for representing binary operations.
Definition Pixel.h:421
typename exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition Pixel.h:425
ImagePixelT image() const
evaluate the image part of the expression
Definition Pixel.h:437
typename exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition Pixel.h:423
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:433
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:427
typename exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition Pixel.h:424
VariancePixelT variance() const
evaluate the variance part of the expression
Definition Pixel.h:443
MaskPixelT mask() const
evaluate the mask part of the expression
Definition Pixel.h:440
A pixel of a MaskedImage.
Definition Pixel.h:141
MaskPixelT mask() const
Return the mask part of a Pixel.
Definition Pixel.h:207
Pixel(ImagePixelT const &image, MaskPixelT const &mask=0x0, VariancePixelT const &variance=0)
Construct a Pixel from references to its image/mask/variance components.
Definition Pixel.h:151
_VariancePixelT VariancePixelT
Definition Pixel.h:145
friend Pixel operator/=(Pixel const &e1, ExprT const &e2)
Evaluate e1 /= e2, and return e1.
Definition Pixel.h:271
Pixel operator=(Pixel const &rhs)
Definition Pixel.h:163
friend Pixel operator-=(Pixel const &e1, ExprT const &e2)
Evaluate e1 -= e2, and return e1.
Definition Pixel.h:253
Pixel(Pixel const &rhs)=default
ImagePixelT image() const
Return the image part of a Pixel.
Definition Pixel.h:205
Pixel(SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > &rhs)
Definition Pixel.h:156
friend bool operator==(Pixel const &lhs, SinglePixel< T1, T2, T3 > const &rhs)
Definition Pixel.h:221
friend Pixel operator*=(Pixel const &e1, ExprT const &e2)
Evaluate e1 *= e2, and return e1.
Definition Pixel.h:262
Pixel operator=(rhsExpr const &rhs)
Assign a Pixel by evaluating an expression.
Definition Pixel.h:177
friend Pixel operator+=(Pixel const &e1, ExprT const &e2)
Evaluate e1 += e2, and return e1.
Definition Pixel.h:244
friend bool operator==(Pixel const &lhs, Pixel< T1, T2, T3 > const &rhs)
Return true if two pixels are equal (in all three of image, mask, and variance) Fix C++20 compilation...
Definition Pixel.h:217
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition Pixel.h:232
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:188
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:197
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:227
Pixel(Pixel &&rhs)=default
VariancePixelT variance() const
Return the variance part of a Pixel.
Definition Pixel.h:209
Pixel operator=(Pixel &&rhs)
Definition Pixel.h:185
A single pixel of the same type as a MaskedImage.
Definition Pixel.h:73
VariancePixelT variance() const
Definition Pixel.h:96
SinglePixel(ImagePixelT image, MaskPixelT mask=0, VariancePixelT variance=0)
Definition Pixel.h:84
ImagePixelT image() const
Definition Pixel.h:94
SinglePixel(rhsExpr const &rhs, typename std::enable_if_t<!std::is_fundamental_v< rhsExpr >, void * >=nullptr)
Definition Pixel.h:88
Class for representing Unary operations.
Definition Pixel.h:393
VariancePixelT variance() const
evaluate the variance part of the expression
Definition Pixel.h:410
MaskPixelT mask() const
evaluate the mask part of the expression
Definition Pixel.h:407
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:399
typename exprTraits< ExprT1 >::ImagePixelT ImagePixelT
Definition Pixel.h:395
typename exprTraits< ExprT1 >::VariancePixelT VariancePixelT
Definition Pixel.h:397
ImagePixelT image() const
evaluate the image part of the expression
Definition Pixel.h:404
typename exprTraits< ExprT1 >::MaskPixelT MaskPixelT
Definition Pixel.h:396
ExprT1 operator-=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 -= e2.
Definition Pixel.h:571
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:605
constexpr bool valid_binary_operands
Definition Pixel.h:515
std::ostream & operator<<(std::ostream &os, SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > const &v)
Print a SinglePixel.
Definition Pixel.h:622
auto operator-(ExprT1 e1)
Template for -e1.
Definition Pixel.h:494
ExprT1 plus(ExprT1 &lhs, ExprT2 const &rhs, float covariance)
Like operator+(), but assume that covariance's 2*alpha*sqrt(vx*vy)
Definition Pixel.h:549
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:584
ExprT1 & operator+=(ExprT1 &e1, ExprT2 const &e2)
template for e1 += e2
Definition Pixel.h:529
SinglePixel< ImagePixelT, MaskPixelT, VariancePixelT > makeSinglePixel(ImagePixelT x, MaskPixelT m, VariancePixelT v)
Return a SinglePixel.
Definition Pixel.h:134
ExprT1 operator*=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 *= e2.
Definition Pixel.h:592
std::enable_if_t< valid_binary_operands< T1, T2 > > valid_operands
Definition Pixel.h:518
auto operator+(ExprT1 e1, ExprT2 e2)
Definition Pixel.h:521
ExprT1 operator/=(ExprT1 &e1, ExprT2 e2)
Template to evaluate e1 /= e2.
Definition Pixel.h:613
constexpr bool is_valid_operand
Definition Pixel.h:509
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition hashCombine.h:35
STL namespace.
decltype(sizeof(void *)) size_t
Definition doctest.h:524
T quiet_NaN(T... args)
MatrixQ covariance
A class used to identify classes that represent MaskedImage pixels.
Definition MaskedImage.h:53
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:341
T1 operator()(const T1 &x, const T1 &y) const
Definition Pixel.h:342
T1 operator()(const T1 &x) const
Definition Pixel.h:343
exprTraits< double >::VariancePixelT VariancePixelT
Definition Pixel.h:307
exprTraits< double >::MaskPixelT MaskPixelT
Definition Pixel.h:306
exprTraits< double >::VariancePixelT VariancePixelT
Definition Pixel.h:316
exprTraits< double >::MaskPixelT MaskPixelT
Definition Pixel.h:315
exprTraits< double >::VariancePixelT VariancePixelT
Definition Pixel.h:325
exprTraits< double >::MaskPixelT MaskPixelT
Definition Pixel.h:324
A traits class to return the types of the image/mask/variance.
Definition Pixel.h:286
typename ExprT::ImagePixelT ImagePixelT
Definition Pixel.h:288
typename ExprT::MaskPixelT MaskPixelT
Definition Pixel.h:289
typename ExprT::VariancePixelT VariancePixelT
Definition Pixel.h:290
A noop functor (useful for e.g. masks and variances when changing the sign of the image)
Definition Pixel.h:331
T1 operator()(const T1 &x) const
Definition Pixel.h:332
Calculate the variance when we divide two Pixels.
Definition Pixel.h:352
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition Pixel.h:360
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition Pixel.h:353
Calculate the variance when we multiply two Pixels.
Definition Pixel.h:369
T1 operator()(T1 const &x, T1 const &y, T1 const &vx, T1 const &vy) const
Definition Pixel.h:370
T1 operator()(T1 const &, T1 const &y, T1 const &vx) const
Definition Pixel.h:376
Calculate the variance when we add (or subtract) two Pixels.
Definition Pixel.h:385
T1 operator()(T1 const &, T1 const &, T1 const &vx, T1 const &vy) const
Definition Pixel.h:386
T1 operator()(T1 const &, T1 const &, T1 const &vx) const
Definition Pixel.h:388