camellia.h

Go to the documentation of this file.
00001 
00371 #ifndef _CAMELLIA_H_
00372 #define _CAMELLIA_H_
00373 
00374 #define CAM_VERSION "2.5.10 : Luxembourg ($Rev: 90 $)"
00375 
00376 #include <stdlib.h>
00377 
00378 /*******************************************
00379  * Compilation options :                   *
00380  */
00381 // Pixel definition
00382 #define CAM_PIXEL unsigned char
00383 #define CAM_SIGNED_PIXEL signed char
00384 
00385 // Max image size
00386 #define CAM_MAX_SCANLINE 1280
00387 #define CAM_MAX_FRAME_HEIGHT 1024
00388 
00389 // 64-bit processor or memory bandwidth?
00390 #define CAM_64BITS
00391 
00392 // Pentium4 optimizations?
00393 #define CAM_OPT_P4
00394 
00395 // Big endian arichitecture?
00396 //#define CAM_BIG_ENDIAN
00397 
00398 // Generate 8 AND 16 bits pixel size code
00399 #define CAM_GENERATE_FULL_CODE
00400 
00401 /*                                         *
00402  *******************************************/ 
00403 #ifdef _WIN32
00404 #define CAM_INT64 __int64
00405 #define CAM_UINT64 unsigned __int64
00406 #else
00407 #define CAM_INT64 long long
00408 #define CAM_UINT64 unsigned long long
00409 #endif
00410 
00411 #ifdef __INTEL_COMPILER
00412 #define CAM_ALIGN16 __declspec(align(16))
00413 #else
00414 #define CAM_ALIGN16
00415 #endif
00416 
00417 #define CAM_FIXED_POINT signed long
00418 #define CAM_FLOAT2FIXED(x,dot_pos) ((CAM_FIXED_POINT)((x)*(1<<dot_pos)))
00419 
00420 #define CAM_DEPTH_SIGN 0x80000000               
00421 #define CAM_DEPTH_MASK 0x7FFFFFFF               
00422 
00423 #define CAM_DEPTH_1U     1
00424 #define CAM_DEPTH_8U     8
00425 #define CAM_DEPTH_10U   10
00426 #define CAM_DEPTH_12U   12
00427 #define CAM_DEPTH_16U   16
00428 
00429 #define CAM_DEPTH_8S  (CAM_DEPTH_SIGN| 8)
00430 #define CAM_DEPTH_10S (CAM_DEPTH_SIGN|10)
00431 #define CAM_DEPTH_12S (CAM_DEPTH_SIGN|12)
00432 #define CAM_DEPTH_16S (CAM_DEPTH_SIGN|16)
00433 
00434 #define CAM_DATA_ORDER_PIXEL  0
00435 #define CAM_DATA_ORDER_PLANE  1
00436 
00437 #define CAM_ORIGIN_TL 0
00438 
00439 #define CAM_ALIGN_4BYTES   4
00440 #define CAM_ALIGN_8BYTES   8
00441 #define CAM_ALIGN_16BYTES 16
00442 #define CAM_ALIGN_32BYTES 32
00443 
00444 #define CAM_ALIGN_DWORD   CAM_ALIGN_4BYTES
00445 #define CAM_ALIGN_QWORD   CAM_ALIGN_8BYTES
00446  
00447 #define CAM_BORDER_CONSTANT   0
00448 #define CAM_BORDER_REPLICATE  1
00449 
00450 /*---  Indexes to access IplImage.BorderMode[],IplImage.BorderConst[]  ----*/
00451 #define CAM_SIDE_TOP_INDEX    0
00452 #define CAM_SIDE_BOTTOM_INDEX 1
00453 #define CAM_SIDE_LEFT_INDEX   2
00454 #define CAM_SIDE_RIGHT_INDEX  3
00455 
00456 /*----------  values of argument of iplSetBorderMode(,,border,)  ----------*/
00457 #define CAM_SIDE_TOP        (1<<CAM_SIDE_TOP_INDEX)
00458 #define CAM_SIDE_BOTTOM     (1<<CAM_SIDE_BOTTOM_INDEX)
00459 #define CAM_SIDE_LEFT       (1<<CAM_SIDE_LEFT_INDEX)
00460 #define CAM_SIDE_RIGHT      (1<<CAM_SIDE_RIGHT_INDEX)
00461 #define CAM_SIDE_ALL        (CAM_SIDE_RIGHT | CAM_SIDE_TOP | CAM_SIDE_LEFT | CAM_SIDE_BOTTOM)
00462 
00463 #ifdef CAM_BIG_ENDIAN
00464 #define CAM_FC( ch0, ch1, ch2, ch3 ) \
00465     ((int)(ch3)|((int)(ch2)<<8)|((int)(ch1)<<16)|((int)(ch0)<<24))
00466 #else
00467 #define CAM_FC( ch0, ch1, ch2, ch3 ) \
00468     ((int)(ch0)|((int)(ch1)<<8)|((int)(ch2)<<16)|((int)(ch3)<<24))
00469 #endif
00470 
00471 #ifndef SWIG
00472 #define CAM_COLORMODEL_RGB   CAM_FC('R','G','B',000)
00473 #define CAM_COLORMODEL_RGBA  CAM_FC('R','G','B','A')
00474 #define CAM_COLORMODEL_YUV   CAM_FC('Y','U','V',000)
00475 #define CAM_COLORMODEL_GREY  CAM_FC('G',000,000,000)
00476 #endif
00477 
00478 #ifdef __cplusplus
00479 struct CamImage;
00480 struct CamTableOfBasins;
00481 struct CamBitmapFont;
00482 
00484 struct CamROI {
00485 #else
00486 
00487 typedef struct {
00488 #endif
00489 
00490 
00494     int             coi;                
00495     int             xOffset;            
00496     int             yOffset;            
00497     int             width;              
00498     int             height;             
00499     
00500     // C++ Wrapping
00501 #ifdef __cplusplus
00502     CamROI() {coi=0; xOffset=0; yOffset=0; width=0; height=0;}
00503     CamROI(int _coi, int _xOffset, int _yOffset, int _width, int _height) {
00504         coi=_coi; xOffset=_xOffset; yOffset=_yOffset; width=_width; height=_height;
00505     }
00506     CamROI(const CamImage &image, int _coi=0);
00507     ~CamROI() {};
00508     CamROI intersect(const CamROI &roi) const; 
00509     bool clip(CamImage &image);
00510     bool reduce(int i);
00511     bool enlarge(int i);
00512 };
00513 
00514 struct CamLinearFilterKernel;
00515 struct CamMorphoMathsKernel;
00516 struct CamRLEImage;
00517 struct CamTable;
00518 struct CamMeasuresResults;
00519 struct CamSepFilterKernel;
00520 
00521 #else
00522 } CamROI;
00523 #endif
00524 
00525 #define CAM_POINT   1
00526 #define CAM_CROSS   2
00527 #define CAM_CIRCLE  4
00528 
00530 
00535 #ifdef __cplusplus
00536 struct CamImage {
00537 #else
00538 typedef struct {
00539 #endif
00540 #ifdef SWIG
00541 %immutable;
00542 #endif
00543     int             nSize;              
00544     int             id;                 
00545     int             nChannels;          
00546     int             alphaChannel;       
00547     
00549 
00551     int             depth;              
00552     char            colorModel[4];      
00553     
00555 
00558     char            channelSeq[4];              
00559     int             dataOrder;          
00560     int             origin;             
00561     int             align;              
00562     int             width;              
00563     int             height;             
00564  
00566 
00569     CamROI         *roi;
00570     
00572 
00577     void           *mask;               
00578     
00580 
00582     void           *imageId;            
00583     
00584     void           *misc;               
00585     int             imageSize;          
00586     unsigned char  *imageData;          
00587     int             widthStep;          
00588     int             borderMode[4];      
00589     int             borderConst[4];     
00590     unsigned char  *imageDataOrigin;    
00591 
00592     // C++ Wrapping
00593 
00594 #ifdef __cplusplus
00595     CamImage() {imageData=NULL; roi=NULL; imageSize=0; mask=NULL; imageDataOrigin=NULL; depth=CAM_DEPTH_8U; nChannels=1; } 
00596     CamImage(int width, int height, int depth=CAM_DEPTH_8U, int colormodel=0); 
00597     CamImage(const CamImage& image);                    
00598     ~CamImage();                                        
00599 
00600     CamImage& operator=(const CamImage &image);         
00601     CamImage* clone() const;                            
00602     CamImage* copy() const;                             
00603     bool copy(CamImage &dest) const;                    
00604     bool allocated() const {return (imageData)?true:false;} 
00605     bool alloc(int width, int height, int depth=CAM_DEPTH_8U, int colormodel=0); 
00606     bool dealloc();                                     
00607     bool alloc_rgb(int width, int height);              
00608     bool alloc_rgba(int width, int height);             
00609     bool alloc_yuv(int width, int height);              
00610     bool load_pgm(const char *filename);                
00611     bool save_pgm(const char *filename) const;          
00612     bool load_bmp(const char *filename);                
00613     bool save_bmp(const char *filename) const;          
00614     bool set_roi(const CamROI &roi);                    
00615     void get_pixels(char **result, int *len) const;     
00616     bool set_pixels(const char *pixels, int sz);        
00617     void inspect(char **result, int *len) const;        
00618     bool view() const;                                  
00619     bool set(int color);                                
00620     bool alpha_composite(const CamImage& source2, CamImage& dest) const; 
00621 
00622     int erode_square3();                                
00623     int erode_square3(CamImage &dest) const;            
00624     int erode_circle5();                                
00625     int erode_circle5(CamImage &dest) const;            
00626     int erode_circle7();                                
00627     int erode_circle7(CamImage &dest) const;            
00628     int dilate_square3();                               
00629     int dilate_square3(CamImage &dest) const;           
00630     int dilate_circle5();                               
00631     int dilate_circle5(CamImage &dest) const;           
00632     int dilate_circle7();                               
00633     int dilate_circle7(CamImage &dest) const;           
00634     int morpho_gradient_square3();                      
00635     int morpho_gradient_square3(CamImage &dest) const;  
00636     int morpho_gradient_circle5();                      
00637     int morpho_gradient_circle5(CamImage &dest) const;  
00638     int morpho_gradient_circle7();                      
00639     int morpho_gradient_circle7(CamImage &dest) const;  
00640 
00641     int morpho_maths(const CamMorphoMathsKernel &ker);                                  
00642     int morpho_maths(CamImage &dest, const CamMorphoMathsKernel &ker) const;            
00643     int erode_3x3(const CamMorphoMathsKernel &ker);                                     
00644     int erode_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00645     int dilate_3x3(const CamMorphoMathsKernel &ker);                                    
00646     int dilate_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00647     int erode_5x5(const CamMorphoMathsKernel &ker);                                     
00648     int erode_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00649     int dilate_5x5(const CamMorphoMathsKernel &ker);                                    
00650     int dilate_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00651     int erode_7x7(const CamMorphoMathsKernel &ker);                                     
00652     int erode_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00653     int dilate_7x7(const CamMorphoMathsKernel &ker);                                    
00654     int dilate_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00655 
00656     int linear_filter_3x3(const CamLinearFilterKernel &ker);                            
00657     int linear_filter_3x3(CamImage &dest, const CamLinearFilterKernel &k) const;        
00658     int linear_filter_5x5(const CamLinearFilterKernel &ker);                            
00659     int linear_filter_5x5(CamImage &dest, const CamLinearFilterKernel &k) const;        
00660     int linear_filter_abs_3x3(const CamLinearFilterKernel &ker);                        
00661     int linear_filter_abs_3x3(CamImage &dest, const CamLinearFilterKernel &k) const;    
00662     int linear_filter_abs_5x5(const CamLinearFilterKernel &ker);                        
00663     int linear_filter_abs_5x5(CamImage &dest, const CamLinearFilterKernel &k) const;    
00664     bool sobel_v();                                                                     
00665     bool sobel_h();                                                                     
00666     bool sobel_v_abs();                                                                 
00667     bool sobel_h_abs();                                                                 
00668     bool sobel_v(CamImage &dest) const;                                                 
00669     bool sobel_h(CamImage &dest) const;                                                 
00670     bool sobel_v_abs(CamImage &dest) const;                                             
00671     bool sobel_h_abs(CamImage &dest) const;                                             
00672     int sep_filter_3x3(const CamSepFilterKernel &ker);                                  
00673     int sep_filter_3x3(CamImage &dest, const CamSepFilterKernel &k) const;              
00674     int sep_filter_5x5(const CamSepFilterKernel &ker);                                  
00675     int sep_filter_5x5(CamImage &dest, const CamSepFilterKernel &k) const;              
00676     int sep_filter_7x7(const CamSepFilterKernel &ker);                                  
00677     int sep_filter_7x7(CamImage &dest, const CamSepFilterKernel &k) const;              
00678     int sep_filter_abs_3x3(const CamSepFilterKernel &ker);                              
00679     int sep_filter_abs_3x3(CamImage &dest, const CamSepFilterKernel &k) const;          
00680     int sep_filter_abs_5x5(const CamSepFilterKernel &ker);                              
00681     int sep_filter_abs_5x5(CamImage &dest, const CamSepFilterKernel &k) const;          
00682     int sep_filter_abs_7x7(const CamSepFilterKernel &ker);                              
00683     int sep_filter_abs_7x7(CamImage &dest, const CamSepFilterKernel &k) const;          
00684     bool fixed_filter(CamImage &dest, int filter) const;                                
00685     bool fixed_filter(int filter);                                                      
00686 
00687     bool draw_line(int x1, int y1, int x2, int y2, int color);                          
00688     bool accumulate_line(int x1, int y1, int x2, int y2, int acc);                      
00689     bool draw_rectangle(int x1, int y1, int x2, int y2, int color);                     
00690     bool draw_text_16s(const char *text, int x, int y, int cwidth, int cheight, int orientation, int color); 
00691     bool draw_text_bitmap(const char *text, int x, int y, const CamBitmapFont &font);   
00692     bool draw_circle(int x, int y, int r, int color);                                   
00693     bool draw_ellipse(int x, int y, int rx, int ry, int color);                         
00694     bool plot(int x, int y, int color, int kind=CAM_POINT);                             
00695     int fill_color(int x, int y, int fillcolor, int tolerance=-1);                      
00696 
00697     bool scale(CamImage &dest) const;                                                   
00698     bool set_mask(const CamRLEImage &mask);                                             
00699     bool set_mask(const CamImage &mask);                                                
00700     bool apply_lut(const CamTable &lut);                                                
00701     bool apply_lut(CamImage &dest, const CamTable &lut) const;                          
00702 
00703     CamImage *to_yuv() const;                                                           
00704     bool to_yuv(CamImage &dest) const;                                                  
00705     CamImage *to_rgb() const;                                                           
00706     bool to_rgb(CamImage &dest) const;                                                  
00707 
00708     CamRLEImage* encode() const;                                                        
00709     CamRLEImage* encode_lut(const CamTable &LUT)  const;                                
00710     CamRLEImage* encode_threshold(int threshold) const;                                 
00711     CamRLEImage* encode_threshold_inv(int threshold) const;                             
00712     CamRLEImage* encode_color(const CamTable &clusters) const;                          
00713     bool encode(CamRLEImage& dest) const;                                               
00714     bool encode_lut(CamRLEImage& dest, const CamTable &LUT)  const;                     
00715     bool encode_threshold(CamRLEImage& dest, int threshold) const;                      
00716     bool encode_threshold_inv(CamRLEImage& dest, int threshold) const;                  
00717 
00718     int threshold(CamImage &dest,int threshold) const;                                  
00719     int threshold_inv(CamImage &dest,int threshold) const;                              
00720     int abs(CamImage &dest) const;                                                      
00721     int threshold(int threshold);                                                       
00722     int threshold_inv(int threshold);                                                   
00723     int abs();                                                                          
00724 
00725     int arithm(int operation, int c1=0, int c2=0, int c3=0);                            
00726     int arithm(CamImage& dest, int operation, int c1=0, int c2=0, int c3=0) const;      
00727     int arithm(const CamImage& source2, CamImage& dest, int operation, int c1=0, int c2=0, int c3=0, int c4=0) const; 
00728 
00729     CamMeasuresResults measures() const;                                                
00730     float average_deviation(int average=0) const;                                       
00731 
00732     bool sum_hv(CamTable& hsum, CamTable &vsum) const;                                  
00733     bool sum_h(CamTable& sum) const;                                                    
00734     bool sum_v(CamTable& sum) const;                                                    
00735 
00736     bool histogram(CamTable& histo) const;                                              
00737     bool histogram_2_channels(int ch1, int ch2, CamImage &result, int size=1) const;    
00738     int find_threshold(int percent) const;                                              
00739 
00740     int hough_circle(int percent, int rmin, int rmax, int &xc, int &yc, int &rc) const; 
00741 
00742     int hierarchical_watershed(CamImage &watershed, CamTableOfBasins &tob) const;       
00743     int hierarchical_watershed_contours(CamImage &ws, CamTableOfBasins &tob) const;     
00744     int hierarchical_watershed_regions(const CamTableOfBasins &tob);                    
00745 };
00746 
00747 inline CamROI::CamROI(const CamImage &image, int _coi) { coi=_coi; xOffset=0; yOffset=0; width=image.width; height=image.height; }
00748 
00749 #else
00750 } CamImage;
00751 #endif
00752 
00753 /* Camellia C functions headers
00754  */
00755 
00756 #ifndef SWIG
00757 
00758 #define CAM_PIXEL_ACCESS(ptr,y,x) \
00759     ((CAM_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
00760 
00761 #define CAM_MAX(a,b) (((a)>(b))?(a):(b))
00762 #define CAM_MIN(a,b) (((a)<(b))?(a):(b))
00763 
00767 #define CAM_RGBA(r,g,b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24))
00768 
00773 #define CAM_RGB(r,g,b) ((r)|((g)<<8)|((b)<<16))
00774 
00775 #endif // SWIG
00776 
00777 /* General purpose structures
00778  */
00779 
00781 typedef struct {
00782     int x; 
00783     int y; 
00784 } CamPoint;
00785 
00786 /* Monadic and Dyadic Arithmetic Operators kernel
00787  */
00788 
00789 #define CAM_ARITHM_ABS              0
00790 #define CAM_ARITHM_INVERSE          1
00791 #define CAM_ARITHM_SELECT           2
00792 #define CAM_ARITHM_THRESHOLD        3 
00793 #define CAM_ARITHM_DOUBLE_THRESHOLD 4
00794 
00795 #define CAM_ARITHM_ADD              0
00796 #define CAM_ARITHM_SUM              0
00797 #define CAM_ARITHM_SUB              1
00798 #define CAM_ARITHM_MUL              2
00799 #define CAM_ARITHM_ABSDIFF          3
00800 #define CAM_ARITHM_WEIGHTED_SUM     4
00801 #define CAM_ARITHM_INF              5
00802 #define CAM_ARITHM_SUP              6
00803 #define CAM_ARITHM_COMP_INF         7
00804 #define CAM_ARITHM_COMP_EQUAL       8
00805 #define CAM_ARITHM_COMP_SUP         9
00806 #define CAM_ARITHM_AND              10
00807 #define CAM_ARITHM_OR               11
00808 
00809 // Shorter constants
00810 #define CAM_ABS                     0
00811 #define CAM_INVERSE                 1
00812 #define CAM_SELECT                  2
00813 #define CAM_THRESHOLD               3 
00814 #define CAM_DOUBLE_THRESHOLD        4
00815 
00816 #define CAM_ADD                     0
00817 #define CAM_SUM                     0
00818 #define CAM_SUB                     1
00819 #define CAM_ABSDIFF                 2
00820 #define CAM_WEIGHTED_SUM            3
00821 #define CAM_INF                     4
00822 #define CAM_SUP                     5
00823 #define CAM_COMP_INF                6
00824 #define CAM_COMP_EQUAL              7
00825 #define CAM_COMP_SUP                8
00826 #define CAM_AND                     9
00827 #define CAM_OR                      10
00828 
00829 #ifndef SWIG
00830 
00832 
00835 typedef struct {
00836     int operation;   
00837     int c1; 
00838     int c2; 
00839     int c3; 
00840     int c4; 
00841 } CamArithmParams;
00842 
00843 #endif // SWIG
00844 
00845 #ifdef __cplusplus
00846 extern "C" {
00847 #endif
00848 
00849 #ifndef SWIG
00850 
00852 
00876 int camMonadicArithm(CamImage *source, CamImage *dest, CamArithmParams *params);
00877 
00879 
00918 int camDyadicArithm(CamImage *source1, CamImage *source2, CamImage *dest, CamArithmParams *params);
00919 
00921 
00923 int camThreshold(CamImage *source, CamImage *dest, int threshold);
00924 
00926 
00928 int camThresholdInv(CamImage *source, CamImage *dest, int threshold);
00929 
00931 int camAbs(CamImage *source, CamImage *dest);
00932 
00933 /* Apply-a-LUT-on-image Kernel
00934  */
00935 
00936 // 12 bits maximum LUT management
00937 #define CAM_TABLE_SIZE 4096
00938 
00939 #define CamLUT CamTable
00940 #define CamHisto CamTable
00941 
00942 #ifdef __cplusplus
00943 
00944 struct CamTable {
00945 #else
00946 
00947 typedef struct {
00948 #endif
00949     int t[CAM_TABLE_SIZE]; 
00950     int size;              
00951 #ifdef __cplusplus    
00952     CamTable(int s=0) {size=s;}
00953     int &operator[](int n);
00954     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;} 
00955 };
00956 #else
00957 } CamTable;
00958 #endif
00959 
00961 int camApplyLUT(CamImage *source, CamImage *dest, CamTable *LUT);
00962 
00963 #endif // SWIG
00964 
00965 /* Fundamental Morphological Mathematics Algorithms' kernel
00966  */
00967 #define CAM_MM_NEIGHB           7
00968 
00969 #define CAM_MM_DILATED          0
00970 #define CAM_MM_ERODED           1
00971 #define CAM_MM_ORIGINAL         2
00972 
00973 #define CAM_MM_SUBSTRACTION     0
00974 #define CAM_MM_MULTIPLEX        1
00975 #define CAM_MM_THINNING         2
00976 #define CAM_MM_THICKENING       3
00977 
00979 
00982 #ifdef __cplusplus
00983 struct CamMorphoMathsKernel {
00984 #else
00985 typedef struct {
00986 #endif
00987     // Structural elements
00988 #ifndef SWIG
00989     int dilationStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; 
00990     int erosionStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB];  
00991 #endif
00992     int source1;            
00993     int source2;            
00994     int operation;          
00995 #ifdef __cplusplus
00996 
00997     CamMorphoMathsKernel() {
00998         for (int i=0;i<CAM_MM_NEIGHB;i++) {
00999             for (int j=0;j<CAM_MM_NEIGHB;j++) {
01000                 dilationStructElt[i][j]=0;
01001                 erosionStructElt[i][j]=0;
01002             }
01003         }
01004         source1=CAM_MM_ORIGINAL;
01005         source2=CAM_MM_ORIGINAL;
01006         operation=CAM_MM_MULTIPLEX;
01007     }       
01009     bool set_dilate(int x, int y, int val) {
01010         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
01011             dilationStructElt[x][y]=val; return true;
01012         } else return false;
01013     }
01015     int get_dilate(int x,int y) {
01016         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
01017             return dilationStructElt[x][y];
01018         } else return 0;
01019     }
01021     bool set_erode(int x, int y, int val) {
01022         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
01023             erosionStructElt[x][y]=val; return true;
01024         } else return false;
01025     }
01027     int get_erode(int x,int y) {
01028         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
01029             return erosionStructElt[x][y];
01030         } else return 0;
01031     }
01032 };
01033 #else
01034 } CamMorphoMathsKernel;
01035 #endif
01036 
01037 #ifndef SWIG
01038 
01043 
01045 
01057 int camMorphoMaths(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel);
01058 
01059 // These are specific functions able to compute only erosion or dilation, on 3x3, 5x5 or 7x7 neighbourhood
01060 
01069 int camErode3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01070 
01079 int camErode5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01080 
01089 int camErode7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01090 
01099 int camDilate3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01100 
01109 int camDilate5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01110 
01119 int camDilate7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
01120 
01132 int camMorphoGradientCircle5(CamImage *source, CamImage *dest); 
01133 
01143 int camErodeCircle5(CamImage *source, CamImage *dest); 
01144 
01154 int camDilateCircle5(CamImage *source, CamImage *dest);  
01155 
01167 int camMorphoGradientCircle7(CamImage *source, CamImage *dest); 
01168 
01178 int camErodeCircle7(CamImage *source, CamImage *dest); 
01179 
01189 int camDilateCircle7(CamImage *source, CamImage *dest);  
01190 
01202 int camMorphoGradientSquare3(CamImage *source, CamImage *dest); 
01203 
01213 int camErodeSquare3(CamImage *source, CamImage *dest); 
01214 
01224 int camDilateSquare3(CamImage *source, CamImage *dest); 
01225 
01226 
01227 /* Labeling kernel
01228  */
01229 #define CamLabellingResults CamLabelingResults
01230 #define camLabelling camLabeling
01231 #define camLabelling2ndScan camLabeling2ndScan
01232 #define camRLELabelling camRLELabeling
01233 
01234 #define CAM_LABEL_MAX_BLOBS 1024
01235 #define CAM_LABEL_PIXEL unsigned short
01236 
01237 #define CAM_LABEL_PIXEL_ACCESS(ptr,y,x) \
01238     ((CAM_LABEL_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
01239 
01241 typedef struct {
01242     int nbLabels;                   
01243     int equiv[CAM_LABEL_MAX_BLOBS]; 
01244 } CamLabelingResults;
01245 
01247 
01260 int camLabeling(CamImage *source, CamImage *dest, CamLabelingResults *results); 
01261                                                                                   
01266 int camLabeling2ndScan(CamImage *image, CamLabelingResults *results); 
01267 
01268 /* Blob analysis Kernel
01269  * C code */
01270 
01271 #endif // SWIG
01272 
01273 #define CAM_RLE_INT_TYPE unsigned short
01274 
01276 
01278 typedef struct {
01279     CAM_RLE_INT_TYPE value;     
01280     CAM_RLE_INT_TYPE length;    
01281     CAM_RLE_INT_TYPE blob;      
01282     CAM_RLE_INT_TYPE line;      
01283 } CamRun;
01284 
01285 #ifndef SWIG
01286 
01288 typedef struct {
01289     int id;
01290     int left;           
01291     int top;            
01292     int width;          
01293     int height;         
01294     int surface;        
01295     int cx;             
01296     int cy;             
01297     int value;          
01298     int min;            
01299     int max;            
01300     CamRun *first;      
01301     CamRun *last;       
01302     void *misc;         
01303 } CamBlobInfo;
01304 
01305 #define CamBlobAnalysisResults CamBlobs // For compatibility with previous versions
01306 
01307 #ifdef __cplusplus
01308 
01309 struct CamBlobs {
01310     int nbBlobs;                                
01311     CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS];  
01312     CamBlobs() {nbBlobs=0;}                     
01313     CamBlobInfo& operator[](int index);
01314 };
01315 #else
01316 
01317 typedef struct {
01318     int nbBlobs;                                
01319     CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS];  
01320 } CamBlobs;
01321 #endif
01322 
01337 int camBlobAnalysis1stScan(CamImage *blobImage, CamImage *original, CamLabelingResults *info, CamBlobs *results); 
01338 
01340 
01349 int camBlobAnalysisRefinement(CamImage *blobImage, CamImage *original, CamBlobs *results);
01350 
01351 /* RLE Labeling kernel
01352  * New : v1.4 of LLAs
01353  * Updated v1.6 and v1.9, v2.0 of LLAs
01354  */
01355 
01359 
01360 #ifdef __cplusplus
01361 
01362 struct CamRLEImage {
01363 #else
01364 
01365 typedef struct {
01366 #endif
01367     int nSize;                  
01368     int id;                     
01369     int height;                 
01370     int width;                  
01371     int nbRuns;                 
01372     int allocated;              
01373     CamRun *runs;               
01374 
01375 #ifdef __cplusplus
01376     CamRLEImage() {allocated=0; runs=NULL; nbRuns=0;}   
01377     CamRLEImage(int nbruns);                            
01378     CamRLEImage(const CamRLEImage &image);              
01379     ~CamRLEImage();                                     
01380 
01381     CamRLEImage& operator=(const CamRLEImage &image);   
01382     CamRLEImage* clone() const;                         
01383     bool alloc(int nbruns);                             
01384     bool realloc(int nbruns);                           
01385 
01386     bool encode(const CamImage &image);                             
01387     bool encode_lut(const CamImage &image, const CamTable &LUT);    
01388     bool encode_threshold(const CamImage &image, int threshold);    
01389     bool encode_threshold_inv(const CamImage &image, int threshold);
01390     bool encode_color(const CamImage &image, const CamTable &clusters); 
01391     CamBlobs* labeling();                                           
01392     bool labeling(CamBlobs &results);                               
01393     bool blob_analysis(CamBlobs &results) const;                    
01394     bool apply_lut(const CamTable &LUT);                            
01395     bool apply_lut(CamRLEImage &dest, const CamTable &LUT) const;   
01396     bool decode(CamImage &dest) const;                              
01397     bool decode(CamImage &dest, const CamTable &LUT) const;         
01398     bool decode_blobs(CamImage &dest) const;                        
01399     bool decode_blobs(CamImage &dest, const CamTable &LUT) const;   
01400     bool inverse();                                                 
01401     bool erode_cross(CamRLEImage &dest) const;                      
01402     CamRLEImage *erode_cross() const;                               
01403     bool erode_3x3(CamRLEImage &dest) const;                        
01404     CamRLEImage *erode_3x3() const;                                 
01405     bool erode_3x2(CamRLEImage &dest) const;                        
01406     CamRLEImage *erode_3x2() const;                                 
01407 };
01408 #else
01409 } CamRLEImage;
01410 #endif
01411 
01413 
01434 int camRLEAllocate(CamRLEImage *rle, int max_runs);
01435 
01437 
01445 int camRLEDeallocate(CamRLEImage *rle);
01446 
01448 
01457 int camRLEReallocate(CamRLEImage *rle, int new_max_runs);
01458 
01460 
01468 int camRLEClone(CamRLEImage *source, CamRLEImage *dest);
01469 
01471 
01481 int camRLEEncode(CamImage *src, CamRLEImage *dest);
01482 
01484 
01494 int camRLEEncodeLUT(CamImage *src, CamRLEImage *dest, CamTable *LUT);
01495 
01497 
01505 int camRLEEncodeThreshold(CamImage *src, CamRLEImage *dest, int threshold);
01506 
01508 
01516 int camRLEEncodeThresholdInv(CamImage *src, CamRLEImage *dest, int threshold);
01517 
01518 int camRLEEncodeColor(CamImage *source, CamRLEImage *dest, CamTable *clusters);
01519 
01521 
01545 int camRLELabeling(CamRLEImage *src, CamBlobs *results);
01546 
01548 
01555 int camRLEBlobAnalysis(CamRLEImage *src, CamBlobs *results);
01556 
01558 
01568 int camRLEApplyLUT(CamRLEImage *src, CamRLEImage *dest, CamTable *LUT);
01569 
01571 
01582 int camRLEDecode(CamRLEImage *src, CamImage *dest, CamTable *LUT);
01583 
01585 
01596 int camRLEDecodeBlobs(CamRLEImage *src, CamImage *dest, CamTable *LUT);
01597 
01599 
01603 int camRLEInverse(CamRLEImage *image);
01604 
01606 int camRLEBlobSides(CamBlobInfo *blob, int *left, int *top, int *right, int *bottom);
01607 
01609 int camRLEBlobROIIntersect(CamBlobInfo *blob, CamROI *roi);
01610 
01612 int camRLEBlobMeasures(CamBlobInfo *blob, CamImage *original);
01613 
01615 
01620 int camRLEErodeCross(CamRLEImage *image, CamRLEImage *result);
01621 
01623 
01628 int camRLEErode3x3(CamRLEImage *image, CamRLEImage *result);
01629 
01631 
01636 int camRLEErode3x2(CamRLEImage *image, CamRLEImage *result);
01637 
01639 
01643 
01645 
01655 int camHistogram(CamImage *image, CamTable *histo);
01656 
01658 
01667 int camHistogram2Channels(CamImage *image, int ch1, int ch2, CamImage *result, int size);
01668 
01670 int camFindThreshold(CamTable *histo, int percent);
01672 
01673 /* Horizontal and vertical summing
01674  */
01675 
01677 
01685 int camSumHV(CamImage *image, CamTable *hsum, CamTable *vsum);
01686 
01688 
01695 int camSumV(CamImage *image, CamTable *results);
01696 
01698 
01705 int camSumH(CamImage *image, CamTable *results);
01706 
01707 #endif // SWIG
01708 
01709 /* Measures in an image : min, max, average computation
01710  */
01711 #ifdef __cplusplus
01712 
01713 struct CamMeasuresResults {
01714 #else
01715 
01716 typedef struct {
01717 #endif
01718     int min, xmin, ymin;        
01719     int max, xmax, ymax;        
01720     int average;                
01721     int sum;                    
01722 #ifdef __cplusplus
01723     CamMeasuresResults() {min=0;xmin=0;ymin=0;max=0;xmax=0;ymax=0;average=0;sum=0;}
01724 };
01725 #else
01726 } CamMeasuresResults;
01727 #endif
01728 
01729 #ifndef SWIG
01730 
01732 
01738 int camMeasures(CamImage *image, CamMeasuresResults *results);
01739 
01741 
01749 float camMeasureAverageDeviation(CamImage *image, int average);
01750 
01754 
01756 
01764 #ifdef CAM_VOLBERG_ORIGINAL
01765 void volbergfvd(double f[], int in[] , int out[] , int inlen, int outlen);
01766 #else
01767 void camVolbergFwdScanline(CAM_PIXEL *in, int inlen, CAM_PIXEL *out, int outlen, double f[]);
01768 #endif
01769 
01771 typedef struct {
01772     void (*hfwd)(int x, int y, double *xp); 
01773     void (*vfwd)(int x, int y, double *yp); 
01774 } CamVolbergFwdParams;
01775 
01777 
01782 void camVolbergFwd(CamImage *source, CamImage *dest, CamVolbergFwdParams *params);
01783 
01784 /* Backward warping
01785  */
01786 
01787 #define CAM_NN_INTERPOLATION 0
01788 #define CAM_BILINEAR_INTERPOLATION 1
01789 
01791 typedef struct {
01792     int interpolation;  
01793     int perspective;    
01794     
01796 
01804     CamPoint p[4];
01805 } CamWarpingParams;
01806 
01808 
01817 int camWarping(CamImage *source, CamImage *dest, CamWarpingParams *params);
01818 
01820 
01826 int camScale(CamImage *source, CamImage *dest);
01827 
01828 int camWarpingSuperSampling(CamImage *source, CamImage *dest, CamWarpingParams *params);
01829 
01831 
01837 int camIntersectionSegments(CamPoint p[4], CamPoint *res);
01839 
01843 
01844 // For compatibility with older versions
01845 #define CamSobel3x3 camSobel
01846 #define CamSobelAbs3x3 camSobelAbs
01847 
01848 #define CAM_LINEAR_FILTER_KERNEL_MAX_SIZE 7
01849 
01850 #endif //SWIG
01851 
01852 #ifdef __cplusplus
01853 
01854 struct CamLinearFilterKernel {
01855 #else
01856 
01857 typedef struct {
01858 #endif
01859 #ifndef SWIG
01860     int kernel[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE][CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01861 #endif
01862     int coeff1;         
01863     int coeff2;         
01864 #ifdef __cplusplus
01865 
01866     CamLinearFilterKernel() {
01867         for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
01868             for (int j=0;j<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;j++) {
01869                 kernel[i][j]=0;
01870             }
01871         }
01872         coeff1=1;
01873         coeff2=0;
01874     }       
01876     bool set(int x, int y, int val) {
01877         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01878             kernel[x][y]=val; return true;
01879         } else return false;
01880     }
01882     int get(int x,int y) {
01883         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01884             return kernel[x][y];
01885         } else return 0;
01886     }
01887 };
01888 #else
01889 } CamLinearFilterKernel;
01890 #endif
01891 
01892 #ifndef SWIG
01893 
01895 
01906 int camLinearFilter3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01907 
01909 
01920 int camLinearFilter5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01921 
01923 
01934 int camLinearFilterAbs3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01935 
01937 
01948 int camLinearFilterAbs5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01949 
01950 /* Obsolete
01951  * int camSobel(CamImage *source, CamImage *dest, int vert_edges);
01952  * int camSobelAbs(CamImage *source, CamImage *dest, int vert_edges);
01953  */
01954 
01955 #endif //SWIG
01956 
01957 #ifdef __cplusplus
01958 
01959 struct CamSepFilterKernel {
01960 #else
01961 
01962 typedef struct {
01963 #endif
01964 #ifndef SWIG
01965     int x[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01966     int y[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01967 #endif
01968     int coeff1;         
01969     int coeff2;         
01970 #ifdef __cplusplus
01971 
01972     CamSepFilterKernel() {
01973         for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
01974             x[i]=0; y[i]=0;
01975         }
01976         coeff1=1;
01977         coeff2=0;
01978     }       
01980     bool set_x(int y, int val) {
01981         if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01982             x[y]=val; return true;
01983         } else return false;
01984     }
01985     bool set_y(int x, int val) {
01986         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01987             y[x]=val; return true;
01988         } else return false;
01989     }
01991     int get_x(int y) {
01992         if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01993             return x[y];
01994         } else return 0;
01995     }
01996     int get_y(int x) {
01997         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01998             return y[x];
01999         } else return 0;
02000     }
02001 };
02002 #else
02003 } CamSepFilterKernel;
02004 #endif
02005 
02006 #define CAM_SOBEL_H         1
02007 #define CAM_SOBEL_V         2
02008 #define CAM_GAUSSIAN_3x3    3
02009 #define CAM_GAUSSIAN_5x5    4
02010 #define CAM_GAUSSIAN_7x7    5
02011 #define CAM_SCHARR_H        6
02012 #define CAM_SCHARR_V        7
02013 
02014 #ifndef SWIG
02015 
02017 
02027 int camSepFilter3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02028 
02030 
02040 int camSepFilterAbs3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02041 
02043 
02053 int camSepFilter5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02054 
02056 
02066 int camSepFilterAbs5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02067 
02069 
02079 int camSepFilter7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02080 
02082 
02092 int camSepFilterAbs7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
02093 
02095 
02104 int camSobelH(CamImage *source, CamImage *dest);
02105 
02107 
02116 int camSobelHAbs(CamImage *source, CamImage *dest);
02117 
02119 
02128 int camSobelV(CamImage *source, CamImage *dest);
02129 
02131 
02140 int camSobelVAbs(CamImage *source, CamImage *dest);
02141 
02143 
02162 int camFixedFilter(CamImage *source, CamImage *dest, int filter);
02163 
02164 int camScharrH(CamImage *source, CamImage *dest);
02165 int camScharrV(CamImage *source, CamImage *dest);
02166 int camScharrHAbs(CamImage *source, CamImage *dest);
02167 int camScharrVAbs(CamImage *source, CamImage *dest);
02168 
02170 
02174 
02175 #define camMedianFiltering3x3 camMedianFilter3x3
02176 #define camMedianFiltering5x5 camMedianFilter5x5
02177 
02179 
02188 int camMedianFilter3x3(CamImage *source, CamImage *dest);
02189 
02191 
02200 int camMedianFilter5x5(CamImage *source, CamImage *dest);
02202 
02206 
02208 
02225 int camWatershed1D(int *input, int size, int *results);
02226 #else
02227 %immutable;
02228 #endif // SWIG
02229 
02231 typedef struct 
02232 {
02233    int dynamics;        
02234    int minimum;         
02235    int flooded;         
02236    int surface;         
02237    int accsurface;      
02238    unsigned short x,y;  
02239 } CamBasin;
02240 
02241 #define CAM_NOT_COMPUTED 65536
02242 
02243 #ifndef SWIG
02244 #ifdef __cplusplus
02245 
02246 struct CamTableOfBasins {
02247     int sizeMax;
02248     int nbBasins;
02249     CamBasin *tab;
02250     CamBasin& operator[](int index) {return tab[index];}
02251     void get_rid_of(CamBasin &basin) {basin.surface=0;}
02252     CamTableOfBasins() {tab=NULL;sizeMax=0;nbBasins=0;}
02253     ~CamTableOfBasins();
02254 };
02255 #else
02256 typedef struct
02257 {
02258    int sizeMax;
02259    int nbBasins;
02260    CamBasin *tab;
02261 } CamTableOfBasins;
02262 #endif
02263 
02265 void camFreeTableOfBasins(CamTableOfBasins *t);
02266 
02268 
02284 int camHierarchicalWatershed(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
02285 
02287 
02304 int camHierarchicalWatershedContours(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
02305 
02307 
02313 int camHierarchicalWatershedRegions(CamImage *watershed, CamTableOfBasins *tob);
02315 
02319 
02321 
02333 int camHoughCircle(CamImage *image, int percent, int rmin, int rmax, int *xc, int *yc, int *rc);
02334 
02338 
02339 /* Image allocation utility routines
02340  */
02341 
02343 int camAllocateImage(CamImage *image, int width, int height, int depth);
02345 int camAllocateYUVImage(CamImage *image, int width, int height);
02347 int camAllocateRGBImage(CamImage *image, int width, int height);
02349 int camAllocateRGBAImage(CamImage *image, int width, int height);
02351 int camDeallocateImage(CamImage *image);
02352 
02353 /* Other useful functions
02354  */
02356 int camSetROI(CamROI *roi, int coi, int xOffset, int yOffset, int width, int height);
02358 int camSetMaxROI(CamROI *roi, CamImage *image);
02360 int camReduceROI(CamROI *roi, int pixels);
02362 int camEnlargeROI(CamROI *roi, int pixels);
02364 int camZoom2x(CamImage *src, CamImage *dst);
02366 int camDecimateNN(CamImage *src, CamImage *dest, int factor);
02368 int camSetRLEMask(CamImage *image, CamRLEImage *mask);
02370 int camSetMask(CamImage *image, CamImage *mask);
02371 
02372 #define camDownScaling2x2 camDownscaling2x2
02373 
02374 int camDownScaling2x2(CamImage *src, CamImage *dest);
02376 
02380 int camCopy(CamImage *source, CamImage *dest);
02382 
02385 int camClone(CamImage *source, CamImage *dest);
02387 
02390 int camRefCopy(CamImage *source, CamImage *dest);
02392 int camSet(CamImage *image, int fillValue);
02394 
02398 int camAlphaComposite(CamImage *source1, CamImage *source2, CamImage *dest);
02399 
02401 int camSetBorder(CamImage *image, int borderValue);
02403 int camClipROI(CamImage *image);
02405 int camClip(CamROI *roi, CamImage *image);
02407 int camROIIntersect(CamROI *roi1, CamROI *roi2, CamROI *dest);
02408 
02409 #endif //SWIG
02410 int camSetImageViewer(char *s);
02411 #ifndef SWIG
02412 
02414 int camView(CamImage *image);
02416 const char *camVersion();
02417 
02418 /* Drawing functions
02419  */
02421 int camDrawLine(CamImage *image, int x1, int y1, int x2, int y2, int color);
02423 int camAccumulateLine(CamImage *image, int x1, int y1, int x2, int y2, int acc);
02425 int camDrawRectangle(CamImage *image, int x1, int y1, int x2, int y2, int color);
02427 int camDrawText16s(CamImage *image, char *text, int x, int y, int cwidth, int cheight, int orientation, int color);
02429 int camDrawCircle(CamImage *image, int x, int y, int r, int color);
02431 int camDrawEllipse(CamImage *image, int x, int y, int rx, int ry, int color);
02433 
02435 int camPlot(CamImage *image, int x, int y, int color, int kind);
02437 
02448 int camFillColor(CamImage *image, int x, int y, int fillcolor, int tolerance);
02449 
02450 #endif // SWIG
02451 
02452 #ifdef __cplusplus
02453 
02454 struct CamBitmapFont {
02455 #else
02456 typedef struct {
02457 #endif
02458     int first_char;
02459     int nb_chars;
02460     int height;
02461     CamRLEImage *masks;
02462     CamImage *letters;
02463 #ifdef __cplusplus
02464     CamBitmapFont() {first_char=33; nb_chars=0; masks=NULL; letters=NULL;}
02465     CamBitmapFont(const char *filename);
02466     ~CamBitmapFont();
02467     bool load(const char *filename);
02468 };
02469 #else
02470 } CamBitmapFont;
02471 #endif
02472 
02473 #ifndef SWIG
02474 
02475 int camBitmapFontLoad(CamBitmapFont *font, char *filename);
02477 int camBitmapFontDeallocate(CamBitmapFont *font);
02479 int camDrawTextBitmap(CamImage *image, char *text, int x, int y, CamBitmapFont *font);
02480 #endif // SWIG
02481 
02483 
02485 int camRGB(int r, int g, int b);
02486 
02488 int camRGBA(int r, int g, int b, int a);
02489 
02490 #ifndef SWIG
02491 
02492 /* Load and save PGM images
02493  */
02495 int camLoadPGM(CamImage *image, char *fn);
02497 int camSavePGM(CamImage *image, char *filename);
02498 
02499 /* Load and save BMP images
02500  */
02502 int camLoadBMP(CamImage *image, char *fn);
02504 int camSaveBMP(CamImage *image, char *filename);
02505 
02506 /* Load config files
02507  */
02508 #define CAM_CONFIG_MAX_ENTRIES 256
02509 typedef struct {
02510     int nbEntries;
02511     char parameter[CAM_CONFIG_MAX_ENTRIES][128];
02512     char value[CAM_CONFIG_MAX_ENTRIES][128];
02513 } CamConfig;
02514 
02515 int camLoadConfig(const char *filename, CamConfig *config);
02516 int camConfigInt(const CamConfig *config, const char *entry);
02517 float camConfigFloat(const CamConfig *config, const char *entry);
02518 const char *camConfigString(const CamConfig *config, const char *entry);
02519 
02521 void camError(char *module, char *error);
02522 typedef void (*camErrorFunct)(char *,char*);
02523 void camSetErrorFunct(camErrorFunct funct);
02525 
02529 int camYUV2RGB(CamImage* source, CamImage *dest); 
02530 int camRGB2YUV(CamImage* source, CamImage *dest); 
02531 int camRGB2Y(CamImage *source, CamImage *dest);   
02532 
02533 
02537 /*
02538  * Computes the Sum of Absolute Values between two 8x8 blocks
02539  *
02540  * This function takes into account the blocks lying partially outside the image.
02541  * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
02542  *
02543  *
02544  * \param image1    Current image
02545  * \param image2    Previous image
02546  * \param bleft     The x coordinate of the current block
02547  * \param btop      The y coordinate of the current block
02548  * \param dx        The x offset to reach the candidate block
02549  * \param dy        The y offset to reach the candidate block
02550  *
02551  * \return The SAD value between the given two blocks
02552  */
02553 int camSAD8x8(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
02554 
02555 /*
02556  * Computes the Sum of Absolute Values between two 16x16 blocks
02557  *
02558  * This function takes into account the blocks lying partially outside the image.
02559  * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
02560  *
02561  *
02562  * \param image1    Current image
02563  * \param image2    Previous image
02564  * \param bleft     The x coordinate of the current block
02565  * \param btop      The y coordinate of the current block
02566  * \param dx        The x offset to reach the candidate block
02567  * \param dy        The y offset to reach the candidate block
02568  *
02569  * \return The SAD value between the given two blocks
02570  */
02571 int camSAD16x16(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
02572 
02573 typedef struct {
02574     int niter;          
02575     int seed;           
02576     int lsearch;        
02577     int rsearch;        
02578     int blockSize;      
02579     int scans;          
02580     int candidates;     
02581     int test0;          
02582 } CamMotionEstimation3DRSParams;
02583 
02584 typedef struct {
02585     int vx[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];   
02586     int vy[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];   
02587     int SAD[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];  
02588 } CamMotionEstimation3DRSResults;
02589 
02590 int camMotionEstimation3DRSInit(CamMotionEstimation3DRSParams *params, int seed, int lsearch, int rsearch, int bs, int scans, int candidates, int test0);
02591 int camMotionEstimation3DRS(CamImage *current, CamImage *previous, CamMotionEstimation3DRSParams *params, CamMotionEstimation3DRSResults *results);
02593 
02597 
02598 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);
02599 
02600 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);
02601 
02602 int camUndistort(CamImage *source, CamImage *dest,
02603                  const float* intrinsic_matrix,
02604                  const float* dist_coeffs);
02605 int camUndistortFixed(CamImage *source, CamImage *dest,
02606                       const CAM_FIXED_POINT* intrinsic_matrix,
02607                       const CAM_FIXED_POINT* dist_coeffs);
02608 int camUndistortBuildLUT(CamImage *source,
02609                          const float* intrinsic_matrix,
02610                          const float* dist_coeffs,
02611                          CamImage *LUTX, CamImage *LUTY);
02612 int camUndistortLUT(CamImage *source, CamImage *dest,
02613                     CamImage *LUTX, CamImage *LUTY);
02614 
02616 
02617 #endif // SWIG
02618 
02619 #ifdef __cplusplus
02620 }
02621 #endif
02622 
02623 #endif
02624 

Generated on Wed Aug 2 14:00:17 2006 for Camellia by  doxygen 1.4.6