Magick++  7.1.0
Statistic.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright @ 2014 ImageMagick Studio LLC, a non-profit organization
4 // dedicated to making software imaging solutions freely available.
5 //
6 // Definition of channel moments.
7 //
8 
9 #if !defined (Magick_ChannelMoments_header)
10 #define Magick_ChannelMoments_header
11 
12 #include "Magick++/Include.h"
13 #include <vector>
14 
15 namespace Magick
16 {
17  class Image;
18 
20  {
21  public:
22 
23  // Default constructor
24  ChannelMoments(void);
25 
26  // Copy constructor
27  ChannelMoments(const ChannelMoments &channelMoments_);
28 
29  // Destroy channel moments
30  ~ChannelMoments(void);
31 
32  // X position of centroid
33  double centroidX(void) const;
34 
35  // Y position of centroid
36  double centroidY(void) const;
37 
38  // The channel
39  PixelChannel channel(void) const;
40 
41  // X position of ellipse axis
42  double ellipseAxisX(void) const;
43 
44  // Y position of ellipse axis
45  double ellipseAxisY(void) const;
46 
47  // Ellipse angle
48  double ellipseAngle(void) const;
49 
50  // Ellipse eccentricity
51  double ellipseEccentricity(void) const;
52 
53  // Ellipse intensity
54  double ellipseIntensity(void) const;
55 
56  // Hu invariants (valid range for index is 0-7)
57  double huInvariants(const size_t index_) const;
58 
59  // Does object contain valid channel moments?
60  bool isValid() const;
61 
62  //
63  // Implemementation methods
64  //
65 
66  ChannelMoments(const PixelChannel channel_,
67  const MagickCore::ChannelMoments *channelMoments_);
68 
69  private:
70  PixelChannel _channel;
71  std::vector<double> _huInvariants;
72  double _centroidX;
73  double _centroidY;
74  double _ellipseAxisX;
75  double _ellipseAxisY;
76  double _ellipseAngle;
77  double _ellipseEccentricity;
78  double _ellipseIntensity;
79  };
80 
82  {
83  public:
84 
85  // Default constructor
87 
88  // Copy constructor
89  ChannelPerceptualHash(const ChannelPerceptualHash &channelPerceptualHash_);
90 
91  // Constructor using the specified hash string
92  ChannelPerceptualHash(const PixelChannel channel_,
93  const std::string &hash_);
94 
95  // Destroy channel perceptual hash
96  ~ChannelPerceptualHash(void);
97 
98  // Return hash string
99  operator std::string() const;
100 
101  // The channel
102  PixelChannel channel(void) const;
103 
104  // Does object contain valid channel perceptual hash?
105  bool isValid() const;
106 
107  // Returns the sum squared difference between this hash and the other hash
108  double sumSquaredDifferences(
109  const ChannelPerceptualHash &channelPerceptualHash_);
110 
111  // SRGB hu preceptual hash (valid range for index is 0-6)
112  double srgbHuPhash(const size_t index_) const;
113 
114  // HCLp hu preceptual hash (valid range for index is 0-6)
115  double hclpHuPhash(const size_t index_) const;
116 
117  //
118  // Implemementation methods
119  //
120 
121  ChannelPerceptualHash(const PixelChannel channel_,
122  const MagickCore::ChannelPerceptualHash *channelPerceptualHash_);
123 
124  private:
125  PixelChannel _channel;
126  std::vector<double> _srgbHuPhash;
127  std::vector<double> _hclpHuPhash;
128  };
129 
130  // Obtain image statistics. Statistics are normalized to the range
131  // of 0.0 to 1.0 and are output to the specified ImageStatistics
132  // structure.
134  {
135  public:
136 
137  // Default constructor
138  ChannelStatistics(void);
139 
140  // Copy constructor
141  ChannelStatistics(const ChannelStatistics &channelStatistics_);
142 
143  // Destroy channel statistics
144  ~ChannelStatistics(void);
145 
146  // Area
147  double area() const;
148 
149  // The channel
150  PixelChannel channel(void) const;
151 
152  // Depth
153  size_t depth() const;
154 
155  // Entropy
156  double entropy() const;
157 
158  // Does object contain valid channel statistics?
159  bool isValid() const;
160 
161  // Kurtosis
162  double kurtosis() const;
163 
164  // Minimum value observed
165  double maxima() const;
166 
167  // Average (mean) value observed
168  double mean() const;
169 
170  // Maximum value observed
171  double minima() const;
172 
173  // Skewness
174  double skewness() const;
175 
176  // Standard deviation, sqrt(variance)
177  double standardDeviation() const;
178 
179  // Sum
180  double sum() const;
181 
182  // Sum cubed
183  double sumCubed() const;
184 
185  // Sum fourth power
186  double sumFourthPower() const;
187 
188  // Sum squared
189  double sumSquared() const;
190 
191  // Variance
192  double variance() const;
193 
194  //
195  // Implemementation methods
196  //
197 
198  ChannelStatistics(const PixelChannel channel_,
199  const MagickCore::ChannelStatistics *channelStatistics_);
200 
201  private:
202  PixelChannel _channel;
203  double _area;
204  size_t _depth;
205  double _entropy;
206  double _kurtosis;
207  double _maxima;
208  double _mean;
209  double _minima;
210  double _skewness;
211  double _standardDeviation;
212  double _sum;
213  double _sumCubed;
214  double _sumFourthPower;
215  double _sumSquared;
216  double _variance;
217  };
218 
220  {
221  public:
222 
223  // Default constructor
224  ImageMoments(void);
225 
226  // Copy constructor
227  ImageMoments(const ImageMoments &imageMoments_);
228 
229  // Destroy image moments
230  ~ImageMoments(void);
231 
232  // Returns the moments for the specified channel
233  ChannelMoments channel(const PixelChannel channel_) const;
234 
235  //
236  // Implemementation methods
237  //
238  ImageMoments(const Image &image_);
239 
240  private:
241  std::vector<ChannelMoments> _channels;
242  };
243 
245  {
246  public:
247 
248  // Default constructor
249  ImagePerceptualHash(void);
250 
251  // Copy constructor
252  ImagePerceptualHash(const ImagePerceptualHash &imagePerceptualHash_);
253 
254  // Constructor using the specified hash string
255  ImagePerceptualHash(const std::string &hash_);
256 
257  // Destroy image perceptual hash
258  ~ImagePerceptualHash(void);
259 
260  // Return hash string
261  operator std::string() const;
262 
263  // Returns the perceptual hash for the specified channel
264  ChannelPerceptualHash channel(const PixelChannel channel_) const;
265 
266  // Does object contain valid perceptual hash?
267  bool isValid() const;
268 
269  // Returns the sum squared difference between this hash and the other hash
270  double sumSquaredDifferences(
271  const ImagePerceptualHash &channelPerceptualHash_);
272 
273  //
274  // Implemementation methods
275  //
276  ImagePerceptualHash(const Image &image_);
277 
278  private:
279  std::vector<ChannelPerceptualHash> _channels;
280  };
281 
283  {
284  public:
285 
286  // Default constructor
287  ImageStatistics(void);
288 
289  // Copy constructor
290  ImageStatistics(const ImageStatistics &imageStatistics_);
291 
292  // Destroy image statistics
293  ~ImageStatistics(void);
294 
295  // Returns the statistics for the specified channel
296  ChannelStatistics channel(const PixelChannel channel_) const;
297 
298  //
299  // Implemementation methods
300  //
301  ImageStatistics(const Image &image_);
302 
303  private:
304  std::vector<ChannelStatistics> _channels;
305  };
306 }
307 
308 #endif // Magick_ChannelMoments_header
#define MagickPPExport
Definition: Include.h:297
class MagickPPExport Image
Definition: Drawable.h:722
Definition: Blob.h:17