1 /** \file
2  * \brief Image Processing - Point Operations
3  *
4  * See Copyright Notice in im_lib.h
5  */
6 module im.im_process_pnt;
7 
8 version(IM) :
9 
10 import im.im : FreeEnumMembers;
11 import im.im_image : imImage;
12 
13 //version(DigitalMars) version(Windows) { pragma(lib, "im.lib"); } // required anyway
14 
15 extern(C) :
16 @nogc nothrow {
17 
18 /** \defgroup point Point Based Custom Operations
19  * \par
20  * See \ref im_process_pnt.h
21  * \ingroup process */
22 
23 
24 /** Custom unary point function. \n
25  * Data will be set only if the returned value is non zero.
26  * \verbatim func(src_value: number, params1, param2, ..., x: number, y: number, d: number) -> dst_value: number  [in Lua 5] \endverbatim
27  * In Lua, the params table is unpacked.
28  * And the returned value contains only the target values to update, or nil (also no return value) to leave target intact.
29  * \ingroup point */
30 alias imUnaryPointOpFunc = int function(float src_value, float* dst_value, float* params, void* userdata, int x, int y, int d);
31 
32 /** Apply an unary point operation using a custom function.
33  * One pixel from the source affects the same pixel on target. \n
34  * Can be done in-place, images must match size and depth.
35  * Data type can be different, but complex is not supported. \n
36  * op_name is used only by the counter and can be NULL.
37  * Returns zero if the counter aborted.
38  *
39  * \verbatim im.ProcessUnaryPointOp(src_image: imImage, dst_image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean [in Lua 5] \endverbatim
40  * \verbatim im.ProcessUnaryPointOpNew(image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
41  * In Lua, the params table is passed to the function by using the Lua stack,
42  * so its table can contain any type of objects, but they all must be unnamed.
43  * \ingroup point */
44 int imProcessUnaryPointOp(const(imImage)* src_image, imImage* dst_image, imUnaryPointOpFunc func, float* params, void* userdata, const(char)* op_name);
45 
46 /** Custom unary point color function. \n
47  * Data will be set only if the returned value is non zero.
48  * \verbatim func(src_value_plane0: number, src_value_plane1: number, ... , params1, param2, ..., x: number, y: number) -> dst_value_plane0: number, dst_value_plane1: number, ...  [in Lua 5] \endverbatim
49  * In Lua, the params table is unpacked.
50  * Also each color plane is passed as a separate value, instead of inside an array.
51  * And the returned value contains only the target values to update, or nil (also no return value) to leave target intact.
52  * \ingroup point */
53 alias imUnaryPointColorOpFunc = int function(const(float)* src_value, float* dst_value, float* params, void* userdata, int x, int y);
54 
55 /** Apply an unary point color operation using a custom function.
56  * One pixel from the source affects the same pixel on target. \n
57  * Can be done in-place, images must match size, depth can be different.
58  * Data type can be different, but complex is not supported. \n
59  * op_name is used only by the counter and can be NULL.
60  * Returns zero if the counter aborted.
61  *
62  * \verbatim im.ProcessUnaryPointColorOp(src_image: imImage, dst_image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean [in Lua 5] \endverbatim
63  * \verbatim im.ProcessUnaryPointColorOpNew(image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
64  * In Lua, the params table is passed to the function by using the Lua stack,
65  * so its table can contain any type of objects, but they all must be unnamed.
66  * \ingroup point */
67 int imProcessUnaryPointColorOp(const(imImage)* src_image, imImage* dst_image, imUnaryPointColorOpFunc func, float* params, void* userdata, const(char)* op_name);
68 
69 /** Custom multiple point function. \n
70  * Source values are copies, so they can be changed inside the function without affecting the original image. \n
71  * Data will be set only if the returned value is non zero.
72  * \verbatim func(src_value1: number, src_value2: number, ... , params1, param2, ..., x: number, y: number, d: number) -> dst_value: number  [in Lua 5] \endverbatim
73  * In Lua, the source images data and the params table are unpacked.
74  * And the returned value contains only the target values to update, or nil (also no return value) to leave target intact.
75  * \ingroup point */
76 alias imMultiPointOpFunc = int function(const(float)* src_value, float* dst_value, float* params, void* userdata, int x, int y, int d, int src_image_count);
77 
78 /** Apply an multiple point operation using a custom function.
79  * One pixel from each source affects the same pixel on target. \n
80  * All source images must match in size, depth and data type.
81  * Can be done in-place, source and target must match size and depth.
82  * Data type can be different between sources and target, but complex is not supported. \n
83  * op_name is used only by the counter and can be NULL.
84  * Returns zero if the counter aborted.
85  *
86  * \verbatim im.ProcessMultiPointOp(src_image: table of imImage, dst_image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean [in Lua 5] \endverbatim
87  * \verbatim im.ProcessMultiPointOpNew(src_image: table of imImage, func: function, params: table, [op_name: string]) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
88  * In Lua, the params table is passed to the function by using the Lua stack, 
89  * so its table can contain any type of objects, but they all must be unnamed.
90  * \ingroup point */
91 int imProcessMultiPointOp(const(imImage)** src_image_list, int src_image_count, imImage* dst_image, imMultiPointOpFunc func, float* params, void* userdata, const(char)* op_name);
92 
93 /** Custom multiple point color function. \n
94  * Source values are copies, so they can be changed inside the function without affecting the original image. \n
95  * Data will be set only if the returned value is non zero.
96  * \verbatim func(src_value1_plane0: number, src_value1_plane1: number, ..., src_value2_plane0: number, src_value2_plane1: number, ... , params1, param2, ..., x: number, y: number) -> dst_value_plane0: number, dst_value_plane1: number, ...  [in Lua 5] \endverbatim
97  * In Lua, the source images data and the params table are unpacked.
98  * Also each color plane is passed as a separate value, instead of inside an array.
99  * And the returned value contains only the target values to update, or nil (also no return value) to leave target intact.
100  * \ingroup point */
101 alias imMultiPointColorOpFunc = int function(float* src_value, float* dst_value, float* params, void* userdata, int x, int y, int src_image_count, int src_depth, int dst_depth);
102 
103 /** Apply an multiple point color operation using a custom function.
104  * One pixel from each source affects the same pixel on target. \n
105  * All source images must match in size, depth and data type.
106  * Can be done in-place, source and target must match size, depth can be different.
107  * Data type can be different between sources and target, but complex is not supported. \n
108  * op_name is used only by the counter and can be NULL.
109  * Returns zero if the counter aborted.
110  *
111  * \verbatim im.ProcessMultiPointColorOp(src_image: table of imImage, dst_image: imImage, func: function, params: table, [op_name: string]) -> counter: boolean [in Lua 5] \endverbatim
112  * \verbatim im.ProcessMultiPointColorOpNew(src_image: table of imImage, func: function, params: table, [op_name: string]) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
113  * In Lua, the params table is passed to the function by using the Lua stack,
114  * so its table can contain any type of objects, but they all must be unnamed.
115  * \ingroup point */
116 int imProcessMultiPointColorOp(const(imImage)** src_image_list, int src_image_count, imImage* dst_image, imMultiPointColorOpFunc func, float* params, void* userdata, const(char)* op_name);
117 
118 } // @nogc nothrow
119 
120 /** \defgroup arithm Arithmetic Operations
121  * \par
122  * Simple math operations for images.
123  * \par
124  * See \ref im_process_pnt.h
125  * \ingroup process */
126 
127 /** Unary Arithmetic Operations. \n
128  * (#) Inverse and log may lead to math exceptions.
129  * \ingroup arithm */
130 enum imUnaryOp {
131   IM_UN_EQL,     /**< equal             = a              */
132   IM_UN_ABS,     /**< absolute         = |a|            */
133   IM_UN_LESS,    /**< less              = -a             */
134   IM_UN_INV,     /**< invert (#)        = 1/a            */
135   IM_UN_SQR,     /**< square            = a*a            */
136   IM_UN_SQRT,    /**< square root       = a^(1/2)        */
137   IM_UN_LOG,     /**< natural logarithm (#) =  ln(a)     */
138   IM_UN_EXP,     /**< exponential       = exp(a)         */
139   IM_UN_SIN,     /**< sine              = sin(a)         */
140   IM_UN_COS,     /**< cosine            = cos(a)         */
141   IM_UN_CONJ,    /**< complex conjugate = ar - ai*i      */
142   IM_UN_CPXNORM, /**< complex normalization by magnitude = a / cpxmag(a)  */
143   IM_UN_POSITIVES, /**< positives       = if a<0 then a=0   */
144   IM_UN_NEGATIVES  /**< negatives       = if a>0 then a=0   */
145 }
146 mixin FreeEnumMembers!imUnaryOp;
147 
148 /** Apply an arithmetic unary operation. \n
149  * Can be done in-place, images must match color space and size. \n
150  * Target image can be several types depending on source: \n
151  * \li any integer -> any integer or real
152  * \li real -> real
153  * \li complex -> complex
154  * If source is complex, target complex must be the same data type (imcfloat-imcfloat or imcdouble-imcdouble only). \n
155  * If target is byte, then the result is cropped to 0-255.
156  *
157  * \verbatim im.ProcessUnArithmeticOp(src_image: imImage, dst_image: imImage, op: number) [in Lua 5] \endverbatim
158  * \verbatim im.ProcessUnArithmeticOpNew(image: imImage, op: number) -> new_image: imImage [in Lua 5] \endverbatim
159  * \ingroup arithm */
160 void imProcessUnArithmeticOp(const(imImage)* src_image, imImage* dst_image, int op);
161 
162 /** Binary Arithmetic Operations. \n
163  * Divide may lead to math exceptions.
164  * \ingroup arithm */
165 enum imBinaryOp {
166   IM_BIN_ADD,    /**< add         =    a+b            */
167   IM_BIN_SUB,    /**< subtract    =    a-b            */
168   IM_BIN_MUL,    /**< multiply    =    a*b            */
169   IM_BIN_DIV,    /**< divide      =    a/b            (#) */
170   IM_BIN_DIFF,   /**< difference  =    |a-b|          */
171   IM_BIN_POW,    /**< power       =    a^b            */
172   IM_BIN_MIN,    /**< minimum     =    (a < b)? a: b  */
173   IM_BIN_MAX     /**< maximum     =    (a > b)? a: b  */
174 }
175 mixin FreeEnumMembers!imBinaryOp;
176 
177 @nogc nothrow {
178 
179 /** Apply a binary arithmetic operation. \n
180  * Can be done in-place, images must match color space and size. \n
181  * Source images must match, target image can be several types depending on source: \n
182  * \li any integer -> any integer+ or real
183  * \li real -> real
184  * \li complex -> complex
185  * One exception is that you can use src1=complex src2=real resulting dst=complex. \n
186  * If source is complex, target complex must be the same data type (imcfloat-imcfloat or imcdouble-imcdouble only). \n
187  * If target is integer then it must have equal or more precision than the source. \n
188  * If target is byte, then the result is cropped to 0-255.
189  * Alpha channel is not included.
190  *
191  * \verbatim im.ProcessArithmeticOp(src_image1: imImage, src_image2: imImage, dst_image: imImage, op: number) [in Lua 5] \endverbatim
192  * \verbatim im.ProcessArithmeticOpNew(image1: imImage, image2: imImage, op: number) -> new_image: imImage [in Lua 5] \endverbatim
193  * The New function will create a new image of the same type of the source images.
194  * \ingroup arithm */
195 void imProcessArithmeticOp(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image, int op);
196 
197 /** Apply a binary arithmetic operation with a constant value. \n
198  * Can be done in-place, images must match color space and size. \n
199  * Target image can be several types depending on source: \n
200  * \li any integer -> any integer or real
201  * \li real -> real
202  * \li complex -> complex
203  * The constant value is type casted to an appropriate type before the operation. \n
204  * If source is complex, target complex must be the same data type (imcfloat-imcfloat or imcdouble-imcdouble only). \n
205  * If target is byte, then the result is cropped to 0-255.
206  *
207  * \verbatim im.ProcessArithmeticConstOp(src_image: imImage, src_const: number, dst_image: imImage, op: number) [in Lua 5] \endverbatim
208  * \verbatim im.ProcessArithmeticConstOpNew(image: imImage, src_const: number, op: number) -> new_image: imImage [in Lua 5] \endverbatim
209  * \ingroup arithm */
210 void imProcessArithmeticConstOp(const(imImage)* src_image, float src_const, imImage* dst_image, int op);
211 
212 /** Blend two images using an alpha value = [a * alpha + b * (1 - alpha)]. \n
213  * Can be done in-place, images must match. \n
214  * alpha value must be in the interval [0.0 - 1.0].
215  *
216  * \verbatim im.ProcessBlendConst(src_image1: imImage, src_image2: imImage, dst_image: imImage, alpha: number) [in Lua 5] \endverbatim
217  * \verbatim im.ProcessBlendConstNew(image1: imImage, image2: imImage, alpha: number) -> new_image: imImage [in Lua 5] \endverbatim
218  * \ingroup arithm */
219 void imProcessBlendConst(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image, float alpha);
220 
221 /** Blend two images using an alpha channel = [a * alpha + b * (1 - alpha)]. \n
222  * Can be done in-place, images must match. \n
223  * alpha_image must have the same data type except for complex images that must be real, 
224  * and color_space must be IM_GRAY.
225  * Maximum alpha values are based in \ref imColorMax. Minimum is always 0.
226  * \verbatim im.ProcessBlend(src_image1: imImage, src_image2: imImage, alpha_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
227  * \verbatim im.ProcessBlendNew(image1: imImage, image2: imImage, alpha_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
228  * \ingroup arithm */
229 void imProcessBlend(const(imImage)* src_image1, const(imImage)* src_image2, const(imImage)* alpha_image, imImage* dst_image);
230 
231 /** Compose two images that have an alpha channel using the OVER operator. \n
232  * Can be done in-place, images must match. \n
233  * Maximum alpha values are baed in \ref imColorMax. Minimum is always 0.
234  * \verbatim im.ProcessCompose(src_image1: imImage, src_image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim
235  * \verbatim im.ProcessComposeNew(image1: imImage, image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim
236  * \ingroup arithm */
237 void imProcessCompose(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image);
238 
239 /** Split a complex image into two images with real and imaginary parts \n
240  * or magnitude and phase parts (polar). \n
241  * Source image must be complex, target images must be real.
242  *
243  * \verbatim im.ProcessSplitComplex(src_image: imImage, dst_image1: imImage, dst_image2: imImage, polar: boolean) [in Lua 5] \endverbatim
244  * \verbatim im.ProcessSplitComplexNew(image: imImage, polar: boolean) -> dst_image1: imImage, dst_image2: imImage [in Lua 5] \endverbatim
245  * \ingroup arithm */
246 void imProcessSplitComplex(const(imImage)* src_image, imImage* dst_image1, imImage* dst_image2, int polar);
247 
248 /** Merges two images as the real and imaginary parts of a complex image, \n
249  * or as magnitude and phase parts (polar = 1). \n
250  * Source images must be real, target image must be complex.
251  *
252  * \verbatim im.ProcessMergeComplex(src_image1: imImage, src_image2: imImage, dst_image: imImage, polar: boolean) [in Lua 5] \endverbatim
253  * \verbatim im.ProcessMergeComplexNew(image1: imImage, image2: imImage, polar: boolean) -> new_image: imImage [in Lua 5] \endverbatim
254  * \ingroup arithm */
255 void imProcessMergeComplex(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image, int polar);
256 
257 /** Calculates the mean of multiple images. \n
258  * Images must match size and type.
259  *
260  * \verbatim im.ProcessMultipleMean(src_image_list: table of imImage, dst_image: imImage) [in Lua 5] \endverbatim
261  * \verbatim im.ProcessMultipleMeanNew(src_image_list: table of imImage) -> new_image: imImage [in Lua 5] \endverbatim
262  * \ingroup arithm */
263 void imProcessMultipleMean(const(imImage)** src_image_list, int src_image_count, imImage* dst_image);
264 
265 /** Calculates the standard deviation of multiple images. \n
266  * Images must match size and type. Use \ref imProcessMultipleMean to calculate the mean_image.
267  *
268  * \verbatim im.ProcessMultipleStdDev(src_image_list: table of imImage, mean_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
269  * \verbatim im.ProcessMultipleStdDevNew(src_image_list: table of imImage, mean_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
270  * \ingroup arithm */
271 void imProcessMultipleStdDev(const(imImage)** src_image_list, int src_image_count, const(imImage)* mean_image, imImage* dst_image);
272 
273 /** Calculates the median of multiple images. \n
274  * Images must match size and type. Complex is not supported.\n
275  * Uses \ref imProcessMultiPointOp internally.
276  *
277  * \verbatim im.ProcessMultipleMedian(src_image_list: table of imImage, dst_image: imImage) -> counter: boolean [in Lua 5] \endverbatim
278  * \verbatim im.ProcessMultipleMedianNew(src_image_list: table of imImage) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
279  * \ingroup arithm */
280 int imProcessMultipleMedian(const(imImage)** src_image_list, int src_image_count, imImage* dst_image);
281 
282 /** Calculates the auto-covariance of an image with the mean of a set of images. \n
283  * Images must match. Returns zero if the counter aborted. \n
284  * Target is IM_FLOAT, except if source is IM_DOUBLE.
285  * Returns zero if the counter aborted.
286  *
287  * \verbatim im.ProcessAutoCovariance(src_image: imImage, mean_image: imImage, dst_image: imImage) -> counter: boolean [in Lua 5] \endverbatim
288  * \verbatim im.ProcessAutoCovarianceNew(src_image: imImage, mean_image: imImage) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
289  * \ingroup arithm */
290 int imProcessAutoCovariance(const(imImage)* src_image, const(imImage)* mean_image, imImage* dst_image);
291 
292 /** Multiplies the conjugate of one complex image with another complex image. \n
293  * Images must match size. Conj(img1) * img2 \n
294  * Can be done in-place.
295  *
296  * \verbatim im.ProcessMultiplyConj(src_image1: imImage, src_image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim
297  * \verbatim im.ProcessMultiplyConjNew(src_image1: imImage, src_image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim
298  * \ingroup arithm */
299 void imProcessMultiplyConj(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image);
300 
301 
302 
303 /** \defgroup quantize Additional Image Quantization Operations
304  * \par
305  * Additionally operations to the \ref imConvertColorSpace function.
306  * \par
307  * See \ref im_process_pnt.h
308  * \ingroup process */
309 
310 /** Converts a RGB image to a MAP image using uniform quantization
311  * with an optional 8x8 ordered dither. The RGB image must have data type IM_BYTE.
312  *
313  * \verbatim im.ProcessQuantizeRGBUniform(src_image: imImage, dst_image: imImage, do_dither: boolean) [in Lua 5] \endverbatim
314  * \verbatim im.ProcessQuantizeRGBUniformNew(src_image: imImage, do_dither: boolean) -> new_image: imImage [in Lua 5] \endverbatim
315  * \ingroup quantize */
316 void imProcessQuantizeRGBUniform(const(imImage)* src_image, imImage* dst_image, int do_dither);
317 
318 /** Quantizes a gray scale image in less that 256 grays using uniform quantization. \n
319  * Both images should be IM_BYTE/IM_GRAY, the target can be IM_MAP. Can be done in-place. \n
320  * The result is in the 0-255 range, except when target is IM_MAP that is in the 0-(grays-1) range.
321  *
322  * \verbatim im.ProcessQuantizeGrayUniform(src_image: imImage, dst_image: imImage, grays: number) [in Lua 5] \endverbatim
323  * \verbatim im.ProcessQuantizeGrayUniformNew(src_image: imImage, grays: number) -> new_image: imImage [in Lua 5] \endverbatim
324  * \ingroup quantize */
325 void imProcessQuantizeGrayUniform(const(imImage)* src_image, imImage* dst_image, int grays);
326 
327 
328 
329 /** \defgroup histo Histogram Based Operations
330  * \par
331  * See \ref im_process_pnt.h
332  * \ingroup process */
333 
334 /** Performs an histogram expansion based on a percentage of the number of pixels. \n
335  * Percentage is used to obtain the amount of pixels of the lowest level and the highest level, relative to the total of pixels.
336  * The histogram is used an each level is summed while the result is less than the obtained amount from 0 (for the lowest level) and from the last level (for the highest).
337  * If it is zero, then only empty counts of the histogram will be considered. \n
338  * Images must be (IM_BYTE, IM_SHORT or IM_USHORT)/(IM_RGB or IM_GRAY). Can be done in-place. \n
339  * To expand the gamut without using the histogram, by just specifying the lowest and highest levels
340  * use the \ref IM_GAMUT_EXPAND tone gamut operation (\ref imProcessToneGamut).
341  *
342  * \verbatim im.ProcessExpandHistogram(src_image: imImage, dst_image: imImage, percent: number) [in Lua 5] \endverbatim
343  * \verbatim im.ProcessExpandHistogramNew(src_image: imImage, percent: number) -> new_image: imImage [in Lua 5] \endverbatim
344  * \ingroup histo */
345 void imProcessExpandHistogram(const(imImage)* src_image, imImage* dst_image, float percent);
346 
347 /** Performs an histogram equalization. \n
348  * Images must be (IM_BYTE, IM_SHORT or IM_USHORT)/(IM_RGB or IM_GRAY). Can be done in-place. 
349  *
350  * \verbatim im.ProcessEqualizeHistogram(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
351  * \verbatim im.ProcessEqualizeHistogramNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
352  * \ingroup histo */
353 void imProcessEqualizeHistogram(const(imImage)* src_image, imImage* dst_image);
354 
355 
356 
357 /** \defgroup colorproc Color Processing Operations
358  * \par
359  * Operations to change the color components configuration.
360  * \par
361  * See \ref im_process_pnt.h
362  * \ingroup process */
363 
364 /** Split a RGB image into luma and chroma. \n
365  * Chroma is calculated as R-Y,G-Y,B-Y. Source image must be IM_RGB/IM_BYTE. \n
366  * luma image is IM_GRAY/IM_BYTE and chroma is IM_RGB/IM_BYTE. \n
367  * Source and target must have the same size.
368  *
369  * \verbatim im.ProcessSplitYChroma(src_image: imImage, y_image: imImage, chroma_image: imImage) [in Lua 5] \endverbatim
370  * \verbatim im.ProcessSplitYChromaNew(src_image: imImage) -> y_image: imImage, chroma_image: imImage [in Lua 5] \endverbatim
371  * \ingroup colorproc */
372 void imProcessSplitYChroma(const(imImage)* src_image, imImage* y_image, imImage* chroma_image);
373 
374 /** Split a RGB image into HSI planes. \n
375  * Source image can be IM_RGB/IM_BYTE or IM_RGB/IM_FLOAT only. Target images are all IM_GRAY/IM_FLOAT. \n
376  * Source images must normalized to 0-1 if type is IM_FLOAT (\ref imProcessToneGamut can be used).
377  * See \ref hsi for a definition of the color conversion.\n
378  * Source and target must have the same size.
379  *
380  * \verbatim im.ProcessSplitHSI(src_image: imImage, h_image: imImage, s_image: imImage, i_image: imImage) [in Lua 5] \endverbatim
381  * \verbatim im.ProcessSplitHSINew(src_image: imImage) -> h_image: imImage, s_image: imImage, i_image: imImage [in Lua 5] \endverbatim
382  * \ingroup colorproc */
383 void imProcessSplitHSI(const(imImage)* src_image, imImage* h_image, imImage* s_image, imImage* i_image);
384 
385 /** Merge HSI planes into a RGB image. \n
386  * Source images must be IM_GRAY/IM_FLOAT. Target image can be IM_RGB/IM_BYTE or IM_RGB/IM_FLOAT only. \n
387  * Source and target must have the same size. See \ref hsi for a definition of the color conversion.
388  *
389  * \verbatim im.ProcessMergeHSI(h_image: imImage, s_image: imImage, i_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
390  * \verbatim im.ProcessMergeHSINew(h_image: imImage, s_image: imImage, i_image: imImage) -> dst_image: imImage [in Lua 5] \endverbatim
391  * \ingroup colorproc */
392 void imProcessMergeHSI(const(imImage)* h_image, const(imImage)* s_image, const(imImage)* i_image, imImage* dst_image);
393 
394 /** Split a multicomponent image into separate components, including alpha.\n
395  * Target images must be IM_GRAY. Size and data types must be all the same.\n
396  * The number of target images must match the depth of the source image, including alpha.
397  *
398  * \verbatim im.ProcessSplitComponents(src_image: imImage, dst_image_list: table of imImage) [in Lua 5] \endverbatim
399  * \verbatim im.ProcessSplitComponentsNew(src_image: imImage) -> dst_image_list: table of imImage [in Lua 5] \endverbatim
400  * \ingroup colorproc */
401 void imProcessSplitComponents(const(imImage)* src_image, imImage** dst_image_list);
402 
403 /** Merges separate components into a multicomponent image, including alpha.\n
404  * Source images must be IM_GRAY. Size and data types must be all the same.\n
405  * The number of source images must match the depth of the target image, including alpha.
406  *
407  * \verbatim im.ProcessMergeComponents(src_image_list: table of imImage, dst_image: imImage) [in Lua 5] \endverbatim
408  * \verbatim im.ProcessMergeComponentsNew(src_image_list: table of imImage) -> dst_image: imImage [in Lua 5] \endverbatim
409  * \ingroup colorproc */
410 void imProcessMergeComponents(const(imImage)** src_image_list, imImage* dst_image);
411 
412 /** Normalize the color components by their sum. Example: c1 = c1/(c1+c2+c3). \n
413  * It will not change the alpha channel if any.
414  * Target is IM_FLOAT, except if source is IM_DOUBLE.
415  *
416  * \verbatim im.ProcessNormalizeComponents(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
417  * \verbatim im.ProcessNormalizeComponentsNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
418  * \ingroup colorproc */
419 void imProcessNormalizeComponents(const(imImage)* src_image, imImage* dst_image);
420 
421 /** Replaces the source color by the target color. \n
422  * The color will be type casted to the image data type. \n
423  * The colors must have the same number of components of the images. \n
424  * Supports all color spaces and all data types except complex.
425  *
426  * \verbatim im.ProcessReplaceColor(src_image: imImage, dst_image: imImage, src_color: table of numbers, dst_color: table of numbers) [in Lua 5] \endverbatim
427  * \verbatim im.ProcessReplaceColorNew(src_image: imImage, src_color: table of numbers, dst_color: table of numbers) -> new_image: imImage [in Lua 5] \endverbatim
428  * \ingroup colorproc */
429 void imProcessReplaceColor(const(imImage)* src_image, imImage* dst_image, float* src_color, float* dst_color);
430 
431 /** Sets the alpha channel in target where the given color occours in source,
432  * elsewhere alpha remains untouched. \n
433  * The color must have the same number of components of the source image. \n
434  * If target does not have an alpha channel, then its plane=0 is used. \n
435  * Supports all color spaces for source and all data types except complex.
436  * Images must have the same size.
437  *
438  * \verbatim im.ProcessSetAlphaColor(src_image: imImage, dst_image: imImage, src_color: table of numbers, dst_alpha: number) [in Lua 5] \endverbatim
439  * \ingroup colorproc */
440 void imProcessSetAlphaColor(const(imImage)* src_image, imImage* dst_image, float* src_color, float dst_alpha);
441 
442 
443 } // @nogc nothrow
444 
445 /** \defgroup logic Logical Arithmetic Operations
446  * \par
447  * Logical binary math operations for images.
448  * \par
449  * See \ref im_process_pnt.h
450  * \ingroup process */
451 
452 /** Logical Operations.
453  * \ingroup logic */
454 enum imLogicOp {
455   IM_BIT_AND,   /**< and  =   a & b   */
456   IM_BIT_OR,    /**< or   =   a | b   */
457   IM_BIT_XOR    /**< xor  = ~(a | b)  */
458 }
459 mixin FreeEnumMembers!imLogicOp;
460 
461 @nogc nothrow {
462 
463 /** Apply a logical operation.\n
464  * Images must have data type integer. Can be done in-place.
465  *
466  * \verbatim im.ProcessBitwiseOp(src_image1: imImage, src_image2: imImage, dst_image: imImage, op: number) [in Lua 5] \endverbatim
467  * \verbatim im.ProcessBitwiseOpNew(src_image1: imImage, src_image2: imImage, op: number) -> new_image: imImage [in Lua 5] \endverbatim
468  * \ingroup logic */
469 void imProcessBitwiseOp(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image, int op);
470 
471 /** Apply a logical NOT operation.\n
472  * Images must have data type integer. Can be done in-place.
473  *
474  * \verbatim im.ProcessBitwiseNot(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
475  * \verbatim im.ProcessBitwiseNotNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
476  * \ingroup logic */
477 void imProcessBitwiseNot(const(imImage)* src_image, imImage* dst_image);
478 
479 /** Apply a bit mask. \n
480  * The same as imProcessBitwiseOp but the second image is replaced by a fixed mask. \n
481  * Images must have data type IM_BYTE. It is valid only for AND, OR and XOR. Can be done in-place.
482  *
483  * \verbatim im.ProcessBitMask(src_image: imImage, dst_image: imImage, mask: string, op: number) [in Lua 5] \endverbatim
484  * \verbatim im.ProcessBitMaskNew(src_image: imImage, mask: string, op: number) -> new_image: imImage [in Lua 5] \endverbatim
485  * In Lua, mask is a string with 0s and 1s, for example: "11001111".
486  * \ingroup logic */
487 void imProcessBitMask(const(imImage)* src_image, imImage* dst_image, ubyte mask, int op);
488 
489 /** Extract or Reset a bit plane. For ex: 000X0000 or XXX0XXXX (plane=3).\n
490  * Images must have data type IM_BYTE. Can be done in-place.
491  *
492  * \verbatim im.ProcessBitPlane(src_image: imImage, dst_image: imImage, plane: number, do_reset: boolean) [in Lua 5] \endverbatim
493  * \verbatim im.ProcessBitPlaneNew(src_image: imImage, plane: number, do_reset: boolean) -> new_image: imImage [in Lua 5] \endverbatim
494  * \ingroup logic */
495 void imProcessBitPlane(const(imImage)* src_image, imImage* dst_image, int plane, int do_reset);
496 
497 
498 
499 /** \defgroup render Synthetic Image Render
500  * \par
501  * Renders some 2D mathematical functions as images. All the functions operates in-place
502  * and supports all data types except complex.
503  * \par
504  * See \ref im_process_pnt.h
505  * \ingroup process */
506 
507 /** Render Funtion.
508  * \verbatim func(x: number, y: number, d: number, params: table) -> value: number [in Lua 5] \endverbatim
509  * \ingroup render */
510 alias imRenderFunc = float function(int x, int y, int d, float* params);
511 
512 /** Render Conditional Funtion.
513  * \verbatim func(x: number, y: number, d: number, params: table) -> value: number, cond: boolean [in Lua 5] \endverbatim
514  * \ingroup render */
515 alias imRenderCondFunc = float function(int x, int y, int d, int* cond, float* params);
516 
517 /** Render a synthetic image using a render function. \n
518  * plus will make the render be added to the current image data,
519  * or else all data will be replaced. All the render functions use this or the conditional function. \n
520  * Returns zero if the counter aborted.
521  *
522  * \verbatim im.ProcessRenderOp(image: imImage, func: function, render_name: string, params: table, plus: boolean) -> counter: boolean [in Lua 5] \endverbatim
523  * \ingroup render */
524 int imProcessRenderOp(imImage* image, imRenderFunc func, const(char)* render_name, float* params, int plus);
525 
526 /** Render a synthetic image using a conditional render function. \n
527  * Data will be rendered only if the condional parameter is true. \n
528  * Returns zero if the counter aborted.
529  *
530  * \verbatim im.ProcessRenderCondOp(image: imImage, func: function, render_name: string, params: table) -> counter: boolean [in Lua 5] \endverbatim
531  * \ingroup render */
532 int imProcessRenderCondOp(imImage* image, imRenderCondFunc func, const(char)* render_name, float* params);
533 
534 /** Render speckle noise on existing data. Can be done in-place.
535  *
536  * \verbatim im.ProcessRenderAddSpeckleNoise(src_image: imImage, dst_image: imImage, percent: number) -> counter: boolean [in Lua 5] \endverbatim
537  * \verbatim im.ProcessRenderAddSpeckleNoiseNew(src_image: imImage, percent: number) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
538  * \ingroup render */
539 int imProcessRenderAddSpeckleNoise(const(imImage)* src_image, imImage* dst_image, float percent);
540 
541 /** Render gaussian noise on existing data. Can be done in-place.
542  *
543  * \verbatim im.ProcessRenderAddGaussianNoise(src_image: imImage, dst_image: imImage, mean: number, stddev: number) -> counter: boolean [in Lua 5] \endverbatim
544  * \verbatim im.ProcessRenderAddGaussianNoiseNew(src_image: imImage, mean: number, stddev: number) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
545  * \ingroup render */
546 int imProcessRenderAddGaussianNoise(const(imImage)* src_image, imImage* dst_image, float mean, float stddev);
547 
548 /** Render uniform noise on existing data. Can be done in-place.
549  *
550  * \verbatim im.ProcessRenderAddUniformNoise(src_image: imImage, dst_image: imImage, mean: number, stddev: number) -> counter: boolean [in Lua 5] \endverbatim
551  * \verbatim im.ProcessRenderAddUniformNoiseNew(src_image: imImage, mean: number, stddev: number) -> counter: boolean, new_image: imImage [in Lua 5] \endverbatim
552  * \ingroup render */
553 int imProcessRenderAddUniformNoise(const(imImage)* src_image, imImage* dst_image, float mean, float stddev);
554 
555 /** Render random noise.
556  *
557  * \verbatim im.ProcessRenderRandomNoise(image: imImage) -> counter: boolean [in Lua 5] \endverbatim
558  * \ingroup render */
559 int imProcessRenderRandomNoise(imImage* image);
560 
561 /** Render a constant. The number of values must match the depth of the image.
562  *
563  * \verbatim im.ProcessRenderConstant(image: imImage, value: table of number) -> counter: boolean [in Lua 5] \endverbatim
564  * \ingroup render */
565 int imProcessRenderConstant(imImage* image, float* value);
566 
567 /** Render a centered wheel.
568  *
569  * \verbatim im.ProcessRenderWheel(image: imImage, internal_radius: number, external_radius: number) -> counter: boolean [in Lua 5] \endverbatim
570  * \ingroup render */
571 int imProcessRenderWheel(imImage* image, int internal_radius, int external_radius);
572 
573 /** Render a centered cone.
574  *
575  * \verbatim im.ProcessRenderCone(image: imImage, radius: number) -> counter: boolean [in Lua 5] \endverbatim
576  * \ingroup render */
577 int imProcessRenderCone(imImage* image, int radius);
578 
579 /** Render a centered tent.
580  *
581  * \verbatim im.ProcessRenderTent(image: imImage, tent_width: number, tent_height: number) -> counter: boolean [in Lua 5] \endverbatim
582  * \ingroup render */
583 int imProcessRenderTent(imImage* image, int tent_width, int tent_height);
584 
585 /** Render a ramp. Direction can be vertical (1) or horizontal (0).
586  *
587  * \verbatim im.ProcessRenderRamp(image: imImage, start: number, end: number, vert_dir: boolean) -> counter: boolean [in Lua 5] \endverbatim
588  * \ingroup render */
589 int imProcessRenderRamp(imImage* image, int start, int end, int vert_dir);
590 
591 /** Render a centered box.
592  *
593  * \verbatim im.ProcessRenderBox(image: imImage, box_width: number, box_height: number) -> counter: boolean [in Lua 5] \endverbatim
594  * \ingroup render */
595 int imProcessRenderBox(imImage* image, int box_width, int box_height);
596 
597 /** Render a centered sinc.
598  *
599  * \verbatim im.ProcessRenderSinc(image: imImage, x_period: number, y_period: number) -> counter: boolean [in Lua 5] \endverbatim
600  * \ingroup render */
601 int imProcessRenderSinc(imImage* image, float x_period, float y_period);
602 
603 /** Render a centered gaussian.
604  *
605  * \verbatim im.ProcessRenderGaussian(image: imImage, stddev: number) -> counter: boolean [in Lua 5] \endverbatim
606  * \ingroup render */
607 int imProcessRenderGaussian(imImage* image, float stddev);
608 
609 /** Render the laplacian of a centered gaussian.
610  *
611  * \verbatim im.ProcessRenderLapOfGaussian(image: imImage, stddev: number) -> counter: boolean [in Lua 5] \endverbatim
612  * \ingroup render */
613 int imProcessRenderLapOfGaussian(imImage* image, float stddev);
614 
615 /** Render a centered cosine.
616  *
617  * \verbatim im.ProcessRenderCosine(image: imImage, x_period: number, y_period: number) -> counter: boolean [in Lua 5] \endverbatim
618  * \ingroup render */
619 int imProcessRenderCosine(imImage* image, float x_period, float y_period);
620 
621 /** Render a centered grid.
622  *
623  * \verbatim im.ProcessRenderGrid(image: imImage, x_space: number, y_space: number) -> counter: boolean [in Lua 5] \endverbatim
624  * \ingroup render */
625 int imProcessRenderGrid(imImage* image, int x_space, int y_space);
626 
627 /** Render a centered chessboard.
628  *
629  * \verbatim im.ProcessRenderChessboard(image: imImage, x_space: number, y_space: number) -> counter: boolean [in Lua 5] \endverbatim
630  * \ingroup render */
631 int imProcessRenderChessboard(imImage* image, int x_space, int y_space);
632 
633 /** Render a color flood fill. \n
634  * Image must the IM_RGB color space. replace_color must have 3 components.
635  *
636  * \verbatim im.ProcessRenderFloodFill(image: imImage, start_x, start_y: number, replace_color: table of 3 numbers, tolerance: number)  [in Lua 5] \endverbatim
637  * \ingroup render */
638 void imProcessRenderFloodFill(imImage* image, int start_x, int start_y, float* replace_color, float tolerance);
639 
640 } // @nogc nothrow
641 
642 
643 
644 /** \defgroup tonegamut Tone Gamut Operations
645  * \par
646  * Operations that try to preserve the min-max interval in the output (the dynamic range).
647  * \par
648  * See \ref im_process_pnt.h
649  * \ingroup process */
650 
651 
652 /** Tone Gamut Operations.
653  * \ingroup tonegamut */
654 enum imToneGamut {
655   IM_GAMUT_NORMALIZE, /**< normalize = (a-min) / (max-min)     (result is always real)   */
656   IM_GAMUT_POW,       /**< pow       = ((a-min) / (max-min))^gamma * (max-min) + min                  \n
657                                        params[0]=gamma                                             */
658   IM_GAMUT_LOG,       /**< log       = log(K * (a-min) / (max-min) + 1))*(max-min)/log(K+1) + min     \n
659                                        params[0]=K     (K>0)                                       */
660   IM_GAMUT_EXP,       /**< exp       = (exp(K * (a-min) / (max-min)) - 1))*(max-min)/(exp(K)-1) + min \n
661                                        params[0]=K                                                 */
662   IM_GAMUT_INVERT,    /**< invert    = max - (a-min)                                              */
663   IM_GAMUT_ZEROSTART, /**< zerostart = a - min                                                    */
664   IM_GAMUT_SOLARIZE,  /**< solarize  = a < level ?  a:  (level * (max-min) - a * (level-min)) / (max-level) \n
665                                        params[0]=level percentage (0-100) relative to min-max      \n
666                                        photography solarization effect. */
667   IM_GAMUT_SLICE,     /**< slice     = start < a || a > end ?  min:  binarize?  max: a                     \n
668                                        params[0]=start,  params[1]=end,  params[2]=binarize          */
669   IM_GAMUT_EXPAND,    /**< expand    = a < start ?  min: a > end ? max :  (a-start)*(max-min)/(end-start) + min  \n
670                                        params[0]=start,  params[1]=end                              */
671   IM_GAMUT_CROP,      /**< crop      = a < start ?  start: a > end ? end : a                                        \n
672                                        params[0]=start,  params[1]=end                              */
673   IM_GAMUT_BRIGHTCONT /**< brightcont = a < min ?  min:  a > max ?  max:  a * tan(c_a) + b_s + (max-min)*(1 - tan(c_a))/2  \n
674                                         params[0]=bright_shift (-100%..+100%),  params[1]=contrast_factor (-100%..+100%)     \n
675                                         change brightness and contrast simultaneously. */
676 }
677 mixin FreeEnumMembers!imToneGamut;
678 
679 /** Tone Gamut Flags.
680  * Combine with imToneGamut values with bitwise or (|).
681  * \ingroup tonegamut */
682 enum imToneGamutFlags {
683   IM_GAMUT_MINMAX = 0x0100 /**<  min and max are given in params (params[0]=min, params[1]=max), all other parameters shift 2 positions.  */
684 }
685 mixin FreeEnumMembers!imToneGamutFlags;
686 
687 @nogc nothrow :
688 
689 /** Apply a gamut operation with arguments. \n
690  * Supports all data types except complex. \n
691  * For IM_GAMUT_NORMALIZE when min > 0 and max < 1, it will just do a copy. \n
692  * IM_BYTE images have min=0 and max=255 always. \n
693  * To control min and max values use the IM_GAMUT_MINMAX flag.
694  * Can be done in-place. When there is no extra parameters, params can use NULL.
695  *
696  * \verbatim im.ProcessToneGamut(src_image: imImage, dst_image: imImage, op: number, params: table of number) [in Lua 5] \endverbatim
697  * \verbatim im.ProcessToneGamutNew(src_image: imImage, op: number, params: table of number) -> new_image: imImage [in Lua 5] \endverbatim
698  * See also \ref imageenhance.
699  * \ingroup tonegamut */
700 void imProcessToneGamut(const(imImage)* src_image, imImage* dst_image, int op, float* params);
701 
702 /** Converts from (0-1) to (0-255), crop out of bounds values. \n
703  * Source image must be real, and target image must be IM_BYTE.
704  *
705  * \verbatim im.ProcessUnNormalize(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
706  * \verbatim im.ProcessUnNormalizeNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
707  * \ingroup tonegamut */
708 void imProcessUnNormalize(const(imImage)* src_image, imImage* dst_image);
709 
710 /** Directly converts integer and real data types into IM_BYTE images. \n
711  * This can also be done using \ref imConvertDataType with IM_CAST_DIRECT flag.
712  *
713  * \verbatim im.ProcessDirectConv(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
714  * \verbatim im.ProcessDirectConvNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
715  * \ingroup tonegamut */
716 void imProcessDirectConv(const(imImage)* src_image, imImage* dst_image);
717 
718 /** A negative effect. Uses \ref imProcessToneGamut with IM_GAMUT_INVERT for non MAP images. \n
719  * Supports all color spaces and all data types except complex. \n
720  * Can be done in-place.
721  *
722  * \verbatim im.ProcessNegative(src_image: imImage, dst_image: imImage) [in Lua 5] \endverbatim
723  * \verbatim im.ProcessNegativeNew(src_image: imImage) -> new_image: imImage [in Lua 5] \endverbatim
724  * \ingroup tonegamut */
725 void imProcessNegative(const(imImage)* src_image, imImage* dst_image);
726 
727 /** Calculates an automatic gamma factor. \n
728  * gamma=log((mean-min)/(max-min))/log(0.5);
729  * Usefull for \ref imProcessToneGamut when using IM_GAMUT_POW.
730  *
731  * \verbatim im.ProcessCalcAutoGamma(image: imImage) -> gamma: number [in Lua 5] \endverbatim
732  * \ingroup tonegamut */
733 float imProcessCalcAutoGamma(const(imImage)* image);
734 
735 /** Apply a shift using HSI coordinates. \n
736  * Supports all data types except complex. \n
737  * Can be done in-place.
738  *
739  * \verbatim im.ProcessShiftHSI(src_image: imImage, dst_image: imImage, h_shift, s_shift, i_shift: number) [in Lua 5] \endverbatim
740  * \verbatim im.ProcessShiftHSI(src_image: imImage, h_shift, s_shift, i_shift: number) -> new_image: imImage [in Lua 5] \endverbatim
741  * \ingroup tonegamut */
742 void imProcessShiftHSI(const(imImage)* src_image, imImage* dst_image, float h_shift, float s_shift, float i_shift);
743 
744 
745 /** \defgroup threshold Threshold Operations
746  * \par
747  * Operations that converts a usually IM_GRAY/IM_BYTE image into a IM_BINARY image using several threshold techniques.
748  * \par
749  * See \ref im_process_pnt.h
750  * \ingroup process */
751 
752 /** Apply a manual threshold. \n
753  * threshold = a <= level ? 0: value \n
754  * Normal value is 1 but another common value is 255. Can be done in-place for IM_BYTE source. \n
755  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
756  * complex is not supported. \n
757  *
758  * \verbatim im.ProcessThreshold(src_image: imImage, dst_image: imImage, level: number, value: number) [in Lua 5] \endverbatim
759  * \verbatim im.ProcessThresholdNew(src_image: imImage, level: number, value: number) -> new_image: imImage [in Lua 5] \endverbatim
760  * \ingroup threshold */
761 void imProcessThreshold(const(imImage)* src_image, imImage* dst_image, float level, int value);
762 
763 /** Apply a threshold by the difference of two images. \n
764  * threshold = a1 <= a2 ? 0: 1   \n
765  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
766  * complex is not supported. Can be done in-place for IM_BYTE source. \n
767  *
768  * \verbatim im.ProcessThresholdByDiff(src_image1: imImage, src_image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim
769  * \verbatim im.ProcessThresholdByDiffNew(src_image1: imImage, src_image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim
770  * \ingroup threshold */
771 void imProcessThresholdByDiff(const(imImage)* src_image1, const(imImage)* src_image2, imImage* dst_image);
772 
773 /** Apply a threshold by the Hysteresis method. \n
774  * Hysteresis thersholding of edge pixels. Starting at pixels with a
775  * value greater than the HIGH threshold, trace a connected sequence
776  * of pixels that have a value greater than the LOW threhsold. \n
777  * complex is not supported. Can be done in-place for IM_BYTE source. \n
778  * Note: could not find the original source code author name.
779  *
780  * \verbatim im.ProcessHysteresisThreshold(src_image: imImage, dst_image: imImage, low_thres: number, high_thres: number) [in Lua 5] \endverbatim
781  * \verbatim im.ProcessHysteresisThresholdNew(src_image: imImage, low_thres: number, high_thres: number) -> new_image: imImage [in Lua 5] \endverbatim
782  * \ingroup threshold */
783 void imProcessHysteresisThreshold(const(imImage)* src_image, imImage* dst_image, int low_thres, int high_thres);
784 
785 /** Estimates hysteresis low and high threshold levels. \n
786  * Image data type can be IM_BYTE, IM_SHORT or IM_USHORT. \n
787  * Usefull for \ref imProcessHysteresisThreshold.
788  *
789  * \verbatim im.ProcessHysteresisThresEstimate(image: imImage) -> low_level: number, high_level: number [in Lua 5] \endverbatim
790  * \ingroup threshold */
791 void imProcessHysteresisThresEstimate(const(imImage)* image, int* low_level, int* high_level);
792 
793 /** Calculates the threshold level for manual threshold using an uniform error approach. \n
794  * Supports only IM_BYTE images.
795  * Extracted from XITE, Copyright 1991, Blab, UiO \n
796  * http://www.ifi.uio.no/~blab/Software/Xite/
797 \verbatim
798   Reference:
799     S. M. Dunn & D. Harwood & L. S. Davis:
800     "Local Estimation of the Uniform Error Threshold"
801     IEEE Trans. on PAMI, Vol PAMI-6, No 6, Nov 1984.
802   Comments: It only works well on images whith large objects.
803   Author: Olav Borgli, BLAB, ifi, UiO
804   Image processing lab, Department of Informatics, University of Oslo
805 \endverbatim
806  * Returns the used level.
807  *
808  * \verbatim im.ProcessUniformErrThreshold(src_image: imImage, dst_image: imImage) -> level: number [in Lua 5] \endverbatim
809  * \verbatim im.ProcessUniformErrThresholdNew(src_image: imImage)  -> level: number, new_image: imImage [in Lua 5] \endverbatim
810  * \ingroup threshold */
811 int imProcessUniformErrThreshold(const(imImage)* src_image, imImage* dst_image);
812 
813 /** Apply a dithering on each image channel by using a difusion error method. \n
814  * It can be applied on any IM_BYTE images. It will "threshold" each channel indivudually, so
815  * source and target must be of the same depth.
816  * Not using OpenMP when enabled.
817  *
818  * \verbatim im.ProcessDifusionErrThreshold(src_image: imImage, dst_image: imImage, level: number) [in Lua 5] \endverbatim
819  * \verbatim im.ProcessDifusionErrThresholdNew(src_image: imImage, level: number) -> new_image: imImage [in Lua 5] \endverbatim
820  * \ingroup threshold */
821 void imProcessDifusionErrThreshold(const(imImage)* src_image, imImage* dst_image, int level);
822 
823 /** Calculates the threshold level for manual threshold using a percentage of pixels
824  * that should stay bellow the threshold. \n
825  * Image data type can be IM_BYTE, IM_SHORT or IM_USHORT. \n
826  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
827  * Returns the used level.
828  *
829  * \verbatim im.ProcessPercentThreshold(src_image: imImage, dst_image: imImage, percent: number) -> level: number [in Lua 5] \endverbatim
830  * \verbatim im.ProcessPercentThresholdNew(src_image: imImage, percent: number) -> level: number, new_image: imImage [in Lua 5] \endverbatim
831  * \ingroup threshold */
832 int imProcessPercentThreshold(const(imImage)* src_image, imImage* dst_image, float percent);
833 
834 /** Calculates the threshold level for manual threshold using the Otsu approach. \n
835  * Image can be IM_BYTE, IM_SHORT or IM_USHORT. \n
836  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
837  * Returns the used level. \n
838  * Original implementation by Flavio Szenberg.
839  *
840  * \verbatim im.ProcessOtsuThreshold(src_image: imImage, dst_image: imImage) -> level: number [in Lua 5] \endverbatim
841  * \verbatim im.ProcessOtsuThresholdNew(src_image: imImage) -> level: number, new_image: imImage [in Lua 5] \endverbatim
842  * \ingroup threshold */
843 int imProcessOtsuThreshold(const(imImage)* src_image, imImage* dst_image);
844 
845 /** Calculates the threshold level for manual threshold using (max-min)/2. \n
846  * Returns the used level. \n
847  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
848  * complex is not supported. Can be done in-place for IM_BYTE source. \n
849  *
850  * \verbatim im.ProcessMinMaxThreshold(src_image: imImage, dst_image: imImage) -> level: number [in Lua 5] \endverbatim
851  * \verbatim im.ProcessMinMaxThresholdNew(src_image: imImage) -> level: number, new_image: imImage [in Lua 5] \endverbatim
852  * \ingroup threshold */
853 float imProcessMinMaxThreshold(const(imImage)* src_image, imImage* dst_image);
854 
855 /** Estimates Local Max threshold level for images.
856  * Image can be IM_BYTE, IM_SHORT or IM_USHORT. \n
857  *
858  * \verbatim im.ProcessLocalMaxThresEstimate(image: imImage) -> level: number [in Lua 5] \endverbatim
859  * \ingroup threshold */
860 void imProcessLocalMaxThresEstimate(const(imImage)* image, int* level);
861 
862 /** Apply a manual threshold using an interval. \n
863  * threshold = start_level <= a <= end_level ? 1: 0 \n
864  * Normal value is 1 but another common value is 255. \n
865  * Source color space must be IM_GRAY, and target color space must be IM_BINARY.
866  * complex is not supported. Can be done in-place for IM_BYTE source. \n
867  *
868  * \verbatim im.ProcessSliceThreshold(src_image: imImage, dst_image: imImage, start_level: number, end_level: number) [in Lua 5] \endverbatim
869  * \verbatim im.ProcessSliceThresholdNew(src_image: imImage, start_level: number, end_level: number) -> new_image: imImage [in Lua 5] \endverbatim
870  * \ingroup threshold */
871 void imProcessSliceThreshold(const(imImage)* src_image, imImage* dst_image, float start_level, float end_level);
872 
873 
874 /** \defgroup effects Special Effects
875  * \par
876  * Operations to change image appearance.
877  * \par
878  * See \ref im_process_pnt.h
879  * \ingroup process */
880 
881 
882 /** Generates a zoom in effect averaging colors inside a square region. \n
883  * Operates only on IM_BYTE images.
884  *
885  * \verbatim im.ProcessPixelate(src_image: imImage, dst_image: imImage, box_size: number) [in Lua 5] \endverbatim
886  * \verbatim im.ProcessPixelateNew(src_image: imImage, box_size: number) -> new_image: imImage [in Lua 5] \endverbatim
887  * \ingroup effects */
888 void imProcessPixelate(const(imImage)* src_image, imImage* dst_image, int box_size);
889 
890 /** A simple Posterize effect. It reduces the number of colors in the image eliminating
891  * less significant bit planes. Can have 1 to 7 levels. See \ref imProcessBitMask. \n
892  * Images must have data type IM_BYTE.
893  *
894  * \verbatim im.ProcessPosterize(src_image: imImage, dst_image: imImage, level: number) [in Lua 5] \endverbatim
895  * \verbatim im.ProcessPosterizeNew(src_image: imImage, level: number) -> new_image: imImage [in Lua 5] \endverbatim
896  * \ingroup effects */
897 void imProcessPosterize(const(imImage)* src_image, imImage* dst_image, int level);
898 
899 
900 /** \defgroup remotesens Remote Sensing Operations
901  * \par
902  * Operations used in Remote Sensing.
903  * \par
904  * See \ref im_process_pnt.h
905  * \ingroup process */
906 
907 
908 /** Calculates the Normalized Difference Ratio. \n
909  * Uses the formula NormDiffRatio = (a-b)/(a+b), \n
910  * The result image has [-1,1] interval. \n
911  * Images must be IM_GRAY, and the target image must be IM_FLOAT, except if source is IM_DOUBLE.
912  *
913  * \verbatim im.ProcessNormDiffRatio(image1: imImage, image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim
914  * \verbatim im.ProcessNormDiffRatioNew(image1: imImage, image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim
915  * \ingroup remotesens */
916 void imProcessNormDiffRatio(const(imImage)* image1, const(imImage)* image2, imImage* dst_image);
917 
918 /** Applies the abnormal pixel correction as described in the article. (Since 3.8) \n
919  * Images must be IM_GRAY. Source and Target must have the same datatype, and complex is not supported. \n
920  * image_abnormal is optional, can be NULL. If not NULL, must be IM_BINARY and
921  * it will store the abnormal pixels distribution. \n
922  * Can be done in-place. \n
923  * threshold_percent is the percentage of the height that must have abnormal pixels candidates. \n
924  * threshold_consecutive is the minimum number of consecutive abnormal pixels candidates to be considered an abnormal range.
925  * (usually the longest vertical ground feature in pixels)\n
926  * \par
927  * Based on "Detection and Correction of Abnormal Pixels in Hyperion Images"
928  * from T. Han, D. G. Goodenough, A. Dyk, and J. Love
929  *
930  * \verbatim im.AbnormalHyperionCorrection(src_image: imImage, dst_image: imImage, threshold_consecutive, threshold_percent: number[, image_abnormal: imImage]) [in Lua 5] \endverbatim
931  * \verbatim im.AbnormalHyperionCorrectionNew(src_image: imImage, threshold_consecutive, threshold_percent: number[, image_abnormal: imImage]) -> new_image: imImage [in Lua 5] \endverbatim
932  * \ingroup remotesens */
933 void imProcessAbnormalHyperionCorrection(const(imImage)* src_image, imImage* dst_image, int threshold_consecutive, int threshold_percent, imImage* image_abnormal);
934 
935 
936 /** \defgroup procconvert Image Conversion
937  * \par
938  * Same as imConvert functions but using OpenMP when enabled.
939  * \par
940  * See \ref im_process_pnt.h
941  * \ingroup process */
942 
943 
944 /** Same as  \ref imConvertDataType.
945  * But returns zero if the counter aborted.
946  *
947  * \verbatim im.ProcessConvertDataType(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, absolute: boolean, cast_mode: number) -> error: number [in Lua 5] \endverbatim
948  * \verbatim im.ProcessConvertDataTypeNew(image: imImage, data_type: number, cpx2real: number, gamma: number, absolute: boolean, cast_mode: number) -> error: number, new_image: imImage  [in Lua 5] \endverbatim
949  * \ingroup procconvert */
950 int imProcessConvertDataType(const(imImage)* src_image, imImage* dst_image, int cpx2real, float gamma, int absolute, int cast_mode);
951 
952 /** Same as  \ref imConvertColorSpace.
953  * But returns zero if the counter aborted.
954  *
955  * \verbatim im.ProcessConvertColorSpace(src_image: imImage, dst_image: imImage) -> error: number [in Lua 5] \endverbatim
956  * \verbatim im.ProcessConvertColorSpaceNew(image: imImage, color_space: number, has_alpha: boolean) -> error: number, new_image: imImage [in Lua 5] \endverbatim
957  * \ingroup procconvert */
958 int imProcessConvertColorSpace(const(imImage)* src_image, imImage* dst_image);
959 
960 /** Same as  \ref imConvertToBitmap.
961  * But returns zero if the counter aborted.
962  *
963  * \verbatim im.ProcessConvertToBitmap(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, absolute: boolean, cast_mode: number) -> error: number [in Lua 5] \endverbatim
964  * \verbatim im.ProcessConvertToBitmapNew(image: imImage, color_space: number, has_alpha: boolean, cpx2real: number, gamma: number, absolute: boolean, cast_mode: number) -> error: number, new_image: imImage [in Lua 5] \endverbatim
965  * \ingroup procconvert */
966 int imProcessConvertToBitmap(const(imImage)* src_image, imImage* dst_image, int cpx2real, float gamma, int absolute, int cast_mode);
967 
968 
969 /** \defgroup imageenhance Image Enhance Utilities in Lua
970  * \par
971  * Operations are done in-place. Limitations are the same of the original functions.
972  * \par
973  * See \ref im_process_pnt.h
974  * \ingroup process */
975 
976 /** Same as \ref imProcessToneGamut using \ref IM_GAMUT_POW.
977  *
978  * \verbatim image:Gamma(gamma) [in Lua 5] \endverbatim
979  * \ingroup imageenhance */
980 void imImageGamma(imImage* _image, float _gamma) { float[1] params; params[0] = _gamma; imProcessToneGamut(_image, _image, IM_GAMUT_POW, params.ptr); }
981 
982 /** Same as \ref imProcessToneGamut using \ref IM_GAMUT_BRIGHTCONT.
983  *
984  * \verbatim image:BrightnessContrast(bright_shift, contrast_factor: number)   [in Lua 5] \endverbatim
985  * \ingroup imageenhance */
986 void imImageBrightnessContrast(imImage* _image, float _bright_shift, float _contrast_factor) { float[2] _params; _params[0] = _bright_shift; _params[1] = _contrast_factor; imProcessToneGamut(_image, _image, IM_GAMUT_BRIGHTCONT, _params.ptr); }
987 
988 /** Same as \ref imProcessToneGamut using \ref IM_GAMUT_EXPAND.
989  *
990  * \verbatim image:Level(start, end)  [in Lua 5] \endverbatim
991  * \ingroup imageenhance */
992 void imImageLevel(imImage* _image, float _start, float _end) { float[2] _params; _params[0] = _start; _params[1] = _end; imProcessToneGamut(_image, _image, IM_GAMUT_EXPAND, _params.ptr); }
993 
994 /** Same as \ref imProcessEqualizeHistogram.
995  *
996  * \verbatim image:Equalize()  [in Lua 5] \endverbatim
997  * \ingroup imageenhance */
998 void imImageEqualize(imImage* _image) { imProcessEqualizeHistogram(_image, _image); }
999 
1000 /** Same as \ref imProcessNegative.
1001  * Also same as \ref imProcessToneGamut using \ref IM_GAMUT_INVERT.
1002  *
1003  * \verbatim image:Negative()  [in Lua 5] \endverbatim
1004  * \ingroup imageenhance */
1005 void imImageNegative(imImage* _image) { imProcessNegative(_image, _image); }
1006 
1007 /** Same as \ref imProcessExpandHistogram.
1008  *
1009  * \verbatim image:AutoLevel(percent)  [in Lua 5] \endverbatim
1010  * \ingroup imageenhance */
1011 void imImageAutoLevel(imImage* _image, float _percent) { imProcessExpandHistogram(_image, _image, _percent); }
1012