Home | History | Annotate | Download | only in MagickCore
      1 /*
      2   Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
      3   dedicated to making software imaging solutions freely available.
      4 
      5   You may not use this file except in compliance with the License.  You may
      6   obtain a copy of the License at
      7 
      8     https://imagemagick.org/script/license.php
      9 
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15 
     16   MagickCore statistical methods.
     17 */
     18 #ifndef MAGICKCORE_STATISTIC_H
     19 #define MAGICKCORE_STATISTIC_H
     20 
     21 #if defined(__cplusplus) || defined(c_plusplus)
     22 extern "C" {
     23 #endif
     24 
     25 #define MaximumNumberOfImageMoments  8
     26 #define MaximumNumberOfPerceptualColorspaces  6
     27 #define MaximumNumberOfPerceptualHashes  7
     28 
     29 typedef struct _ChannelStatistics
     30 {
     31   size_t
     32     depth;
     33 
     34   double
     35     area,
     36     minima,
     37     maxima,
     38     sum,
     39     sum_squared,
     40     sum_cubed,
     41     sum_fourth_power,
     42     mean,
     43     variance,
     44     standard_deviation,
     45     kurtosis,
     46     skewness,
     47     entropy;
     48 } ChannelStatistics;
     49 
     50 typedef struct _ChannelMoments
     51 {
     52   double
     53     invariant[MaximumNumberOfImageMoments+1];
     54 
     55   PointInfo
     56     centroid,
     57     ellipse_axis;
     58 
     59   double
     60     ellipse_angle,
     61     ellipse_eccentricity,
     62     ellipse_intensity;
     63 } ChannelMoments;
     64 
     65 typedef struct _ChannelPerceptualHash
     66 {
     67   double
     68     srgb_hu_phash[MaximumNumberOfImageMoments+1],
     69     hclp_hu_phash[MaximumNumberOfImageMoments+1];
     70 
     71   size_t
     72     number_colorspaces;
     73 
     74   ColorspaceType
     75     colorspace[MaximumNumberOfPerceptualColorspaces+1];
     76 
     77   double
     78     phash[MaximumNumberOfPerceptualColorspaces+1][MaximumNumberOfImageMoments+1];
     79 
     80   size_t
     81     number_channels;
     82 } ChannelPerceptualHash;
     83 
     84 typedef enum
     85 {
     86   UndefinedEvaluateOperator,
     87   AbsEvaluateOperator,
     88   AddEvaluateOperator,
     89   AddModulusEvaluateOperator,
     90   AndEvaluateOperator,
     91   CosineEvaluateOperator,
     92   DivideEvaluateOperator,
     93   ExponentialEvaluateOperator,
     94   GaussianNoiseEvaluateOperator,
     95   ImpulseNoiseEvaluateOperator,
     96   LaplacianNoiseEvaluateOperator,
     97   LeftShiftEvaluateOperator,
     98   LogEvaluateOperator,
     99   MaxEvaluateOperator,
    100   MeanEvaluateOperator,
    101   MedianEvaluateOperator,
    102   MinEvaluateOperator,
    103   MultiplicativeNoiseEvaluateOperator,
    104   MultiplyEvaluateOperator,
    105   OrEvaluateOperator,
    106   PoissonNoiseEvaluateOperator,
    107   PowEvaluateOperator,
    108   RightShiftEvaluateOperator,
    109   RootMeanSquareEvaluateOperator,
    110   SetEvaluateOperator,
    111   SineEvaluateOperator,
    112   SubtractEvaluateOperator,
    113   SumEvaluateOperator,
    114   ThresholdBlackEvaluateOperator,
    115   ThresholdEvaluateOperator,
    116   ThresholdWhiteEvaluateOperator,
    117   UniformNoiseEvaluateOperator,
    118   XorEvaluateOperator
    119 } MagickEvaluateOperator;
    120 
    121 typedef enum
    122 {
    123   UndefinedFunction,
    124   ArcsinFunction,
    125   ArctanFunction,
    126   PolynomialFunction,
    127   SinusoidFunction
    128 } MagickFunction;
    129 
    130 typedef enum
    131 {
    132   UndefinedStatistic,
    133   GradientStatistic,
    134   MaximumStatistic,
    135   MeanStatistic,
    136   MedianStatistic,
    137   MinimumStatistic,
    138   ModeStatistic,
    139   NonpeakStatistic,
    140   RootMeanSquareStatistic,
    141   StandardDeviationStatistic
    142 } StatisticType;
    143 
    144 extern MagickExport ChannelStatistics
    145   *GetImageStatistics(const Image *,ExceptionInfo *);
    146 
    147 extern MagickExport ChannelMoments
    148   *GetImageMoments(const Image *,ExceptionInfo *);
    149 
    150 extern MagickExport ChannelPerceptualHash
    151   *GetImagePerceptualHash(const Image *,ExceptionInfo *);
    152 
    153 extern MagickExport Image
    154   *EvaluateImages(const Image *,const MagickEvaluateOperator,ExceptionInfo *),
    155   *PolynomialImage(const Image *,const size_t,const double *,ExceptionInfo *),
    156   *StatisticImage(const Image *,const StatisticType,const size_t,const size_t,
    157     ExceptionInfo *);
    158 
    159 extern MagickExport MagickBooleanType
    160   EvaluateImage(Image *,const MagickEvaluateOperator,const double,
    161     ExceptionInfo *),
    162   FunctionImage(Image *,const MagickFunction,const size_t,const double *,
    163     ExceptionInfo *),
    164   GetImageEntropy(const Image *,double *,ExceptionInfo *),
    165   GetImageExtrema(const Image *,size_t *,size_t *,ExceptionInfo *),
    166   GetImageMean(const Image *,double *,double *,ExceptionInfo *),
    167   GetImageKurtosis(const Image *,double *,double *,ExceptionInfo *),
    168   GetImageRange(const Image *,double *,double *,ExceptionInfo *);
    169 
    170 #if defined(__cplusplus) || defined(c_plusplus)
    171 }
    172 #endif
    173 
    174 #endif
    175