PageRenderTime 36ms CodeModel.GetById 13ms app.highlight 19ms RepoModel.GetById 2ms app.codeStats 0ms

/dmagick/c/statistic.d

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