camellia 2.5.10-i486-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/README +58 -0
  2. data/doc/README +58 -0
  3. data/doc/camellia.dox +205 -0
  4. data/doc/html/annotated.html +46 -0
  5. data/doc/html/camellia_8h-source.html +1350 -0
  6. data/doc/html/camellia_8h.html +4873 -0
  7. data/doc/html/doxygen.css +310 -0
  8. data/doc/html/doxygen.png +0 -0
  9. data/doc/html/files.html +27 -0
  10. data/doc/html/ftv2blank.png +0 -0
  11. data/doc/html/ftv2doc.png +0 -0
  12. data/doc/html/ftv2folderclosed.png +0 -0
  13. data/doc/html/ftv2folderopen.png +0 -0
  14. data/doc/html/ftv2lastnode.png +0 -0
  15. data/doc/html/ftv2link.png +0 -0
  16. data/doc/html/ftv2mlastnode.png +0 -0
  17. data/doc/html/ftv2mnode.png +0 -0
  18. data/doc/html/ftv2node.png +0 -0
  19. data/doc/html/ftv2plastnode.png +0 -0
  20. data/doc/html/ftv2pnode.png +0 -0
  21. data/doc/html/ftv2vertline.png +0 -0
  22. data/doc/html/functions.html +292 -0
  23. data/doc/html/functions_func.html +204 -0
  24. data/doc/html/functions_vars.html +177 -0
  25. data/doc/html/globals.html +172 -0
  26. data/doc/html/globals_defs.html +37 -0
  27. data/doc/html/globals_func.html +170 -0
  28. data/doc/html/hierarchy.html +46 -0
  29. data/doc/html/index.html +8 -0
  30. data/doc/html/main.html +21 -0
  31. data/doc/html/pages.html +23 -0
  32. data/doc/html/structCamArithmParams.html +61 -0
  33. data/doc/html/structCamBasin.html +63 -0
  34. data/doc/html/structCamBitmapFont.html +38 -0
  35. data/doc/html/structCamBlobInfo.html +91 -0
  36. data/doc/html/structCamBlobs.html +52 -0
  37. data/doc/html/structCamImage.html +791 -0
  38. data/doc/html/structCamLabelingResults.html +47 -0
  39. data/doc/html/structCamLinearFilterKernel.html +64 -0
  40. data/doc/html/structCamMeasuresResults.html +55 -0
  41. data/doc/html/structCamMorphoMathsKernel.html +82 -0
  42. data/doc/html/structCamPoint.html +47 -0
  43. data/doc/html/structCamRLEImage.html +184 -0
  44. data/doc/html/structCamROI.html +89 -0
  45. data/doc/html/structCamRun.html +57 -0
  46. data/doc/html/structCamSepFilterKernel.html +68 -0
  47. data/doc/html/structCamTable.html +47 -0
  48. data/doc/html/structCamTableOfBasins.html +38 -0
  49. data/doc/html/structCamVolbergFwdParams.html +47 -0
  50. data/doc/html/structCamWarpingParams.html +79 -0
  51. data/doc/html/tab_b.gif +0 -0
  52. data/doc/html/tab_l.gif +0 -0
  53. data/doc/html/tab_r.gif +0 -0
  54. data/doc/html/tabs.css +102 -0
  55. data/doc/html/todo.html +28 -0
  56. data/doc/html/tree.html +132 -0
  57. data/doc/rtf/refman.rtf +38378 -0
  58. data/ext/INSTALL +9 -0
  59. data/ext/Makefile +139 -0
  60. data/ext/camellia_ruby.i +308 -0
  61. data/ext/camellia_ruby_wrap.cxx +16086 -0
  62. data/ext/extconf.rb +4 -0
  63. data/ext/install.rb +11 -0
  64. data/ext/swig_ruby.dsp +159 -0
  65. data/inc/camellia.h +2624 -0
  66. data/inc/camellia_internals.h +192 -0
  67. data/lib/camellia-fox.rb +39 -0
  68. data/test/test_arithm.rb +13 -0
  69. data/test/test_color_labeling.rb +45 -0
  70. data/test/test_copy.rb +13 -0
  71. data/test/test_draw.rb +15 -0
  72. data/test/test_fixed_filters.rb +23 -0
  73. data/test/test_fox.rb +106 -0
  74. data/test/test_fox2.rb +108 -0
  75. data/test/test_histogram.rb +18 -0
  76. data/test/test_hough.rb +29 -0
  77. data/test/test_labeling.rb +30 -0
  78. data/test/test_mask.rb +34 -0
  79. data/test/test_watershed.rb +35 -0
  80. data/test/ts_camellia.rb +10 -0
  81. metadata +138 -0
