cxmisc.h
上传用户:soukeisyuu
上传日期:2022-07-03
资源大小:5943k
文件大小:27k
源码类别:

波变换

开发平台:

Visual C++

  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. //  By downloading, copying, installing or using the software you agree to this license.
  6. //  If you do not agree to this license, do not download, install,
  7. //  copy or use the software.
  8. //
  9. //
  10. //                           License Agreement
  11. //                For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. //   * Redistribution's of source code must retain the above copyright notice,
  21. //     this list of conditions and the following disclaimer.
  22. //
  23. //   * Redistribution's in binary form must reproduce the above copyright notice,
  24. //     this list of conditions and the following disclaimer in the documentation
  25. //     and/or other materials provided with the distribution.
  26. //
  27. //   * The name of the copyright holders may not be used to endorse or promote products
  28. //     derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. /* The header is mostly for internal use and it is likely to change.
  43.    It contains some macro definitions that are used in cxcore, cv, cvaux
  44.    and, probably, other libraries. If you need some of this functionality,
  45.    the safe way is to copy it into your code and rename the macros.
  46. */
  47. #ifndef _CXCORE_MISC_H_
  48. #define _CXCORE_MISC_H_
  49. #ifdef HAVE_CONFIG_H
  50.     #include "cvconfig.h"
  51. #endif
  52. #include <limits.h>
  53. #ifdef _OPENMP
  54. #include "omp.h"
  55. #endif
  56. /****************************************************************************************
  57. *                              Compile-time tuning parameters                            *
  58. ****************************************************************************************/
  59. /* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */
  60. #define  CV_MAX_INLINE_MAT_OP_SIZE  10
  61. /* maximal linear size of matrix to allocate it on stack. */
  62. #define  CV_MAX_LOCAL_MAT_SIZE  32
  63. /* maximal size of local memory storage */
  64. #define  CV_MAX_LOCAL_SIZE  
  65.     (CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double))
  66. /* default image row align (in bytes) */
  67. #define  CV_DEFAULT_IMAGE_ROW_ALIGN  4
  68. /* matrices are continuous by default */
  69. #define  CV_DEFAULT_MAT_ROW_ALIGN  1
  70. /* maximum size of dynamic memory buffer.
  71.    cvAlloc reports an error if a larger block is requested. */
  72. #define  CV_MAX_ALLOC_SIZE    (((size_t)1 << (sizeof(size_t)*8-2)))
  73. /* the alignment of all the allocated buffers */
  74. #define  CV_MALLOC_ALIGN    16
  75. /* default alignment for dynamic data strucutures, resided in storages. */
  76. #define  CV_STRUCT_ALIGN    ((int)sizeof(double))
  77. /* default storage block size */
  78. #define  CV_STORAGE_BLOCK_SIZE   ((1<<16) - 128)
  79. /* default memory block for sparse array elements */
  80. #define  CV_SPARSE_MAT_BLOCK    (1<<12)
  81. /* initial hash table size */
  82. #define  CV_SPARSE_HASH_SIZE0    (1<<10)
  83. /* maximal average node_count/hash_size ratio beyond which hash table is resized */
  84. #define  CV_SPARSE_HASH_RATIO    3
  85. /* max length of strings */
  86. #define  CV_MAX_STRLEN  1024
  87. /* maximum possible number of threads in parallel implementations */
  88. #ifdef _OPENMP
  89. #define CV_MAX_THREADS 128
  90. #else
  91. #define CV_MAX_THREADS 1
  92. #endif
  93. #if 0 /*def  CV_CHECK_FOR_NANS*/
  94.     #define CV_CHECK_NANS( arr ) cvCheckArray((arr))
  95. #else
  96.     #define CV_CHECK_NANS( arr )
  97. #endif
  98. /****************************************************************************************
  99. *                                  Common declarations                                   *
  100. ****************************************************************************************/
  101. /* get alloca declaration */
  102. #ifdef __GNUC__
  103.     #undef alloca
  104.     #define alloca __builtin_alloca
  105. #elif defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64 || 
  106.       defined WINCE || defined _MSC_VER || defined __BORLANDC__
  107.     #include <malloc.h>
  108. #elif defined HAVE_ALLOCA_H
  109.     #include <alloca.h>
  110. #elif defined HAVE_ALLOCA
  111.     #include <stdlib.h>
  112. #else
  113.     #error "No alloca!"
  114. #endif
  115. #ifdef __GNUC__
  116. #define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
  117. #elif defined _MSC_VER
  118. #define CV_DECL_ALIGNED(x) __declspec(align(x))
  119. #else
  120. #define CV_DECL_ALIGNED(x)
  121. #endif
  122. /* ! DO NOT make it an inline function */
  123. #define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )
  124. #if defined _MSC_VER || defined __BORLANDC__
  125.     #define CV_BIG_INT(n)   n##I64
  126.     #define CV_BIG_UINT(n)  n##UI64
  127. #else
  128.     #define CV_BIG_INT(n)   n##LL
  129.     #define CV_BIG_UINT(n)  n##ULL
  130. #endif
  131. #define CV_IMPL CV_EXTERN_C
  132. #define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; }
  133. /* default step, set in case of continuous data
  134.    to work around checks for valid step in some ipp functions */
  135. #define  CV_STUB_STEP     (1 << 30)
  136. #define  CV_SIZEOF_FLOAT ((int)sizeof(float))
  137. #define  CV_SIZEOF_SHORT ((int)sizeof(short))
  138. #define  CV_ORIGIN_TL  0
  139. #define  CV_ORIGIN_BL  1
  140. /* IEEE754 constants and macros */
  141. #define  CV_POS_INF       0x7f800000
  142. #define  CV_NEG_INF       0x807fffff /* CV_TOGGLE_FLT(0xff800000) */
  143. #define  CV_1F            0x3f800000
  144. #define  CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
  145. #define  CV_TOGGLE_DBL(x) 
  146.     ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
  147. #define  CV_NOP(a)      (a)
  148. #define  CV_ADD(a, b)   ((a) + (b))
  149. #define  CV_SUB(a, b)   ((a) - (b))
  150. #define  CV_MUL(a, b)   ((a) * (b))
  151. #define  CV_AND(a, b)   ((a) & (b))
  152. #define  CV_OR(a, b)    ((a) | (b))
  153. #define  CV_XOR(a, b)   ((a) ^ (b))
  154. #define  CV_ANDN(a, b)  (~(a) & (b))
  155. #define  CV_ORN(a, b)   (~(a) | (b))
  156. #define  CV_SQR(a)      ((a) * (a))
  157. #define  CV_LT(a, b)    ((a) < (b))
  158. #define  CV_LE(a, b)    ((a) <= (b))
  159. #define  CV_EQ(a, b)    ((a) == (b))
  160. #define  CV_NE(a, b)    ((a) != (b))
  161. #define  CV_GT(a, b)    ((a) > (b))
  162. #define  CV_GE(a, b)    ((a) >= (b))
  163. #define  CV_NONZERO(a)      ((a) != 0)
  164. #define  CV_NONZERO_FLT(a)  (((a)+(a)) != 0)
  165. /* general-purpose saturation macros */
  166. #define  CV_CAST_8U(t)  (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0)
  167. #define  CV_CAST_8S(t)  (schar)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128)
  168. #define  CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0)
  169. #define  CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768)
  170. #define  CV_CAST_32S(t) (int)(t)
  171. #define  CV_CAST_64S(t) (int64)(t)
  172. #define  CV_CAST_32F(t) (float)(t)
  173. #define  CV_CAST_64F(t) (double)(t)
  174. #define  CV_PASTE2(a,b) a##b
  175. #define  CV_PASTE(a,b)  CV_PASTE2(a,b)
  176. #define  CV_EMPTY
  177. #define  CV_MAKE_STR(a) #a
  178. #define  CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x)))
  179. #define  CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0])))
  180. #define  cvUnsupportedFormat "Unsupported format"
  181. CV_INLINE void* cvAlignPtr( const void* ptr, int align CV_DEFAULT(32) )
  182. {
  183.     assert( (align & (align-1)) == 0 );
  184.     return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
  185. }
  186. CV_INLINE int cvAlign( int size, int align )
  187. {
  188.     assert( (align & (align-1)) == 0 && size < INT_MAX );
  189.     return (size + align - 1) & -align;
  190. }
  191. CV_INLINE  CvSize  cvGetMatSize( const CvMat* mat )
  192. {
  193.     CvSize size;
  194.     size.width = mat->cols;
  195.     size.height = mat->rows;
  196.     return size;
  197. }
  198. #define  CV_DESCALE(x,n)     (((x) + (1 << ((n)-1))) >> (n))
  199. #define  CV_FLT_TO_FIX(x,n)  cvRound((x)*(1<<(n)))
  200. /****************************************************************************************
  201.   Generic implementation of QuickSort algorithm.
  202.   ----------------------------------------------
  203.   Using this macro user can declare customized sort function that can be much faster
  204.   than built-in qsort function because of lower overhead on elements
  205.   comparison and exchange. The macro takes less_than (or LT) argument - a macro or function
  206.   that takes 2 arguments returns non-zero if the first argument should be before the second
  207.   one in the sorted sequence and zero otherwise.
  208.   Example:
  209.     Suppose that the task is to sort points by ascending of y coordinates and if
  210.     y's are equal x's should ascend.
  211.     The code is:
  212.     ------------------------------------------------------------------------------
  213.            #define cmp_pts( pt1, pt2 ) 
  214.                ((pt1).y < (pt2).y || ((pt1).y < (pt2).y && (pt1).x < (pt2).x))
  215.            [static] CV_IMPLEMENT_QSORT( icvSortPoints, CvPoint, cmp_pts )
  216.     ------------------------------------------------------------------------------
  217.     After that the function "void icvSortPoints( CvPoint* array, size_t total, int aux );"
  218.     is available to user.
  219.   aux is an additional parameter, which can be used when comparing elements.
  220.   The current implementation was derived from *BSD system qsort():
  221.     * Copyright (c) 1992, 1993
  222.     *  The Regents of the University of California.  All rights reserved.
  223.     *
  224.     * Redistribution and use in source and binary forms, with or without
  225.     * modification, are permitted provided that the following conditions
  226.     * are met:
  227.     * 1. Redistributions of source code must retain the above copyright
  228.     *    notice, this list of conditions and the following disclaimer.
  229.     * 2. Redistributions in binary form must reproduce the above copyright
  230.     *    notice, this list of conditions and the following disclaimer in the
  231.     *    documentation and/or other materials provided with the distribution.
  232.     * 3. All advertising materials mentioning features or use of this software
  233.     *    must display the following acknowledgement:
  234.     *  This product includes software developed by the University of
  235.     *  California, Berkeley and its contributors.
  236.     * 4. Neither the name of the University nor the names of its contributors
  237.     *    may be used to endorse or promote products derived from this software
  238.     *    without specific prior written permission.
  239.     *
  240.     * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  241.     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  242.     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  243.     * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  244.     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  245.     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  246.     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  247.     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  248.     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  249.     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  250.     * SUCH DAMAGE.
  251. ****************************************************************************************/
  252. #define CV_IMPLEMENT_QSORT_EX( func_name, T, LT, user_data_type )                   
  253. void func_name( T *array, size_t total, user_data_type aux )                        
  254. {                                                                                   
  255.     int isort_thresh = 7;                                                           
  256.     T t;                                                                            
  257.     int sp = 0;                                                                     
  258.                                                                                     
  259.     struct                                                                          
  260.     {                                                                               
  261.         T *lb;                                                                      
  262.         T *ub;                                                                      
  263.     }                                                                               
  264.     stack[48];                                                                      
  265.                                                                                     
  266.     aux = aux;                                                                      
  267.                                                                                     
  268.     if( total <= 1 )                                                                
  269.         return;                                                                     
  270.                                                                                     
  271.     stack[0].lb = array;                                                            
  272.     stack[0].ub = array + (total - 1);                                              
  273.                                                                                     
  274.     while( sp >= 0 )                                                                
  275.     {                                                                               
  276.         T* left = stack[sp].lb;                                                     
  277.         T* right = stack[sp--].ub;                                                  
  278.                                                                                     
  279.         for(;;)                                                                     
  280.         {                                                                           
  281.             int i, n = (int)(right - left) + 1, m;                                  
  282.             T* ptr;                                                                 
  283.             T* ptr2;                                                                
  284.                                                                                     
  285.             if( n <= isort_thresh )                                                 
  286.             {                                                                       
  287.             insert_sort:                                                            
  288.                 for( ptr = left + 1; ptr <= right; ptr++ )                          
  289.                 {                                                                   
  290.                     for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--)   
  291.                         CV_SWAP( ptr2[0], ptr2[-1], t );                            
  292.                 }                                                                   
  293.                 break;                                                              
  294.             }                                                                       
  295.             else                                                                    
  296.             {                                                                       
  297.                 T* left0;                                                           
  298.                 T* left1;                                                           
  299.                 T* right0;                                                          
  300.                 T* right1;                                                          
  301.                 T* pivot;                                                           
  302.                 T* a;                                                               
  303.                 T* b;                                                               
  304.                 T* c;                                                               
  305.                 int swap_cnt = 0;                                                   
  306.                                                                                     
  307.                 left0 = left;                                                       
  308.                 right0 = right;                                                     
  309.                 pivot = left + (n/2);                                               
  310.                                                                                     
  311.                 if( n > 40 )                                                        
  312.                 {                                                                   
  313.                     int d = n / 8;                                                  
  314.                     a = left, b = left + d, c = left + 2*d;                         
  315.                     left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a))     
  316.                                       : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c));    
  317.                                                                                     
  318.                     a = pivot - d, b = pivot, c = pivot + d;                        
  319.                     pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a))    
  320.                                       : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c));    
  321.                                                                                     
  322.                     a = right - 2*d, b = right - d, c = right;                      
  323.                     right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a))    
  324.                                       : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c));    
  325.                 }                                                                   
  326.                                                                                     
  327.                 a = left, b = pivot, c = right;                                     
  328.                 pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a))        
  329.                                    : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c));       
  330.                 if( pivot != left0 )                                                
  331.                 {                                                                   
  332.                     CV_SWAP( *pivot, *left0, t );                                   
  333.                     pivot = left0;                                                  
  334.                 }                                                                   
  335.                 left = left1 = left0 + 1;                                           
  336.                 right = right1 = right0;                                            
  337.                                                                                     
  338.                 for(;;)                                                             
  339.                 {                                                                   
  340.                     while( left <= right && !LT(*pivot, *left) )                    
  341.                     {                                                               
  342.                         if( !LT(*left, *pivot) )                                    
  343.                         {                                                           
  344.                             if( left > left1 )                                      
  345.                                 CV_SWAP( *left1, *left, t );                        
  346.                             swap_cnt = 1;                                           
  347.                             left1++;                                                
  348.                         }                                                           
  349.                         left++;                                                     
  350.                     }                                                               
  351.                                                                                     
  352.                     while( left <= right && !LT(*right, *pivot) )                   
  353.                     {                                                               
  354.                         if( !LT(*pivot, *right) )                                   
  355.                         {                                                           
  356.                             if( right < right1 )                                    
  357.                                 CV_SWAP( *right1, *right, t );                      
  358.                             swap_cnt = 1;                                           
  359.                             right1--;                                               
  360.                         }                                                           
  361.                         right--;                                                    
  362.                     }                                                               
  363.                                                                                     
  364.                     if( left > right )                                              
  365.                         break;                                                      
  366.                     CV_SWAP( *left, *right, t );                                    
  367.                     swap_cnt = 1;                                                   
  368.                     left++;                                                         
  369.                     right--;                                                        
  370.                 }                                                                   
  371.                                                                                     
  372.                 if( swap_cnt == 0 )                                                 
  373.                 {                                                                   
  374.                     left = left0, right = right0;                                   
  375.                     goto insert_sort;                                               
  376.                 }                                                                   
  377.                                                                                     
  378.                 n = MIN( (int)(left1 - left0), (int)(left - left1) );               
  379.                 for( i = 0; i < n; i++ )                                            
  380.                     CV_SWAP( left0[i], left[i-n], t );                              
  381.                                                                                     
  382.                 n = MIN( (int)(right0 - right1), (int)(right1 - right) );           
  383.                 for( i = 0; i < n; i++ )                                            
  384.                     CV_SWAP( left[i], right0[i-n+1], t );                           
  385.                 n = (int)(left - left1);                                            
  386.                 m = (int)(right1 - right);                                          
  387.                 if( n > 1 )                                                         
  388.                 {                                                                   
  389.                     if( m > 1 )                                                     
  390.                     {                                                               
  391.                         if( n > m )                                                 
  392.                         {                                                           
  393.                             stack[++sp].lb = left0;                                 
  394.                             stack[sp].ub = left0 + n - 1;                           
  395.                             left = right0 - m + 1, right = right0;                  
  396.                         }                                                           
  397.                         else                                                        
  398.                         {                                                           
  399.                             stack[++sp].lb = right0 - m + 1;                        
  400.                             stack[sp].ub = right0;                                  
  401.                             left = left0, right = left0 + n - 1;                    
  402.                         }                                                           
  403.                     }                                                               
  404.                     else                                                            
  405.                         left = left0, right = left0 + n - 1;                        
  406.                 }                                                                   
  407.                 else if( m > 1 )                                                    
  408.                     left = right0 - m + 1, right = right0;                          
  409.                 else                                                                
  410.                     break;                                                          
  411.             }                                                                       
  412.         }                                                                           
  413.     }                                                                               
  414. }
  415. #define CV_IMPLEMENT_QSORT( func_name, T, cmp )  
  416.     CV_IMPLEMENT_QSORT_EX( func_name, T, cmp, int )
  417. /****************************************************************************************
  418. *                     Structures and macros for integration with IPP                     *
  419. ****************************************************************************************/
  420. /* IPP-compatible return codes */
  421. typedef enum CvStatus
  422. {
  423.     CV_BADMEMBLOCK_ERR          = -113,
  424.     CV_INPLACE_NOT_SUPPORTED_ERR= -112,
  425.     CV_UNMATCHED_ROI_ERR        = -111,
  426.     CV_NOTFOUND_ERR             = -110,
  427.     CV_BADCONVERGENCE_ERR       = -109,
  428.     CV_BADDEPTH_ERR             = -107,
  429.     CV_BADROI_ERR               = -106,
  430.     CV_BADHEADER_ERR            = -105,
  431.     CV_UNMATCHED_FORMATS_ERR    = -104,
  432.     CV_UNSUPPORTED_COI_ERR      = -103,
  433.     CV_UNSUPPORTED_CHANNELS_ERR = -102,
  434.     CV_UNSUPPORTED_DEPTH_ERR    = -101,
  435.     CV_UNSUPPORTED_FORMAT_ERR   = -100,
  436.     CV_BADARG_ERR      = -49,  //ipp comp
  437.     CV_NOTDEFINED_ERR  = -48,  //ipp comp
  438.     CV_BADCHANNELS_ERR = -47,  //ipp comp
  439.     CV_BADRANGE_ERR    = -44,  //ipp comp
  440.     CV_BADSTEP_ERR     = -29,  //ipp comp
  441.     CV_BADFLAG_ERR     =  -12,
  442.     CV_DIV_BY_ZERO_ERR =  -11, //ipp comp
  443.     CV_BADCOEF_ERR     =  -10,
  444.     CV_BADFACTOR_ERR   =  -7,
  445.     CV_BADPOINT_ERR    =  -6,
  446.     CV_BADSCALE_ERR    =  -4,
  447.     CV_OUTOFMEM_ERR    =  -3,
  448.     CV_NULLPTR_ERR     =  -2,
  449.     CV_BADSIZE_ERR     =  -1,
  450.     CV_NO_ERR          =   0,
  451.     CV_OK              =   CV_NO_ERR
  452. }
  453. CvStatus;
  454. #define IPPI_CALL(stmt) CV_Assert((stmt) >= 0)
  455. #define CV_NOTHROW throw()
  456. typedef struct CvFuncTable
  457. {
  458.     void*   fn_2d[CV_DEPTH_MAX];
  459. }
  460. CvFuncTable;
  461. typedef struct CvBigFuncTable
  462. {
  463.     void*   fn_2d[CV_DEPTH_MAX*CV_CN_MAX];
  464. }
  465. CvBigFuncTable;
  466. #define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG )         
  467.     (tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG;    
  468.     (tab).fn_2d[CV_8S] = 0;                             
  469.     (tab).fn_2d[CV_16U] = (void*)FUNCNAME##_16u##FLAG;  
  470.     (tab).fn_2d[CV_16S] = (void*)FUNCNAME##_16s##FLAG;  
  471.     (tab).fn_2d[CV_32S] = (void*)FUNCNAME##_32s##FLAG;  
  472.     (tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG;  
  473.     (tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
  474. #endif /*_CXCORE_MISC_H_*/