/dmagick/c/statistic.d

http://github.com/MikeWey/DMagick · D · 240 lines · 199 code · 29 blank · 12 comment · 13 complexity · 8830b80b551915863dce5a5925f01aa3 MD5 · raw file

  1. module dmagick.c.statistic;
  2. import dmagick.c.draw;
  3. import dmagick.c.exception;
  4. import dmagick.c.image;
  5. import dmagick.c.magickType;
  6. import dmagick.c.magickVersion;
  7. extern(C)
  8. {
  9. struct ChannelStatistics
  10. {
  11. size_t
  12. depth;
  13. static if ( MagickLibVersion >= 0x664 )
  14. {
  15. double
  16. minima,
  17. maxima,
  18. sum,
  19. sum_squared,
  20. sum_cubed,
  21. sum_fourth_power,
  22. mean,
  23. variance,
  24. standard_deviation,
  25. kurtosis,
  26. skewness;
  27. }
  28. else
  29. {
  30. double
  31. minima,
  32. maxima,
  33. mean,
  34. standard_deviation,
  35. kurtosis,
  36. skewness;
  37. }
  38. static if ( MagickLibVersion >= 0x690 )
  39. {
  40. double entropy;
  41. }
  42. }
  43. static if ( MagickLibVersion >= 0x689 )
  44. {
  45. struct ChannelMoments
  46. {
  47. double[32]
  48. I;
  49. PointInfo
  50. centroid,
  51. ellipse_axis;
  52. double
  53. ellipse_angle,
  54. ellipse_eccentricity,
  55. ellipse_intensity;
  56. }
  57. struct ChannelPerceptualHash
  58. {
  59. double[32]
  60. P,
  61. Q;
  62. }
  63. }
  64. /**
  65. * Alter channel pixels by evaluating an arithmetic, relational,
  66. * or logical expression.
  67. */
  68. enum MagickEvaluateOperator
  69. {
  70. UndefinedEvaluateOperator, ///
  71. AddEvaluateOperator, /// Add value to pixels.
  72. AndEvaluateOperator, /// Binary AND of pixels with value.
  73. DivideEvaluateOperator, /// Divide pixels by value.
  74. LeftShiftEvaluateOperator, /// Shift the pixel values left by value bits.
  75. MaxEvaluateOperator, /// Clip pixels at lower bound value.
  76. MinEvaluateOperator, /// Clip pixels at upper bound value.
  77. MultiplyEvaluateOperator, /// Multiply pixels by value.
  78. OrEvaluateOperator, /// Binary OR of pixels with value.
  79. RightShiftEvaluateOperator, /// Shift the pixel values right by value bits.
  80. SetEvaluateOperator, /// Set pixel equal to value.
  81. SubtractEvaluateOperator, /// Subtract value from pixels.
  82. XorEvaluateOperator, /// Binary XOR of pixels with value.
  83. PowEvaluateOperator, /// Raise normalized pixels to the power value.
  84. LogEvaluateOperator, /// Apply scaled logarithm to normalized pixels.
  85. ThresholdEvaluateOperator, /// Threshold pixels larger than value.
  86. ThresholdBlackEvaluateOperator, /// Threshold pixels to zero values equal to or below value.
  87. ThresholdWhiteEvaluateOperator, /// Threshold pixels to maximum values above value.
  88. GaussianNoiseEvaluateOperator, ///
  89. ImpulseNoiseEvaluateOperator, /// ditto
  90. LaplacianNoiseEvaluateOperator, /// ditto
  91. MultiplicativeNoiseEvaluateOperator, /// ditto
  92. PoissonNoiseEvaluateOperator, /// ditto
  93. UniformNoiseEvaluateOperator, /// ditto
  94. CosineEvaluateOperator, /// Apply cosine to pixels with frequency value with 50% bias added.
  95. SineEvaluateOperator, /// Apply sine to pixels with frequency value with 50% bias added.
  96. AddModulusEvaluateOperator, /// Add value to pixels modulo QuantumRange.
  97. MeanEvaluateOperator, /// Add the value and divide by 2.
  98. AbsEvaluateOperator, /// Add value to pixels and return absolute value.
  99. ExponentialEvaluateOperator, /// base-e exponential function.
  100. MedianEvaluateOperator, /// Choose the median value from an image sequence.
  101. SumEvaluateOperator, /// Add value to pixels.
  102. RootMeanSquareEvaluateOperator ///
  103. }
  104. /**
  105. * Apply a function to channel values.
  106. *
  107. * See_Also: $(XREF Image, functionImage).
  108. */
  109. enum MagickFunction
  110. {
  111. UndefinedFunction, ///
  112. PolynomialFunction, /// ditto
  113. SinusoidFunction, /// ditto
  114. ArcsinFunction, /// ditto
  115. ArctanFunction /// ditto
  116. }
  117. version(D_Ddoc)
  118. {
  119. /**
  120. * The statistic method to apply.
  121. */
  122. enum StatisticType
  123. {
  124. UndefinedStatistic, ///
  125. GradientStatistic, /// Maximum difference in area.
  126. MaximumStatistic, /// Maximum value per channel in neighborhood.
  127. MeanStatistic, /// Average value per channel in neighborhood.
  128. MedianStatistic, /// Median value per channel in neighborhood.
  129. MinimumStatistic, /// Minimum value per channel in neighborhood.
  130. ModeStatistic, /// Mode (most frequent) value per channel in neighborhood.
  131. NonpeakStatistic, /// Value just before or after the median value per channel in neighborhood.
  132. StandardDeviationStatistic, ///
  133. RootMeanSquareStatistic ///
  134. }
  135. }
  136. else
  137. {
  138. mixin(
  139. {
  140. string types = "enum StatisticType
  141. {
  142. UndefinedStatistic,";
  143. static if ( MagickLibVersion >= 0x670 )
  144. {
  145. types ~= "GradientStatistic,";
  146. }
  147. types ~= "
  148. MaximumStatistic,
  149. MeanStatistic,
  150. MedianStatistic,
  151. MinimumStatistic,
  152. ModeStatistic,
  153. NonpeakStatistic,";
  154. static if ( MagickLibVersion >= 0x670 )
  155. {
  156. types ~= "StandardDeviationStatistic,";
  157. }
  158. static if ( MagickLibVersion >= 0x690 )
  159. {
  160. types ~= "RootMeanSquareStatistic,";
  161. }
  162. types ~= "
  163. }";
  164. return types;
  165. }());
  166. }
  167. ChannelStatistics* GetImageChannelStatistics(const(Image)*, ExceptionInfo*);
  168. static if ( MagickLibVersion >= 0x689 )
  169. {
  170. ChannelMoments* GetImageChannelMoments(const(Image)*, ExceptionInfo*);
  171. ChannelPerceptualHash* GetImageChannelPerceptualHash(const(Image)*, ExceptionInfo*);
  172. }
  173. static if ( MagickLibVersion < 0x661 )
  174. {
  175. Image* AverageImages(const(Image)*, ExceptionInfo*);
  176. }
  177. static if ( MagickLibVersion >= 0x661 )
  178. {
  179. Image* EvaluateImages(const(Image)*, const MagickEvaluateOperator, ExceptionInfo*);
  180. }
  181. static if ( MagickLibVersion >= 0x681 )
  182. {
  183. Image* PolynomialImage(const(Image)*, const size_t, const(double)*, ExceptionInfo*);
  184. Image* PolynomialImageChannel(const(Image)*, const ChannelType, const size_t, const(double)*, ExceptionInfo*);
  185. }
  186. static if ( MagickLibVersion >= 0x669 )
  187. {
  188. Image* StatisticImage(const(Image)*, const StatisticType, const size_t, const size_t, ExceptionInfo*);
  189. Image* StatisticImageChannel(const(Image)*, const ChannelType, const StatisticType, const size_t, const size_t, ExceptionInfo*);
  190. }
  191. MagickBooleanType EvaluateImage(Image*, const MagickEvaluateOperator, const double, ExceptionInfo*);
  192. MagickBooleanType EvaluateImageChannel(Image*, const ChannelType, const MagickEvaluateOperator, const double, ExceptionInfo*);
  193. MagickBooleanType FunctionImage(Image*, const MagickFunction, const size_t, const(double)*, ExceptionInfo*);
  194. MagickBooleanType FunctionImageChannel(Image*, const ChannelType, const MagickFunction, const size_t, const(double)*, ExceptionInfo*);
  195. static if ( MagickLibVersion >= 0x690 )
  196. {
  197. MagickBooleanType GetImageChannelEntropy(const(Image)*, const ChannelType, double*, ExceptionInfo*);
  198. }
  199. MagickBooleanType GetImageChannelExtrema(const(Image)*, const ChannelType, size_t*, size_t*, ExceptionInfo*);
  200. MagickBooleanType GetImageChannelMean(const(Image)*, const ChannelType, double*, double*, ExceptionInfo*);
  201. MagickBooleanType GetImageChannelKurtosis(const(Image)*, const ChannelType, double*, double*, ExceptionInfo*);
  202. MagickBooleanType GetImageChannelRange(const(Image)*, const ChannelType, double*, double*, ExceptionInfo*);
  203. static if ( MagickLibVersion >= 0x690 )
  204. {
  205. MagickBooleanType GetImageEntropy(const(Image)*, double*, ExceptionInfo*);
  206. }
  207. MagickBooleanType GetImageExtrema(const(Image)*, size_t*, size_t*, ExceptionInfo*);
  208. MagickBooleanType GetImageMean(const(Image)*, double*, double*, ExceptionInfo*);
  209. MagickBooleanType GetImageKurtosis(const(Image)*, double*, double*, ExceptionInfo*);
  210. MagickBooleanType GetImageRange(const(Image)*, double*, double*, ExceptionInfo*);
  211. }