data/inc/camellia.h ADDED
@@ -0,0 +1,2624 @@
1
+ /** \file camellia.h
2
+ * \brief Camellia Image Processing Library header file
3
+ * \author Bruno STEUX (ENSMP)
4
+ *
5
+ * Camellia Image Processing Library
6
+ *
7
+
8
+ The Camellia Image Processing Library is an open source low-level image processing library.
9
+ As it uses the IplImage structure to describe images, it is a good replacement to the IPL (Intel) library
10
+ and a good complement to the OpenCV library. It includes a lot of functions for image processing
11
+ (filtering, morphological mathematics, labeling, warping, loading/saving images, etc.),
12
+ some of them being highly optimized; It is also cross-platform and robust. It is doxygen-documented
13
+ and examples of use are provided.
14
+
15
+ This software library is an outcome of the Camellia european project (IST-2001-34410).
16
+ It was developped by the Ecole des Mines de Paris (ENSMP), in coordination with
17
+ the other partners of the project.
18
+
19
+ ==========================================================================
20
+
21
+ Copyright (c) 2002-2006, Ecole des Mines de Paris - Centre de Robotique
22
+ All rights reserved.
23
+
24
+ Redistribution and use in source and binary forms, with or without
25
+ modification, are permitted provided that the following conditions are met:
26
+
27
+ * Redistributions of source code must retain the above copyright
28
+ notice, this list of conditions and the following disclaimer.
29
+ * Redistributions in binary form must reproduce the above copyright
30
+ notice, this list of conditions and the following disclaimer
31
+ in the documentation and/or other materials provided with the distribution.
32
+ * Neither the name of the Ecole des Mines de Paris nor the names of
33
+ its contributors may be used to endorse or promote products
34
+ derived from this software without specific prior written permission.
35
+
36
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
38
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
40
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
42
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
43
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47
+
48
+ ==========================================================================
49
+
50
+ *
51
+ * v1.0 : 28th of October 2002
52
+ *
53
+ * v1.1 : 8th of November 2002
54
+ * - Added error checking in labeling
55
+ * - Blob analysis was divided into two phases
56
+ * - Added Warping code (two scan calls to Volberg's algorithm)
57
+ * - Added BMP files load/save (by Winfried Gehrke)
58
+ * - Header is now compatible with C++, IPL/OpenCV and RT-Maps
59
+ *
60
+ * v1.2 : 19th of November 2002
61
+ * - Slight bug correction in morpho maths kernel
62
+ * - Bug correction in labeling (CAM_LABEL_OPTIMIZE1 wrong + bad loop for first line)
63
+ * - Modified camSavePGM so that it is possible to save 16-bits images
64
+ * - Added Linear kernel filtering and median filtering algorithms
65
+ * - Added Example 3 (from ULP) & Example 4 (filtering)
66
+ * - Added makefile for Unix
67
+ *
68
+ * v1.21 : 5th of February 2003
69
+ * - Removed the free(roi) in camDeallocateImage
70
+ *
71
+ * v1.3 : 19th of February, 2003
72
+ * - Added "sum" measure in CamMeasuresResults (in addition to average, min, max)
73
+ * - Added camCopy to copy images and camMirror for mirroring
74
+ *
75
+ * v1.4 : 10th of April, 2003
76
+ * - Added RLE compression and RLE-based labeling
77
+ * - Added camSetROI, camCopy and camZoom2x in cam_utils
78
+ *
79
+ * v1.5 : 16th of June, 2003
80
+ * - Fixed a bug in camLabeling and camWarping (detected with Valgrind (purify-like))
81
+ * - Added camAllocateYUVImage and camAllocateRGBImage utility functions
82
+ * - Added a new LLA : camHistogram2Channels (used for face tracking)
83
+ * - Added some arguments checking to functions
84
+ * - Now uses border parameters in IplImage structure instead of "border" parameter
85
+ * - Added camSetBorder utility function
86
+ * - Added CAM_ARITHM_DOUBLE_THRESHOLD to camMonadicArithm LLA
87
+ * - Added camRLEDecodeBlobs function
88
+ * - Added idempotence evaluation to the morpho maths kernel
89
+ * - Added camDecimateNN utility function
90
+ * - Changed the RLE encoding function so that it stores the line number of each run
91
+ *
92
+ * v1.6 : 24th of June, 2003
93
+ * - Added dynamic memory allocation for RLE images
94
+ * - Little modification for morpho maths kernel (added saturation on SUBSTRACTION operation)
95
+ * - Added camClipROI utility function
96
+ *
97
+ * v1.61 : 4th of July, 2003
98
+ * - Corrected bug in camClipROI utility function
99
+ *
100
+ * v1.7 : 7th of July, 2003
101
+ * - Added new camWarping LLA (backward and NOT using volberg)
102
+ * - Former camWarping was renamed camVolbergFwd
103
+ *
104
+ * v1.8 : 9th of July, 2003
105
+ * - Added perspective parameter to camWarping LLA
106
+ *
107
+ * v1.9 : 28th of July, 2003
108
+ * - Modified border management for LLAs using neighborhood
109
+ * - Slightly adapted morpho maths kernel to work on 3x3, 5x5, 7x7 kernels
110
+ * and do only dilations, erosions...
111
+ * - Added RLE encoding with integrated thresholding
112
+ * - New warping function, more classical (with NN and bilinear interpolation)
113
+ * - Modified example7 and added example8 to cam_demo.c
114
+ *
115
+ * v1.91 : 9th of August, 2003
116
+ * - camRLE -> CamRun
117
+ *
118
+ * v2.0 : 13th of August, 2003
119
+ * - Optimized all neighborhood operators
120
+ * - Added binary images processing in camMonadicArithm
121
+ * - Added binary images processing in camDyadicArithm
122
+ * - Added binary images processing in camRLEEncode
123
+ * - Added binary images processing in CamMorphoMathsKernel
124
+ * - Added utilities supporting binary images
125
+ * - Added camThreshold function
126
+ * - Added Circle7, Circle5 & Square3 dilation/erosion/gradient optimization
127
+ * - Introduced doxygen documentation support
128
+ *
129
+ * v2.1 : 27th of August, 2003
130
+ * - Linux compatibility issue solved (unsigned long long constants)
131
+ * - Added cam_RLE_utils.c file
132
+ * - Added id, first, last and misc members to the CamBlobInfo structure
133
+ * - Added a start and stop run in RLE encoding (eases further blob analysis)
134
+ * - Added camRLEBlobSides and camRLEBlobRectIntersect functions
135
+ * - Introduced cam_config.h file
136
+ * - Nows accepts call to camXSquare3, camXCircle5 and camXCircle7 with binary images.
137
+ *
138
+ * v2.11 : 19th of September, 2003
139
+ * - Corrected bug in camRLEBlobRectIntersect
140
+ * - Added LGPL license text + camellia.h header
141
+ *
142
+ * v2.2 : 23th of September, 2003
143
+ * - Added 1D watershed operation : camWatershed1D()
144
+ * - Added 2D hierarchical watershed operation.
145
+ * - Removed camHistogramResults structure.
146
+ * - Changed camSet second parameter
147
+ * - Introduced both 8 and 16-bits depth code generation
148
+ * - Changed CamTable parameters
149
+ * - Enhanced CamTable (binary ops + 8/16 bits depth generation)
150
+ *
151
+ * v2.21 : 21th of October, 2003
152
+ * - Corrected a bug in camRLEBlobAnalysis (blobs with 1 run are erroneous)
153
+ *
154
+ * v2.22 : 27th of October, 2003
155
+ * - Corrected some bugs in neighborhood operators (bottom line was incorrect).
156
+ *
157
+ * v2.23 : 26th of November, 2003
158
+ * - Corrected some other big bugs in neighborhood operators (still with the bottom line).
159
+ *
160
+ * v2.24 : 20th of January, 2005
161
+ * - Changed signed saturation in linear filter from (-128;+127) to (-127;+127) (unbiased)
162
+ *
163
+ * v2.25 : 12th of February, 2005
164
+ * - Added camDownscaling2x2 function
165
+ *
166
+ * v2.26 : 10th of June, 2005
167
+ * - File name changed : cam_generate.c -> cam_LUT.c
168
+ * - camSaveBMP can save color images
169
+ * - Corrected bug in camClipROI function
170
+ * - Added camClip function
171
+ * - Added camDrawLine, camDrawRectangle, camDrawText16s, camDrawCircle and camDrawEllipse functions
172
+ *
173
+ * v2.3 : 23th of June, 2005
174
+ * - Added erosion on RLE images (camRLEErodeXXX functions)
175
+ * - Corrected small bug in camRLEDecode
176
+ * - Added camSAD8x8 and camSAD16x16 functions (MMX optimized)
177
+ *
178
+ * v2.31 : 27th of June, 2005
179
+ * - Added camROIIntersect function
180
+ * - camRLEBlobRectIntersect disappears. Replaced by camRLEBlobROIIntersect
181
+ * - camRect disappears. IplROI is enough.
182
+ *
183
+ * v2.32 : 1st of July, 2005
184
+ * - Added camPlot function
185
+ * - camAllocateRGBImage allocates "BGR" oriented images
186
+ *
187
+ * v2.33 : 5th of July, 2005
188
+ * - Added camVSumming and camHSumming functions
189
+ * - Added camAbs wrapper
190
+ *
191
+ * v2.34 : 9th of July 2005
192
+ * - Corrected bug in camAllocateRGBImage
193
+ *
194
+ * v2.35 : 13th of July 2005
195
+ * - Corrected a bug in 3DRS algorithm (F. Guyot)
196
+ *
197
+ * v2.40 : 18th of July 2005
198
+ * - Added color conversion functions
199
+ * - Dispatched cam_utils.c to cam_utils.c, cam_io.c and cam_draw.c
200
+ * - camAllocateYUVImage now allocates planar images
201
+ * - camLoadBMP reads color images
202
+ *
203
+ * v2.41 : 19th of July 2005
204
+ * - Bug correction in camSAD8x8 (F. Guyot)
205
+ *
206
+ * v2.42 : 25th of October 2005
207
+ * - Added camThresholdInv, camRLEEncodeThreshold and camRLEEncodeThresholdInv functions
208
+ * - Enhanced camSet function so that it can work with color (RGB, YUV) values
209
+ *
210
+ * v2.43 : 14th of November 2005
211
+ * - Labelling -> labeling (Well, both of them are syntaxically correct)
212
+ * - Optimized camLinearFiltering function (speedup with partially empty kernels)
213
+ * - Added camLinearFilterAbs functions
214
+ * - camLinearFiltering -> camLinearFilter
215
+ * - camMedianFiltering -> camMedianFilter
216
+ *
217
+ * v2.44 : 28th of November 2005
218
+ * - Saturation optimization camLinearFilter
219
+ *
220
+ * v2.45 : 12th of December 2005
221
+ * - Added Projection and Retroprojection functions
222
+ * - Introduced CamImage structure
223
+ *
224
+ * v2.46 : 15th of December 2005
225
+ * - Tests __INTEL_COMPILER directive for optimizations
226
+ * - Removed cam_config.h
227
+ * - Removed benchmarking functions (trouble with winmm.lib)
228
+ * - Added CamSobel3x3 and camSobel3x3Abs functions
229
+ * - Performance optimized linear filtering and erosion/dilation (use of memcpy)
230
+ * - Added camUndistort function
231
+ * - Added camRGB2Y function
232
+ * - Corrected rounding bug in camWarping
233
+ *
234
+ * v2.47 : 27th of December 2005
235
+ * - Small modifications in CamImage structure
236
+ * - Added camUndistortFixed (Fixed point implementation)
237
+ * - Added camUndistortLUT
238
+ * - Implemented CAM_BORDER_REPLICATE border mode (set as default)
239
+ * - Checked compilation with Cygwin
240
+ *
241
+ * v2.48 : 1st of January 2006
242
+ * - Added a field to CamRLEImage to identify the structure
243
+ * - The mask field in CamImage was turned to void*
244
+ * - Added configuration loading and query functions (cam_utils.c)
245
+ * - Corrected bug in Circle7 erosion/dilation algorithm
246
+ * - camDownScaling2x2 -> camDownscaling2x2
247
+ * - camDownscaling2x2 now supports several channels
248
+ * - Align 16bits deep images lines to 16 bytes boundaries (for cam_watershed operation)
249
+ * - Enhanced Watershed algorithm (now computes region surfaces)
250
+ * - Added camFillColor function
251
+ * - Solved Linux compilation problems
252
+ * - camRLEEncode now works on 16-bits images (especially watershed results)
253
+ * - Added camHierarchicalWatershedContours function
254
+ * - Turned BGR images to RGB
255
+ * - camMeasures now locates the position of min & max
256
+ * - Added camRLEEncodeColor function
257
+ * - Removed projection related functions (except undistort)
258
+ * - Added camVersion function (to check function)
259
+ * - typedef struct _camX { => typedef struct {
260
+ *
261
+ * v2.49 : 25th of January 2006
262
+ * - Added camRLEBlobMeasures function
263
+ * - Added camProject and camBackproject functions, compatible with the MATLAB calibration toolbox
264
+ *
265
+ * v2.50pre1 : 13th of February 2006
266
+ * - Implemented coherent ROI policy
267
+ * - Added better error management
268
+ * - Added 8->16 bits image operations
269
+ * - Added camScale function
270
+ * - Moved to Subversion (instead of CVS)
271
+ * - Added SVN Revision Id to version number
272
+ * - Added camCheckArgs2 function
273
+ * - Implemented masking in linear filter functions, morpho maths kernel, camCopy and arithmetic functions
274
+ * - camLinearFilter and morpho maths kernel functions now return accumulated sum of pixels
275
+ * - Added camSetRLEMask function
276
+ * - Automatic image allocation in most functions
277
+ * - First version of C++ wrapping
278
+ * - Implemented better error management
279
+ * - camLoadPGM can now load 16 bits deep images
280
+ * - First version of Ruby wrapping (ROI support)
281
+ * - Added camClone function
282
+ * - Added camRLEClone and camRLEReallocate functions
283
+ * - CamTable -> camApplyLUT. Introduced CamTable structure
284
+ * - Added camAccumulateLine function
285
+ * - Removed any IPL related reference
286
+ * - Big bug correction in camRLEEncode functions
287
+ * - camHVSumming disappears, replaced by camSumHV, camSumH and camSumV
288
+ * - New camFindThreshold function
289
+ * - Slight modifications in camMeasures functions
290
+ * - Added camCircleHough function
291
+ *
292
+ * v2.50pre2 : 4th of April 2006
293
+ * - set_rle_mask => set_mask
294
+ * - Modified camROIIntersect function so that it doesn't return a CamROI (pb. incompatibility C/C++)
295
+ * - Added management of CamImage masks (not just CamRLEImage as before)
296
+ * - Added implementation of separable linear filters
297
+ * - Added camRefCopy function
298
+ * - Added camFixedFilter function and an implementation of 3x3 to 7x7 gaussian filtering
299
+ *
300
+ * v2.5.0 : 11th of April 2006
301
+ * - All CamName functions were turned to camName
302
+ * - camSet functions now supports masking
303
+ * - Added CamImage::inspect function (for Ruby wrapping)
304
+ * - C++ constructor can alloc color images
305
+ * - Added camAllocRGBAImage (with alpha channel)
306
+ * - Added size member to CamTable
307
+ * - Modified camRLEEncodeColor so that it uses CamTable class
308
+ * - Wrapped camRLEEncodeColor to C++/Ruby
309
+ * - Enhanced CamTable Ruby wrapping (Enumerable)
310
+ * - Added CamTable::set function
311
+ * - Added CamImage::set_pixels function
312
+ * - camCopy now supports Grey to Color conversion, adding and removing alpha channels
313
+ * - camSaveBMP can save images with alpha channels
314
+ * - Added camRGBA and CAM_RGBA macro
315
+ * - Version numbering -> 2.5.0
316
+ * - Added CAM_ARITHM_MUL parameter to CamDyadicArithm (dyadic multiplication)
317
+ * - Added camAlphaComposite function (support for alpha channels)
318
+ * - Drawing is now possible on alpha channels
319
+ *
320
+ * v2.5.1 : 5th of May 2006
321
+ * - Faster camCopy function (using memcpy)
322
+ * - Faster camSet function (using memset)
323
+ * - camConfig -> CamConfig.
324
+ *
325
+ * v2.5.2 : 9th of May 2006
326
+ * - camFillColor : Corrected bug (x,y outside frame)
327
+ * - camFillColor : static allocation for queues
328
+ *
329
+ * v2.5.3 : 17th of May 2006
330
+ * - Corrected bug in camLoadPGM function
331
+ * - Added Visual C++ Express project files
332
+ *
333
+ * v2.5.4 : 18th of May 2006
334
+ * - camFillColor : added tolerance parameter
335
+ * - fixed SWIG compilation with Visual C++ Express
336
+ *
337
+ * v2.5.5 : 23rd of June 2006
338
+ * - Added Scharr filter (to test)
339
+ * - Modified circular hough
340
+ *
341
+ * v2.5.6 : 28th of June 2006
342
+ * - Bug correction in camWarping(). Bad ROI maganement.
343
+ *
344
+ * v2.5.7 : 6th of July 2006
345
+ * - Small bug correction to camDrawCircle and camDrawEllipse : radius=0 was crashing
346
+ *
347
+ * v2.5.8 : 12th Of July 2006
348
+ * - Added C++/Ruby wrapping for Watershed functions
349
+ *
350
+ * v2.5.9 : 13th of July 2006
351
+ * - Main feature : Added bitmap font support
352
+ * - Better FXRuby GUI support (support for FXBMPImage, FXJPGImage...)
353
+ * - camRGB2YUV supports 4 channel images in input + ROI & mask support
354
+ * - Added mask and acc support to camHistogram
355
+ * - camInternalROIPolicyStruct -> CamInternal...
356
+ * - Corrected bugs in camRLEApplyLUT
357
+ * - introduced camellia_internals.h
358
+ * - Corrected small bug in camWarping
359
+ * - Brand new macros for supporting partially out of boundaries masks
360
+ *
361
+ * v2.5.10 : 30th of July 2006
362
+ * - Corrected dummy bug in camRLEEncodeColor, that made Visual C++ Express to break in debug mode
363
+ * - Bug correction in camScale function
364
+ * - 16->8 bits image copy now satures correctly
365
+ * - Corrected bug in camAbs (with 16-bits images)
366
+ * - Corrected bug in camHistogram (with 12-bits images)
367
+ * - camHistogram centers histogram for signed images
368
+ * - Bug correction in mask management in camDyadicArithm
369
+ */
370
+
371
+ #ifndef _CAMELLIA_H_
372
+ #define _CAMELLIA_H_
373
+
374
+ #define CAM_VERSION "2.5.10 : Luxembourg ($Rev: 90 $)"
375
+
376
+ #include <stdlib.h>
377
+
378
+ /*******************************************
379
+ * Compilation options : *
380
+ */
381
+ // Pixel definition
382
+ #define CAM_PIXEL unsigned char
383
+ #define CAM_SIGNED_PIXEL signed char
384
+
385
+ // Max image size
386
+ #define CAM_MAX_SCANLINE 1280
387
+ #define CAM_MAX_FRAME_HEIGHT 1024
388
+
389
+ // 64-bit processor or memory bandwidth?
390
+ #define CAM_64BITS
391
+
392
+ // Pentium4 optimizations?
393
+ #define CAM_OPT_P4
394
+
395
+ // Big endian arichitecture?
396
+ //#define CAM_BIG_ENDIAN
397
+
398
+ // Generate 8 AND 16 bits pixel size code
399
+ #define CAM_GENERATE_FULL_CODE
400
+
401
+ /* *
402
+ *******************************************/
403
+ #ifdef _WIN32
404
+ #define CAM_INT64 __int64
405
+ #define CAM_UINT64 unsigned __int64
406
+ #else
407
+ #define CAM_INT64 long long
408
+ #define CAM_UINT64 unsigned long long
409
+ #endif
410
+
411
+ #ifdef __INTEL_COMPILER
412
+ #define CAM_ALIGN16 __declspec(align(16))
413
+ #else
414
+ #define CAM_ALIGN16
415
+ #endif
416
+
417
+ #define CAM_FIXED_POINT signed long
418
+ #define CAM_FLOAT2FIXED(x,dot_pos) ((CAM_FIXED_POINT)((x)*(1<<dot_pos)))
419
+
420
+ #define CAM_DEPTH_SIGN 0x80000000
421
+ #define CAM_DEPTH_MASK 0x7FFFFFFF
422
+
423
+ #define CAM_DEPTH_1U 1
424
+ #define CAM_DEPTH_8U 8
425
+ #define CAM_DEPTH_10U 10
426
+ #define CAM_DEPTH_12U 12
427
+ #define CAM_DEPTH_16U 16
428
+
429
+ #define CAM_DEPTH_8S (CAM_DEPTH_SIGN| 8)
430
+ #define CAM_DEPTH_10S (CAM_DEPTH_SIGN|10)
431
+ #define CAM_DEPTH_12S (CAM_DEPTH_SIGN|12)
432
+ #define CAM_DEPTH_16S (CAM_DEPTH_SIGN|16)
433
+
434
+ #define CAM_DATA_ORDER_PIXEL 0
435
+ #define CAM_DATA_ORDER_PLANE 1
436
+
437
+ #define CAM_ORIGIN_TL 0
438
+
439
+ #define CAM_ALIGN_4BYTES 4
440
+ #define CAM_ALIGN_8BYTES 8
441
+ #define CAM_ALIGN_16BYTES 16
442
+ #define CAM_ALIGN_32BYTES 32
443
+
444
+ #define CAM_ALIGN_DWORD CAM_ALIGN_4BYTES
445
+ #define CAM_ALIGN_QWORD CAM_ALIGN_8BYTES
446
+
447
+ #define CAM_BORDER_CONSTANT 0
448
+ #define CAM_BORDER_REPLICATE 1
449
+
450
+ /*--- Indexes to access IplImage.BorderMode[],IplImage.BorderConst[] ----*/
451
+ #define CAM_SIDE_TOP_INDEX 0
452
+ #define CAM_SIDE_BOTTOM_INDEX 1
453
+ #define CAM_SIDE_LEFT_INDEX 2
454
+ #define CAM_SIDE_RIGHT_INDEX 3
455
+
456
+ /*---------- values of argument of iplSetBorderMode(,,border,) ----------*/
457
+ #define CAM_SIDE_TOP (1<<CAM_SIDE_TOP_INDEX)
458
+ #define CAM_SIDE_BOTTOM (1<<CAM_SIDE_BOTTOM_INDEX)
459
+ #define CAM_SIDE_LEFT (1<<CAM_SIDE_LEFT_INDEX)
460
+ #define CAM_SIDE_RIGHT (1<<CAM_SIDE_RIGHT_INDEX)
461
+ #define CAM_SIDE_ALL (CAM_SIDE_RIGHT | CAM_SIDE_TOP | CAM_SIDE_LEFT | CAM_SIDE_BOTTOM)
462
+
463
+ #ifdef CAM_BIG_ENDIAN
464
+ #define CAM_FC( ch0, ch1, ch2, ch3 ) \
465
+ ((int)(ch3)|((int)(ch2)<<8)|((int)(ch1)<<16)|((int)(ch0)<<24))
466
+ #else
467
+ #define CAM_FC( ch0, ch1, ch2, ch3 ) \
468
+ ((int)(ch0)|((int)(ch1)<<8)|((int)(ch2)<<16)|((int)(ch3)<<24))
469
+ #endif
470
+
471
+ #ifndef SWIG
472
+ #define CAM_COLORMODEL_RGB CAM_FC('R','G','B',000)
473
+ #define CAM_COLORMODEL_RGBA CAM_FC('R','G','B','A')
474
+ #define CAM_COLORMODEL_YUV CAM_FC('Y','U','V',000)
475
+ #define CAM_COLORMODEL_GREY CAM_FC('G',000,000,000)
476
+ #endif
477
+
478
+ #ifdef __cplusplus
479
+ struct CamImage;
480
+ struct CamTableOfBasins;
481
+ struct CamBitmapFont;
482
+
483
+ /// The IPL Region Of Interest structure
484
+ struct CamROI {
485
+ #else
486
+ /// The IPL Region Of Interest structure
487
+ typedef struct {
488
+ #endif
489
+ /// The channel of interest number
490
+ /** This parameter indicates which channel in the original image will
491
+ * be affected by processing taking place in the region of interest;
492
+ * coi equal to 0 indicates that all channel will be affected
493
+ */
494
+ int coi;
495
+ int xOffset; ///< The offset from the origin of the rectangular ROI.
496
+ int yOffset; ///< The offset from the origin of the rectangular ROI.
497
+ int width; ///< The size of the rectangular ROI
498
+ int height; ///< The size of the rectangular ROI
499
+
500
+ // C++ Wrapping
501
+ #ifdef __cplusplus
502
+ CamROI() {coi=0; xOffset=0; yOffset=0; width=0; height=0;}
503
+ CamROI(int _coi, int _xOffset, int _yOffset, int _width, int _height) {
504
+ coi=_coi; xOffset=_xOffset; yOffset=_yOffset; width=_width; height=_height;
505
+ }
506
+ CamROI(const CamImage &image, int _coi=0);
507
+ ~CamROI() {};
508
+ CamROI intersect(const CamROI &roi) const; ///< C++ wrapping for function camROIIntersect()
509
+ bool clip(CamImage &image);
510
+ bool reduce(int i);
511
+ bool enlarge(int i);
512
+ };
513
+
514
+ struct CamLinearFilterKernel;
515
+ struct CamMorphoMathsKernel;
516
+ struct CamRLEImage;
517
+ struct CamTable;
518
+ struct CamMeasuresResults;
519
+ struct CamSepFilterKernel;
520
+
521
+ #else
522
+ } CamROI;
523
+ #endif
524
+
525
+ #define CAM_POINT 1
526
+ #define CAM_CROSS 2
527
+ #define CAM_CIRCLE 4
528
+
529
+ /// The famous IplImage/CamImage structure, today's standard structure for image processing.
530
+ /** This structure originally comes from IPL (Image Processing Library) by Intel.
531
+ * This standard structure is also used in OpenCV (Open Source Computer Vision Libary).
532
+ * The IplImage structure is the preferred structure for image processing with RT-Maps
533
+ * (Real-Time "des Mines" Automotive Prototyping System).
534
+ */
535
+ #ifdef __cplusplus
536
+ struct CamImage {
537
+ #else
538
+ typedef struct {
539
+ #endif
540
+ #ifdef SWIG
541
+ %immutable;
542
+ #endif
543
+ int nSize; ///< Size of CamImage struct
544
+ int id; ///< Frame Id (user dependant)
545
+ int nChannels; ///< Number of channels in the image (generally 1,3 or 4)
546
+ int alphaChannel; ///< Alpha channel number (0 if there is no alpha channel in the image)
547
+
548
+ /// Bit depth of pixels.
549
+ /** Can be one of CAM_DEPTH_1U, CAM_DEPTH_8U, CAM_DEPTH_8S, CAM_DEPTH_10U, CAM_DEPTH_10S, CAM_DEPTH_12U, CAM_DEPTH_12S, CAM_DEPTH_16U, CAM_DEPTH_16S.
550
+ */
551
+ int depth;
552
+ char colorModel[4]; ///< A four-character string describing the color model: "RGB", "GRAY", "HLS", etc.
553
+
554
+ /// The sequence of color channels
555
+ /** Can be one of the following: "G", "GREY", "BGR", "BGRA", "RGB", "RGBA", "HSV", "HLS", "XYZ",
556
+ * "YUV", "YCr", "YCC", "LUV".
557
+ */
558
+ char channelSeq[4];
559
+ int dataOrder; ///< CAM_DATA_ORDER_PIXEL or CAM_DATA_ORDER_PLANE
560
+ int origin; ///< The origin of the image. Can only be CAM_ORIGIN_TL (top left).
561
+ int align; ///< Alignment of image data : 4 (CAM_ALIGN_DWORD) or 8 (CAM_ALIGN_QWORD) byte align
562
+ int width; ///< Width of the image in pixels
563
+ int height; ///< Height of the image in pixels
564
+
565
+ /// Pointer to a ROI (Region of interest) structure.
566
+ /** This argument can be NULL, which implies that a region of interest
567
+ * comprises all channels and the entire image area.
568
+ */
569
+ CamROI *roi;
570
+
571
+ /// Pointer to the header of another image that specifies the mask ROI.
572
+ /** This argument can be NULL, which indicates that no mask ROI is used.
573
+ * A pixel is processed if the corresponding mask pixel is not 0, and is not
574
+ * processed if the mask pixel is 0. At the moment, only RLE encoded masks
575
+ * are supported (CamRLEImage structure)
576
+ **/
577
+ void *mask; ///< Pointer to mask image
578
+
579
+ /// The image ID
580
+ /** Field reserved for the use of the application to identify the image.
581
+ */
582
+ void *imageId; ///< Free for user application
583
+
584
+ void *misc; ///< Free for user application (information on tiling in IplImage structure)
585
+ int imageSize; ///< Useful size in bytes
586
+ unsigned char *imageData; ///< Pointer to aligned image
587
+ int widthStep; ///< The size of aligned line in bytes
588
+ int borderMode[4]; ///< The top, bottom, left and right border mode
589
+ int borderConst[4]; ///< Constants for the top, bottom, left and right border
590
+ unsigned char *imageDataOrigin; ///< Pointer to full, nonaligned image. A NULL value indicates that the image is not owned by the structure
591
+
592
+ // C++ Wrapping
593
+
594
+ #ifdef __cplusplus
595
+ CamImage() {imageData=NULL; roi=NULL; imageSize=0; mask=NULL; imageDataOrigin=NULL; depth=CAM_DEPTH_8U; nChannels=1; } ///< Default non-allocating constructor
596
+ CamImage(int width, int height, int depth=CAM_DEPTH_8U, int colormodel=0); ///< Allocating constructor (1 to 16 bits, signed/unsigned, G/RGB/RGBA/YUV)
597
+ CamImage(const CamImage& image); ///< Copy constructor
598
+ ~CamImage(); ///< Default destructor. Free any allocated memory.
599
+
600
+ CamImage& operator=(const CamImage &image); ///< Operator= redefinition
601
+ CamImage* clone() const; ///< Clone image (using camClone() function)
602
+ CamImage* copy() const; ///< Copy (not clone). Takes into account ROI and masks. C++ wrapping for camCopy() function
603
+ bool copy(CamImage &dest) const; ///< Copy (not clone). Takes into account ROI and masks. C++ wrapping for camCopy() function
604
+ bool allocated() const {return (imageData)?true:false;} ///< Check whether the image is allocated or not
605
+ bool alloc(int width, int height, int depth=CAM_DEPTH_8U, int colormodel=0); ///< Image allocation (1 to 16 bits, signed/unsigned, G/RGB/RGBA/YUV)
606
+ bool dealloc(); ///< Deallocate image (C++ wrapping for camDeallocateImae() function)
607
+ bool alloc_rgb(int width, int height); ///< RGB image allocation (8 bits, pixel oriented)
608
+ bool alloc_rgba(int width, int height); ///< RGBA image allocation (8 bits, pixel oriented, alpha channel)
609
+ bool alloc_yuv(int width, int height); ///< YUV image allocation (8 bits, planar oriented)
610
+ bool load_pgm(const char *filename); ///< C++ wrapping for camLoadPGM() function
611
+ bool save_pgm(const char *filename) const; ///< C++ wrapping for camSavePGM() function
612
+ bool load_bmp(const char *filename); ///< C++ wrapping for camLoadPGM() function
613
+ bool save_bmp(const char *filename) const; ///< C++ wrapping for camSavePGM() function
614
+ bool set_roi(const CamROI &roi); ///< C++ wrapping for camSetROI() function
615
+ void get_pixels(char **result, int *len) const; ///< Fills an char array allocated with C++ operator new. len is filled with the length of the array. Used for mapping Ruby to_s member.
616
+ bool set_pixels(const char *pixels, int sz); ///< Set pixels of the picture, from a byte array
617
+ void inspect(char **result, int *len) const; ///< Returns some textual information about the image
618
+ bool view() const; ///< View the picture
619
+ bool set(int color); ///< C++ wrapping for camSet() function
620
+ bool alpha_composite(const CamImage& source2, CamImage& dest) const; ///< C++ wrapping for camAlphaComposite() function
621
+
622
+ int erode_square3(); ///< C++ wrapping for camErodeSquare3() function
623
+ int erode_square3(CamImage &dest) const; ///< C++ wrapping for camErodeSquare3() function
624
+ int erode_circle5(); ///< C++ wrapping for camErodeCircle5() function
625
+ int erode_circle5(CamImage &dest) const; ///< C++ wrapping for camErodeCircle5() function
626
+ int erode_circle7(); ///< C++ wrapping for camErodeCircle7() function
627
+ int erode_circle7(CamImage &dest) const; ///< C++ wrapping for camErodeCircle7() function
628
+ int dilate_square3(); ///< C++ wrapping for camDilateSquare3() function
629
+ int dilate_square3(CamImage &dest) const; ///< C++ wrapping for camDilateSquare3() function
630
+ int dilate_circle5(); ///< C++ wrapping for camDilateCircle5() function
631
+ int dilate_circle5(CamImage &dest) const; ///< C++ wrapping for camDilateCircle5() function
632
+ int dilate_circle7(); ///< C++ wrapping for camDilateCircle7() function
633
+ int dilate_circle7(CamImage &dest) const; ///< C++ wrapping for camDilateCircle7() function
634
+ int morpho_gradient_square3(); ///< C++ wrapping for camMorphoGradientSquare3() function
635
+ int morpho_gradient_square3(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientSquare3() function
636
+ int morpho_gradient_circle5(); ///< C++ wrapping for camMorphoGradientCircle5() function
637
+ int morpho_gradient_circle5(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientCircle5() function
638
+ int morpho_gradient_circle7(); ///< C++ wrapping for camMorphoGradientCircle7() function
639
+ int morpho_gradient_circle7(CamImage &dest) const; ///< C++ wrapping for camMorphoGradientCircle7() function
640
+
641
+ int morpho_maths(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camMorphoMaths() function
642
+ int morpho_maths(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camMorphoMaths() function
643
+ int erode_3x3(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode3x3() function
644
+ int erode_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode3x3() function
645
+ int dilate_3x3(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate3x3() function
646
+ int dilate_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate3x3() function
647
+ int erode_5x5(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode5x5() function
648
+ int erode_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode5x5() function
649
+ int dilate_5x5(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate5x5() function
650
+ int dilate_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate5x5() function
651
+ int erode_7x7(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camErode7x7() function
652
+ int erode_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camErode7x7() function
653
+ int dilate_7x7(const CamMorphoMathsKernel &ker); ///< C++ wrapping for camDilate7x7() function
654
+ int dilate_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const; ///< C++ wrapping for camDilate7x7() function
655
+
656
+ int linear_filter_3x3(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilter3x3() function
657
+ int linear_filter_3x3(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilter3x3() function
658
+ int linear_filter_5x5(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilter5x5() function
659
+ int linear_filter_5x5(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilter5x5() function
660
+ int linear_filter_abs_3x3(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilterAbs3x3() function
661
+ int linear_filter_abs_3x3(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilterAbs3x3() function
662
+ int linear_filter_abs_5x5(const CamLinearFilterKernel &ker); ///< C++ wrapping for camLinearFilterAbs5x5() function
663
+ int linear_filter_abs_5x5(CamImage &dest, const CamLinearFilterKernel &k) const; ///< C++ wrapping for camLinearFilterAbs5x5() function
664
+ bool sobel_v(); ///< C++ wrapping for camSobelV() function
665
+ bool sobel_h(); ///< C++ wrapping for camSobelH() function
666
+ bool sobel_v_abs(); ///< C++ wrapping for camSobelVAbs() function
667
+ bool sobel_h_abs(); ///< C++ wrapping for camSobelHAbs() function
668
+ bool sobel_v(CamImage &dest) const; ///< C++ wrapping for camSobelV() function
669
+ bool sobel_h(CamImage &dest) const; ///< C++ wrapping for camSobelH() function
670
+ bool sobel_v_abs(CamImage &dest) const; ///< C++ wrapping for camSobelVAbs() function
671
+ bool sobel_h_abs(CamImage &dest) const; ///< C++ wrapping for camSobelHAbs() function
672
+ int sep_filter_3x3(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter3x3() function
673
+ int sep_filter_3x3(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter3x3() function
674
+ int sep_filter_5x5(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter5x5() function
675
+ int sep_filter_5x5(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter5x5() function
676
+ int sep_filter_7x7(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilter7x7() function
677
+ int sep_filter_7x7(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilter7x7() function
678
+ int sep_filter_abs_3x3(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs3x3() function
679
+ int sep_filter_abs_3x3(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs3x3() function
680
+ int sep_filter_abs_5x5(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs5x5() function
681
+ int sep_filter_abs_5x5(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs5x5() function
682
+ int sep_filter_abs_7x7(const CamSepFilterKernel &ker); ///< C++ wrapping for camSepFilterAbs7x7() function
683
+ int sep_filter_abs_7x7(CamImage &dest, const CamSepFilterKernel &k) const; ///< C++ wrapping for camSepFilterAbs7x7() function
684
+ bool fixed_filter(CamImage &dest, int filter) const; ///< C++ wrapping for camFixedFilter() function
685
+ bool fixed_filter(int filter); ///< C++ wrapping for camFixedFilter() function
686
+
687
+ bool draw_line(int x1, int y1, int x2, int y2, int color); ///< C++ wrapping for camDrawLine() function
688
+ bool accumulate_line(int x1, int y1, int x2, int y2, int acc); ///< C++ wrapping for camAccumulateLine() function
689
+ bool draw_rectangle(int x1, int y1, int x2, int y2, int color); ///< C++ wrapping for camDrawRectangle() function
690
+ bool draw_text_16s(const char *text, int x, int y, int cwidth, int cheight, int orientation, int color); ///< C++ wrapping for camDrawText16s() function
691
+ bool draw_text_bitmap(const char *text, int x, int y, const CamBitmapFont &font); ///< C++ wrapping for camDrawTextBitmap() function
692
+ bool draw_circle(int x, int y, int r, int color); ///< C++ wrapping for camDrawCircle() function
693
+ bool draw_ellipse(int x, int y, int rx, int ry, int color); ///< C++ wrapping for camDrawEllipse() function
694
+ bool plot(int x, int y, int color, int kind=CAM_POINT); ///< C++ wrapping for camPlot() function
695
+ int fill_color(int x, int y, int fillcolor, int tolerance=-1); ///< C++ wrapping for camFillColor() function
696
+
697
+ bool scale(CamImage &dest) const; ///< C++ wrapping for camScale() function
698
+ bool set_mask(const CamRLEImage &mask); ///< C++ wrapping for camSetRLEMask() function
699
+ bool set_mask(const CamImage &mask); ///< C++ wrapping for camSetMask() function
700
+ bool apply_lut(const CamTable &lut); ///< C++ wrapping for camApplyLUT() function
701
+ bool apply_lut(CamImage &dest, const CamTable &lut) const; ///< C++ wrapping for camApplyLUT() function
702
+
703
+ CamImage *to_yuv() const; ///< C++ wrapping for camRGB2YUV() function
704
+ bool to_yuv(CamImage &dest) const; ///< C++ wrapping for camRGB2YUV() function
705
+ CamImage *to_rgb() const; ///< C++ wrapping for camYUV2RGB() function
706
+ bool to_rgb(CamImage &dest) const; ///< C++ wrapping for camYUV2RGB() function
707
+
708
+ CamRLEImage* encode() const; ///< C++ wrapping for camRLEEncode() function
709
+ CamRLEImage* encode_lut(const CamTable &LUT) const; ///< C++ wrapping for camRLEEncodeLUT() function
710
+ CamRLEImage* encode_threshold(int threshold) const; ///< C++ wrapping for camRLEEncodeThreshold() function
711
+ CamRLEImage* encode_threshold_inv(int threshold) const; ///< C++ wrapping for camRLEEncodeThresholdInv() function
712
+ CamRLEImage* encode_color(const CamTable &clusters) const; ///< C++ wrapping for camRLEEncodeColor() function
713
+ bool encode(CamRLEImage& dest) const; ///< C++ wrapping for camRLEEncode() function
714
+ bool encode_lut(CamRLEImage& dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEEncodeLUT() function
715
+ bool encode_threshold(CamRLEImage& dest, int threshold) const; ///< C++ wrapping for camRLEEncodeThreshold() function
716
+ bool encode_threshold_inv(CamRLEImage& dest, int threshold) const; ///< C++ wrapping for camRLEEncodeThresholdInv() function
717
+
718
+ int threshold(CamImage &dest,int threshold) const; ///< C++ wrapping for camThreshold() function
719
+ int threshold_inv(CamImage &dest,int threshold) const; ///< C++ wrapping for camThresholdInv() function
720
+ int abs(CamImage &dest) const; ///< C++ wrapping for camAbs() function
721
+ int threshold(int threshold); ///< C++ wrapping for camThreshold() function
722
+ int threshold_inv(int threshold); ///< C++ wrapping for camThresholdInv() function
723
+ int abs(); ///< C++ wrapping for camAbs() function
724
+
725
+ int arithm(int operation, int c1=0, int c2=0, int c3=0); ///< C++ wrapping for camMonadicArithm() function
726
+ int arithm(CamImage& dest, int operation, int c1=0, int c2=0, int c3=0) const; ///< C++ wrapping for camMonadicArithm() function
727
+ int arithm(const CamImage& source2, CamImage& dest, int operation, int c1=0, int c2=0, int c3=0, int c4=0) const; ///< C++ wrapping for camDyadicArithm() function
728
+
729
+ CamMeasuresResults measures() const; ///< C++ wrapping for camMeasures() function
730
+ float average_deviation(int average=0) const; ///< C++ wrapping for camMeasureAverageDeviation() function
731
+
732
+ bool sum_hv(CamTable& hsum, CamTable &vsum) const; ///< C++ wrapping for camSumHV() function
733
+ bool sum_h(CamTable& sum) const; ///< C++ wrapping for camSumH() function
734
+ bool sum_v(CamTable& sum) const; ///< C++ wrapping for camSumV() function
735
+
736
+ bool histogram(CamTable& histo) const; ///< C++ wrapping for camHistogram() function
737
+ bool histogram_2_channels(int ch1, int ch2, CamImage &result, int size=1) const; ///< C++ wrapping for camHistogram2Channels() function
738
+ int find_threshold(int percent) const; ///< C++ wrapping for camFindThreshold() function
739
+
740
+ int hough_circle(int percent, int rmin, int rmax, int &xc, int &yc, int &rc) const; ///< C++ wrapping for camHoughCircle() function
741
+
742
+ int hierarchical_watershed(CamImage &watershed, CamTableOfBasins &tob) const; ///< C++ wrapping for camHierarchicalWatershed() function
743
+ int hierarchical_watershed_contours(CamImage &ws, CamTableOfBasins &tob) const; ///< C++ wrapping for camHierarchicalWatershedContours() function
744
+ int hierarchical_watershed_regions(const CamTableOfBasins &tob); ///< C++ wrapping for camHierarchicalWatershedRegions() function
745
+ };
746
+
747
+ inline CamROI::CamROI(const CamImage &image, int _coi) { coi=_coi; xOffset=0; yOffset=0; width=image.width; height=image.height; }
748
+
749
+ #else
750
+ } CamImage;
751
+ #endif
752
+
753
+ /* Camellia C functions headers
754
+ */
755
+
756
+ #ifndef SWIG
757
+
758
+ #define CAM_PIXEL_ACCESS(ptr,y,x) \
759
+ ((CAM_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
760
+
761
+ #define CAM_MAX(a,b) (((a)>(b))?(a):(b))
762
+ #define CAM_MIN(a,b) (((a)<(b))?(a):(b))
763
+
764
+ /*! \def CAM_RGBA
765
+ * \brief 32 bits integer color representation, including an alpha channel.
766
+ */
767
+ #define CAM_RGBA(r,g,b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24))
768
+
769
+ /*! \def CAM_RGB
770
+ * \brief 24 bits integer color representation. Stricly equivalent to the Windows RGB macro.
771
+ * Please use this one in place of RGB for better portability of the code.
772
+ */
773
+ #define CAM_RGB(r,g,b) ((r)|((g)<<8)|((b)<<16))
774
+
775
+ #endif // SWIG
776
+
777
+ /* General purpose structures
778
+ */
779
+
780
+ /// The structure used by warping to identify a point in 2D
781
+ typedef struct {
782
+ int x; ///< x coordinate
783
+ int y; ///< y coordinate
784
+ } CamPoint;
785
+
786
+ /* Monadic and Dyadic Arithmetic Operators kernel
787
+ */
788
+
789
+ #define CAM_ARITHM_ABS 0
790
+ #define CAM_ARITHM_INVERSE 1
791
+ #define CAM_ARITHM_SELECT 2
792
+ #define CAM_ARITHM_THRESHOLD 3
793
+ #define CAM_ARITHM_DOUBLE_THRESHOLD 4
794
+
795
+ #define CAM_ARITHM_ADD 0
796
+ #define CAM_ARITHM_SUM 0
797
+ #define CAM_ARITHM_SUB 1
798
+ #define CAM_ARITHM_MUL 2
799
+ #define CAM_ARITHM_ABSDIFF 3
800
+ #define CAM_ARITHM_WEIGHTED_SUM 4
801
+ #define CAM_ARITHM_INF 5
802
+ #define CAM_ARITHM_SUP 6
803
+ #define CAM_ARITHM_COMP_INF 7
804
+ #define CAM_ARITHM_COMP_EQUAL 8
805
+ #define CAM_ARITHM_COMP_SUP 9
806
+ #define CAM_ARITHM_AND 10
807
+ #define CAM_ARITHM_OR 11
808
+
809
+ // Shorter constants
810
+ #define CAM_ABS 0
811
+ #define CAM_INVERSE 1
812
+ #define CAM_SELECT 2
813
+ #define CAM_THRESHOLD 3
814
+ #define CAM_DOUBLE_THRESHOLD 4
815
+
816
+ #define CAM_ADD 0
817
+ #define CAM_SUM 0
818
+ #define CAM_SUB 1
819
+ #define CAM_ABSDIFF 2
820
+ #define CAM_WEIGHTED_SUM 3
821
+ #define CAM_INF 4
822
+ #define CAM_SUP 5
823
+ #define CAM_COMP_INF 6
824
+ #define CAM_COMP_EQUAL 7
825
+ #define CAM_COMP_SUP 8
826
+ #define CAM_AND 9
827
+ #define CAM_OR 10
828
+
829
+ #ifndef SWIG
830
+
831
+ /// This is the parameter structure for the arithmetic computation kernel
832
+ /** Basically, it includes the code of the operation to execute, and
833
+ * the different parameters for this operation.
834
+ */
835
+ typedef struct {
836
+ int operation; ///< Operation to apply to the sources
837
+ int c1; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
838
+ int c2; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
839
+ int c3; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
840
+ int c4; ///< Additional parameter (see camMonadicArithm() and camDyadicArithm() for details)
841
+ } CamArithmParams;
842
+
843
+ #endif // SWIG
844
+
845
+ #ifdef __cplusplus
846
+ extern "C" {
847
+ #endif
848
+
849
+ #ifndef SWIG
850
+
851
+ /// This is the function that implements all the monadic arithmetic operators (i.e. operators with only one operand)
852
+ /** This function can be used to compute the absolute value of an image (<DFN>CAM_ARITHM_ABS</DFN>),
853
+ * to invert an image (<DFN>CAM_ARITHM_INVERSE</DFN>), to select all pixels with a given value in an image (<DFN>CAM_ARITHM_SELECT</DFN>),
854
+ * to threshold an image either with one threshold value (<DFN>CAM_ARITHM_THRESHOLD</DFN>), or two threshold values (<DFN>CAM_ARITHM_DOUBLE_THRESHOLD</DFN>)
855
+ *
856
+ * \param source The source ::CamImage to process. The source must be a grey-level image,
857
+ * except when the operation is an image inversion (<DFN>CAM_ARITHM_INVERSE</DFN>).
858
+ * \param dest The destination ::CamImage. The destination image can be either a grey-level
859
+ * image or a binary image. In the latter case, <DFN>CAM_ARITHM_ABS</DFN> is not a valid
860
+ * operation
861
+ * \param params A pointer to a ::CamArithmParams structure, defining all the parameters
862
+ * of the function to apply to the source image.
863
+ *
864
+ * Here are the details on the operations and parameters to set in the ::CamArithmParams structure :
865
+ * - <DFN>CAM_ARITHM_ABS</DFN> : Absolute value computation. <I>pdest=abs(psource)</I>.
866
+ * - <DFN>CAM_ARITHM_INVERSE</DFN> : Inverse. <I>pdest=not(psource)</I>.
867
+ * - <DFN>CAM_ARITHM_SELECT</DFN> : Selection of a part of an image. <I>if (psource=c1) then pdest=c2 else pdest=c3</I>.
868
+ * - <DFN>CAM_ARITHM_THRESHOLD</DFN> : Comparison with a scalar (also called thresholding). <I>if (psource<c1) then pdest=c2 else pdest=c3</I>.
869
+ * - <DFN>CAM_ARITHM_DOUBLE_THRESHOLD</DFN> : Double thresholding. <I>if (psource>c1 and psource<c2) then pdest=c3 else pdest=c4</I>.
870
+ *
871
+ * \return 0 (false) if an error occurs. An accumulator of all results pixel values otherwise.
872
+ *
873
+ * Note that this kernel supports in-place processing (i.e. dest can be the same as source param).
874
+ *
875
+ */
876
+ int camMonadicArithm(CamImage *source, CamImage *dest, CamArithmParams *params);
877
+
878
+ /// This is the function that implements all the dyadic arithmetic operators (i.e. operators with two operands)
879
+ /** This function can be used to compute the sum of two images (<DFN>CAM_ARITHM_ADD</DFN>),
880
+ * to substract two images (<DFN>CAM_ARITHM_SUB</DFN>), to compute the absolute difference
881
+ * between two images (<DFN>CAM_ARITHM_ABSDIFF</DFN>), to compute the weighted sum of two images (<DFN>CAM_ARITHM_WEIGHTED_SUM</DFN>),
882
+ * etc. (see below)
883
+ *
884
+ * \param source1 The first source ::CamImage to process. Any source image can be either grey-level or
885
+ * binary, depending on the operation to apply.
886
+ *
887
+ * \param source2 The second source ::CamImage to process. Any source image can be either grey-level or
888
+ * binary, depending on the operation to apply.
889
+ *
890
+ * \param dest The destination ::CamImage. The destination image can be either a grey-level
891
+ * image or a binary image, but source1, source2 and dest must be of the same kind.
892
+ *
893
+ * \param params A pointer to a ::CamArithmParams structure, defining all the parameters
894
+ * of the function to apply to the source images.
895
+ *
896
+ * Here are the details on the operations and parameters to set in the ::CamArithmParams structure :
897
+ * - <DFN>CAM_ARITHM_ADD</DFN> : Addition of images, with saturation. <I>pdest=psource1+psource2; if (pdest<0) then pdest=0; if (pdest>valmax) then pdest=valmax</I>.
898
+ * - <DFN>CAM_ARITHM_SUB</DFN> : Substraction of images, with saturation. <I>pdest=psource1-psource2; if (pdest<valmin) then pdest=valmin; if (pdest>valmax) then pdest=valmax</I>.
899
+ * - <DFN>CAM_ARITHM_MUL</DFN> : Multiplication of images, with saturation. <I>pdest=psource1*psource2; if (pdest<valmin) then pdest=valmin; if (pdest>valmax) then pdest=valmax</I>.
900
+ * - <DFN>CAM_ARITHM_ABSDIFF</DFN> : Absolute difference, with saturation. <I>pdest=abs(psource1-psource2)</I>.
901
+ * - <DFN>CAM_ARITHM_WEIGHTED_SUM</DFN> : Weighted sum. <I>pdest=(c1*psource1+c2*psource2)>>c3</I>.
902
+ * - <DFN>CAM_ARITHM_INF</DFN> : Inf. <I>pdest=inf(psource1,psource2)</I>.
903
+ * - <DFN>CAM_ARITHM_SUP</DFN> : Sup. <I>pdest=sup(psource1,psource2)</I>.
904
+ * - <DFN>CAM_ARITHM_COMP_INF</DFN> : Comparison. <I>if (psource1<psource2) pdest=c1 else pdest=c2</I>.
905
+ * - <DFN>CAM_ARITHM_COMP_EQUAL</DFN> : Equality test. <I>if (psource1=psource2) pdest=c1 else pdest=c2</I>.
906
+ * - <DFN>CAM_ARITHM_COMP_SUP</DFN> : Comparison. <I>if (psource1>psource2) pdest=c1 else pdest=c2</I>.
907
+ * - <DFN>CAM_ARITHM_AND</DFN> : <I>pdest=psource1 & psource2</I> (arithmetic boolean "and" operator)
908
+ * - <DFN>CAM_ARITHM_OR</DFN> : <I>pdest=psource1 | psource2</I> (arithmetic boolean "or" operator)
909
+ *
910
+ * \return 0 (false) if an error occurs. An accumulator of all results pixel values otherwise.
911
+ *
912
+ * Note that this kernel supports in-place processing (i.e. dest can be the same as one of the sources).
913
+ *
914
+ * Note also that this kernel supports signed images, and thus can produce signed results
915
+ * (see the member depth in ::CamImage structure).
916
+ *
917
+ */
918
+ int camDyadicArithm(CamImage *source1, CamImage *source2, CamImage *dest, CamArithmParams *params);
919
+
920
+ /// Simple threshold function (wrapper for camMonadicArithm() function)
921
+ /** Turn all pixels below (<) the threshold value to 0, and all pixels above (>=) to 255
922
+ */
923
+ int camThreshold(CamImage *source, CamImage *dest, int threshold);
924
+
925
+ /// Simple threshold function (wrapper for camMonadicArithm() function)
926
+ /** Turn all pixels below (<) the threshold value to 255, and all pixels above (>=) to 0
927
+ */
928
+ int camThresholdInv(CamImage *source, CamImage *dest, int threshold);
929
+
930
+ /// Compute absolute value of image (for signed images) (wrapper for camMonadicArithm() function)
931
+ int camAbs(CamImage *source, CamImage *dest);
932
+
933
+ /* Apply-a-LUT-on-image Kernel
934
+ */
935
+
936
+ // 12 bits maximum LUT management
937
+ #define CAM_TABLE_SIZE 4096
938
+
939
+ #define CamLUT CamTable
940
+ #define CamHisto CamTable
941
+
942
+ #ifdef __cplusplus
943
+ /// Pixel table (LUT (Look-Up Table) and histogram) structure
944
+ struct CamTable {
945
+ #else
946
+ /// LUT (Look-Up Table) structure
947
+ typedef struct {
948
+ #endif
949
+ int t[CAM_TABLE_SIZE]; ///< Table containing the resulting pixel value for each input
950
+ int size; ///< Number of valid entries
951
+ #ifdef __cplusplus
952
+ CamTable(int s=0) {size=s;}
953
+ int &operator[](int n);
954
+ bool set(const int* const array, int sz) { if (sz<CAM_TABLE_SIZE) { size=sz; for (int i=0;i<sz;i++) t[i]=array[i]; return true;} return false;}
955
+ };
956
+ #else
957
+ } CamTable;
958
+ #endif
959
+
960
+ /// Apply a Look-Up-Table on image function
961
+ int camApplyLUT(CamImage *source, CamImage *dest, CamTable *LUT);
962
+
963
+ #endif // SWIG
964
+
965
+ /* Fundamental Morphological Mathematics Algorithms' kernel
966
+ */
967
+ #define CAM_MM_NEIGHB 7
968
+
969
+ #define CAM_MM_DILATED 0
970
+ #define CAM_MM_ERODED 1
971
+ #define CAM_MM_ORIGINAL 2
972
+
973
+ #define CAM_MM_SUBSTRACTION 0
974
+ #define CAM_MM_MULTIPLEX 1
975
+ #define CAM_MM_THINNING 2
976
+ #define CAM_MM_THICKENING 3
977
+
978
+ /// This is the parameter structure for the morpho maths kernel
979
+ /** Basically, it includes the structural elements for dilation and erosion
980
+ * as well as options for the full kernel.
981
+ */
982
+ #ifdef __cplusplus
983
+ struct CamMorphoMathsKernel {
984
+ #else
985
+ typedef struct {
986
+ #endif
987
+ // Structural elements
988
+ #ifndef SWIG
989
+ int dilationStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; ///< The structural element used for all dilation operations
990
+ int erosionStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; ///< The structural element used for all erosion operations
991
+ #endif
992
+ int source1; ///< CAM_MM_DILATED | CAM_MM_ERODED | CAM_MM_ORIGINAL
993
+ int source2; ///< CAM_MM_DILATED | CAM_MM_ERODED | CAM_MM_ORIGINAL
994
+ int operation; ///< CAM_MM_SUBSTRACTION | CAM_MM_MULTIPLEX | CAM_MM_THINNING | CAM_MM_THICKENING
995
+ #ifdef __cplusplus
996
+ /// Default constructor
997
+ CamMorphoMathsKernel() {
998
+ for (int i=0;i<CAM_MM_NEIGHB;i++) {
999
+ for (int j=0;j<CAM_MM_NEIGHB;j++) {
1000
+ dilationStructElt[i][j]=0;
1001
+ erosionStructElt[i][j]=0;
1002
+ }
1003
+ }
1004
+ source1=CAM_MM_ORIGINAL;
1005
+ source2=CAM_MM_ORIGINAL;
1006
+ operation=CAM_MM_MULTIPLEX;
1007
+ }
1008
+ /// Set an element of the dilation kernel
1009
+ bool set_dilate(int x, int y, int val) {
1010
+ if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
1011
+ dilationStructElt[x][y]=val; return true;
1012
+ } else return false;
1013
+ }
1014
+ /// Get an element from the dilation kernel
1015
+ int get_dilate(int x,int y) {
1016
+ if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
1017
+ return dilationStructElt[x][y];
1018
+ } else return 0;
1019
+ }
1020
+ /// Set an element of the erosion kernel
1021
+ bool set_erode(int x, int y, int val) {
1022
+ if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
1023
+ erosionStructElt[x][y]=val; return true;
1024
+ } else return false;
1025
+ }
1026
+ /// Get an element from the erosion kernel
1027
+ int get_erode(int x,int y) {
1028
+ if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
1029
+ return erosionStructElt[x][y];
1030
+ } else return 0;
1031
+ }
1032
+ };
1033
+ #else
1034
+ } CamMorphoMathsKernel;
1035
+ #endif
1036
+
1037
+ #ifndef SWIG
1038
+
1039
+ /** @name Morphomaths LLAs
1040
+ * These functions share the same morpho maths kernel
1041
+ */
1042
+ //@{
1043
+
1044
+ /// This is the function that can compute erosion AND dilation in one scan (with 5x5 neighborhood).
1045
+ /** It can be used to compute thinning, thickening, or morphological gradient in one scan.
1046
+ * If only erosion or dilation is needed, it's more simple (and a bit faster) to use the
1047
+ * dedicated functions.
1048
+ *
1049
+ * \param source The source ::CamImage to process
1050
+ * \param dest The destination ::CamImage
1051
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1052
+ * elements, as well as the behaviour of the kernel.
1053
+ * \return Sum (Accumulator) of all computed pixels
1054
+ *
1055
+ * Note that this kernel supports in-place processing (i.e. dest can be the same as source param)
1056
+ */
1057
+ int camMorphoMaths(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel);
1058
+
1059
+ // These are specific functions able to compute only erosion or dilation, on 3x3, 5x5 or 7x7 neighbourhood
1060
+
1061
+ /** \param source The source ::CamImage to process
1062
+ * \param dest The destination ::CamImage
1063
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1064
+ * element to use. Only the ErosionStructElt member is used by this function.
1065
+ * \return Sum (Accumulator) of all computed pixels
1066
+ *
1067
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1068
+ */
1069
+ int camErode3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 3x3 neighborhood erosion
1070
+
1071
+ /** \param source The source ::CamImage to process
1072
+ * \param dest The destination ::CamImage
1073
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1074
+ * element to use. Only the ErosionStructElt member is used by this function.
1075
+ * \return Sum (Accumulator) of all computed pixels
1076
+ *
1077
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1078
+ */
1079
+ int camErode5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 5x5 neighborhood erosion
1080
+
1081
+ /** \param source The source ::CamImage to process
1082
+ * \param dest The destination ::CamImage
1083
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1084
+ * element to use. Only the ErosionStructElt member is used by this function.
1085
+ * \return Sum (Accumulator) of all computed pixels
1086
+ *
1087
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1088
+ */
1089
+ int camErode7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 7x7 neighborhood erosion
1090
+
1091
+ /** \param source The source ::CamImage to process
1092
+ * \param dest The destination ::CamImage
1093
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1094
+ * element to use. Only the DilationStructElt member is used by this function.
1095
+ * \return Sum (Accumulator) of all computed pixels
1096
+ *
1097
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1098
+ */
1099
+ int camDilate3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 3x3 neighborhood dilation
1100
+
1101
+ /** \param source The source ::CamImage to process
1102
+ * \param dest The destination ::CamImage
1103
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1104
+ * element to use. Only the DilationStructElt member is used by this function.
1105
+ * \return Sum (Accumulator) of all computed pixels
1106
+ *
1107
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1108
+ */
1109
+ int camDilate5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 5x5 neighborhood dilation
1110
+
1111
+ /** \param source The source ::CamImage to process
1112
+ * \param dest The destination ::CamImage
1113
+ * \param kernel A pointer to a ::CamMorphoMathsKernel structure, defining the structural
1114
+ * element to use. Only the DilationStructElt member is used by this function.
1115
+ * \return Sum (Accumulator) of all computed pixels
1116
+ *
1117
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1118
+ */
1119
+ int camDilate7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); ///< 7x7 neighborhood dilation
1120
+
1121
+ /** Computes the morphological gradient of an image.
1122
+ *
1123
+ * Uses a circular structural element of diameter 5.
1124
+ * It is twice faster than the original morpho maths kernel.
1125
+ *
1126
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1127
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1128
+ * \return Sum (Accumulator) of all computed pixels
1129
+ *
1130
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1131
+ */
1132
+ int camMorphoGradientCircle5(CamImage *source, CamImage *dest); ///< Morphological gradient computation (Diameter-5 circle structural element)
1133
+
1134
+ /** Computes the eroded image of a source image, using a circular structural
1135
+ * element of diameter 5. Highly optimized code.
1136
+ *
1137
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1138
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1139
+ * \return Sum (Accumulator) of all computed pixels
1140
+ *
1141
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1142
+ */
1143
+ int camErodeCircle5(CamImage *source, CamImage *dest); ///< Erosion (Optimized for diameter-5 circle structural element)
1144
+
1145
+ /** Computes the dilated image of a source image, using a circular structural
1146
+ * element of diameter 5. Highly optimized code.
1147
+ *
1148
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1149
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1150
+ * \return Sum (Accumulator) of all computed pixels
1151
+ *
1152
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1153
+ */
1154
+ int camDilateCircle5(CamImage *source, CamImage *dest); ///< Dilation (Optimized for diameter-5 circle structural element)
1155
+
1156
+ /** Computes the morphological gradient of an image.
1157
+ *
1158
+ * Uses a circular structural element of diameter 7.
1159
+ * It is twice faster than the original morpho maths kernel.
1160
+ *
1161
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1162
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1163
+ * \return Sum (Accumulator) of all computed pixels
1164
+ *
1165
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1166
+ */
1167
+ int camMorphoGradientCircle7(CamImage *source, CamImage *dest); ///< Morphological gradient computation (Diameter-7 circle structural element)
1168
+
1169
+ /** Computes the eroded image of a source image, using a circular structural
1170
+ * element of diameter 7. Highly optimized code.
1171
+ *
1172
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1173
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1174
+ * \return Sum (Accumulator) of all computed pixels
1175
+ *
1176
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1177
+ */
1178
+ int camErodeCircle7(CamImage *source, CamImage *dest); ///< Erosion (Optimized for diameter-7 circle structural element)
1179
+
1180
+ /** Computes the dilated image of a source image, using a circular structural
1181
+ * element of diameter 7. Highly optimized code.
1182
+ *
1183
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1184
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1185
+ * \return Sum (Accumulator) of all computed pixels
1186
+ *
1187
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1188
+ */
1189
+ int camDilateCircle7(CamImage *source, CamImage *dest); ///< Dilation (Optimized for diameter-7 circle structural element)
1190
+
1191
+ /** Computes the morphological gradient of an image.
1192
+ *
1193
+ * Uses a 3x3 square structural element (very classical).
1194
+ * Highly optimized code.
1195
+ *
1196
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1197
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1198
+ * \return Sum (Accumulator) of all computed pixels
1199
+ *
1200
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1201
+ */
1202
+ int camMorphoGradientSquare3(CamImage *source, CamImage *dest); ///< Morphological gradient computation (3x3 square structural element)
1203
+
1204
+ /** Computes the eroded image of a source image, using a classical 3x3 square structural
1205
+ * element. Highly optimized code.
1206
+ *
1207
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1208
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1209
+ * \return Sum (Accumulator) of all computed pixels
1210
+ *
1211
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1212
+ */
1213
+ int camErodeSquare3(CamImage *source, CamImage *dest); ///< Erosion (3x3 square structural element)
1214
+
1215
+ /** Computes the dilated image of a source image, using a classical 3x3 square structural
1216
+ * element. Highly optimized code.
1217
+ *
1218
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1219
+ * \param dest The destination ::CamImage. Must be a grey-level image.
1220
+ * \return Sum (Accumulator) of all computed pixels
1221
+ *
1222
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1223
+ */
1224
+ int camDilateSquare3(CamImage *source, CamImage *dest); ///< Dilation (3x3 square structural element)
1225
+ //@}
1226
+
1227
+ /* Labeling kernel
1228
+ */
1229
+ #define CamLabellingResults CamLabelingResults
1230
+ #define camLabelling camLabeling
1231
+ #define camLabelling2ndScan camLabeling2ndScan
1232
+ #define camRLELabelling camRLELabeling
1233
+
1234
+ #define CAM_LABEL_MAX_BLOBS 1024
1235
+ #define CAM_LABEL_PIXEL unsigned short
1236
+
1237
+ #define CAM_LABEL_PIXEL_ACCESS(ptr,y,x) \
1238
+ ((CAM_LABEL_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
1239
+
1240
+ /// Data structure containing the result of pixel-based labeling.
1241
+ typedef struct {
1242
+ int nbLabels; ///< Number of labels found in the frame
1243
+ int equiv[CAM_LABEL_MAX_BLOBS]; ///< Labels equivalence table (see D3.1 for details)
1244
+ } CamLabelingResults;
1245
+
1246
+ /// 4-connectedness labeling function
1247
+ /** Computes the labeled image of a source image,
1248
+ * i.e. finds the connected pixels (using 4-connectedness)
1249
+ *
1250
+ * \param source The source ::CamImage to process. Must be a grey-level image.
1251
+ * \param dest The destination ::CamImage..Must be 16-bits deep (its the label result image)
1252
+ * \param results The ::CamLabelingResults containing the label equivalence table, to provide to a blob analysis function.
1253
+ * \return 0 (false) if an error occurs
1254
+ *
1255
+ * Note that this function is rather obsolete. This pixel-based labeling algorithm is
1256
+ * outdated compared to RLE-based labeling.
1257
+ *
1258
+ * \sa camRLELabeling
1259
+ */
1260
+ int camLabeling(CamImage *source, CamImage *dest, CamLabelingResults *results);
1261
+
1262
+ /** This algorithm is useless. Presented here for better understanding purpose only.
1263
+ * Indeed, Blob analysis first scan (camBlobAnalysis1stScan()) integrates this second scan.
1264
+ * In-place processing only.
1265
+ */
1266
+ int camLabeling2ndScan(CamImage *image, CamLabelingResults *results); ///< Second scan for pixel-based labeling. Obsolete.
1267
+
1268
+ /* Blob analysis Kernel
1269
+ * C code */
1270
+
1271
+ #endif // SWIG
1272
+
1273
+ #define CAM_RLE_INT_TYPE unsigned short
1274
+
1275
+ /// The CamRun structure, basic element of a Run-Length Encoding (RLE) of an image.
1276
+ /** sizeof(_camRLE) is 8 (64 bits)
1277
+ */
1278
+ typedef struct {
1279
+ CAM_RLE_INT_TYPE value; ///< Which color(s) this run represents
1280
+ CAM_RLE_INT_TYPE length; ///< The length of the run (in pixels)
1281
+ CAM_RLE_INT_TYPE blob; ///< Run's parent in the connected components tree, which becomes the blob number after labeling
1282
+ CAM_RLE_INT_TYPE line; ///< The line to which the run belongs
1283
+ } CamRun;
1284
+
1285
+ #ifndef SWIG
1286
+
1287
+ /// The Blob (block of bits) Information Structure. This is the most important result of Labeling + Blob analysis.
1288
+ typedef struct {
1289
+ int id;
1290
+ int left; ///< Leftmost coordinate of the blob
1291
+ int top; ///< Topmost coordinate of the blob
1292
+ int width; ///< Width of the blob
1293
+ int height; ///< Height of the blob
1294
+ int surface; ///< Number of pixels covered by this blob
1295
+ int cx; ///< Center of gravity (x)
1296
+ int cy; ///< Center of gravity (y)
1297
+ int value; ///< Blob value, or average pixel value in the original image
1298
+ int min; ///< Minimum pixel value in the original image
1299
+ int max; ///< Maximum pixel value in the original image
1300
+ CamRun *first; ///< First run of the blob (only for RLE labeling)
1301
+ CamRun *last; ///< Last run of the blob (only for RLE labeling)
1302
+ void *misc; ///< Additional user-dependant blob information
1303
+ } CamBlobInfo;
1304
+
1305
+ #define CamBlobAnalysisResults CamBlobs // For compatibility with previous versions
1306
+
1307
+ #ifdef __cplusplus
1308
+ /// The result of any blob analysis. Essentially an array of ::CamBlobInfo
1309
+ struct CamBlobs {
1310
+ int nbBlobs; ///< Number of valid blobs
1311
+ CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS]; ///< Array of information on the blobs
1312
+ CamBlobs() {nbBlobs=0;} ///< Default constructor
1313
+ CamBlobInfo& operator[](int index);
1314
+ };
1315
+ #else
1316
+ /// The result of any blob analysis. Essentially an array of ::CamBlobInfo
1317
+ typedef struct {
1318
+ int nbBlobs; ///< Number of valid blobs
1319
+ CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS]; ///< Array of information on the blobs
1320
+ } CamBlobs;
1321
+ #endif
1322
+
1323
+ /** Computes the most important blob information :
1324
+ * <DFN>top</DFN>, <DFN>left</DFN>, <DFN>width</DFN>, <DFN>height</DFN>, <DFN>cx</DFN>, <DFN>cy</DFN>,
1325
+ * and <DFN>surface</DFN>. <DFN>average</DFN>, <DFN>min</DFN> and <DFN>max</DFN>
1326
+ * are computed only if a pointer on the original image is provided (slower).
1327
+ *
1328
+ * \param blobImage The result of a previous labeling operation.
1329
+ * \param original The original ::CamImage that was labelled previously. Can bet set to NULL.
1330
+ * \param info The ::CamLabelingResults structure provided by the former call to camLabeling().(in data)
1331
+ * \param results The ::CamBlobs structure that is filled with the collected blob information.
1332
+ *
1333
+ * \return 0 (false) if an error occurs, especially if the number of blobs is too high.(more than the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant)
1334
+ *
1335
+ * In-place processing (<DFN>blobImage</DFN> will be affected).
1336
+ */
1337
+ int camBlobAnalysis1stScan(CamImage *blobImage, CamImage *original, CamLabelingResults *info, CamBlobs *results); ///< Blob analysis function.
1338
+
1339
+ /// Second pass, to get some more information if needed.
1340
+ /** Computes the <DFN>average</DFN>, <DFN>min</DFN> and <DFN>max</DFN> blob information, if it was
1341
+ * not computed before.
1342
+ *
1343
+ * \param blobImage The result of a previous labeling operation.
1344
+ * \param original The original ::CamImage.that was labelled previously.
1345
+ * \param results The ::CamBlobs structure that is filled with the collected blob information.
1346
+ *
1347
+ * \return 0 (false) if an error occurs.
1348
+ */
1349
+ int camBlobAnalysisRefinement(CamImage *blobImage, CamImage *original, CamBlobs *results);
1350
+
1351
+ /* RLE Labeling kernel
1352
+ * New : v1.4 of LLAs
1353
+ * Updated v1.6 and v1.9, v2.0 of LLAs
1354
+ */
1355
+
1356
+ /** @name RLE images processing functions and data structures
1357
+ */
1358
+ //@{
1359
+
1360
+ #ifdef __cplusplus
1361
+ /// The CamRLEImage structure : the RLE (Run Length Encoded) image structure.
1362
+ struct CamRLEImage {
1363
+ #else
1364
+ /// The CamRLEImage structure : the RLE (Run Length Encoded) image structure.
1365
+ typedef struct {
1366
+ #endif
1367
+ int nSize; ///< Size of CamImage struct
1368
+ int id; ///< Frame id (user dependent)
1369
+ int height; ///< Image height
1370
+ int width; ///< Image width
1371
+ int nbRuns; ///< The number of runs
1372
+ int allocated; ///< Number of runs allocated
1373
+ CamRun *runs; ///< A pointer to the array of runs
1374
+
1375
+ #ifdef __cplusplus
1376
+ CamRLEImage() {allocated=0; runs=NULL; nbRuns=0;} ///< Default constructor
1377
+ CamRLEImage(int nbruns); ///< Constructor with max number of runs parameter
1378
+ CamRLEImage(const CamRLEImage &image); ///< Copy constructor
1379
+ ~CamRLEImage(); ///< Default destructor
1380
+
1381
+ CamRLEImage& operator=(const CamRLEImage &image); ///< Operator= redefinition
1382
+ CamRLEImage* clone() const; ///< Clone RLE image (using camRLEClone() function)
1383
+ bool alloc(int nbruns); ///< Allocator (C++ wrapping of camRLEAllocate() function)
1384
+ bool realloc(int nbruns); ///< Reallocator (C++ wrapping of camRLEReallocate() function)
1385
+
1386
+ bool encode(const CamImage &image); ///< C++ wrapping for camRLEEncode() function
1387
+ bool encode_lut(const CamImage &image, const CamTable &LUT); ///< C++ wrapping for camRLEEncodeLUT() function
1388
+ bool encode_threshold(const CamImage &image, int threshold); ///< C++ wrapping for camRLEEncodeThreshold() function
1389
+ bool encode_threshold_inv(const CamImage &image, int threshold);///< C++ wrapping for camRLEEncodeThresholdInv() function
1390
+ bool encode_color(const CamImage &image, const CamTable &clusters); ///< C++ wrapping for camRLEEncodeColor() function
1391
+ CamBlobs* labeling(); ///< C++ wrapping for camRLELabeling() function
1392
+ bool labeling(CamBlobs &results); ///< C++ wrapping for camRLELabeling() function
1393
+ bool blob_analysis(CamBlobs &results) const; ///< C++ wrapping for camRLEBlobAnalysis() function
1394
+ bool apply_lut(const CamTable &LUT); ///< C++ wrapping for camRLEApplyLUT() function
1395
+ bool apply_lut(CamRLEImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEApplyLUT() function
1396
+ bool decode(CamImage &dest) const; ///< C++ wrapping for camRLEDecode() function
1397
+ bool decode(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEDecode() function
1398
+ bool decode_blobs(CamImage &dest) const; ///< C++ wrapping for camRLEDecodeBlobs() function
1399
+ bool decode_blobs(CamImage &dest, const CamTable &LUT) const; ///< C++ wrapping for camRLEDecodeBlos() function
1400
+ bool inverse(); ///< C++ wrapping for camRLEInverse() function
1401
+ bool erode_cross(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErodeCross() function
1402
+ CamRLEImage *erode_cross() const; ///< C++ wrapping for camRLEErodeCross() function
1403
+ bool erode_3x3(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErode3x3() function
1404
+ CamRLEImage *erode_3x3() const; ///< C++ wrapping for camRLEErode3x3() function
1405
+ bool erode_3x2(CamRLEImage &dest) const; ///< C++ wrapping for camRLEErode3x2() function
1406
+ CamRLEImage *erode_3x2() const; ///< C++ wrapping for camRLEErode3x2() function
1407
+ };
1408
+ #else
1409
+ } CamRLEImage;
1410
+ #endif
1411
+
1412
+ /// RLE Image allocation.
1413
+ /** Allocates a RLE image.
1414
+ *
1415
+ * \param rle The ::CamRLEImage to allocate. The number of runs should be chosen
1416
+ * so that it is enough to encode the image to process. A typical value
1417
+ * used for this parameter is <DFN>source.width*source.height/16</DFN>, assuming
1418
+ * a typical run will of length 16. Note that this is very realistic when
1419
+ * the original image was thresholded and filtered.
1420
+ * \param max_runs The number of runs to allocate.
1421
+ * \return 0 (false) if an error occurs.
1422
+ *
1423
+ * Note that this function uses the standard C <DFN>malloc()</DFN> function.
1424
+ *
1425
+ * Note also that the amount of memory allocated is <DFN>8*max_runs</DFN> bytes. Thus, using
1426
+ * the typical <DFN>max_runs</DFN> value exposed above, a grey-level image will be compressed
1427
+ * by a factor of 2, and a binary image expanded by a factor of 4 using RLE encoding.
1428
+ *
1429
+ * The RLE image should be deallocated using the camRLEDeallocate() function,
1430
+ * or by calling the standard C function <DFN>free()</DFN> on the
1431
+ * <DFN>runs</DFN> member of the ::CamRLEImage structure.
1432
+ *
1433
+ */
1434
+ int camRLEAllocate(CamRLEImage *rle, int max_runs);
1435
+
1436
+ /// RLE image deallocation.
1437
+ /** Deallocates a RLE image. Should be matched with a call to camRLEAllocate()
1438
+ *
1439
+ * \param rle The ::CamRLEImage to deallocate.
1440
+ * \return 0 (false) if an error occurs.
1441
+ *
1442
+ * Note that this function uses the standard C <DFN>free()</DFN> function.
1443
+ *
1444
+ */
1445
+ int camRLEDeallocate(CamRLEImage *rle);
1446
+
1447
+ /// RLE image reallocation
1448
+ /** Reallocates a RLE image.
1449
+ *
1450
+ * \param rle The ::CamRLEImage to reallocate.
1451
+ * \param new_max_runs The new number of allocated runs
1452
+ * \return 0 (false) if an error occurs.
1453
+ *
1454
+ * Note that this function uses the standard C <DFN>realloc()</DFN> function.
1455
+ *
1456
+ */
1457
+ int camRLEReallocate(CamRLEImage *rle, int new_max_runs);
1458
+
1459
+ /// RLE image cloning
1460
+ /** Clone a RLE image.
1461
+ *
1462
+ * \param source The ::CamRLEImage to clone.
1463
+ * \param dest The ::CamRLEImage to allocate (shouldn't be allocated)
1464
+ * \return 0 (false) if an error occurs.
1465
+ *
1466
+ * Note that this function uses the standard C <DFN>malloc()</DFN> function.
1467
+ */
1468
+ int camRLEClone(CamRLEImage *source, CamRLEImage *dest);
1469
+
1470
+ /// Run-Length encoding
1471
+ /**
1472
+ * \param src The source ::CamImage to encode. This should be either a thresholded
1473
+ * image or a binary image. Note that this source image should be filtered
1474
+ * (using camErode3x3() for instance) before encoding,
1475
+ * in order to avoid a too high number of runs.
1476
+ * \param dest The ::CamRLEImage resulting of the encoding.
1477
+ * \return 0 (false) if an error occurs.
1478
+ *
1479
+ * Note that binary images encoding was optimized.
1480
+ */
1481
+ int camRLEEncode(CamImage *src, CamRLEImage *dest);
1482
+
1483
+ /// Run-Length encoding, with integrated LUT operations.
1484
+ /** Introduced v1.9.
1485
+ *
1486
+ * \param src The source ::CamImage to encode. This must be a grey-level image.
1487
+ * Note that this source image should be filtered
1488
+ * (using camErode3x3() for instance) before encoding,
1489
+ * in order to avoid a too high number of runs.
1490
+ * \param dest The ::CamRLEImage resulting of the encoding.
1491
+ * \param LUT An array of integer used to classify the source image pixels.
1492
+ * \return 0 (false) if an error occurs.
1493
+ */
1494
+ int camRLEEncodeLUT(CamImage *src, CamRLEImage *dest, CamTable *LUT);
1495
+
1496
+ /// Run-Length encoding, with integrated thresholding.
1497
+ /** \param src The source ::CamImage to encode. This must be a grey-level image.
1498
+ * Note that this source image should be filtered
1499
+ * (using camErodeSquare3() for instance) before encoding,
1500
+ * in order to avoid a too high number of runs.
1501
+ * \param dest The ::CamRLEImage resulting of the encoding.
1502
+ * \param threshold The threshold used. All pixels with value higher (>=) than threshold will be labelled..
1503
+ * \return 0 (false) if an error occurs.
1504
+ */
1505
+ int camRLEEncodeThreshold(CamImage *src, CamRLEImage *dest, int threshold);
1506
+
1507
+ /// Run-Length encoding, with integrated thresholding.
1508
+ /** \param src The source ::CamImage to encode. This must be a grey-level image.
1509
+ * Note that this source image should be filtered
1510
+ * (using camErodeSquare3() for instance) before encoding,
1511
+ * in order to avoid a too high number of runs.
1512
+ * \param dest The ::CamRLEImage resulting of the encoding.
1513
+ * \param threshold The threshold used. All pixels with value lower (>=) than threshold will be labelled..
1514
+ * \return 0 (false) if an error occurs.
1515
+ */
1516
+ int camRLEEncodeThresholdInv(CamImage *src, CamRLEImage *dest, int threshold);
1517
+
1518
+ int camRLEEncodeColor(CamImage *source, CamRLEImage *dest, CamTable *clusters);
1519
+
1520
+ /// RLE image labeling + blob analysis. 4-connectedness labeling.
1521
+ /** Very fast labeling algorithm originally introduced by the Carneggie Mellon University (see below).
1522
+ * This function also performs a basic blob analysis
1523
+ *
1524
+ * \param src The source ::CamRLEImage to label. Note that the content of <DFN>src</DFN> is altered,
1525
+ * for RLE labeling is performed in-place. This is what makes it especially fast,
1526
+ * since it doesn't require neither an additional label image nor an equivalence
1527
+ * table, everything being stored in the ::CamRLEImage structure.
1528
+ * \param results The ::CamBlobs containing the results of the blob analysis.
1529
+ * \return 0 (false) if an error occurs. Generally when the number
1530
+ * of blobs exceeds the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant.
1531
+ *
1532
+ * This code is based on the ideas developped in the CMVision library by CMU.
1533
+ *
1534
+ * \verbatim
1535
+
1536
+ -------------------------------------------------------------------------
1537
+ Copyright 1999, 2000 #### ### ### ## ## ## #### ## ### ## ##
1538
+ James R. Bruce ## ####### ## ## ## ## ## ## ## ######
1539
+ School of Computer Science ## ## # ## ## ## ## ### ## ## ## ## ###
1540
+ Carnegie Mellon University #### ## ## ### ## #### ## ### ## ##
1541
+ -------------------------------------------------------------------------
1542
+
1543
+ * \endverbatim
1544
+ */
1545
+ int camRLELabeling(CamRLEImage *src, CamBlobs *results);
1546
+
1547
+ /// The RLE Blob Analysis function
1548
+ /** Automatically called by camRLELabeling().
1549
+ *
1550
+ * \param src The source ::CamRLEImage, already labelled.
1551
+ * \param results The ::CamBlobs containing the results of the blob analysis.
1552
+ * \return 0 (false) if an error occurs. Generally when the number
1553
+ * of blobs exceeds the <DFN>CAM_LABEL_MAX_BLOBS</DFN> constant.
1554
+ */
1555
+ int camRLEBlobAnalysis(CamRLEImage *src, CamBlobs *results);
1556
+
1557
+ /// The RLE "Apply a LUT" function
1558
+ /** Very useful to post-process a RLE image. This function join runs when needed.
1559
+ *
1560
+ * Applying a LUT (i.e. for instance thresholding) can be useful
1561
+ * for many purposes (like "several thresholds at once" processing). For experts only.
1562
+ *
1563
+ * \param src The source ::CamRLEImage.
1564
+ * \param dest The destination ::CamRLEImage.
1565
+ * \param LUT Look-up-table applied to the <DFN>value</DFN> member of each run.
1566
+ * \return 0 (false) if an error occurs.
1567
+ */
1568
+ int camRLEApplyLUT(CamRLEImage *src, CamRLEImage *dest, CamTable *LUT);
1569
+
1570
+ /// The RLE decoding function
1571
+ /** Reconstructs an ::CamImage from runs.
1572
+ *
1573
+ * \param src The source ::CamRLEImage.
1574
+ * \param dest The destination ::CamImage. Must be grey-level image
1575
+ * (binary image RLE decoding not yet implemented).
1576
+ * \param LUT Look-up-table applied to the <DFN>value</DFN> member of each run, to produce
1577
+ * the pixel value in the <DFN>dest</DFN> image.
1578
+ * \return 0 (false) if an error occurs.
1579
+ *
1580
+ * \todo Implement binary image RLE decoding
1581
+ */
1582
+ int camRLEDecode(CamRLEImage *src, CamImage *dest, CamTable *LUT);
1583
+
1584
+ /// Another RLE decoding function, used to retrieve some specific blobs.
1585
+ /** Reconstructs an ::CamImage from a labelled RLE image. Very useful to see the result of labeling.
1586
+ *
1587
+ * \param src The source ::CamRLEImage.
1588
+ * \param dest The destination ::CamImage. Must be grey-level image
1589
+ * (binary image RLE decoding not yet implemented).
1590
+ * \param LUT Look-up-table applied to the <DFN>blob</DFN> member of each run, to produce
1591
+ * the pixel value in the <DFN>dest</DFN> image.
1592
+ * \return 0 (false) if an error occurs.
1593
+ *
1594
+ * \todo Implement binary image RLE decoding
1595
+ */
1596
+ int camRLEDecodeBlobs(CamRLEImage *src, CamImage *dest, CamTable *LUT);
1597
+
1598
+ /// RLE image inversion
1599
+ /** Very useful function, for finding holes in blobs.
1600
+ * \param image The source and destination ::CamRLEImage. In-place processing only.
1601
+ * \return 0 (false) if an error occurs.
1602
+ */
1603
+ int camRLEInverse(CamRLEImage *image);
1604
+
1605
+ /// RLE blob sides reconstruction
1606
+ int camRLEBlobSides(CamBlobInfo *blob, int *left, int *top, int *right, int *bottom);
1607
+
1608
+ /// RLE blob intersection with a ROI
1609
+ int camRLEBlobROIIntersect(CamBlobInfo *blob, CamROI *roi);
1610
+
1611
+ /// Retrieves the average, min and max values
1612
+ int camRLEBlobMeasures(CamBlobInfo *blob, CamImage *original);
1613
+
1614
+ /// RLE image erosion (cross structural element)
1615
+ /**
1616
+ * \param image The source ::CamRLEImage.
1617
+ * \param result The destination ::CamRLEImage
1618
+ * \return 0 (false) if an error occurs.
1619
+ */
1620
+ int camRLEErodeCross(CamRLEImage *image, CamRLEImage *result);
1621
+
1622
+ /// RLE image erosion (3x3 square structural element)
1623
+ /**
1624
+ * \param image The source ::CamRLEImage.
1625
+ * \param result The destination ::CamRLEImage
1626
+ * \return 0 (false) if an error occurs.
1627
+ */
1628
+ int camRLEErode3x3(CamRLEImage *image, CamRLEImage *result);
1629
+
1630
+ /// RLE image erosion (3x2 square structural element)
1631
+ /**
1632
+ * \param image The source ::CamRLEImage.
1633
+ * \param result The destination ::CamRLEImage
1634
+ * \return 0 (false) if an error occurs.
1635
+ */
1636
+ int camRLEErode3x2(CamRLEImage *image, CamRLEImage *result);
1637
+
1638
+ //@}
1639
+
1640
+ /** @name Histogram computation
1641
+ */
1642
+ //@{
1643
+
1644
+ /// The classical image histogramming
1645
+ /** Counts the number of occurence of each pixel value, on one channel only
1646
+ * (grey-level image), for images up to 12-bits deep. It supports signed images
1647
+ * by centering the histogram around the 0 value.
1648
+ *
1649
+ * \param image The ::CamImage to analyze. One channel only.
1650
+ * \param histo A pointer to a CamTable (array of integers) that will contain the results of histogramming.
1651
+ * \return 0 (false) if an error occurs. Accumulated values of scanned pixels otherwise.
1652
+ *
1653
+ * camHistogram supports masking and ROIs.
1654
+ */
1655
+ int camHistogram(CamImage *image, CamTable *histo);
1656
+
1657
+ /// Two channels histogram computation
1658
+ /** The result of this operation is 2D, and thus is stored in an image.
1659
+ *
1660
+ * \param image The ::CamImage for which to compute the histogram
1661
+ * \param ch1 The first channel number
1662
+ * \param ch2 The second channel number
1663
+ * \param result The ::CamImage containing the results of histogramming.
1664
+ * \param size Subsampling factor. size=1 results in a 256x256 picture, size=2 results in a 128x128 picture, etc.
1665
+ * \return 0 (false) if an error occurs.
1666
+ */
1667
+ int camHistogram2Channels(CamImage *image, int ch1, int ch2, CamImage *result, int size);
1668
+
1669
+ /// Compute the threshold for a given percentage of pixels
1670
+ int camFindThreshold(CamTable *histo, int percent);
1671
+ //@}
1672
+
1673
+ /* Horizontal and vertical summing
1674
+ */
1675
+
1676
+ /// Horizontal and vertical summing function
1677
+ /** Very useful to detect features in images, generally after applying
1678
+ * a filter like sobel or morphological gradient.
1679
+ *
1680
+ * \param image The ::CamImage to process (or its ROI)
1681
+ * \param hsum The ::CamTable array of integers containing the horizontal sum.
1682
+ * \param vsum The ::CamTable array of integers containing the vertical sum.
1683
+ * \return 0 (false) if an error occurs.
1684
+ */
1685
+ int camSumHV(CamImage *image, CamTable *hsum, CamTable *vsum);
1686
+
1687
+ /// Vertical summing function
1688
+ /** Very useful to detect features in images, generally after applying
1689
+ * a filter like sobel or morphological gradient.
1690
+ *
1691
+ * \param image The ::CamImage to process (or its ROI)
1692
+ * \param results The ::CamTable array of integers filled with results.
1693
+ * \return 0 (false) if an error occurs.
1694
+ */
1695
+ int camSumV(CamImage *image, CamTable *results);
1696
+
1697
+ /// Horizontal summing function
1698
+ /** Very useful to detect features in images, generally after applying
1699
+ * a filter like sobel or morphological gradient.
1700
+ *
1701
+ * \param image The ::CamImage to process (or its ROI)
1702
+ * \param results The ::CamTable array of integers filled with results.
1703
+ * \return 0 (false) if an error occurs.
1704
+ */
1705
+ int camSumH(CamImage *image, CamTable *results);
1706
+
1707
+ #endif // SWIG
1708
+
1709
+ /* Measures in an image : min, max, average computation
1710
+ */
1711
+ #ifdef __cplusplus
1712
+ /// The structure containing the result of measuring
1713
+ struct CamMeasuresResults {
1714
+ #else
1715
+ /// The structure containing the result of measuring
1716
+ typedef struct {
1717
+ #endif
1718
+ int min, xmin, ymin; ///< Minimum pixel value
1719
+ int max, xmax, ymax; ///< Maximum pixel value
1720
+ int average; ///< Average pixel value
1721
+ int sum; ///< Sum of all the pixels
1722
+ #ifdef __cplusplus
1723
+ CamMeasuresResults() {min=0;xmin=0;ymin=0;max=0;xmax=0;ymax=0;average=0;sum=0;}
1724
+ };
1725
+ #else
1726
+ } CamMeasuresResults;
1727
+ #endif
1728
+
1729
+ #ifndef SWIG
1730
+
1731
+ /// Measures in an image : min, max, average and sum
1732
+ /** Average deviation is not measured. See camMeasuresAverageDeviation().
1733
+ *
1734
+ * \param image The ::CamImage to process (or its ROI)
1735
+ * \param results The ::CamMeasuresResults structure to be filled.
1736
+ * \return 0 (false) if an error occurs.
1737
+ */
1738
+ int camMeasures(CamImage *image, CamMeasuresResults *results);
1739
+
1740
+ /// Average deviation computation
1741
+ /** This makes the second scan required for average deviation estimation.
1742
+ * Uses the average field in ::CamMeasuresResults structure, so camMeasures()
1743
+ * must have been called prior to this function (to do the 1st scan).
1744
+ *
1745
+ * \param image The ::CamImage to process (or its ROI)
1746
+ * \param average A former measure of average. If 0 or a negative number is provided, the average will be computed
1747
+ * \return 0 (false) if an error occurs.
1748
+ */
1749
+ float camMeasureAverageDeviation(CamImage *image, int average);
1750
+
1751
+ /** @name Warping functions
1752
+ */
1753
+ //@{
1754
+
1755
+ /// Warping using Volberg's algorithm
1756
+ /** This is a forward separable mapping algorithm, i.e. the user
1757
+ * must provide two functions that compute the destination points
1758
+ * of any source point.
1759
+ *
1760
+ * This function is the core function, making a single scanline mapping.
1761
+ * It must be called twice to have a full mapping. Use camVolbergFwd()
1762
+ * to do this.
1763
+ */
1764
+ #ifdef CAM_VOLBERG_ORIGINAL
1765
+ void volbergfvd(double f[], int in[] , int out[] , int inlen, int outlen);
1766
+ #else
1767
+ void camVolbergFwdScanline(CAM_PIXEL *in, int inlen, CAM_PIXEL *out, int outlen, double f[]);
1768
+ #endif
1769
+
1770
+ /// The structure to provide to the Volberg's algorithm : two functions
1771
+ typedef struct {
1772
+ void (*hfwd)(int x, int y, double *xp); ///< First scan, horizontal resampling
1773
+ void (*vfwd)(int x, int y, double *yp); ///< Second scan, vertical resampling
1774
+ } CamVolbergFwdParams;
1775
+
1776
+ /// Helper function for using Volberg's warping algorithm
1777
+ /**
1778
+ * \param source The ::CamImage to warp
1779
+ * \param dest The warped image
1780
+ * \param params The ::camVolbergFwdParams structure providing the mapping functions
1781
+ */
1782
+ void camVolbergFwd(CamImage *source, CamImage *dest, CamVolbergFwdParams *params);
1783
+
1784
+ /* Backward warping
1785
+ */
1786
+
1787
+ #define CAM_NN_INTERPOLATION 0
1788
+ #define CAM_BILINEAR_INTERPOLATION 1
1789
+
1790
+ /// The parameters structure used by camWarping()
1791
+ typedef struct {
1792
+ int interpolation; ///< Interpolation method (either <DFN>CAM_NN_INTERPOLATION</DFN> or <DFN>CAM_BILINEAR_INTERPOLATION</DFN>.
1793
+ int perspective; ///< 2D (0) or 3D (parallel to the ground)
1794
+
1795
+ /// The points in the source image.
1796
+ /** Beware : These are 16-bits fixed-points (1 is (1<<16)).
1797
+ *
1798
+ * Indexes :
1799
+ * - 0 : top-left source point
1800
+ * - 1 : top-right source point
1801
+ * - 2 : bottom-right source point
1802
+ * - 3 : bottom-left source point
1803
+ */
1804
+ CamPoint p[4];
1805
+ } CamWarpingParams;
1806
+
1807
+ /// Backward warping function
1808
+ /** This function operates a backward mapping from the source image to a destination image.
1809
+ * All the params refer to locations in the source image, whereas the ROI scanned
1810
+ * by this warping function is set by the <DFN>roi</DFN> member of the dest image
1811
+ *
1812
+ * \param source The ::CamImage to warp
1813
+ * \param dest The warped image
1814
+ * \param params The ::CamWarpingParams structure providing the ROI in the source image (not rectangular)
1815
+ *
1816
+ */
1817
+ int camWarping(CamImage *source, CamImage *dest, CamWarpingParams *params);
1818
+
1819
+ /// Scaling function
1820
+ /** This function operates a scaling from the source image to the destination image.
1821
+ * It can upscale or downscale pictures, and uses bilinear interpolation technique.
1822
+ *
1823
+ * \param source The ::CamImage to warp
1824
+ * \param dest The warped image
1825
+ */
1826
+ int camScale(CamImage *source, CamImage *dest);
1827
+
1828
+ int camWarpingSuperSampling(CamImage *source, CamImage *dest, CamWarpingParams *params);
1829
+
1830
+ /// Simple helper function, used by camWarping()
1831
+ /**
1832
+ * \param p An array defining the segments to intersect (AB and CD). These points
1833
+ * must be provided in 16-bits fixed-point arithmetic form (1 is (1<<16)).
1834
+ * \param res The intersection point.
1835
+ * \return 0 if the segments are parallel. 1 otherwise
1836
+ */
1837
+ int camIntersectionSegments(CamPoint p[4], CamPoint *res);
1838
+ //@}
1839
+
1840
+ /** @name Linear filtering kernel
1841
+ */
1842
+ //@{
1843
+
1844
+ // For compatibility with older versions
1845
+ #define CamSobel3x3 camSobel
1846
+ #define CamSobelAbs3x3 camSobelAbs
1847
+
1848
+ #define CAM_LINEAR_FILTER_KERNEL_MAX_SIZE 7
1849
+
1850
+ #endif //SWIG
1851
+
1852
+ #ifdef __cplusplus
1853
+ /// The parameters structure for linear filtering
1854
+ struct CamLinearFilterKernel {
1855
+ #else
1856
+ /// The parameters structure for linear filtering
1857
+ typedef struct {
1858
+ #endif
1859
+ #ifndef SWIG
1860
+ int kernel[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE][CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The NxN coefficients matrix (aka the kernel)
1861
+ #endif
1862
+ int coeff1; ///< Multiplicative coefficient
1863
+ int coeff2; ///< Final value is (result*coeff1)>>coeff2. This is to simulate division.
1864
+ #ifdef __cplusplus
1865
+ /// Default constructor
1866
+ CamLinearFilterKernel() {
1867
+ for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
1868
+ for (int j=0;j<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;j++) {
1869
+ kernel[i][j]=0;
1870
+ }
1871
+ }
1872
+ coeff1=1;
1873
+ coeff2=0;
1874
+ }
1875
+ /// Set an element of the linear filter kernel
1876
+ bool set(int x, int y, int val) {
1877
+ if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1878
+ kernel[x][y]=val; return true;
1879
+ } else return false;
1880
+ }
1881
+ /// Get an element from the linear filter kernel
1882
+ int get(int x,int y) {
1883
+ if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1884
+ return kernel[x][y];
1885
+ } else return 0;
1886
+ }
1887
+ };
1888
+ #else
1889
+ } CamLinearFilterKernel;
1890
+ #endif
1891
+
1892
+ #ifndef SWIG
1893
+
1894
+ /// 3x3 Linear Filtering function
1895
+ /** \param source The source ::CamImage to process. Grey scale only.
1896
+ * \param dest The destination ::CamImage
1897
+ * \param params A pointer to a ::CamLinearFilterKernel structure, providing
1898
+ * the linear kernel to use.
1899
+ * \return Sum (Accumulator) of all computed pixels
1900
+ *
1901
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1902
+ *
1903
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
1904
+ * so that results of filtering are unbiased.
1905
+ */
1906
+ int camLinearFilter3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
1907
+
1908
+ /// 5x5 Linear Filtering function
1909
+ /** \param source The source ::CamImage to process. Grey scale only.
1910
+ * \param dest The destination ::CamImage
1911
+ * \param params A pointer to a ::CamLinearFilterKernel structure, providing
1912
+ * the linear kernel to use.
1913
+ * \return Sum (Accumulator) of all computed pixels
1914
+ *
1915
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1916
+ *
1917
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
1918
+ * so that results of filtering are unbiased.
1919
+ */
1920
+ int camLinearFilter5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
1921
+
1922
+ /// 3x3 Linear Filtering function (absolute)
1923
+ /** \param source The source ::CamImage to process. Grey scale only.
1924
+ * \param dest The destination ::CamImage
1925
+ * \param params A pointer to a ::CamLinearFilterKernel structure, providing
1926
+ * the linear kernel to use.
1927
+ * \return Sum (Accumulator) of all computed pixels
1928
+ *
1929
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1930
+ *
1931
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
1932
+ * so that results of filtering are unbiased.
1933
+ */
1934
+ int camLinearFilterAbs3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
1935
+
1936
+ /// 5x5 Linear Filtering function (absolute)
1937
+ /** \param source The source ::CamImage to process. Grey scale only.
1938
+ * \param dest The destination ::CamImage
1939
+ * \param params A pointer to a ::CamLinearFilterKernel structure, providing
1940
+ * the linear kernel to use.
1941
+ * \return Sum (Accumulator) of all computed pixels
1942
+ *
1943
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
1944
+ *
1945
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
1946
+ * so that results of filtering are unbiased.
1947
+ */
1948
+ int camLinearFilterAbs5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
1949
+
1950
+ /* Obsolete
1951
+ * int camSobel(CamImage *source, CamImage *dest, int vert_edges);
1952
+ * int camSobelAbs(CamImage *source, CamImage *dest, int vert_edges);
1953
+ */
1954
+
1955
+ #endif //SWIG
1956
+
1957
+ #ifdef __cplusplus
1958
+ /// The parameters structure for linear filtering
1959
+ struct CamSepFilterKernel {
1960
+ #else
1961
+ /// The parameters structure for linear filtering
1962
+ typedef struct {
1963
+ #endif
1964
+ #ifndef SWIG
1965
+ int x[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The horizontal array of coefficients
1966
+ int y[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; ///< The vertical array of coefficients
1967
+ #endif
1968
+ int coeff1; ///< Multiplicative coefficient
1969
+ int coeff2; ///< Final value is (result*coeff1)>>coeff2. This is to simulate division.
1970
+ #ifdef __cplusplus
1971
+ /// Default constructor
1972
+ CamSepFilterKernel() {
1973
+ for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
1974
+ x[i]=0; y[i]=0;
1975
+ }
1976
+ coeff1=1;
1977
+ coeff2=0;
1978
+ }
1979
+ /// Set an element of the linear separable filter kernel
1980
+ bool set_x(int y, int val) {
1981
+ if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1982
+ x[y]=val; return true;
1983
+ } else return false;
1984
+ }
1985
+ bool set_y(int x, int val) {
1986
+ if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1987
+ y[x]=val; return true;
1988
+ } else return false;
1989
+ }
1990
+ /// Get an element from the linear separable filter kernel
1991
+ int get_x(int y) {
1992
+ if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1993
+ return x[y];
1994
+ } else return 0;
1995
+ }
1996
+ int get_y(int x) {
1997
+ if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
1998
+ return y[x];
1999
+ } else return 0;
2000
+ }
2001
+ };
2002
+ #else
2003
+ } CamSepFilterKernel;
2004
+ #endif
2005
+
2006
+ #define CAM_SOBEL_H 1
2007
+ #define CAM_SOBEL_V 2
2008
+ #define CAM_GAUSSIAN_3x3 3
2009
+ #define CAM_GAUSSIAN_5x5 4
2010
+ #define CAM_GAUSSIAN_7x7 5
2011
+ #define CAM_SCHARR_H 6
2012
+ #define CAM_SCHARR_V 7
2013
+
2014
+ #ifndef SWIG
2015
+
2016
+ /// 3x3 Linear Filtering function with a separable kernel
2017
+ /** \param source The source ::CamImage to process. Grey scale only.
2018
+ * \param dest The destination ::CamImage
2019
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2020
+ * \return Sum (Accumulator) of all computed pixels
2021
+ *
2022
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2023
+ *
2024
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2025
+ * so that results of filtering are unbiased.
2026
+ */
2027
+ int camSepFilter3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2028
+
2029
+ /// 3x3 Linear Filtering function with a separable kernel (absolute value)
2030
+ /** \param source The source ::CamImage to process. Grey scale only.
2031
+ * \param dest The destination ::CamImage
2032
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2033
+ * \return Sum (Accumulator) of all computed pixels
2034
+ *
2035
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2036
+ *
2037
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2038
+ * so that results of filtering are unbiased.
2039
+ */
2040
+ int camSepFilterAbs3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2041
+
2042
+ /// 5x5 Linear Filtering function with a separable kernel
2043
+ /** \param source The source ::CamImage to process. Grey scale only.
2044
+ * \param dest The destination ::CamImage
2045
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2046
+ * \return Sum (Accumulator) of all computed pixels
2047
+ *
2048
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2049
+ *
2050
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2051
+ * so that results of filtering are unbiased.
2052
+ */
2053
+ int camSepFilter5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2054
+
2055
+ /// 5x5 Linear Filtering function with a separable kernel (absolute value)
2056
+ /** \param source The source ::CamImage to process. Grey scale only.
2057
+ * \param dest The destination ::CamImage
2058
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2059
+ * \return Sum (Accumulator) of all computed pixels
2060
+ *
2061
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2062
+ *
2063
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2064
+ * so that results of filtering are unbiased.
2065
+ */
2066
+ int camSepFilterAbs5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2067
+
2068
+ /// 7x7 Linear Filtering function with a separable kernel
2069
+ /** \param source The source ::CamImage to process. Grey scale only.
2070
+ * \param dest The destination ::CamImage
2071
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2072
+ * \return Sum (Accumulator) of all computed pixels
2073
+ *
2074
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2075
+ *
2076
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2077
+ * so that results of filtering are unbiased.
2078
+ */
2079
+ int camSepFilter7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2080
+
2081
+ /// 7x7 Linear Filtering function with a separable kernel (absolute value)
2082
+ /** \param source The source ::CamImage to process. Grey scale only.
2083
+ * \param dest The destination ::CamImage
2084
+ * \param kernel A pointer to a ::CamSepFilterKernel structure, specifying the separable linear kernel to use.
2085
+ * \return Sum (Accumulator) of all computed pixels
2086
+ *
2087
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2088
+ *
2089
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2090
+ * so that results of filtering are unbiased.
2091
+ */
2092
+ int camSepFilterAbs7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
2093
+
2094
+ /// 3x3 Horizontal Sobel Filter. Detects horizontal edges.
2095
+ /** \param source The source ::CamImage to process. Grey scale only.
2096
+ * \param dest The destination ::CamImage
2097
+ * \return 1 if the function succeeds. 0 otherwise.
2098
+ *
2099
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2100
+ *
2101
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2102
+ * so that results of filtering are unbiased.
2103
+ */
2104
+ int camSobelH(CamImage *source, CamImage *dest);
2105
+
2106
+ /// 3x3 Horizontal Sobel Filter (absolute). Detects horizontal edges.
2107
+ /** \param source The source ::CamImage to process. Grey scale only.
2108
+ * \param dest The destination ::CamImage
2109
+ * \return 1 if the function succeeds. 0 otherwise.
2110
+ *
2111
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2112
+ *
2113
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2114
+ * so that results of filtering are unbiased.
2115
+ */
2116
+ int camSobelHAbs(CamImage *source, CamImage *dest);
2117
+
2118
+ /// 3x3 Vertical Sobel Filter. Detects Vertical edges.
2119
+ /** \param source The source ::CamImage to process. Grey scale only.
2120
+ * \param dest The destination ::CamImage
2121
+ * \return 1 if the function succeeds. 0 otherwise.
2122
+ *
2123
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2124
+ *
2125
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2126
+ * so that results of filtering are unbiased.
2127
+ */
2128
+ int camSobelV(CamImage *source, CamImage *dest);
2129
+
2130
+ /// 3x3 Vertical Sobel Filter (absolute). Detects Vertical edges.
2131
+ /** \param source The source ::CamImage to process. Grey scale only.
2132
+ * \param dest The destination ::CamImage
2133
+ * \return 1 if the function succeeds. 0 otherwise.
2134
+ *
2135
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2136
+ *
2137
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2138
+ * so that results of filtering are unbiased.
2139
+ */
2140
+ int camSobelVAbs(CamImage *source, CamImage *dest);
2141
+
2142
+ /// Linear convolution with a predefined kernel
2143
+ /** The function camFixedFilter() is used to convolve the input image with a predefined filter kernel
2144
+ * specified in argument.
2145
+ *
2146
+ * \param source The source ::CamImage to process. Grey scale only.
2147
+ * \param dest The destination ::CamImage
2148
+ * \param filter Constant defining the kernel to be used. The filter kernel can be one of the following :
2149
+ * - <DFN>CAM_SOBEL_H</DFN> performs a horizontal edges detection (3x3 sobel)
2150
+ * - <DFN>CAM_SOBEL_V</DFN> performs a vertical edges detection (3x3 sobel)
2151
+ * - <DFN>CAM_GAUSSIAN_3x3</DFN> performs a gaussian filtering
2152
+ * - <DFN>CAM_GAUSSIAN_5x5</DFN> performs a gaussian filtering
2153
+ * - <DFN>CAM_GAUSSIAN_7x7</DFN> performs a gaussian filtering
2154
+ *
2155
+ * \return 1 if the function succeeds. 0 otherwise.
2156
+ *
2157
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2158
+ *
2159
+ * Note also that signed saturation is to (-127;+127) instead of the traditional signed char (-128;+127),
2160
+ * so that results of filtering are unbiased.
2161
+ */
2162
+ int camFixedFilter(CamImage *source, CamImage *dest, int filter);
2163
+
2164
+ int camScharrH(CamImage *source, CamImage *dest);
2165
+ int camScharrV(CamImage *source, CamImage *dest);
2166
+ int camScharrHAbs(CamImage *source, CamImage *dest);
2167
+ int camScharrVAbs(CamImage *source, CamImage *dest);
2168
+
2169
+ //@}
2170
+
2171
+ /** @name Median filtering kernel
2172
+ */
2173
+ //@{
2174
+
2175
+ #define camMedianFiltering3x3 camMedianFilter3x3
2176
+ #define camMedianFiltering5x5 camMedianFilter5x5
2177
+
2178
+ /// 3x3 Median Filtering function
2179
+ /** For each 3x3 set of pixels, keep the median value. Considered as being a
2180
+ * good filter, less sensitive to noise.than linear filtering.
2181
+ *
2182
+ * \param source The source ::CamImage to process. Grey scale only.
2183
+ * \param dest The destination ::CamImage
2184
+ * \return 0 (false) if an error occurs
2185
+ *
2186
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2187
+ */
2188
+ int camMedianFilter3x3(CamImage *source, CamImage *dest);
2189
+
2190
+ /// 5x5 Median Filtering function
2191
+ /** For each 5x5 set of pixels, keep the median value. Considered as being a
2192
+ * good filter, less sensitive to noise.than linear filtering.
2193
+ *
2194
+ * \param source The source ::CamImage to process. Grey scale only.
2195
+ * \param dest The destination ::CamImage
2196
+ * \return 0 (false) if an error occurs
2197
+ *
2198
+ * Note that this function supports in-place processing (i.e. dest can be the same as source param)
2199
+ */
2200
+ int camMedianFilter5x5(CamImage *source, CamImage *dest);
2201
+ //@}
2202
+
2203
+ /** @name Watersheding kernel
2204
+ */
2205
+ //@{
2206
+
2207
+ /// 1D watershed computation
2208
+ /** Retrieves all the watershed points, along with their depth (i.e. the minimum depth of
2209
+ * the 2 catchment bassins contributing to the watershed point).
2210
+ *
2211
+ * 1D watersheding operation is a very smart way to analyze the results of an histogram
2212
+ * (generally before thresholding), yielding better results than a simple n% threshold.
2213
+ *
2214
+ * \param input The 1D integer data for which to compute the watershed
2215
+ * \param size The size of the 1D integer array (<DFN>t</DFN>). Generally 256 when <DFN>t</DFN> is the
2216
+ * results of an histogramming operation.
2217
+ * \param results The 1D integer array contaning the results of the watershed computation.
2218
+ * A value different from 0 indicates a watershed point, the value indicating the depth
2219
+ * (and thus the importance) associated to this watershed point.
2220
+ * The memory for this array is not allocated by this function, and thus an array
2221
+ * of appropriate size must be allocated before calling this function.
2222
+ *
2223
+ * \return 0 (false) if an error occurs
2224
+ */
2225
+ int camWatershed1D(int *input, int size, int *results);
2226
+ #else
2227
+ %immutable;
2228
+ #endif // SWIG
2229
+
2230
+ /// The structure defining a basin
2231
+ typedef struct
2232
+ {
2233
+ int dynamics; ///< Its dynamics (importance)
2234
+ int minimum; ///< Minimum of the basin
2235
+ int flooded; ///< The catchment basin which has flooded it
2236
+ int surface; ///< Surface of the region
2237
+ int accsurface; ///< Accumulated surface of all children
2238
+ unsigned short x,y; ///< Position of the minimum
2239
+ } CamBasin;
2240
+
2241
+ #define CAM_NOT_COMPUTED 65536
2242
+
2243
+ #ifndef SWIG
2244
+ #ifdef __cplusplus
2245
+ /// The table of basins structure. Simply a dynamic size array of <DFN>CamBasin</DFN>.
2246
+ struct CamTableOfBasins {
2247
+ int sizeMax;
2248
+ int nbBasins;
2249
+ CamBasin *tab;
2250
+ CamBasin& operator[](int index) {return tab[index];}
2251
+ void get_rid_of(CamBasin &basin) {basin.surface=0;}
2252
+ CamTableOfBasins() {tab=NULL;sizeMax=0;nbBasins=0;}
2253
+ ~CamTableOfBasins();
2254
+ };
2255
+ #else
2256
+ typedef struct
2257
+ {
2258
+ int sizeMax;
2259
+ int nbBasins;
2260
+ CamBasin *tab;
2261
+ } CamTableOfBasins;
2262
+ #endif
2263
+
2264
+ /// Free a table of basins after use.
2265
+ void camFreeTableOfBasins(CamTableOfBasins *t);
2266
+
2267
+ /// 2D Hierarchical watershed computation
2268
+ /** Retrieves all the basins (regional segmentation)
2269
+ *
2270
+ * Watersheding computes a hierarchichal segmentation of an image.
2271
+ * Watersheding operation is a very smart way to analyze the results of a gradient image.
2272
+ *
2273
+ * \param source The ::CamImage for which to compute the watershed
2274
+ * \param dest A 16-bits deep ::CamImage where the results of the watersheding operation are stored.
2275
+ * The index of the basin is given by the pixel value minus 1 (so starting at 1).
2276
+ * Border pixels are set to -32768.
2277
+ * <DFN>dest</DFN> must be allocated by the caller, and must have the same size as
2278
+ * the <DFN>source</DFN> image. It must also be a signed 16 bits deep image (<dfn>CAM_DEPTH_16S</dfn>).
2279
+ * \param tob The table of basins, containing their dynamics, their surface and their minimum value.
2280
+ * This table is allocated by the function.
2281
+ *
2282
+ * \return 0 (false) if an error occurs
2283
+ */
2284
+ int camHierarchicalWatershed(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
2285
+
2286
+ /// 2D Hierarchical watershed computation (with watershed/contours markers)
2287
+ /** Retrieves all the watershed points, along with all the basins (regional segmentation)
2288
+ *
2289
+ * Watersheding computes a hierarchichal segmentation of an image.
2290
+ * Watersheding operation is a very smart way to analyze the results of a gradient image.
2291
+ *
2292
+ * \param source The ::CamImage for which to compute the watershed
2293
+ * \param dest A 16-bits deep ::CamImage where the results of the watersheding operation are stored.
2294
+ * A negative pixel value indicates a watershed point.
2295
+ * A positive indicates that this pixel belongs to a basin.
2296
+ * The index of the basin is given by the pixel value minus 1. Border pixels are set to -32768.
2297
+ * <DFN>dest</DFN> must be allocated by the caller, and must have the same size as
2298
+ * the <DFN>source</DFN> image. It must also be a signed 16 bits deep image (<dfn>CAM_DEPTH_16S</dfn>).
2299
+ * \param tob The table of basins, containing their dynamics, their surface and their minimum value.
2300
+ * This table is allocated by the function.
2301
+ *
2302
+ * \return 0 (false) if an error occurs
2303
+ */
2304
+ int camHierarchicalWatershedContours(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
2305
+
2306
+ /// Retrieves regions from a watershed image
2307
+ /** Retrieves all the regions of basins with surface different from 0. The user can set the surface of a basin in
2308
+ * the table of basins to deselect it. Thus, the user can remove from the watershed image all the basins with
2309
+ * low dynamics, and the pixels of this basin will be affected to a flooding basin.
2310
+ *
2311
+ * \return 0 (false) if an error occurs
2312
+ */
2313
+ int camHierarchicalWatershedRegions(CamImage *watershed, CamTableOfBasins *tob);
2314
+ //@}
2315
+
2316
+ /** @name Hough functions
2317
+ */
2318
+ //@{
2319
+
2320
+ /// Circle Hough. Find a circle in a picture.
2321
+ /** Find a circle in the input picture. Returns the circle with the bigger hough accumulation.
2322
+ *
2323
+ * \param image The ::CamImage to process
2324
+ * \param percent The percentage of pixels to consider (from the gradient image). Directly proportionnal to the speed of exection. Typically 10.
2325
+ * \param rmin The minimum radius to look for
2326
+ * \param rmax The maximum radius to look for. This determines the size of the (x,y,r) Hough cube
2327
+ * \param xc A pointer to the circle center (return value)
2328
+ * \param yc A pointer to the circle center (return value)
2329
+ * \param rc A pointer to the circle radius (return value)
2330
+ *
2331
+ * \return The confidence in the circle found (hough accumulator)
2332
+ */
2333
+ int camHoughCircle(CamImage *image, int percent, int rmin, int rmax, int *xc, int *yc, int *rc);
2334
+
2335
+ /** @name Utility functions
2336
+ */
2337
+ //@{
2338
+
2339
+ /* Image allocation utility routines
2340
+ */
2341
+
2342
+ /// Grey scale image allocation
2343
+ int camAllocateImage(CamImage *image, int width, int height, int depth);
2344
+ /// YUV image allocation
2345
+ int camAllocateYUVImage(CamImage *image, int width, int height);
2346
+ /// RGB image allocation
2347
+ int camAllocateRGBImage(CamImage *image, int width, int height);
2348
+ /// RGB image allocation with alpha channel
2349
+ int camAllocateRGBAImage(CamImage *image, int width, int height);
2350
+ /// Image deallocation
2351
+ int camDeallocateImage(CamImage *image);
2352
+
2353
+ /* Other useful functions
2354
+ */
2355
+ /// Set the ROI utility function
2356
+ int camSetROI(CamROI *roi, int coi, int xOffset, int yOffset, int width, int height);
2357
+ /// Set the ROI to the maximum size of the image
2358
+ int camSetMaxROI(CamROI *roi, CamImage *image);
2359
+ /// Reduce the roi by a given number of pixels on each side
2360
+ int camReduceROI(CamROI *roi, int pixels);
2361
+ /// Enlarge the roi by a given number of pixels on each side
2362
+ int camEnlargeROI(CamROI *roi, int pixels);
2363
+ /// Simple 2x Zoom functin (by pixels replication)
2364
+ int camZoom2x(CamImage *src, CamImage *dst);
2365
+ /// Simple nearest-neighbour decimation
2366
+ int camDecimateNN(CamImage *src, CamImage *dest, int factor);
2367
+ /// Set the image mask (Run-Length encoded mask)
2368
+ int camSetRLEMask(CamImage *image, CamRLEImage *mask);
2369
+ /// Set the image mask (::CamImage mask)
2370
+ int camSetMask(CamImage *image, CamImage *mask);
2371
+
2372
+ #define camDownScaling2x2 camDownscaling2x2
2373
+ /// 2x2 linear interpolation downscaling
2374
+ int camDownScaling2x2(CamImage *src, CamImage *dest);
2375
+ /// Copy function, without any color space conversion, but able to deal with planar/pixel oriented conversion, ROIs and even masking
2376
+ /** Supports grey scale to color conversion, as well as RGB to RGBA, and RGBA to RGB copying (adding and removing alpha channel)
2377
+ *
2378
+ * \return 0 (false) if an error occurs
2379
+ */
2380
+ int camCopy(CamImage *source, CamImage *dest);
2381
+ /// Simple cloning function
2382
+ /** This function allocates the memory for the dest image. dest actual content is not considered by this function.
2383
+ * Beware not to have allocated an image in dest before, otherwise this will result in a memory leak.
2384
+ */
2385
+ int camClone(CamImage *source, CamImage *dest);
2386
+ /// Reference copy
2387
+ /** This function doesn't copy the pixels, only the structure. Destination image will reference the same pixels as the source image.
2388
+ * The image will be freed when source will be deallocated through camDeallocateImage() function.
2389
+ */
2390
+ int camRefCopy(CamImage *source, CamImage *dest);
2391
+ /// Set all the pixel values to <DFN>fillValue</DFN>
2392
+ int camSet(CamImage *image, int fillValue);
2393
+ /// Alpha channel compositing
2394
+ /** \param source1 must be a RGB image
2395
+ * \param source2 must be a RGBA image (with an alpha channel)
2396
+ * \param dest destination image
2397
+ */
2398
+ int camAlphaComposite(CamImage *source1, CamImage *source2, CamImage *dest);
2399
+
2400
+ /// Set the border value of an image
2401
+ int camSetBorder(CamImage *image, int borderValue);
2402
+ /// Clip the roi of an image
2403
+ int camClipROI(CamImage *image);
2404
+ /// Clip a ROI with respect to an image
2405
+ int camClip(CamROI *roi, CamImage *image);
2406
+ /// Compute intersection between ROIs
2407
+ int camROIIntersect(CamROI *roi1, CamROI *roi2, CamROI *dest);
2408
+
2409
+ #endif //SWIG
2410
+ int camSetImageViewer(char *s);
2411
+ #ifndef SWIG
2412
+
2413
+ /// View an image
2414
+ int camView(CamImage *image);
2415
+ /// Returns the version of the library
2416
+ const char *camVersion();
2417
+
2418
+ /* Drawing functions
2419
+ */
2420
+ /// Draw a line
2421
+ int camDrawLine(CamImage *image, int x1, int y1, int x2, int y2, int color);
2422
+ /// Accumulate a line in a frame (very useful for Hough transforms)
2423
+ int camAccumulateLine(CamImage *image, int x1, int y1, int x2, int y2, int acc);
2424
+ /// Draw a rectangle
2425
+ int camDrawRectangle(CamImage *image, int x1, int y1, int x2, int y2, int color);
2426
+ /// Draw some text using 16 segments font (looks like an alarm clock...)
2427
+ int camDrawText16s(CamImage *image, char *text, int x, int y, int cwidth, int cheight, int orientation, int color);
2428
+ /// Draw a circle
2429
+ int camDrawCircle(CamImage *image, int x, int y, int r, int color);
2430
+ /// Draw an ellipse
2431
+ int camDrawEllipse(CamImage *image, int x, int y, int rx, int ry, int color);
2432
+ /// Plot
2433
+ /** Plots a point (\ref CAM_POINT), a cross (\ref CAM_CROSS), a circle (\ref CAM_CIRCLE) or a combination of them (<DFN>CAM_CROSS|CAM_CIRCLE</DFN> for instance)
2434
+ */
2435
+ int camPlot(CamImage *image, int x, int y, int color, int kind);
2436
+ /// Fill a region with a color
2437
+ /** Try to fill the image with pixels as much possible pixels with the same color as the original pixel color in (x,y)
2438
+ *
2439
+ * \param x horizontal coordinate where to start the filling
2440
+ * \param y vertical coordinate where to start the filling
2441
+ * \param fillcolor filling color (use CAM_RGB or CAM_RGBA macros to set this color)
2442
+ * \param tolerance this sets where the filling should stop. The reference is the color of the original pixel color in (x,y), and all the pixels nearby that are within the
2443
+ * tolerance parameters get filled. If tolerance is set to -1, the filling stops with pixels having the same color as the filling color
2444
+ * (this mode is very useful for filling circles, rectangles, etc.)
2445
+ *
2446
+ * \return The number of colored pixels (at least 1 is function succeeds)
2447
+ */
2448
+ int camFillColor(CamImage *image, int x, int y, int fillcolor, int tolerance);
2449
+
2450
+ #endif // SWIG
2451
+
2452
+ #ifdef __cplusplus
2453
+ /// The bitmap font structure
2454
+ struct CamBitmapFont {
2455
+ #else
2456
+ typedef struct {
2457
+ #endif
2458
+ int first_char;
2459
+ int nb_chars;
2460
+ int height;
2461
+ CamRLEImage *masks;
2462
+ CamImage *letters;
2463
+ #ifdef __cplusplus
2464
+ CamBitmapFont() {first_char=33; nb_chars=0; masks=NULL; letters=NULL;}
2465
+ CamBitmapFont(const char *filename);
2466
+ ~CamBitmapFont();
2467
+ bool load(const char *filename);
2468
+ };
2469
+ #else
2470
+ } CamBitmapFont;
2471
+ #endif
2472
+
2473
+ #ifndef SWIG
2474
+ /// Load a bitmap font
2475
+ int camBitmapFontLoad(CamBitmapFont *font, char *filename);
2476
+ /// Deallocate a bitmap font
2477
+ int camBitmapFontDeallocate(CamBitmapFont *font);
2478
+ /// Draw some text using a bitmap font
2479
+ int camDrawTextBitmap(CamImage *image, char *text, int x, int y, CamBitmapFont *font);
2480
+ #endif // SWIG
2481
+
2482
+ /// 24 bits integer color representation. Stricly equivalent to the Windows RGB macro.
2483
+ /** Please use this one in place of RGB for better portability of the code.
2484
+ */
2485
+ int camRGB(int r, int g, int b);
2486
+
2487
+ /// 32 bits integer color representation, including an alpha channel
2488
+ int camRGBA(int r, int g, int b, int a);
2489
+
2490
+ #ifndef SWIG
2491
+
2492
+ /* Load and save PGM images
2493
+ */
2494
+ /// Load a PGM image
2495
+ int camLoadPGM(CamImage *image, char *fn);
2496
+ /// Save a PGM image
2497
+ int camSavePGM(CamImage *image, char *filename);
2498
+
2499
+ /* Load and save BMP images
2500
+ */
2501
+ /// Load a BMP image
2502
+ int camLoadBMP(CamImage *image, char *fn);
2503
+ /// Save a BMP image
2504
+ int camSaveBMP(CamImage *image, char *filename);
2505
+
2506
+ /* Load config files
2507
+ */
2508
+ #define CAM_CONFIG_MAX_ENTRIES 256
2509
+ typedef struct {
2510
+ int nbEntries;
2511
+ char parameter[CAM_CONFIG_MAX_ENTRIES][128];
2512
+ char value[CAM_CONFIG_MAX_ENTRIES][128];
2513
+ } CamConfig;
2514
+
2515
+ int camLoadConfig(const char *filename, CamConfig *config);
2516
+ int camConfigInt(const CamConfig *config, const char *entry);
2517
+ float camConfigFloat(const CamConfig *config, const char *entry);
2518
+ const char *camConfigString(const CamConfig *config, const char *entry);
2519
+
2520
+ /// Error management function
2521
+ void camError(char *module, char *error);
2522
+ typedef void (*camErrorFunct)(char *,char*);
2523
+ void camSetErrorFunct(camErrorFunct funct);
2524
+ //@}
2525
+
2526
+ /** @name Color conversion functions
2527
+ */
2528
+ //@{
2529
+ int camYUV2RGB(CamImage* source, CamImage *dest); ///< Converts a YUV image to a RGB image (previously allocated)
2530
+ int camRGB2YUV(CamImage* source, CamImage *dest); ///< Converts a RGB image to a YUV image (previously allocated)
2531
+ int camRGB2Y(CamImage *source, CamImage *dest); ///< Converts a RGB image to a gray scale image (previously allocated)
2532
+ //@}
2533
+
2534
+ /** @name Motion estimation functions
2535
+ */
2536
+ //@{
2537
+ /*
2538
+ * Computes the Sum of Absolute Values between two 8x8 blocks
2539
+ *
2540
+ * This function takes into account the blocks lying partially outside the image.
2541
+ * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
2542
+ *
2543
+ *
2544
+ * \param image1 Current image
2545
+ * \param image2 Previous image
2546
+ * \param bleft The x coordinate of the current block
2547
+ * \param btop The y coordinate of the current block
2548
+ * \param dx The x offset to reach the candidate block
2549
+ * \param dy The y offset to reach the candidate block
2550
+ *
2551
+ * \return The SAD value between the given two blocks
2552
+ */
2553
+ int camSAD8x8(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
2554
+
2555
+ /*
2556
+ * Computes the Sum of Absolute Values between two 16x16 blocks
2557
+ *
2558
+ * This function takes into account the blocks lying partially outside the image.
2559
+ * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
2560
+ *
2561
+ *
2562
+ * \param image1 Current image
2563
+ * \param image2 Previous image
2564
+ * \param bleft The x coordinate of the current block
2565
+ * \param btop The y coordinate of the current block
2566
+ * \param dx The x offset to reach the candidate block
2567
+ * \param dy The y offset to reach the candidate block
2568
+ *
2569
+ * \return The SAD value between the given two blocks
2570
+ */
2571
+ int camSAD16x16(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
2572
+
2573
+ typedef struct {
2574
+ int niter; ///< Number of iterations (should be set to 0)
2575
+ int seed; ///< Seed for randomization
2576
+ int lsearch; ///< Number of pixels for searching around the blocks (small search)
2577
+ int rsearch; ///< Full random search parameter
2578
+ int blockSize; ///< Block size (8 or 16)
2579
+ int scans; ///< Number of scans
2580
+ int candidates; ///< Number of candidates (per scan)
2581
+ int test0; ///< Systematically test (0,0) motion vector
2582
+ } CamMotionEstimation3DRSParams;
2583
+
2584
+ typedef struct {
2585
+ int vx[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< Horizontal motion vectors
2586
+ int vy[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< Vertical motion vectors
2587
+ int SAD[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8]; ///< SAD results
2588
+ } CamMotionEstimation3DRSResults;
2589
+
2590
+ int camMotionEstimation3DRSInit(CamMotionEstimation3DRSParams *params, int seed, int lsearch, int rsearch, int bs, int scans, int candidates, int test0);
2591
+ int camMotionEstimation3DRS(CamImage *current, CamImage *previous, CamMotionEstimation3DRSParams *params, CamMotionEstimation3DRSResults *results);
2592
+ //@}
2593
+
2594
+ /** @name 3D Projection/Retroprojection functions
2595
+ */
2596
+ //@{
2597
+
2598
+ void camProject(const double extr[4][4], const double fc[2], const double cc[2], double x, double y, double z, int *xp, int *yp);
2599
+
2600
+ void camBackproject(const double extr[4][4], const double fc[2], const double cc[2], int xp, int yp, double z, double *x, double *y);
2601
+
2602
+ int camUndistort(CamImage *source, CamImage *dest,
2603
+ const float* intrinsic_matrix,
2604
+ const float* dist_coeffs);
2605
+ int camUndistortFixed(CamImage *source, CamImage *dest,
2606
+ const CAM_FIXED_POINT* intrinsic_matrix,
2607
+ const CAM_FIXED_POINT* dist_coeffs);
2608
+ int camUndistortBuildLUT(CamImage *source,
2609
+ const float* intrinsic_matrix,
2610
+ const float* dist_coeffs,
2611
+ CamImage *LUTX, CamImage *LUTY);
2612
+ int camUndistortLUT(CamImage *source, CamImage *dest,
2613
+ CamImage *LUTX, CamImage *LUTY);
2614
+
2615
+ //@}
2616
+
2617
+ #endif // SWIG
2618
+
2619
+ #ifdef __cplusplus
2620
+ }
2621
+ #endif
2622
+
2623
+ #endif
2624
+