LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Peak.h
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #if !defined(LSST_AFW_DETECTION_PEAK_H)
24 #define LSST_AFW_DETECTION_PEAK_H
25 
30 #include <algorithm>
31 #include <list>
32 #include <cmath>
33 #include <limits>
34 #include <boost/shared_ptr.hpp>
35 #include "lsst/daf/base/Citizen.h"
36 #include "lsst/afw/geom/Point.h"
37 
38 #include <boost/serialization/nvp.hpp>
39 
40 namespace boost {
41 namespace serialization {
42  class access;
43 }}
44 
45 #ifndef SWIG
46 using boost::serialization::make_nvp;
47 #endif
48 
49 namespace lsst { namespace afw { namespace detection {
52 public:
53  typedef boost::shared_ptr<Peak> Ptr;
55  explicit Peak(int ix,
56  int iy,
57  float peakValue=std::numeric_limits<float>::quiet_NaN()
58  ) : lsst::daf::base::Citizen(typeid(this)),
59  _id(++id),
60  _ix(ix), _iy(iy), _fx(ix), _fy(iy), _peakValue(peakValue) {};
62  explicit Peak(float fx=std::numeric_limits<float>::quiet_NaN(),
63  float fy=std::numeric_limits<float>::quiet_NaN(),
64  float peakValue=std::numeric_limits<float>::quiet_NaN()
65  ) : lsst::daf::base::Citizen(typeid(this)),
66  _id(++id),
67  _ix(fx > 0 ? static_cast<int>(fx) : -static_cast<int>(-fx) - 1),
68  _iy(fy > 0 ? static_cast<int>(fy) : -static_cast<int>(-fy) - 1),
69  _fx(fx), _fy(fy), _peakValue(peakValue) {};
70  Peak(Peak const & other)
71  : lsst::daf::base::Citizen(typeid(this)),
72  _id(++id),
73  _ix(other._ix), _iy(other._iy),
74  _fx(other._fx), _fy(other._fy), _peakValue(other._peakValue)
75  { }
76  Peak& operator=(Peak const & other)
77  {
78  if (this != &other) {
79  _id = ++id;
80  _ix = other._ix; _iy = other._iy;
81  _fx = other._fx; _fy = other._fy;
82  _peakValue = other._peakValue;
83  }
84  return *this;
85  }
86 
87  ~Peak() {};
88 
89  bool operator==(Peak const& rhs) const {
90  return _id == rhs._id;
91  }
92  bool operator!=(Peak const& rhs) const {
93  return !(*this == rhs);
94  }
95 
96  int getId() const { return _id; }
97 
98  int getIx() const { return _ix; }
99  int getIy() const { return _iy; }
100  lsst::afw::geom::Point2I getI() const { return getCentroid(true); }
104  float getFx() const { return _fx; }
105  float getFy() const { return _fy; }
106  lsst::afw::geom::Point2D getF() const { return getCentroid(); }
110  void setFx(float fx) { _fx = fx; }
111  void setFy(float fy) { _fy = fy; }
112 
113  void setPeakValue(float peakValue) { _peakValue = peakValue; }
114  float getPeakValue() const { return _peakValue; }
115 
116  std::string toString();
117 private:
119  template <typename Archive>
120  void serialize(Archive & ar, unsigned int const version) {
121  ar & make_nvp("id", _id);
122  ar & make_nvp("ix", _ix) & make_nvp("iy", _iy);
123  ar & make_nvp("fx", _fx) & make_nvp("fy", _fy);
124  ar & make_nvp("peakValue", _peakValue);
125  }
126  //Peak(const Peak &) {} // XXX How do we manage Citizen's copy constructor?
127  static int id;
128  mutable int _id;
129  int _ix;
130  int _iy;
131  float _fx;
132  float _fy;
133  float _peakValue;
134 };
135 
136 }}}
137 
138 #endif
lsst::afw::geom::Point2I getCentroid(bool) const
Return the coordinates of the highest pixel.
Definition: Peak.h:103
static int id
Counter for Peak IDs.
Definition: Peak.h:127
float _peakValue
value of image at peak position
Definition: Peak.h:133
int _iy
row-position of peak pixel
Definition: Peak.h:130
lsst::afw::geom::Point2D getCentroid() const
Return the peak&#39;s centroid.
Definition: Peak.h:109
void setPeakValue(float peakValue)
Set the value of the image at the peak.
Definition: Peak.h:113
Peak(int ix, int iy, float peakValue=std::numeric_limits< float >::quiet_NaN())
A peak at the pixel (ix, iy)
Definition: Peak.h:55
bool operator==(Peak const &rhs) const
Definition: Peak.h:89
boost::shared_ptr< Peak > Ptr
Definition: Peak.h:53
int _ix
column-position of peak pixel
Definition: Peak.h:129
float _fy
row-position of peak
Definition: Peak.h:132
void serialize(Archive &ar, unsigned int const version)
Definition: Peak.h:120
lsst::afw::geom::Point2I getI() const
Return the coordinates of the highest pixel.
Definition: Peak.h:101
Point< int, 2 > Point2I
Definition: PSF.h:39
float getFy() const
Definition: Peak.h:105
lsst::afw::geom::Point2D getF() const
Return the peak&#39;s centroid.
Definition: Peak.h:107
float getPeakValue() const
Return the value of the image at the peak.
Definition: Peak.h:114
A peak in an image.
Definition: Peak.h:51
std::string toString()
Definition: Peak.cc:44
Peak(Peak const &other)
Definition: Peak.h:70
void setFx(float fx)
Set the column centroid.
Definition: Peak.h:110
Citizen(const std::type_info &)
Definition: Citizen.cc:173
int getIx() const
Return the column pixel position.
Definition: Peak.h:98
Peak(float fx=std::numeric_limits< float >::quiet_NaN(), float fy=std::numeric_limits< float >::quiet_NaN(), float peakValue=std::numeric_limits< float >::quiet_NaN())
A peak at the floating-point position (fx, fy)
Definition: Peak.h:62
int getIy() const
Definition: Peak.h:99
friend class boost::serialization::access
Definition: Peak.h:118
float getFx() const
Return the column centroid.
Definition: Peak.h:104
A coordinate class intended to represent absolute positions.
int _id
unique ID for this peak
Definition: Peak.h:128
Point< double, 2 > Point2D
Definition: Point.h:286
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
int getId() const
Return the Peak&#39;s unique ID.
Definition: Peak.h:96
Peak & operator=(Peak const &other)
Definition: Peak.h:76
float _fx
column-position of peak
Definition: Peak.h:131
void setFy(float fy)
Set the row centroid.
Definition: Peak.h:111
bool operator!=(Peak const &rhs) const
Definition: Peak.h:92