include/opencv2/imgproc/imgproc_c.h
Go to the documentation of this file.
00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 #ifndef __OPENCV_IMGPROC_IMGPROC_C_H__
00044 #define __OPENCV_IMGPROC_IMGPROC_C_H__
00045 
00046 #include "opencv2/core/core_c.h"
00047 #include "opencv2/imgproc/types_c.h"
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /*********************** Background statistics accumulation *****************************/
00054 
00055 /* Adds image to accumulator */
00056 CVAPI(void)  cvAcc( const CvArr* image, CvArr* sum,
00057                    const CvArr* mask CV_DEFAULT(NULL) );
00058 
00059 /* Adds squared image to accumulator */
00060 CVAPI(void)  cvSquareAcc( const CvArr* image, CvArr* sqsum,
00061                          const CvArr* mask CV_DEFAULT(NULL) );
00062 
00063 /* Adds a product of two images to accumulator */
00064 CVAPI(void)  cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc,
00065                            const CvArr* mask CV_DEFAULT(NULL) );
00066 
00067 /* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */
00068 CVAPI(void)  cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
00069                           const CvArr* mask CV_DEFAULT(NULL) );
00070 
00071 /****************************************************************************************\
00072 *                                    Image Processing                                    *
00073 \****************************************************************************************/
00074 
00075 /* Copies source 2D array inside of the larger destination array and
00076    makes a border of the specified type (IPL_BORDER_*) around the copied area. */
00077 CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
00078                               int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
00079 
00080 /* Smoothes array (removes noise) */
00081 CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst,
00082                       int smoothtype CV_DEFAULT(CV_GAUSSIAN),
00083                       int size1 CV_DEFAULT(3),
00084                       int size2 CV_DEFAULT(0),
00085                       double sigma1 CV_DEFAULT(0),
00086                       double sigma2 CV_DEFAULT(0));
00087 
00088 /* Convolves the image with the kernel */
00089 CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel,
00090                         CvPoint anchor CV_DEFAULT(cvPoint(-1,-1)));
00091 
00092 /* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */
00093 CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum,
00094                        CvArr* sqsum CV_DEFAULT(NULL),
00095                        CvArr* tilted_sum CV_DEFAULT(NULL));
00096 
00097 /*
00098    Smoothes the input image with gaussian kernel and then down-samples it.
00099    dst_width = floor(src_width/2)[+1],
00100    dst_height = floor(src_height/2)[+1]
00101 */
00102 CVAPI(void)  cvPyrDown( const CvArr* src, CvArr* dst,
00103                         int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00104 
00105 /*
00106    Up-samples image and smoothes the result with gaussian kernel.
00107    dst_width = src_width*2,
00108    dst_height = src_height*2
00109 */
00110 CVAPI(void)  cvPyrUp( const CvArr* src, CvArr* dst,
00111                       int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00112 
00113 /* Builds pyramid for an image */
00114 CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
00115                                 const CvSize* layer_sizes CV_DEFAULT(0),
00116                                 CvArr* bufarr CV_DEFAULT(0),
00117                                 int calc CV_DEFAULT(1),
00118                                 int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
00119 
00120 /* Releases pyramid */
00121 CVAPI(void)  cvReleasePyramid( CvMat*** pyramid, int extra_layers );
00122 
00123 
00124 /* Filters image using meanshift algorithm */
00125 CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
00126     double sp, double sr, int max_level CV_DEFAULT(1),
00127     CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
00128 
00129 /* Segments image using seed "markers" */
00130 CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
00131 
00132 /* Calculates an image derivative using generalized Sobel
00133    (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
00134    Scharr can be used only for the first dx or dy derivative */
00135 CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
00136                     int xorder, int yorder,
00137                     int aperture_size CV_DEFAULT(3));
00138 
00139 /* Calculates the image Laplacian: (d2/dx + d2/dy)I */
00140 CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
00141                       int aperture_size CV_DEFAULT(3) );
00142 
00143 /* Converts input array pixels from one color space to another */
00144 CVAPI(void)  cvCvtColor( const CvArr* src, CvArr* dst, int code );
00145 
00146 
00147 /* Resizes image (input array is resized to fit the destination array) */
00148 CVAPI(void)  cvResize( const CvArr* src, CvArr* dst,
00149                        int interpolation CV_DEFAULT( CV_INTER_LINEAR ));
00150 
00151 /* Warps image with affine transform */
00152 CVAPI(void)  cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
00153                            int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00154                            CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00155 
00156 /* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */
00157 CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
00158                                     const CvPoint2D32f * dst,
00159                                     CvMat * map_matrix );
00160 
00161 /* Computes rotation_matrix matrix */
00162 CVAPI(CvMat*)  cv2DRotationMatrix( CvPoint2D32f center, double angle,
00163                                    double scale, CvMat* map_matrix );
00164 
00165 /* Warps image with perspective (projective) transform */
00166 CVAPI(void)  cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,
00167                                 int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00168                                 CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00169 
00170 /* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */
00171 CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src,
00172                                          const CvPoint2D32f* dst,
00173                                          CvMat* map_matrix );
00174 
00175 /* Performs generic geometric transformation using the specified coordinate maps */
00176 CVAPI(void)  cvRemap( const CvArr* src, CvArr* dst,
00177                       const CvArr* mapx, const CvArr* mapy,
00178                       int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
00179                       CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
00180 
00181 /* Converts mapx & mapy from floating-point to integer formats for cvRemap */
00182 CVAPI(void)  cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
00183                             CvArr* mapxy, CvArr* mapalpha );
00184 
00185 /* Performs forward or inverse log-polar image transform */
00186 CVAPI(void)  cvLogPolar( const CvArr* src, CvArr* dst,
00187                          CvPoint2D32f center, double M,
00188                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
00189 
00190 /* Performs forward or inverse linear-polar image transform */
00191 CVAPI(void)  cvLinearPolar( const CvArr* src, CvArr* dst,
00192                          CvPoint2D32f center, double maxRadius,
00193                          int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
00194 
00195 /* Transforms the input image to compensate lens distortion */
00196 CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst,
00197                           const CvMat* camera_matrix,
00198                           const CvMat* distortion_coeffs,
00199                           const CvMat* new_camera_matrix CV_DEFAULT(0) );
00200 
00201 /* Computes transformation map from intrinsic camera parameters
00202    that can used by cvRemap */
00203 CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix,
00204                                 const CvMat* distortion_coeffs,
00205                                 CvArr* mapx, CvArr* mapy );
00206 
00207 /* Computes undistortion+rectification map for a head of stereo camera */
00208 CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix,
00209                                        const CvMat* dist_coeffs,
00210                                        const CvMat *R, const CvMat* new_camera_matrix,
00211                                        CvArr* mapx, CvArr* mapy );
00212 
00213 /* Computes the original (undistorted) feature coordinates
00214    from the observed (distorted) coordinates */
00215 CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst,
00216                                const CvMat* camera_matrix,
00217                                const CvMat* dist_coeffs,
00218                                const CvMat* R CV_DEFAULT(0),
00219                                const CvMat* P CV_DEFAULT(0));
00220 
00221 /* creates structuring element used for morphological operations */
00222 CVAPI(IplConvKernel*)  cvCreateStructuringElementEx(
00223             int cols, int  rows, int  anchor_x, int  anchor_y,
00224             int shape, int* values CV_DEFAULT(NULL) );
00225 
00226 /* releases structuring element */
00227 CVAPI(void)  cvReleaseStructuringElement( IplConvKernel** element );
00228 
00229 /* erodes input image (applies minimum filter) one or more times.
00230    If element pointer is NULL, 3x3 rectangular element is used */
00231 CVAPI(void)  cvErode( const CvArr* src, CvArr* dst,
00232                       IplConvKernel* element CV_DEFAULT(NULL),
00233                       int iterations CV_DEFAULT(1) );
00234 
00235 /* dilates input image (applies maximum filter) one or more times.
00236    If element pointer is NULL, 3x3 rectangular element is used */
00237 CVAPI(void)  cvDilate( const CvArr* src, CvArr* dst,
00238                        IplConvKernel* element CV_DEFAULT(NULL),
00239                        int iterations CV_DEFAULT(1) );
00240 
00241 /* Performs complex morphological transformation */
00242 CVAPI(void)  cvMorphologyEx( const CvArr* src, CvArr* dst,
00243                              CvArr* temp, IplConvKernel* element,
00244                              int operation, int iterations CV_DEFAULT(1) );
00245 
00246 /* Calculates all spatial and central moments up to the 3rd order */
00247 CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0));
00248 
00249 /* Retrieve particular spatial, central or normalized central moments */
00250 CVAPI(double)  cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order );
00251 CVAPI(double)  cvGetCentralMoment( CvMoments* moments, int x_order, int y_order );
00252 CVAPI(double)  cvGetNormalizedCentralMoment( CvMoments* moments,
00253                                              int x_order, int y_order );
00254 
00255 /* Calculates 7 Hu's invariants from precalculated spatial and central moments */
00256 CVAPI(void) cvGetHuMoments( CvMoments*  moments, CvHuMoments*  hu_moments );
00257 
00258 /*********************************** data sampling **************************************/
00259 
00260 /* Fetches pixels that belong to the specified line segment and stores them to the buffer.
00261    Returns the number of retrieved points. */
00262 CVAPI(int)  cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer,
00263                           int connectivity CV_DEFAULT(8));
00264 
00265 /* Retrieves the rectangular image region with specified center from the input array.
00266  dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2).
00267  Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/
00268 CVAPI(void)  cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center );
00269 
00270 
00271 /* Retrieves quadrangle from the input array.
00272     matrixarr = ( a11  a12 | b1 )   dst(x,y) <- src(A[x y]' + b)
00273                 ( a21  a22 | b2 )   (bilinear interpolation is used to retrieve pixels
00274                                      with fractional coordinates)
00275 */
00276 CVAPI(void)  cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst,
00277                                     const CvMat* map_matrix );
00278 
00279 /* Measures similarity between template and overlapped windows in the source image
00280    and fills the resultant image with the measurements */
00281 CVAPI(void)  cvMatchTemplate( const CvArr* image, const CvArr* templ,
00282                               CvArr* result, int method );
00283 
00284 /* Computes earth mover distance between
00285    two weighted point sets (called signatures) */
00286 CVAPI(float)  cvCalcEMD2( const CvArr* signature1,
00287                           const CvArr* signature2,
00288                           int distance_type,
00289                           CvDistanceFunction distance_func CV_DEFAULT(NULL),
00290                           const CvArr* cost_matrix CV_DEFAULT(NULL),
00291                           CvArr* flow CV_DEFAULT(NULL),
00292                           float* lower_bound CV_DEFAULT(NULL),
00293                           void* userdata CV_DEFAULT(NULL));
00294 
00295 /****************************************************************************************\
00296 *                              Contours retrieving                                       *
00297 \****************************************************************************************/
00298 
00299 /* Retrieves outer and optionally inner boundaries of white (non-zero) connected
00300    components in the black (zero) background */
00301 CVAPI(int)  cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour,
00302                             int header_size CV_DEFAULT(sizeof(CvContour)),
00303                             int mode CV_DEFAULT(CV_RETR_LIST),
00304                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00305                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
00306 
00307 /* Initalizes contour retrieving process.
00308    Calls cvStartFindContours.
00309    Calls cvFindNextContour until null pointer is returned
00310    or some other condition becomes true.
00311    Calls cvEndFindContours at the end. */
00312 CVAPI(CvContourScanner)  cvStartFindContours( CvArr* image, CvMemStorage* storage,
00313                             int header_size CV_DEFAULT(sizeof(CvContour)),
00314                             int mode CV_DEFAULT(CV_RETR_LIST),
00315                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00316                             CvPoint offset CV_DEFAULT(cvPoint(0,0)));
00317 
00318 /* Retrieves next contour */
00319 CVAPI(CvSeq*)  cvFindNextContour( CvContourScanner scanner );
00320 
00321 
00322 /* Substitutes the last retrieved contour with the new one
00323    (if the substitutor is null, the last retrieved contour is removed from the tree) */
00324 CVAPI(void)   cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour );
00325 
00326 
00327 /* Releases contour scanner and returns pointer to the first outer contour */
00328 CVAPI(CvSeq*)  cvEndFindContours( CvContourScanner* scanner );
00329 
00330 /* Approximates a single Freeman chain or a tree of chains to polygonal curves */
00331 CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
00332                             int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
00333                             double parameter CV_DEFAULT(0),
00334                             int  minimal_perimeter CV_DEFAULT(0),
00335                             int  recursive CV_DEFAULT(0));
00336 
00337 /* Initalizes Freeman chain reader.
00338    The reader is used to iteratively get coordinates of all the chain points.
00339    If the Freeman codes should be read as is, a simple sequence reader should be used */
00340 CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );
00341 
00342 /* Retrieves the next chain point */
00343 CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader );
00344 
00345 
00346 /****************************************************************************************\
00347 *                            Contour Processing and Shape Analysis                       *
00348 \****************************************************************************************/
00349 
00350 /* Approximates a single polygonal curve (contour) or
00351    a tree of polygonal curves (contours) */
00352 CVAPI(CvSeq*)  cvApproxPoly( const void* src_seq,
00353                              int header_size, CvMemStorage* storage,
00354                              int method, double eps,
00355                              int recursive CV_DEFAULT(0));
00356 
00357 /* Calculates perimeter of a contour or length of a part of contour */
00358 CVAPI(double)  cvArcLength( const void* curve,
00359                             CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
00360                             int is_closed CV_DEFAULT(-1));
00361 
00362 CV_INLINE double cvContourPerimeter( const void* contour )
00363 {
00364     return cvArcLength( contour, CV_WHOLE_SEQ, 1 );
00365 }
00366 
00367 
00368 /* Calculates contour boundning rectangle (update=1) or
00369    just retrieves pre-calculated rectangle (update=0) */
00370 CVAPI(CvRect)  cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );
00371 
00372 /* Calculates area of a contour or contour segment */
00373 CVAPI(double)  cvContourArea( const CvArr* contour,
00374                               CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ),
00375                               int oriented CV_DEFAULT(0));
00376 
00377 /* Finds minimum area rotated rectangle bounding a set of points */
00378 CVAPI(CvBox2D)  cvMinAreaRect2( const CvArr* points,
00379                                 CvMemStorage* storage CV_DEFAULT(NULL));
00380 
00381 /* Finds minimum enclosing circle for a set of points */
00382 CVAPI(int)  cvMinEnclosingCircle( const CvArr* points,
00383                                   CvPoint2D32f* center, float* radius );
00384 
00385 /* Compares two contours by matching their moments */
00386 CVAPI(double)  cvMatchShapes( const void* object1, const void* object2,
00387                               int method, double parameter CV_DEFAULT(0));
00388 
00389 /* Calculates exact convex hull of 2d point set */
00390 CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
00391                              void* hull_storage CV_DEFAULT(NULL),
00392                              int orientation CV_DEFAULT(CV_CLOCKWISE),
00393                              int return_points CV_DEFAULT(0));
00394 
00395 /* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */
00396 CVAPI(int)  cvCheckContourConvexity( const CvArr* contour );
00397 
00398 
00399 /* Finds convexity defects for the contour */
00400 CVAPI(CvSeq*)  cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
00401                                    CvMemStorage* storage CV_DEFAULT(NULL));
00402 
00403 /* Fits ellipse into a set of 2d points */
00404 CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points );
00405 
00406 /* Finds minimum rectangle containing two given rectangles */
00407 CVAPI(CvRect)  cvMaxRect( const CvRect* rect1, const CvRect* rect2 );
00408 
00409 /* Finds coordinates of the box vertices */
00410 CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] );
00411 
00412 /* Initializes sequence header for a matrix (column or row vector) of points -
00413    a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */
00414 CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat,
00415                                  CvContour* contour_header,
00416                                  CvSeqBlock* block );
00417 
00418 /* Checks whether the point is inside polygon, outside, on an edge (at a vertex).
00419    Returns positive, negative or zero value, correspondingly.
00420    Optionally, measures a signed distance between
00421    the point and the nearest polygon edge (measure_dist=1) */
00422 CVAPI(double) cvPointPolygonTest( const CvArr* contour,
00423                                   CvPoint2D32f pt, int measure_dist );
00424 
00425 /****************************************************************************************\
00426 *                                  Histogram functions                                   *
00427 \****************************************************************************************/
00428 
00429 /* Creates new histogram */
00430 CVAPI(CvHistogram*)  cvCreateHist( int dims, int* sizes, int type,
00431                                    float** ranges CV_DEFAULT(NULL),
00432                                    int uniform CV_DEFAULT(1));
00433 
00434 /* Assignes histogram bin ranges */
00435 CVAPI(void)  cvSetHistBinRanges( CvHistogram* hist, float** ranges,
00436                                 int uniform CV_DEFAULT(1));
00437 
00438 /* Creates histogram header for array */
00439 CVAPI(CvHistogram*)  cvMakeHistHeaderForArray(
00440                             int  dims, int* sizes, CvHistogram* hist,
00441                             float* data, float** ranges CV_DEFAULT(NULL),
00442                             int uniform CV_DEFAULT(1));
00443 
00444 /* Releases histogram */
00445 CVAPI(void)  cvReleaseHist( CvHistogram** hist );
00446 
00447 /* Clears all the histogram bins */
00448 CVAPI(void)  cvClearHist( CvHistogram* hist );
00449 
00450 /* Finds indices and values of minimum and maximum histogram bins */
00451 CVAPI(void)  cvGetMinMaxHistValue( const CvHistogram* hist,
00452                                    float* min_value, float* max_value,
00453                                    int* min_idx CV_DEFAULT(NULL),
00454                                    int* max_idx CV_DEFAULT(NULL));
00455 
00456 
00457 /* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>.
00458    After that sum of histogram bins is equal to <factor> */
00459 CVAPI(void)  cvNormalizeHist( CvHistogram* hist, double factor );
00460 
00461 
00462 /* Clear all histogram bins that are below the threshold */
00463 CVAPI(void)  cvThreshHist( CvHistogram* hist, double threshold );
00464 
00465 
00466 /* Compares two histogram */
00467 CVAPI(double)  cvCompareHist( const CvHistogram* hist1,
00468                               const CvHistogram* hist2,
00469                               int method);
00470 
00471 /* Copies one histogram to another. Destination histogram is created if
00472    the destination pointer is NULL */
00473 CVAPI(void)  cvCopyHist( const CvHistogram* src, CvHistogram** dst );
00474 
00475 
00476 /* Calculates bayesian probabilistic histograms
00477    (each or src and dst is an array of <number> histograms */
00478 CVAPI(void)  cvCalcBayesianProb( CvHistogram** src, int number,
00479                                 CvHistogram** dst);
00480 
00481 /* Calculates array histogram */
00482 CVAPI(void)  cvCalcArrHist( CvArr** arr, CvHistogram* hist,
00483                             int accumulate CV_DEFAULT(0),
00484                             const CvArr* mask CV_DEFAULT(NULL) );
00485 
00486 CV_INLINE  void  cvCalcHist( IplImage** image, CvHistogram* hist,
00487                              int accumulate CV_DEFAULT(0),
00488                              const CvArr* mask CV_DEFAULT(NULL) )
00489 {
00490     cvCalcArrHist( (CvArr**)image, hist, accumulate, mask );
00491 }
00492 
00493 /* Calculates back project */
00494 CVAPI(void)  cvCalcArrBackProject( CvArr** image, CvArr* dst,
00495                                    const CvHistogram* hist );
00496 #define  cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist)
00497 
00498 
00499 /* Does some sort of template matching but compares histograms of
00500    template and each window location */
00501 CVAPI(void)  cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
00502                                         CvHistogram* hist, int method,
00503                                         double factor );
00504 #define  cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \
00505      cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
00506 
00507 
00508 /* calculates probabilistic density (divides one histogram by another) */
00509 CVAPI(void)  cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
00510                                 CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
00511 
00512 /* equalizes histogram of 8-bit single-channel image */
00513 CVAPI(void)  cvEqualizeHist( const CvArr* src, CvArr* dst );
00514 
00515 
00516 /* Applies distance transform to binary image */
00517 CVAPI(void)  cvDistTransform( const CvArr* src, CvArr* dst,
00518                               int distance_type CV_DEFAULT(CV_DIST_L2),
00519                               int mask_size CV_DEFAULT(3),
00520                               const float* mask CV_DEFAULT(NULL),
00521                               CvArr* labels CV_DEFAULT(NULL),
00522                               int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP));
00523 
00524 
00525 /* Applies fixed-level threshold to grayscale image.
00526    This is a basic operation applied before retrieving contours */
00527 CVAPI(double)  cvThreshold( const CvArr*  src, CvArr*  dst,
00528                             double  threshold, double  max_value,
00529                             int threshold_type );
00530 
00531 /* Applies adaptive threshold to grayscale image.
00532    The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
00533    CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
00534    neighborhood size (3, 5, 7 etc.),
00535    and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */
00536 CVAPI(void)  cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
00537                                   int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
00538                                   int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
00539                                   int block_size CV_DEFAULT(3),
00540                                   double param1 CV_DEFAULT(5));
00541 
00542 /* Fills the connected component until the color difference gets large enough */
00543 CVAPI(void)  cvFloodFill( CvArr* image, CvPoint seed_point,
00544                           CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)),
00545                           CvScalar up_diff CV_DEFAULT(cvScalarAll(0)),
00546                           CvConnectedComp* comp CV_DEFAULT(NULL),
00547                           int flags CV_DEFAULT(4),
00548                           CvArr* mask CV_DEFAULT(NULL));
00549 
00550 /****************************************************************************************\
00551 *                                  Feature detection                                     *
00552 \****************************************************************************************/
00553 
00554 /* Runs canny edge detector */
00555 CVAPI(void)  cvCanny( const CvArr* image, CvArr* edges, double threshold1,
00556                       double threshold2, int  aperture_size CV_DEFAULT(3) );
00557 
00558 /* Calculates constraint image for corner detection
00559    Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy.
00560    Applying threshold to the result gives coordinates of corners */
00561 CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners,
00562                                int aperture_size CV_DEFAULT(3) );
00563 
00564 /* Calculates eigen values and vectors of 2x2
00565    gradient covariation matrix at every image pixel */
00566 CVAPI(void)  cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
00567                                        int block_size, int aperture_size CV_DEFAULT(3) );
00568 
00569 /* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at
00570    every image pixel */
00571 CVAPI(void)  cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
00572                                   int block_size, int aperture_size CV_DEFAULT(3) );
00573 
00574 /* Harris corner detector:
00575    Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */
00576 CVAPI(void)  cvCornerHarris( const CvArr* image, CvArr* harris_responce,
00577                              int block_size, int aperture_size CV_DEFAULT(3),
00578                              double k CV_DEFAULT(0.04) );
00579 
00580 /* Adjust corner position using some sort of gradient search */
00581 CVAPI(void)  cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
00582                                  int count, CvSize win, CvSize zero_zone,
00583                                  CvTermCriteria  criteria );
00584 
00585 /* Finds a sparse set of points within the selected region
00586    that seem to be easy to track */
00587 CVAPI(void)  cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image,
00588                                     CvArr* temp_image, CvPoint2D32f* corners,
00589                                     int* corner_count, double  quality_level,
00590                                     double  min_distance,
00591                                     const CvArr* mask CV_DEFAULT(NULL),
00592                                     int block_size CV_DEFAULT(3),
00593                                     int use_harris CV_DEFAULT(0),
00594                                     double k CV_DEFAULT(0.04) );
00595 
00596 /* Finds lines on binary image using one of several methods.
00597    line_storage is either memory storage or 1 x <max number of lines> CvMat, its
00598    number of columns is changed by the function.
00599    method is one of CV_HOUGH_*;
00600    rho, theta and threshold are used for each of those methods;
00601    param1 ~ line length, param2 ~ line gap - for probabilistic,
00602    param1 ~ srn, param2 ~ stn - for multi-scale */
00603 CVAPI(CvSeq*)  cvHoughLines2( CvArr* image, void* line_storage, int method,
00604                               double rho, double theta, int threshold,
00605                               double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0));
00606 
00607 /* Finds circles in the image */
00608 CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,
00609                               int method, double dp, double min_dist,
00610                               double param1 CV_DEFAULT(100),
00611                               double param2 CV_DEFAULT(100),
00612                               int min_radius CV_DEFAULT(0),
00613                               int max_radius CV_DEFAULT(0));
00614 
00615 /* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */
00616 CVAPI(void)  cvFitLine( const CvArr* points, int dist_type, double param,
00617                         double reps, double aeps, float* line );
00618 
00619 #ifdef __cplusplus
00620 }
00621 #endif
00622 
00623 #endif