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