zoukankan      html  css  js  c++  java
  • opencv笔记二(矩阵边界填充)

    矩阵的边界填充类型

    Mat C =(Mat_<uchar>(3,3)<<1,2,3,4,5,6,7,8,9);
        uchar *data = NULL;
        for (int row = 0; row < C.rows; row++)
        {
            data = (uchar *)C.ptr<uchar>(row);
            cout << "[";
            for (int col = 0; col < C.cols; col++)
            {
                cout << (int)data[col] << " ";
            }
            cout << "]"  << endl;
        }
        Mat D;
        copyMakeBorder(C, D, 2, 2, 2, 2, BORDER_REPLICATE);
        for (int row = 0; row < D.rows; row++)
        {
            data = (uchar *)D.ptr<uchar>(row);
            cout << "[";
            for (int col = 0; col < D.cols; col++)
            {
                cout << (int)data[col] << " ";
            }
            cout << "]"  << endl;
        }
        cout << endl;
    View Code

    结果

    其他填充类型:

    //! Various border types, image boundaries are denoted with `|`
    //! @see borderInterpolate, copyMakeBorder
    enum BorderTypes {
        BORDER_CONSTANT    = 0, //!< `iiiiii|abcdefgh|iiiiiii`  with some specified `i`
        BORDER_REPLICATE   = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
        BORDER_REFLECT     = 2, //!< `fedcba|abcdefgh|hgfedcb`
        BORDER_WRAP        = 3, //!< `cdefgh|abcdefgh|abcdefg`
        BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
        BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
    
        BORDER_REFLECT101  = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
        BORDER_DEFAULT     = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
        BORDER_ISOLATED    = 16 //!< do not look outside of ROI
    };
    View Code
  • 相关阅读:
    DBCP数据库连接池
    Java Ant build.xml详解
    AWK 用法
    java打jar包
    linux 下java jar包的方法
    linux下java命令行引用jar包
    java webservice
    设计模式的几大原则
    ContextLoaderListener
    WebApplicationContextUtils源码
  • 原文地址:https://www.cnblogs.com/walker-lin/p/11578470.html
Copyright © 2011-2022 走看看