fw4spl
Histogram.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "fwData/config.hpp"
10 #include "fwData/factory/new.hpp"
11 #include "fwData/Object.hpp"
12 
13 fwCampAutoDeclareDataMacro((fwData)(Histogram), FWDATA_API);
14 
15 namespace fwData
16 {
17 
21 class FWDATA_CLASS_API Histogram : public Object
22 {
23 
24 public:
25 
26  fwCoreClassDefinitionsWithFactoryMacro( (Histogram)(::fwData::Object), (()), ::fwData::factory::New< Histogram > );
27 
28  fwCampMakeFriendDataMacro((fwData)(Histogram));
29 
30  typedef std::vector< long > fwHistogramValues;
31 
36  FWDATA_API Histogram(::fwData::Object::Key key);
37 
39  FWDATA_API virtual ~Histogram();
40 
42  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
43 
45  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
46 
55  FWDATA_API void addPixel( float pixel );
56 
66  FWDATA_API long getNbPixels( float _min, float _max );
67 
75  FWDATA_API void initialize( float min, float max, float binsWidth );
76 
84  FWDATA_API bool isInRange( float _pixel );
85 
90  const float getBinsWidth() const;
91  void setBinsWidth(float _binsWidth);
93 
98  fwHistogramValues& getValues();
99  const fwHistogramValues& getValues() const;
100  void setValues(const fwHistogramValues& _values);
102 
107  float& getMinValue ();
108  const float& getMinValue () const;
109  void setMinValue (float _minValue);
111 
116  float& getMaxValue();
117  const float& getMaxValue() const;
118  void setMaxValue(float _maxValue);
120 
121 protected:
122 
124  fwHistogramValues m_values;
125 
127  float m_binsWidth;
128 
130  float m_minValue;
131 
133  float m_maxValue;
134 };
135 
136 //-----------------------------------------------------------------------------
137 
138 inline const float Histogram::getBinsWidth() const
139 {
140  return m_binsWidth;
141 }
142 
143 //-----------------------------------------------------------------------------
144 
145 inline void Histogram::setBinsWidth(float _binsWidth)
146 {
147  this->m_binsWidth = _binsWidth;
148 }
149 
150 //-----------------------------------------------------------------------------
151 
152 inline Histogram::fwHistogramValues& Histogram::getValues()
153 {
154  return this->m_values;
155 }
156 
157 //-----------------------------------------------------------------------------
158 
159 inline const Histogram::fwHistogramValues& Histogram::getValues() const
160 {
161  return this->m_values;
162 }
163 
164 //-----------------------------------------------------------------------------
165 
166 inline void Histogram::setValues(const Histogram::fwHistogramValues& _values)
167 {
168  this->m_values = _values;
169 }
170 
171 //-----------------------------------------------------------------------------
172 
173 inline float& Histogram::getMinValue ()
174 {
175  return this->m_minValue;
176 }
177 
178 //-----------------------------------------------------------------------------
179 
180 inline const float& Histogram::getMinValue () const
181 {
182  return this->m_minValue;
183 }
184 
185 //-----------------------------------------------------------------------------
186 
187 inline void Histogram::setMinValue (float _minValue)
188 {
189  this->m_minValue = _minValue;
190 }
191 
192 //-----------------------------------------------------------------------------
193 
194 inline float& Histogram::getMaxValue()
195 {
196  return this->m_maxValue;
197 }
198 
199 //-----------------------------------------------------------------------------
200 
201 inline const float& Histogram::getMaxValue() const
202 {
203  return this->m_maxValue;
204 }
205 
206 //-----------------------------------------------------------------------------
207 
208 inline void Histogram::setMaxValue(float _maxValue)
209 {
210  this->m_maxValue = _maxValue;
211 }
212 
213 //-----------------------------------------------------------------------------
214 
215 } // namespace fwData
fwHistogramValues m_values
Histogram values.
Definition: Histogram.hpp:124
float m_minValue
The minimum pixel value within the histogram (a default value is set to 0).
Definition: Histogram.hpp:130
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
This class defines the histogram of an image.
Definition: Histogram.hpp:21
float m_maxValue
The maximum pixel value within the histogram (a default value is set to 100).
Definition: Histogram.hpp:133
float m_binsWidth
The pixel width of the bins (a default value is set to 1).
Definition: Histogram.hpp:127
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Base class for each data object.
Contains the representation of the data objects used in the framework.