Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:11:40

0001 // This may look like C code, but it is really -*- C++ -*-
0002 //
0003 // Copyright @ 2014 ImageMagick Studio LLC, a non-profit organization
0004 // dedicated to making software imaging solutions freely available.
0005 //
0006 // Definition of channel moments.
0007 //
0008 
0009 #if !defined (Magick_ChannelMoments_header)
0010 #define Magick_ChannelMoments_header
0011 
0012 #include "Magick++/Include.h"
0013 #include <vector>
0014 
0015 namespace Magick
0016 {
0017   class Image;
0018 
0019   class MagickPPExport ChannelMoments
0020   {
0021   public:
0022 
0023     // Default constructor
0024     ChannelMoments(void);
0025 
0026     // Copy constructor
0027     ChannelMoments(const ChannelMoments &channelMoments_);
0028 
0029     // Destroy channel moments
0030     ~ChannelMoments(void);
0031 
0032     // X position of centroid
0033     double centroidX(void) const;
0034 
0035     // Y position of centroid
0036     double centroidY(void) const;
0037 
0038     // The channel
0039     PixelChannel channel(void) const;
0040 
0041     // X position of ellipse axis
0042     double ellipseAxisX(void) const;
0043 
0044     // Y position of ellipse axis
0045     double ellipseAxisY(void) const;
0046 
0047     // Ellipse angle
0048     double ellipseAngle(void) const;
0049 
0050     // Ellipse eccentricity
0051     double ellipseEccentricity(void) const;
0052 
0053     // Ellipse intensity
0054     double ellipseIntensity(void) const;
0055 
0056     // Hu invariants (valid range for index is 0-7)
0057     double huInvariants(const size_t index_) const;
0058 
0059     // Does object contain valid channel moments?
0060     bool isValid() const;
0061 
0062     //
0063     // Implementation methods
0064     //
0065 
0066     ChannelMoments(const PixelChannel channel_,
0067       const MagickCore::ChannelMoments *channelMoments_);
0068 
0069   private:
0070     PixelChannel _channel;
0071     std::vector<double> _huInvariants;
0072     double _centroidX;
0073     double _centroidY;
0074     double _ellipseAxisX;
0075     double _ellipseAxisY;
0076     double _ellipseAngle;
0077     double _ellipseEccentricity;
0078     double _ellipseIntensity;
0079   };
0080 
0081   class MagickPPExport ChannelPerceptualHash
0082   {
0083   public:
0084 
0085     // Default constructor
0086     ChannelPerceptualHash(void);
0087 
0088     // Copy constructor
0089     ChannelPerceptualHash(const ChannelPerceptualHash &channelPerceptualHash_);
0090 
0091     // Constructor using the specified hash string
0092     ChannelPerceptualHash(const PixelChannel channel_,
0093       const std::string &hash_);
0094 
0095     // Destroy channel perceptual hash
0096     ~ChannelPerceptualHash(void);
0097 
0098     // Return hash string
0099     operator std::string() const;
0100 
0101     // The channel
0102     PixelChannel channel(void) const;
0103 
0104     // Does object contain valid channel perceptual hash?
0105     bool isValid() const;
0106 
0107     // Returns the sum squared difference between this hash and the other hash
0108     double sumSquaredDifferences(
0109       const ChannelPerceptualHash &channelPerceptualHash_);
0110 
0111     // SRGB hu preceptual hash (valid range for index is 0-6)
0112     double srgbHuPhash(const size_t index_) const;
0113 
0114     // HCLp hu preceptual hash (valid range for index is 0-6)
0115     double hclpHuPhash(const size_t index_) const;
0116 
0117     //
0118     // Implementation methods
0119     //
0120 
0121     ChannelPerceptualHash(const PixelChannel channel_,
0122       const MagickCore::ChannelPerceptualHash *channelPerceptualHash_);
0123 
0124   private:
0125     PixelChannel _channel;
0126     std::vector<double> _srgbHuPhash;
0127     std::vector<double> _hclpHuPhash;
0128   };
0129 
0130   // Obtain image statistics. Statistics are normalized to the range
0131   // of 0.0 to 1.0 and are output to the specified ImageStatistics
0132   // structure.
0133   class MagickPPExport ChannelStatistics
0134   {
0135   public:
0136 
0137     // Default constructor
0138     ChannelStatistics(void);
0139 
0140     // Copy constructor
0141     ChannelStatistics(const ChannelStatistics &channelStatistics_);
0142 
0143     // Destroy channel statistics
0144     ~ChannelStatistics(void);
0145 
0146     // Area
0147     double area() const;
0148 
0149     // The channel
0150     PixelChannel channel(void) const;
0151 
0152     // Depth
0153     size_t depth() const;
0154 
0155     // Entropy
0156     double entropy() const;
0157 
0158     // Does object contain valid channel statistics?
0159     bool isValid() const;
0160 
0161     // Kurtosis
0162     double kurtosis() const;
0163 
0164     // Minimum value observed
0165     double maxima() const;
0166 
0167     // Average (mean) value observed
0168     double mean() const;
0169 
0170     // Maximum value observed
0171     double minima() const;
0172 
0173     // Skewness
0174     double skewness() const;
0175 
0176     // Standard deviation, sqrt(variance)
0177     double standardDeviation() const;
0178 
0179     // Sum
0180     double sum() const;
0181 
0182     // Sum cubed
0183     double sumCubed() const;
0184 
0185     // Sum fourth power
0186     double sumFourthPower() const;
0187 
0188     // Sum squared
0189     double sumSquared() const;
0190 
0191     // Variance
0192     double variance() const;
0193 
0194     //
0195     // Implementation methods
0196     //
0197 
0198     ChannelStatistics(const PixelChannel channel_,
0199       const MagickCore::ChannelStatistics *channelStatistics_);
0200 
0201   private:
0202     PixelChannel _channel;
0203     double _area;
0204     size_t _depth;
0205     double _entropy;
0206     double _kurtosis;
0207     double _maxima;
0208     double _mean;
0209     double _minima;
0210     double _skewness;
0211     double _standardDeviation;
0212     double _sum;
0213     double _sumCubed;
0214     double _sumFourthPower;
0215     double _sumSquared;
0216     double _variance;
0217   };
0218 
0219   class MagickPPExport ImageMoments
0220   {
0221   public:
0222 
0223     // Default constructor
0224     ImageMoments(void);
0225 
0226     // Copy constructor
0227     ImageMoments(const ImageMoments &imageMoments_);
0228 
0229     // Destroy image moments
0230     ~ImageMoments(void);
0231 
0232     // Returns the moments for the specified channel
0233     ChannelMoments channel(const PixelChannel channel_) const;
0234 
0235     //
0236     // Implementation methods
0237     //
0238     ImageMoments(const Image &image_);
0239 
0240   private:
0241     std::vector<ChannelMoments> _channels;
0242   };
0243 
0244   class MagickPPExport ImagePerceptualHash
0245   {
0246   public:
0247 
0248     // Default constructor
0249     ImagePerceptualHash(void);
0250 
0251     // Copy constructor
0252     ImagePerceptualHash(const ImagePerceptualHash &imagePerceptualHash_);
0253 
0254     // Constructor using the specified hash string
0255     ImagePerceptualHash(const std::string &hash_);
0256 
0257     // Destroy image perceptual hash
0258     ~ImagePerceptualHash(void);
0259 
0260     // Return hash string
0261     operator std::string() const;
0262 
0263     // Returns the perceptual hash for the specified channel
0264     ChannelPerceptualHash channel(const PixelChannel channel_) const;
0265 
0266     // Does object contain valid perceptual hash?
0267     bool isValid() const;
0268 
0269     // Returns the sum squared difference between this hash and the other hash
0270     double sumSquaredDifferences(
0271       const ImagePerceptualHash &channelPerceptualHash_);
0272 
0273     //
0274     // Implementation methods
0275     //
0276     ImagePerceptualHash(const Image &image_);
0277 
0278   private:
0279     std::vector<ChannelPerceptualHash> _channels;
0280   };
0281 
0282   class MagickPPExport ImageStatistics
0283   {
0284   public:
0285 
0286     // Default constructor
0287     ImageStatistics(void);
0288 
0289     // Copy constructor
0290     ImageStatistics(const ImageStatistics &imageStatistics_);
0291 
0292     // Destroy image statistics
0293     ~ImageStatistics(void);
0294 
0295     // Returns the statistics for the specified channel
0296     ChannelStatistics channel(const PixelChannel channel_) const;
0297 
0298     //
0299     // Implementation methods
0300     //
0301     ImageStatistics(const Image &image_);
0302 
0303   private:
0304     std::vector<ChannelStatistics> _channels;
0305   };
0306 }
0307 
0308 #endif // Magick_ChannelMoments_header