• opencv之图像膨胀


    #include <cv.h>
    #include <highgui.h>
    
    void main()
    {
        IplImage* src;
        IplImage*dst;
        src=cvLoadImage("../../lena.jpg");
        dst=cvCreateImage(cvGetSize(src),8,3);
        
        cvNamedWindow("dst");
        cvShowImage("dst",src);
    
        printf("SRC:
    ");
    
        int x,y;
        for (y=0;y<10;y++)
        {
            for (x=0;x<10;x++)
            {
                CvScalar values=cvGet2D(src,y,x);
                printf("%3d ",(int)values.val[1] );
            }
            printf("
    ");
        }
        printf("---------------------------------------------
    ");
        
    
        int values[16]={0,0,0,0,
            0,0,1,0,
            0,1,1,0,
            0,0,0,0
        } ;
        IplConvKernel*element=0;
        int cols=4,rows=4,ancher_x=2,ancher_y=2;
        element=cvCreateStructuringElementEx(cols,rows,ancher_x,ancher_y,CV_SHAPE_CUSTOM,values);
        cvDilate(src,dst,element,1);
        printf("DST:
    ");
        printf("-------------------膨胀后的结果---------------------
    ");
        for (y=0;y<10;y++)
        {
            for (x=0;x<10;x++)
            {
                CvScalar values=cvGet2D(dst,y,x);
                printf("%3d ",(int)values.val[1] );
            }
            printf("
    ");
        }
        cvWaitKey(0);
        //system("pause");
    
    }
    View Code
  • 相关阅读:
    1007 正整数分组
    Review: JQuery
    Summary: DOM modification techniques
    B
    D
    C
    hdu5592 倒序求排列+权值线段树
    主席树入门——询问区间第k大pos2104,询问区间<=k的元素个数hdu4417
    二维前缀和好题hdu6514
    莫比乌斯反演理解
  • 原文地址:https://www.cnblogs.com/wuyuankun/p/3456402.html
Copyright © 2020-2023  润新知