OPENCV初探(四)

其中可用到的图片 

Code

    void cvSmooth(
      const CvArr* src,
      CvArr* dst,
      int smoothtype = CV_GAUSSIAN,
      int param1 = 3,
      int param2 = 0,
      double param3 = 0,
      double param4 = 0
      );
Smooth type   Name        In      Nc            Depth               Depth              Brief description
                                    place?                 of src                of dst
CV_BLUR   Simple blur    Yes     1,3         8u, 32f               8u, 32f           Sum over a param1×param2   
                                                                                                          neighborhood with subsequent
                                                                                                          scaling by 1/
                                                                                                          (param1×param2).
CV_BLUR_NO  Simple blur   No     1           8u                   16s (for 8u        Sum over a param1×param2
_SCALE          with no scaling                                          source) or          neighborhood.
                                                                                    32f (for 32f
                                                                                    source)

CV_MEDIAN     Median blur  No     1,3         8u                  8u                   Find median over a
                                                                                                           param1×param1 square
                                                                                                           neighborhood.
CV_GAUSSIAN Gaussian blur Yes 1,3        8u, 32f             8u (for 8u         Sum over a param1×param2
                                                                                    source) or         neighborhood.
                                                                                    32f (for 32f
                                                                                    source)
CV_BILATERAL Bilateral filter   No 1,3       8u                    8u                   Apply bilateral 3-by-3 fi ltering
                                                                                                         with color sigma=param1 and
                                                                                                          a space sigma=param2
      void cvErode(
      IplImage* src,
      IplImage* dst,      
      IplConvKernel* B = NULL,
      int iterations = 1
      );

      void cvDilate(      
      IplImage* src,
      IplImage* dst,
      IplConvKernel* B = NULL,
      int iterations = 1
      );


      IplConvKernel* cvCreateStructuringElementEx(
      int cols,
      int rows,
      int anchor_x,
      int anchor_y,
      int shape,
      int* values=NULL
      );
//Shape value Meaning
CV_SHAPE_RECT The kernel is rectangular
CV_SHAPE_CROSS The kernel is cross shaped
CV_SHAPE_ELLIPSE The kernel is elliptical
CV_SHAPE_CUSTOM The kernel is user-defi ned via values

      void cvMorphologyEx(
      const CvArr* src,
      CvArr* dst,
      CvArr* temp,
      IplConvKernel* element,
      int operation,
      int iterations = 1
      );
//Value of operation Morphological operator Requires temp image?
CV_MOP_OPEN Opening No
CV_MOP_CLOSE Closing No
CV_MOP_GRADIENT Morphological gradient Always
CV_MOP_TOPHAT Top Hat For in-place only (src = dst)
CV_MOP_BLACKHAT Black Hat For in-place only (src = dst)

    void cvFloodFill(
    IplImage* img,
    CvPoint seedPoint,
    CvScalar newVal,
    CvScalar loDiff = cvScalarAll(0),
    CvScalar upDiff = cvScalarAll(0),
    CvConnectedComp* comp = NULL,            //Non-NULL  将记录被填区域的统计信息
    int flags = 4,                                           //(0-7){4,水平垂直邻域;8,+对角线}(16-23){CV_FLOODFILL_FIXED_RANGE 与SeedPoint
                                                                    比较,否则Neighborhood;CV_FLOODFILL_MASK_ONLY 对MASK上位置操作,否则源图像}(8–15)
                                                                   {MASK被赋的值}
    CvArr* mask = NULL                               //初始化
    );

    void cvResize(
    const CvArr* src,
    CvArr* dst,
    int interpolation = CV_INTER_LINEAR
    );
//Interpolation Meaning
CV_INTER_NN Nearest neighbor
CV_INTER_LINEAR Bilinear
CV_INTER_AREA Pixel area re-sampling
CV_INTER_CUBIC Bicubic interpolation

    void cvPyrDown(
    IplImage* src,
    IplImage* dst,
    IplFilter filter = IPL_GAUSSIAN_5x5
    );

   void cvPyrUp(
   IplImage* src,
   IplImage* dst,
   IplFilter filter = IPL_GAUSSIAN_5x5
   );
//PyrUp() is not the inverse of PyrDown().
//L i  = G i - PyrUp(G i+1)                     Laplacian Pyramids             Gaussian Pyramids

      void cvPyrSegmentation(
      IplImage* src,      
      IplImage* dst,
      CvMemStorage* storage,
      CvSeq** comp,
      int level,
      double threshold1,
      double threshold2
      );
//!!!注意长宽须是2的幂的倍数,具体指数须看需做的pyramid level number 

    CvMemStorage* storage = cvCreateMemStorage();
    
      int n_comp = comp->total;
      for( int i=0; i<n_comp; i++ ) {
            CvConnectedComp* cc = (CvConnectedComp*) cvGetSeqElem( comp, i );
            do_something_with( cc );
      }

      typedef struct CvConnectedComponent {
      double area;
      CvScalar value;
      CvRect rect;
      CvSeq* contour;
      };

      double cvThreshold(
      CvArr* src,
      CvArr* dst,                             //三种可能:0,M,SRC i
      double threshold,
      double max_value,
      int threshold_type
      );
//Threshold type Operation
CV_THRESH_BINARY dst j=(src j >T)?M:0
CV_THRESH_BINARY_INV dst j=(src j >T)?0:M
CV_THRESH_TRUNC dst j=(src j >T)?M:src j
CV_THRESH_TOZERO_INV dst j=(src j >T)?0:src j
CV_THRESH_TOZERO dst j=(src j >T)?src j:0

      void cvAdaptiveThreshold(
      CvArr* src,
      CvArr* dst,
      double max_val,
      int adaptive_method = CV_ADAPTIVE_THRESH_MEAN_C             //CV_ADAPTIVE_THRESH_GAUSSIAN_C 加权不等,否则相等
      int threshold_type = CV_THRESH_BINARY,
      int block_size = 3,
      double param1 = 5
      );

posted @ 2009-08-03 15:18  Orcus  阅读(1978)  评论(0编辑  收藏  举报